]> xenbits.xen.org Git - xenclient/xen-pq.git/commitdiff
cope with disapearing serial cards
authorJames Mckenzie <jamesmck@taoand.cam.xci-test.com>
Wed, 9 Dec 2009 19:23:41 +0000 (19:23 +0000)
committerJames Mckenzie <jamesmck@taoand.cam.xci-test.com>
Wed, 9 Dec 2009 19:23:41 +0000 (19:23 +0000)
master/cope-with-dead-serial [new file with mode: 0644]
master/series

diff --git a/master/cope-with-dead-serial b/master/cope-with-dead-serial
new file mode 100644 (file)
index 0000000..069bcf7
--- /dev/null
@@ -0,0 +1,74 @@
+diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
+index 60c373b..4fc1a86 100644
+--- a/xen/drivers/char/ns16550.c
++++ b/xen/drivers/char/ns16550.c
+@@ -127,8 +127,9 @@ static void ns16550_interrupt(
+ {
+     struct serial_port *port = dev_id;
+     struct ns16550 *uart = port->uart;
++    int bail = 0;
+-    while ( !(ns_read_reg(uart, IIR) & IIR_NOINT) )
++    while ( !(ns_read_reg(uart, IIR) & IIR_NOINT)  && (bail++ < 0x10))
+     {
+         char lsr = ns_read_reg(uart, LSR);
+         if ( lsr & LSR_THRE )
+@@ -143,11 +144,14 @@ static void ns16550_poll(void *data)
+     struct serial_port *port = data;
+     struct ns16550 *uart = port->uart;
+     struct cpu_user_regs *regs = guest_cpu_user_regs();
++    int bail;
+-    while ( ns_read_reg(uart, LSR) & LSR_DR )
++    bail=0;
++    while (( ns_read_reg(uart, LSR) & LSR_DR ) && (bail++ < 0x10))
+         serial_rx_interrupt(port, regs);
+-    if ( ns_read_reg(uart, LSR) & LSR_THRE )
++    bail=0;
++    if (( ns_read_reg(uart, LSR) & LSR_THRE && (bail++ < 0x10))
+         serial_tx_interrupt(port, regs);
+     set_timer(&uart->timer, NOW() + MILLISECS(uart->timeout_ms));
+diff --git a/xen/drivers/char/serial.c b/xen/drivers/char/serial.c
+index 3d261ca..88512ae 100644
+--- a/xen/drivers/char/serial.c
++++ b/xen/drivers/char/serial.c
+@@ -115,7 +115,8 @@ static void __serial_putc(struct serial_port *port, char c)
+             {
+                 /* Buffer is full: we spin waiting for space to appear. */
+                 int i;
+-                while ( !port->driver->tx_empty(port) )
++              int bail=0;
++                while ( !port->driver->tx_empty(port) && ( bail++ < 0x20 ) )
+                     cpu_relax();
+                 for ( i = 0; i < port->tx_fifo_size; i++ )
+                     port->driver->putc(
+@@ -145,8 +146,9 @@ static void __serial_putc(struct serial_port *port, char c)
+     }
+     else if ( port->driver->tx_empty )
+     {
++      int bail=0;
+         /* Synchronous finite-capacity transmitter. */
+-        while ( !port->driver->tx_empty(port) )
++        while ( !port->driver->tx_empty(port)  && (bail++ < 0x20))
+             cpu_relax();
+         port->driver->putc(port, c);
+     }
+@@ -354,6 +356,7 @@ void serial_start_sync(int handle)
+ {
+     struct serial_port *port;
+     unsigned long flags;
++    int bail=0;
+     if ( handle == -1 )
+         return;
+@@ -366,7 +369,7 @@ void serial_start_sync(int handle)
+     {
+         while ( (port->txbufp - port->txbufc) != 0 )
+         {
+-            while ( !port->driver->tx_empty(port) )
++            while ( !port->driver->tx_empty(port)  && (bail++ < 0x20 ))
+                 cpu_relax();
+             port->driver->putc(
+                 port, port->txbuf[mask_serial_txbuf_idx(port->txbufc++)]);
index 9f1291e2613198c8b4a4c2915800cd2a843b1b1e..d7ceca867e548fad3838e9077a0e6157432341bb 100644 (file)
@@ -29,3 +29,4 @@ hack-vbe-always-on
 filter-igfx-io
 hack-vbe-dont-check-mem
 hp-host-resume-workaround
+cope-with-dead-serial