ia64/xen-unstable

changeset 17514:64c0014ae757

Drop characters if an asynchronous serial tx buffer fills up.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Apr 23 14:17:35 2008 +0100 (2008-04-23)
parents a7ddd6bcd564
children 6b48da5586f2
files xen/drivers/char/serial.c
line diff
     1.1 --- a/xen/drivers/char/serial.c	Wed Apr 23 14:06:51 2008 +0100
     1.2 +++ b/xen/drivers/char/serial.c	Wed Apr 23 14:17:35 2008 +0100
     1.3 @@ -15,6 +15,9 @@
     1.4  #include <xen/mm.h>
     1.5  #include <xen/serial.h>
     1.6  
     1.7 +/* Never drop characters, even if the async transmit buffer fills. */
     1.8 +/* #define SERIAL_NEVER_DROP_CHARS 1 */
     1.9 +
    1.10  unsigned int serial_txbufsz = 16384;
    1.11  static void __init parse_serial_tx_buffer(const char *s)
    1.12  {
    1.13 @@ -91,22 +94,24 @@ void serial_tx_interrupt(struct serial_p
    1.14  
    1.15  static void __serial_putc(struct serial_port *port, char c)
    1.16  {
    1.17 -    int i;
    1.18 -
    1.19      if ( (port->txbuf != NULL) && !port->sync )
    1.20      {
    1.21          /* Interrupt-driven (asynchronous) transmitter. */
    1.22 +#ifdef SERIAL_NEVER_DROP_CHARS
    1.23          if ( (port->txbufp - port->txbufc) == serial_txbufsz )
    1.24          {
    1.25 -            /* Buffer is full: we spin, but could alternatively drop chars. */
    1.26 +            /* Buffer is full: we spin waiting for space to appear. */
    1.27 +            int i;
    1.28              while ( !port->driver->tx_empty(port) )
    1.29                  cpu_relax();
    1.30              for ( i = 0; i < port->tx_fifo_size; i++ )
    1.31                  port->driver->putc(
    1.32                      port, port->txbuf[mask_serial_txbuf_idx(port->txbufc++)]);
    1.33              port->txbuf[mask_serial_txbuf_idx(port->txbufp++)] = c;
    1.34 +            return;
    1.35          }
    1.36 -        else if ( ((port->txbufp - port->txbufc) == 0) &&
    1.37 +#endif
    1.38 +        if ( ((port->txbufp - port->txbufc) == 0) &&
    1.39                    port->driver->tx_empty(port) )
    1.40          {
    1.41              /* Buffer and UART FIFO are both empty. */