From owner-freebsd-current@FreeBSD.ORG Fri Sep 11 21:37:28 2009 Return-Path: Delivered-To: freebsd-current@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B174C1065672 for ; Fri, 11 Sep 2009 21:37:28 +0000 (UTC) (envelope-from nox@jelal.kn-bremen.de) Received: from smtp.kn-bremen.de (gelbbaer.kn-bremen.de [78.46.108.116]) by mx1.freebsd.org (Postfix) with ESMTP id 723928FC0C for ; Fri, 11 Sep 2009 21:37:28 +0000 (UTC) Received: by smtp.kn-bremen.de (Postfix, from userid 10) id ADE151E0038B; Fri, 11 Sep 2009 23:37:26 +0200 (CEST) Received: from triton8.kn-bremen.de (noident@localhost [127.0.0.1]) by triton8.kn-bremen.de (8.14.3/8.14.3) with ESMTP id n8BLZ9uV098014; Fri, 11 Sep 2009 23:35:09 +0200 (CEST) (envelope-from nox@triton8.kn-bremen.de) Received: (from nox@localhost) by triton8.kn-bremen.de (8.14.3/8.14.3/Submit) id n8BLZ8EW098012; Fri, 11 Sep 2009 23:35:08 +0200 (CEST) (envelope-from nox) From: Juergen Lock Date: Fri, 11 Sep 2009 23:35:08 +0200 To: qemu-devel@nongnu.org Message-ID: <20090911213508.GA97446@triton8.kn-bremen.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Cc: Olivier =?us-ascii?B?PT9pc28tODg1OS0xP1E/Q29jaGFyZC1MYWJiPUU5Pz0=?= , freebsd-current@FreeBSD.org Subject: qemu serial: lost tx irqs (affectig FreeBSD's new uart(4) driver) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2009 21:37:28 -0000 Hi! I got a report of FreeBSD guest's new uart(4) driver misbehaving in qemu again(?) (output stopping for no apparent reason), and now found out the problem is tx irqs (UART_IIR_THRI) are getting lost because serial_update_irq() checks for the rx condtion, ... if ((s->ier & UART_IER_RDI) && (s->lsr & UART_LSR_DR)) first before checking for the tx irq condition, ... if ((s->ier & UART_IER_THRI) && s->thr_ipending) which at least in this case (FreeBSD 8 guest after doing set console="comconsole" at the loader prompt or when simply echo'ing text to /dev/ttyu0 or typing to the serial port from cu(1) on a `regular' vga console) causes the second condition (.. && s->thr_ipending) to be never reached anymore, or only after a very long delay. Moving that condition up so it is checked first like this, Index: qemu/hw/serial.c @@ -189,7 +188,9 @@ static void serial_update_irq(SerialStat { uint8_t tmp_iir = UART_IIR_NO_INT; - if ((s->ier & UART_IER_RLSI) && (s->lsr & UART_LSR_INT_ANY)) { + if ((s->ier & UART_IER_THRI) && s->thr_ipending) { + tmp_iir = UART_IIR_THRI; + } else if ((s->ier & UART_IER_RLSI) && (s->lsr & UART_LSR_INT_ANY)) { tmp_iir = UART_IIR_RLSI; } else if ((s->ier & UART_IER_RDI) && s->timeout_ipending) { /* Note that(s->ier & UART_IER_RDI) can mask this interrupt, @@ -202,8 +203,6 @@ static void serial_update_irq(SerialStat } else if (s->recv_fifo.count >= s->recv_fifo.itl) { tmp_iir = UART_IIR_RDI; } - } else if ((s->ier & UART_IER_THRI) && s->thr_ipending) { - tmp_iir = UART_IIR_THRI; } else if ((s->ier & UART_IER_MSI) && (s->msr & UART_MSR_ANY_DELTA)) { tmp_iir = UART_IIR_MSI; } ...fixes the issue for me, but I'm not 100% sure if this might cause rx irqs to come (too?) late when a guest keeps sending while its receiving at the same time. Anyone care to comment? :) Thanx, Juergen