|
|
9ae3a8 |
From ba96da130a625a71b574c1bb9f6027e3b8d655ab Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
Date: Fri, 9 Jun 2017 11:43:59 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 4/6] serial: reinstate watch after migration
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
Message-id: <20170609114359.13036-4-pbonzini@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 75566
|
|
|
9ae3a8 |
O-Subject: [RHEL7.4 qemu-kvm PATCH v2 3/3] serial: reinstate watch after migration
|
|
|
9ae3a8 |
Bugzilla: 1452067
|
|
|
9ae3a8 |
RH-Acked-by: David Hildenbrand <david@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Otherwise, a serial port can get stuck if it is migrated while flow control
|
|
|
9ae3a8 |
is in effect.
|
|
|
9ae3a8 |
|
|
|
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 9f34a35e0020b0b2b2e21c086a486d7dfd18df4f)
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/char/serial.c | 29 +++++++++++++++++++++++++----
|
|
|
9ae3a8 |
1 file changed, 25 insertions(+), 4 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/hw/char/serial.c b/hw/char/serial.c
|
|
|
9ae3a8 |
index 0518a6f..820960b 100644
|
|
|
9ae3a8 |
--- a/hw/char/serial.c
|
|
|
9ae3a8 |
+++ b/hw/char/serial.c
|
|
|
9ae3a8 |
@@ -637,13 +637,34 @@ static int serial_post_load(void *opaque, int version_id)
|
|
|
9ae3a8 |
if (version_id < 3) {
|
|
|
9ae3a8 |
s->fcr_vmstate = 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
- if (s->tsr_retry > MAX_XMIT_RETRY) {
|
|
|
9ae3a8 |
- s->tsr_retry = MAX_XMIT_RETRY;
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
if (s->thr_ipending == -1) {
|
|
|
9ae3a8 |
s->thr_ipending = ((s->iir & UART_IIR_ID) == UART_IIR_THRI);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ if (s->tsr_retry > 0) {
|
|
|
9ae3a8 |
+ /* tsr_retry > 0 implies LSR.TEMT = 0 (transmitter not empty). */
|
|
|
9ae3a8 |
+ if (s->lsr & UART_LSR_TEMT) {
|
|
|
9ae3a8 |
+ error_report("inconsistent state in serial device "
|
|
|
9ae3a8 |
+ "(tsr empty, tsr_retry=%d", s->tsr_retry);
|
|
|
9ae3a8 |
+ return -1;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ if (s->tsr_retry > MAX_XMIT_RETRY) {
|
|
|
9ae3a8 |
+ s->tsr_retry = MAX_XMIT_RETRY;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
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 |
+ } else {
|
|
|
9ae3a8 |
+ /* tsr_retry == 0 implies LSR.TEMT = 1 (transmitter empty). */
|
|
|
9ae3a8 |
+ if (!(s->lsr & UART_LSR_TEMT)) {
|
|
|
9ae3a8 |
+ error_report("inconsistent state in serial device "
|
|
|
9ae3a8 |
+ "(tsr not empty, tsr_retry=0");
|
|
|
9ae3a8 |
+ return -1;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
s->last_break_enable = (s->lcr >> 6) & 1;
|
|
|
9ae3a8 |
/* Initialize fcr via setter to perform essential side-effects */
|
|
|
9ae3a8 |
serial_write_fcr(s, s->fcr_vmstate);
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|