qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
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 3/6] serial: separate serial_xmit and serial_watch_cb
Date: Wed, 22 Jun 2016 16:09:21 +0100	[thread overview]
Message-ID: <20160622150920.GD6604@work-vm> (raw)
In-Reply-To: <1466432945-28682-4-git-send-email-pbonzini@redhat.com>

* Paolo Bonzini (pbonzini@redhat.com) wrote:
> serial_xmit starts transmission of whatever is in the FIFO or THR;
> serial_watch_cb is a wrapper around it.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  hw/char/serial.c | 21 +++++++++++++--------
>  1 file changed, 13 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/char/serial.c b/hw/char/serial.c
> index 6f0a49e..4196a2e 100644
> --- a/hw/char/serial.c
> +++ b/hw/char/serial.c
> @@ -106,6 +106,7 @@ do {} while (0)
>  #endif
>  
>  static void serial_receive1(void *opaque, const uint8_t *buf, int size);
> +static void serial_xmit(SerialState *s);
>  
>  static inline void recv_fifo_put(SerialState *s, uint8_t chr)
>  {
> @@ -223,10 +224,16 @@ static void serial_update_msl(SerialState *s)
>      }
>  }
>  
> -static gboolean serial_xmit(GIOChannel *chan, GIOCondition cond, void *opaque)
> +static gboolean serial_watch_cb(GIOChannel *chan, GIOCondition cond,
> +                                void *opaque)
>  {
>      SerialState *s = opaque;
> +    serial_xmit(s);
> +    return FALSE;
> +}

Yes, with a side question.
We register this with G_IO_OUT|G_IO_HUP  but don't check the cond, what's this
code supposed to do if it gets a HUP?

Since we didn't do anything with cond before either:

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>


>  
> +static void serial_xmit(SerialState *s)
> +{
>      do {
>          assert(!(s->lsr & UART_LSR_TEMT));
>          if (s->tsr_retry == 0) {
> @@ -254,9 +261,9 @@ static gboolean serial_xmit(GIOChannel *chan, GIOCondition cond, void *opaque)
>          } 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_xmit, s) > 0) {
> +                                      serial_watch_cb, s) > 0) {
>                  s->tsr_retry++;
> -                return FALSE;
> +                return;
>              }
>              s->tsr_retry = 0;
>          } else {
> @@ -269,11 +276,8 @@ static gboolean serial_xmit(GIOChannel *chan, GIOCondition cond, void *opaque)
>  
>      s->last_xmit_ts = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
>      s->lsr |= UART_LSR_TEMT;
> -
> -    return FALSE;
>  }
>  
> -
>  /* Setter for FCR.
>     is_load flag means, that value is set while loading VM state
>     and interrupt should not be invoked */
> @@ -331,7 +335,7 @@ static void serial_ioport_write(void *opaque, hwaddr addr, uint64_t val,
>              s->lsr &= ~UART_LSR_TEMT;
>              serial_update_irq(s);
>              if (s->tsr_retry == 0) {
> -                serial_xmit(NULL, G_IO_OUT, s);
> +                serial_xmit(s);
>              }
>          }
>          break;
> @@ -647,7 +651,8 @@ static int serial_post_load(void *opaque, int version_id)
>          }
>  
>          assert(s->watch_tag == 0);
> -        s->watch_tag = qemu_chr_fe_add_watch(s->chr, G_IO_OUT|G_IO_HUP, serial_xmit, s);
> +        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)) {
> -- 
> 2.5.5
> 
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

  reply	other threads:[~2016-06-22 15:09 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 [this message]
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

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=20160622150920.GD6604@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).