From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, bcketchum@gmail.com
Subject: Re: [Qemu-devel] [PATCH 6/6] serial: remove watch on reset
Date: Wed, 22 Jun 2016 16:38:14 +0100 [thread overview]
Message-ID: <20160622153813.GG6604@work-vm> (raw)
In-Reply-To: <1466432945-28682-7-git-send-email-pbonzini@redhat.com>
* Paolo Bonzini (pbonzini@redhat.com) wrote:
> Otherwise, this can cause serial_xmit to be entered with LSR.TEMT=0,
> which is invalid and causes an assertion failure.
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> Reported-by: Bret Ketchum <bcketchum@gmail.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> hw/char/serial.c | 16 ++++++++++++----
> 1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/hw/char/serial.c b/hw/char/serial.c
> index d232473..7c196e2 100644
> --- a/hw/char/serial.c
> +++ b/hw/char/serial.c
> @@ -228,6 +228,7 @@ static gboolean serial_watch_cb(GIOChannel *chan, GIOCondition cond,
> void *opaque)
> {
> SerialState *s = opaque;
> + s->watch_tag = 0;
> serial_xmit(s);
> return FALSE;
> }
> @@ -258,10 +259,12 @@ static void serial_xmit(SerialState *s)
> if (s->mcr & UART_MCR_LOOP) {
> /* in loopback mode, say that we just received a char */
> serial_receive1(s, &s->tsr, 1);
> - } else if (qemu_chr_fe_write(s->chr, &s->tsr, 1) != 1) {
> - if (s->tsr_retry < MAX_XMIT_RETRY &&
> - qemu_chr_fe_add_watch(s->chr, G_IO_OUT|G_IO_HUP,
> - serial_watch_cb, s) > 0) {
> + } else if (qemu_chr_fe_write(s->chr, &s->tsr, 1) != 1 &&
> + 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);
> + if (s->watch_tag > 0) {
> s->tsr_retry++;
> return;
> }
> @@ -834,6 +837,11 @@ static void serial_reset(void *opaque)
> {
> SerialState *s = opaque;
>
> + if (s->watch_tag > 0) {
> + g_source_remove(s->watch_tag);
> + s->watch_tag = 0;
> + }
> +
> s->rbr = 0;
> s->ier = 0;
> s->iir = UART_IIR_NO_INT;
> --
> 2.5.5
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
prev parent reply other threads:[~2016-06-22 15:38 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-20 14:28 [Qemu-devel] [PATCH 0/6] serial: flow control fixes Paolo Bonzini
2016-06-20 14:29 ` [Qemu-devel] [PATCH 1/6] serial: make tsr_retry unsigned Paolo Bonzini
2016-06-22 14:44 ` Dr. David Alan Gilbert
2016-06-20 14:29 ` [Qemu-devel] [PATCH 2/6] serial: reinstate watch after migration Paolo Bonzini
2016-06-22 15:05 ` Dr. David Alan Gilbert
2016-06-22 15:11 ` Paolo Bonzini
2016-06-22 15:41 ` Dr. David Alan Gilbert
2016-06-20 14:29 ` [Qemu-devel] [PATCH 3/6] serial: separate serial_xmit and serial_watch_cb Paolo Bonzini
2016-06-22 15:09 ` Dr. David Alan Gilbert
2016-06-22 15:14 ` Paolo Bonzini
2016-06-20 14:29 ` [Qemu-devel] [PATCH 4/6] serial: simplify tsr_retry reset Paolo Bonzini
2016-06-22 15:12 ` Dr. David Alan Gilbert
2016-06-20 14:29 ` [Qemu-devel] [PATCH 5/6] char: change qemu_chr_fe_add_watch to return unsigned Paolo Bonzini
2016-06-22 15:22 ` Dr. David Alan Gilbert
2016-06-20 14:29 ` [Qemu-devel] [PATCH 6/6] serial: remove watch on reset Paolo Bonzini
2016-06-22 14:04 ` Bret Ketchum
2016-06-22 15:38 ` Dr. David Alan Gilbert [this message]
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=20160622153813.GG6604@work-vm \
--to=dgilbert@redhat.com \
--cc=bcketchum@gmail.com \
--cc=pbonzini@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).