[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-4.1-testing] ns16550: Simplify UART and UART-interrupt probing logic.



# HG changeset patch
# User Keir Fraser <keir@xxxxxxx>
# Date 1331112642 0
# Node ID f1b85192dbd8eb2da389648077bfd25b8a00a481
# Parent  6c3a6fb7013da78ccddc2e6fd0467cd30bf334fe
ns16550: Simplify UART and UART-interrupt probing logic.

1. No need to check for UART existence in the polling routine. We
already check for UART existence during boot-time initialisation (see
check_existence() function).

2. No obvious need to send a dummy character. The poll routine will
run until a character is eventually sent, but for the most common use
of serial ports (console logging) that will happen almost immediately.

Signed-off-by: Keir Fraser <keir@xxxxxxx>
xen-unstable changeset:   23811:f1349a968a5a
xen-unstable date:        Fri Sep 02 14:56:26 2011 +0100

Revert part of 23811:f1349a968a5a "ns16550: Simplify UART..."

The change to poll LSR.THRE in a loop from __ns16550_poll is a bug.
We can loop indefinitely if there are no chars to transmit.

Thanks to Jan for spotting it.

Signed-off-by: Keir Fraser <keir@xxxxxxx>
xen-unstable changeset:   23948:dcb2bd283dca
xen-unstable date:        Wed Oct 12 17:11:28 2011 +0100
---


diff -r 6c3a6fb7013d -r f1b85192dbd8 xen/drivers/char/ns16550.c
--- a/xen/drivers/char/ns16550.c        Wed Mar 07 09:25:34 2012 +0000
+++ b/xen/drivers/char/ns16550.c        Wed Mar 07 09:30:42 2012 +0000
@@ -39,7 +39,7 @@
     /* UART with no IRQ line: periodically-polled I/O. */
     struct timer timer;
     unsigned int timeout_ms;
-    bool_t probing, intr_works;
+    bool_t intr_works;
     /* PCI card parameters. */
     unsigned int pb_bdf[3]; /* pci bridge BDF */
     unsigned int ps_bdf[3]; /* pci serial port BDF */
@@ -133,12 +133,7 @@
     struct serial_port *port = dev_id;
     struct ns16550 *uart = port->uart;
 
-    if (uart->intr_works == 0)
-    {
-        uart->probing = 0;
-        uart->intr_works = 1;
-        stop_timer(&uart->timer);
-    }
+    uart->intr_works = 1;
 
     while ( !(ns_read_reg(uart, IIR) & IIR_NOINT) )
     {
@@ -150,7 +145,7 @@
     }
 }
 
-/* Safe: ns16550_poll() runs in softirq context so not reentrant on a given 
CPU. */
+/* Safe: ns16550_poll() runs as softirq so not reentrant on a given CPU. */
 static DEFINE_PER_CPU(struct serial_port *, poll_port);
 
 static void __ns16550_poll(struct cpu_user_regs *regs)
@@ -161,12 +156,6 @@
     if ( uart->intr_works )
         return;     /* Interrupts work - no more polling */
 
-    if ( uart->probing ) {
-        uart->probing = 0;
-        if ( (ns_read_reg(uart, LSR) & 0xff) == 0xff )
-            return;     /* All bits set - probably no UART present */
-    }
-
     while ( ns_read_reg(uart, LSR) & LSR_DR )
         serial_rx_interrupt(port, regs);
 
@@ -230,6 +219,8 @@
     unsigned char lcr;
     unsigned int  divisor;
 
+    uart->intr_works = 0;
+
     pci_serial_early_init(uart);
 
     /* I/O ports are distinguished by their size (16 bits). */
@@ -304,12 +295,6 @@
 
         /* Enable receive and transmit interrupts. */
         ns_write_reg(uart, IER, IER_ERDAI | IER_ETHREI);
-
-        /* Do a timed write to make sure we are getting interrupts. */
-        uart->probing = 1;
-        uart->intr_works = 0;
-        ns_write_reg(uart, THR, 0xff);
-        set_timer(&uart->timer, NOW() + MILLISECS(uart->timeout_ms));
     }
 }
 

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.