WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [qemu-xen-unstable] Fix lost serial TX interrupts. Repor

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [qemu-xen-unstable] Fix lost serial TX interrupts. Report receive overruns.
From: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
Date: Mon, 1 Feb 2010 09:05:04 -0800
Delivery-date: Mon, 01 Feb 2010 09:05:31 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
commit 575ed1016f6fba1c6a6cd32a828cb468bdee96bb
Author: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Date:   Mon Feb 1 16:33:52 2010 +0000

    Fix lost serial TX interrupts.  Report receive overruns.
    
    This patch corrects emulation errors in QEMU's 16550 uart emulation,
    which cause compatibility issues with FreeBSD's uart(9) driver.
    
       o Implement receive overrun status.  The FreeBSD uart(9) driver
         relies on this status in it's probe routine to determine the size
         of the FIFO supported.
       o As per the 16550 spec, do not overwrite the RX FIFO on an RX overrun.
       o Do not allow TX or RX FIFO overruns to increment the data valid count
         beyond the size of the FIFO.
       o For reads of the IIR register, only clear the "TX holding register
         empty" (THRE) interrupt if the read reports this interrupt.  This
         is required by the specification and avoids losing TX interrupts
         when other, higher priority interrupts (usually RX) are reported first.
    
    This patch also includes a fix for a second cause of lost TX interrupts,
    which was submitted by Jergen Lock, and is already in the latest QEMU.
    
       o If a receive interrupt is suppressed due to the FIFO not yet filling
         to its interrupt threshold, do not also supress any pending THRE
         interrupt.
    
    A version of this patch, against the latest QEMU, has also been submitted
    to the qemu-devel mailing list.
    
    Signed-off-by: Justin T. Gibbs <gibbs@xxxxxxxxxxx>
    (cherry picked from commit 0994c7a1c4f4026f25f9b80f9b3816fc165ede4d)
---
 hw/serial.c |   38 +++++++++++++++++++++++---------------
 1 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/hw/serial.c b/hw/serial.c
index f554609..86d3d6e 100644
--- a/hw/serial.c
+++ b/hw/serial.c
@@ -159,11 +159,19 @@ static int fifo_put(SerialState *s, int fifo, uint8_t chr)
 {
     SerialFIFO *f = (fifo) ? &s->recv_fifo : &s->xmit_fifo;
 
-    f->data[f->head++] = chr;
+    /* Receive overruns do not overwrite FIFO contents. */
+    if (fifo == XMIT_FIFO || f->count < UART_FIFO_LENGTH) {
 
-    if (f->head == UART_FIFO_LENGTH)
-        f->head = 0;
-    f->count++;
+        f->data[f->head++] = chr;
+
+        if (f->head == UART_FIFO_LENGTH)
+            f->head = 0;
+    }
+
+    if (f->count < UART_FIFO_LENGTH)
+        f->count++;
+    else if (fifo == RECV_FIFO)
+        s->lsr |= UART_LSR_OE;
 
     return 1;
 }
@@ -195,12 +203,10 @@ static void serial_update_irq(SerialState *s)
          * this is not in the specification but is observed on existing
          * hardware.  */
         tmp_iir = UART_IIR_CTI;
-    } else if ((s->ier & UART_IER_RDI) && (s->lsr & UART_LSR_DR)) {
-        if (!(s->fcr & UART_FCR_FE)) {
-           tmp_iir = UART_IIR_RDI;
-        } else if (s->recv_fifo.count >= s->recv_fifo.itl) {
-           tmp_iir = UART_IIR_RDI;
-        }
+    } else if ((s->ier & UART_IER_RDI) && (s->lsr & UART_LSR_DR) &&
+               (!(s->fcr & UART_FCR_FE) ||
+                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)) {
@@ -523,8 +529,10 @@ static uint32_t serial_ioport_read(void *opaque, uint32_t 
addr)
         break;
     case 2:
         ret = s->iir;
-        s->thr_ipending = 0;
-        serial_update_irq(s);
+        if (ret & UART_IIR_THRI) {
+            s->thr_ipending = 0;
+            serial_update_irq(s);
+        }
         break;
     case 3:
         ret = s->lcr;
@@ -534,9 +542,9 @@ static uint32_t serial_ioport_read(void *opaque, uint32_t 
addr)
         break;
     case 5:
         ret = s->lsr;
-        /* Clear break interrupt */
-        if (s->lsr & UART_LSR_BI) {
-            s->lsr &= ~UART_LSR_BI;
+        /* Clear break and overrun interrupts */
+        if (s->lsr & (UART_LSR_BI|UART_LSR_OE)) {
+            s->lsr &= ~(UART_LSR_BI|UART_LSR_OE);
             serial_update_irq(s);
         }
         break;
--
generated by git-patchbot for /home/xen/git/qemu-xen-unstable.git

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [qemu-xen-unstable] Fix lost serial TX interrupts. Report receive overruns., Ian Jackson <=