From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: dgilbert@redhat.com
Subject: [Qemu-devel] [PATCH v2 6/6] serial: reinstate watch after migration
Date: Thu, 23 Jun 2016 19:22:19 +0200 [thread overview]
Message-ID: <1466702539-17607-7-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1466702539-17607-1-git-send-email-pbonzini@redhat.com>
Otherwise, a serial port can get stuck if it is migrated while flow control
is in effect.
Tested-by: Bret Ketchum <bcketchum@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/char/serial.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/hw/char/serial.c b/hw/char/serial.c
index af39e8f..3442f47 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -644,8 +644,29 @@ static int serial_post_load(void *opaque, int version_id)
if (s->thr_ipending == -1) {
s->thr_ipending = ((s->iir & UART_IIR_ID) == UART_IIR_THRI);
}
- if (s->tsr_retry > MAX_XMIT_RETRY) {
- s->tsr_retry = MAX_XMIT_RETRY;
+
+ if (s->tsr_retry > 0) {
+ /* tsr_retry > 0 implies LSR.TEMT = 0 (transmitter not empty). */
+ if (s->lsr & UART_LSR_TEMT) {
+ error_report("inconsistent state in serial device "
+ "(tsr empty, tsr_retry=%d", s->tsr_retry);
+ return -1;
+ }
+
+ if (s->tsr_retry > MAX_XMIT_RETRY) {
+ s->tsr_retry = MAX_XMIT_RETRY;
+ }
+
+ assert(s->watch_tag == 0);
+ s->watch_tag = qemu_chr_fe_add_watch(s->chr, G_IO_OUT|G_IO_HUP,
+ serial_watch_cb, s);
+ } else {
+ /* tsr_retry == 0 implies LSR.TEMT = 1 (transmitter empty). */
+ if (!(s->lsr & UART_LSR_TEMT)) {
+ error_report("inconsistent state in serial device "
+ "(tsr not empty, tsr_retry=0");
+ return -1;
+ }
}
s->last_break_enable = (s->lcr >> 6) & 1;
--
2.5.5
next prev parent reply other threads:[~2016-06-23 17:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-23 17:22 [Qemu-devel] [PATCH v2 0/6] serial: flow control fixes Paolo Bonzini
2016-06-23 17:22 ` [Qemu-devel] [PATCH v2 1/6] serial: make tsr_retry unsigned Paolo Bonzini
2016-06-23 17:22 ` [Qemu-devel] [PATCH v2 2/6] serial: simplify tsr_retry reset Paolo Bonzini
2016-06-23 17:22 ` [Qemu-devel] [PATCH v2 3/6] serial: separate serial_xmit and serial_watch_cb Paolo Bonzini
2016-06-23 17:22 ` [Qemu-devel] [PATCH v2 4/6] char: change qemu_chr_fe_add_watch to return unsigned Paolo Bonzini
2016-06-23 17:22 ` [Qemu-devel] [PATCH v2 5/6] serial: remove watch on reset Paolo Bonzini
2016-06-23 17:22 ` Paolo Bonzini [this message]
2016-06-24 9:30 ` [Qemu-devel] [PATCH v2 0/6] serial: flow control fixes Dr. David Alan Gilbert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1466702539-17607-7-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=dgilbert@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).