From: "Justin T. Gibbs" <gibbs@scsiguy.com>
To: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: [PATCH] iommu-remote: Fix lost serial TX interrupts. Report receive overruns.
Date: Thu, 28 Jan 2010 16:26:57 -0700 [thread overview]
Message-ID: <4B621D41.5030805@scsiguy.com> (raw)
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@FreeBSD.org>
Index: xen-4.0.0-testing/tools/ioemu-remote/hw/serial.c
===================================================================
--- xen-4.0.0-testing.orig/tools/ioemu-remote/hw/serial.c
+++ xen-4.0.0-testing/tools/ioemu-remote/hw/serial.c
@@ -159,11 +159,19 @@
{
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 @@
* 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 @@
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 @@
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;
next reply other threads:[~2010-01-28 23:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-28 23:26 Justin T. Gibbs [this message]
2010-01-29 14:48 ` [PATCH] iommu-remote: Fix lost serial TX interrupts. Report receive overruns Ian Jackson
2010-01-29 15:30 ` Justin T. Gibbs
2010-02-01 16:34 ` Ian Jackson
2010-03-03 18:52 ` Trolle Selander
2010-03-03 23:07 ` Justin T. Gibbs
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=4B621D41.5030805@scsiguy.com \
--to=gibbs@scsiguy.com \
--cc=xen-devel@lists.xensource.com \
/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.