All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: imammedo@redhat.com, andrey@xdel.ru, qemu-devel@nongnu.org,
	dslutz@verizon.com, batuzovk@ispras.ru
Subject: Re: [Qemu-devel] [PATCH v3 2/4] serial: clean up THRE/TEMT handling
Date: Mon, 15 Dec 2014 13:03:17 +0100	[thread overview]
Message-ID: <548ECE05.3050009@redhat.com> (raw)
In-Reply-To: <20141215114018.GC5502@work-vm>



On 15/12/2014 12:40, Dr. David Alan Gilbert wrote:
>> >      do {
>> > +        assert(!(s->lsr & UART_LSR_TEMT));
>> > +        assert(!(s->lsr & UART_LSR_THRE));
>> > +
>> >          if (s->tsr_retry <= 0) {
>> >              if (s->fcr & UART_FCR_FE) {
>> > -                if (fifo8_is_empty(&s->xmit_fifo)) {
>> > -                    return FALSE;
>> > -                }
>> > +                assert(!fifo8_is_empty(&s->xmit_fifo));
> That's undoing dslutz@verizon.com's 
> 
> dffacd46 - Fix emptyness checking
> 
> See, http://permalink.gmane.org/gmane.comp.emulators.qemu/262412
> I don't think your assumptions are safe because of that qemu_chr_fe_add_watch.

I think it's safe because:

- serial_xmit is called from outside only after resetting TEMT and THRE
and pushing a character on the FIFO

- serial_xmit iterates a second time over do...while() only if the FIFO
is not empty (both before and after this patch; this patch only changes
the condition that is used)

- if qemu_chr_fe_add_watch is called, the next call will have tsr_retry
>= 1 and thus the "if" would be skipped.

Note that in the middle we had commit f702e62 (serial: change retry
logic to avoid concurrency, 2014-07-11) that fixed some messy behavior
of qemu_chr_fe_add_watch.  The commit message talks about multiple calls
to qemu_chr_fe_add_watch triggering s->tsr_retry >= MAX_XMIT_RETRY but
this is not the only possible failure.  If you have multiple calls, the
subsequent ones will see s->tsr_retry == 0 and will find (s->lsr &
UART_LSR_THRE) != 0 on entry.  But this should really never happen.

(Thanks for making me think more about it. :))

Paolo

  reply	other threads:[~2014-12-15 12:03 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-12 12:43 [Qemu-devel] [PATCH v3 0/4] serial fixes, including 2.2->2.1 migration Paolo Bonzini
2014-12-12 12:44 ` [Qemu-devel] [PATCH v3 1/4] serial: reset thri_pending on IER writes with THRI=0 Paolo Bonzini
2014-12-15 10:46   ` Dr. David Alan Gilbert
2014-12-15 11:51     ` Paolo Bonzini
2014-12-15 13:30       ` Dr. David Alan Gilbert
2014-12-15 13:34         ` Paolo Bonzini
2014-12-15 13:37           ` Dr. David Alan Gilbert
2014-12-15 13:45             ` Paolo Bonzini
2014-12-12 12:44 ` [Qemu-devel] [PATCH v3 2/4] serial: clean up THRE/TEMT handling Paolo Bonzini
2014-12-15 11:40   ` Dr. David Alan Gilbert
2014-12-15 12:03     ` Paolo Bonzini [this message]
2014-12-15 15:21       ` Dr. David Alan Gilbert
2014-12-15 15:26         ` Paolo Bonzini
2014-12-15 15:29           ` Dr. David Alan Gilbert
2014-12-12 12:44 ` [Qemu-devel] [PATCH v3 3/4] serial: update LSR on enabling/disabling FIFOs Paolo Bonzini
2014-12-15 15:50   ` Dr. David Alan Gilbert
2014-12-15 15:52     ` Paolo Bonzini
2014-12-12 12:44 ` [Qemu-devel] [PATCH v3 4/4] serial: only resample THR interrupt on rising edge of IER.THRI Paolo Bonzini
2014-12-15 16:05   ` Dr. David Alan Gilbert
2014-12-15 16:10     ` Paolo Bonzini

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=548ECE05.3050009@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=andrey@xdel.ru \
    --cc=batuzovk@ispras.ru \
    --cc=dgilbert@redhat.com \
    --cc=dslutz@verizon.com \
    --cc=imammedo@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.