|
|
9ae3a8 |
From 768dddfbe60ecc3a9a920101aa755804f8a5700e Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
Date: Thu, 18 May 2017 09:21:31 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 18/18] serial: remove watch on reset
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
Message-id: <20170518092131.16571-19-famz@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 75308
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.4 qemu-kvm PATCH v3 18/18] serial: remove watch on reset
|
|
|
9ae3a8 |
Bugzilla: 1451470
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Otherwise, this can cause serial_xmit to be entered with LSR.TEMT=0,
|
|
|
9ae3a8 |
which is invalid and causes an assertion failure.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Reported-by: Bret Ketchum <bcketchum@gmail.com>
|
|
|
9ae3a8 |
Tested-by: Bret Ketchum <bcketchum@gmail.com>
|
|
|
9ae3a8 |
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit a1df76da57aa8772a75e7c49f8e3829d07b4c46c)
|
|
|
9ae3a8 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/char/serial.c | 16 ++++++++++++----
|
|
|
9ae3a8 |
include/hw/char/serial.h | 1 +
|
|
|
9ae3a8 |
2 files changed, 13 insertions(+), 4 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/hw/char/serial.c b/hw/char/serial.c
|
|
|
9ae3a8 |
index 69fefb2..39de1ca 100644
|
|
|
9ae3a8 |
--- a/hw/char/serial.c
|
|
|
9ae3a8 |
+++ b/hw/char/serial.c
|
|
|
9ae3a8 |
@@ -224,6 +224,7 @@ static gboolean serial_watch_cb(GIOChannel *chan, GIOCondition cond,
|
|
|
9ae3a8 |
void *opaque)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
SerialState *s = opaque;
|
|
|
9ae3a8 |
+ s->watch_tag = 0;
|
|
|
9ae3a8 |
serial_xmit(s);
|
|
|
9ae3a8 |
return FALSE;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -254,10 +255,12 @@ static void serial_xmit(SerialState *s)
|
|
|
9ae3a8 |
if (s->mcr & UART_MCR_LOOP) {
|
|
|
9ae3a8 |
/* in loopback mode, say that we just received a char */
|
|
|
9ae3a8 |
serial_receive1(s, &s->tsr, 1);
|
|
|
9ae3a8 |
- } else if (qemu_chr_fe_write(s->chr, &s->tsr, 1) != 1) {
|
|
|
9ae3a8 |
- if (s->tsr_retry < MAX_XMIT_RETRY &&
|
|
|
9ae3a8 |
- qemu_chr_fe_add_watch(s->chr, G_IO_OUT|G_IO_HUP,
|
|
|
9ae3a8 |
- serial_watch_cb, s) > 0) {
|
|
|
9ae3a8 |
+ } else if (qemu_chr_fe_write(s->chr, &s->tsr, 1) != 1 &&
|
|
|
9ae3a8 |
+ s->tsr_retry < MAX_XMIT_RETRY) {
|
|
|
9ae3a8 |
+ assert(s->watch_tag == 0);
|
|
|
9ae3a8 |
+ s->watch_tag = qemu_chr_fe_add_watch(s->chr, G_IO_OUT|G_IO_HUP,
|
|
|
9ae3a8 |
+ serial_watch_cb, s);
|
|
|
9ae3a8 |
+ if (s->watch_tag > 0) {
|
|
|
9ae3a8 |
s->tsr_retry++;
|
|
|
9ae3a8 |
return;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -656,6 +659,11 @@ static void serial_reset(void *opaque)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
SerialState *s = opaque;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ if (s->watch_tag > 0) {
|
|
|
9ae3a8 |
+ g_source_remove(s->watch_tag);
|
|
|
9ae3a8 |
+ s->watch_tag = 0;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
s->rbr = 0;
|
|
|
9ae3a8 |
s->ier = 0;
|
|
|
9ae3a8 |
s->iir = UART_IIR_NO_INT;
|
|
|
9ae3a8 |
diff --git a/include/hw/char/serial.h b/include/hw/char/serial.h
|
|
|
9ae3a8 |
index 2661f8c..19c7763 100644
|
|
|
9ae3a8 |
--- a/include/hw/char/serial.h
|
|
|
9ae3a8 |
+++ b/include/hw/char/serial.h
|
|
|
9ae3a8 |
@@ -56,6 +56,7 @@ struct SerialState {
|
|
|
9ae3a8 |
int it_shift;
|
|
|
9ae3a8 |
int baudbase;
|
|
|
9ae3a8 |
uint32_t tsr_retry;
|
|
|
9ae3a8 |
+ guint watch_tag;
|
|
|
9ae3a8 |
uint32_t wakeup;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/* Time when the last byte was successfully sent out of the tsr */
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|