Received: from eggs.gnu.org ([208.118.235.92]:56515) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SEjvv-00074B-Hd for qemu-devel@nongnu.org; Mon, 02 Apr 2012 12:16:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SEjvp-0004A8-9L for qemu-devel@nongnu.org; Mon, 02 Apr 2012 12:16:43 -0400 Received: from smtp.eu.citrix.com ([62.200.22.115]:34456) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SEjvp-00049i-2o for qemu-devel@nongnu.org; Mon, 02 Apr 2012 12:16:37 -0400 Date: Mon, 2 Apr 2012 17:18:36 +0100 From: Stefano Stabellini In-Reply-To: <1333377579-7513-2-git-send-email-aliguori@us.ibm.com> Message-ID: References: <1333377579-7513-1-git-send-email-aliguori@us.ibm.com> <1333377579-7513-2-git-send-email-aliguori@us.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Subject: Re: [Qemu-devel] [PATCH 1/2] serial: fix retry logic List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: "qemu-devel@nongnu.org" , Stefano Stabellini On Mon, 2 Apr 2012, Anthony Liguori wrote: > I'm not sure if the retry logic has ever worked when not using FIFO mode. I > found this while writing a test case although code inspection confirms it is > definitely broken. > > The TSR retry logic will never actually happen because it is guarded by an > 'if (s->tsr_rety > 0)' but this is the only place that can ever make the > variable greater than zero. That effectively makes the retry logic an 'if (0)'. > > I believe this is a typo and the intention was >= 0. I agree if you, I don't think there can be another explanation. > Once this is fixed though, > I see double transmits with my test case. This is because in the non FIFO > case, serial_xmit may get invoked while LSR.THRE is still high because the > character was processed but the retransmit timer was still active. If that is the case then this problem must be independent from the tsr_retry bug, considering that the code path you are changing is only taken when tsr_retry <= 0, right? > We can handle this by simply checking for LSR.THRE and returning early. > It's > possible that the FIFO paths also need some attention. The manual states: "In the FIFO mode this bit is set when the XMIT FIFO is empty; it is cleared when at least 1 byte is written to the XMIT FIFO", therefore I would return early if UART_LSR_THRE is set no matter if we are in FIFO mode or not.