ia64/xen-unstable

changeset 17513:a7ddd6bcd564

New boot parameter 'serial_tx_buffer=<size>' to change serial
transmit buffer size from default of 16kB.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Apr 23 14:06:51 2008 +0100 (2008-04-23)
parents ee8fe9aa9c55
children 64c0014ae757
files xen/drivers/char/console.c xen/drivers/char/serial.c xen/include/xen/serial.h
line diff
     1.1 --- a/xen/drivers/char/console.c	Wed Apr 23 13:51:55 2008 +0100
     1.2 +++ b/xen/drivers/char/console.c	Wed Apr 23 14:06:51 2008 +0100
     1.3 @@ -322,7 +322,7 @@ static long guest_console_write(XEN_GUES
     1.4  
     1.5      while ( count > 0 )
     1.6      {
     1.7 -        while ( serial_tx_space(sercon_handle) < (SERIAL_TXBUFSZ / 2) )
     1.8 +        while ( serial_tx_space(sercon_handle) < (serial_txbufsz / 2) )
     1.9          {
    1.10              if ( hypercall_preempt_check() )
    1.11                  break;
     2.1 --- a/xen/drivers/char/serial.c	Wed Apr 23 13:51:55 2008 +0100
     2.2 +++ b/xen/drivers/char/serial.c	Wed Apr 23 14:06:51 2008 +0100
     2.3 @@ -15,6 +15,16 @@
     2.4  #include <xen/mm.h>
     2.5  #include <xen/serial.h>
     2.6  
     2.7 +unsigned int serial_txbufsz = 16384;
     2.8 +static void __init parse_serial_tx_buffer(const char *s)
     2.9 +{
    2.10 +    serial_txbufsz = max((unsigned int)parse_size_and_unit(s, NULL), 512u);
    2.11 +}
    2.12 +custom_param("serial_tx_buffer", parse_serial_tx_buffer);
    2.13 +
    2.14 +#define mask_serial_rxbuf_idx(_i) ((_i)&(serial_rxbufsz-1))
    2.15 +#define mask_serial_txbuf_idx(_i) ((_i)&(serial_txbufsz-1))
    2.16 +
    2.17  static struct serial_port com[2] = {
    2.18      { .rx_lock = SPIN_LOCK_UNLOCKED, .tx_lock = SPIN_LOCK_UNLOCKED }, 
    2.19      { .rx_lock = SPIN_LOCK_UNLOCKED, .tx_lock = SPIN_LOCK_UNLOCKED }
    2.20 @@ -36,8 +46,8 @@ void serial_rx_interrupt(struct serial_p
    2.21              fn = port->rx_hi;
    2.22          else if ( !(c & 0x80) && (port->rx_lo != NULL) )
    2.23              fn = port->rx_lo;
    2.24 -        else if ( (port->rxbufp - port->rxbufc) != SERIAL_RXBUFSZ )
    2.25 -            port->rxbuf[MASK_SERIAL_RXBUF_IDX(port->rxbufp++)] = c;            
    2.26 +        else if ( (port->rxbufp - port->rxbufc) != serial_rxbufsz )
    2.27 +            port->rxbuf[mask_serial_rxbuf_idx(port->rxbufp++)] = c;            
    2.28      }
    2.29  
    2.30      spin_unlock_irqrestore(&port->rx_lock, flags);
    2.31 @@ -72,7 +82,7 @@ void serial_tx_interrupt(struct serial_p
    2.32              if ( port->txbufc == port->txbufp )
    2.33                  break;
    2.34              port->driver->putc(
    2.35 -                port, port->txbuf[MASK_SERIAL_TXBUF_IDX(port->txbufc++)]);
    2.36 +                port, port->txbuf[mask_serial_txbuf_idx(port->txbufc++)]);
    2.37          }
    2.38      }
    2.39  
    2.40 @@ -86,15 +96,15 @@ static void __serial_putc(struct serial_
    2.41      if ( (port->txbuf != NULL) && !port->sync )
    2.42      {
    2.43          /* Interrupt-driven (asynchronous) transmitter. */
    2.44 -        if ( (port->txbufp - port->txbufc) == SERIAL_TXBUFSZ )
    2.45 +        if ( (port->txbufp - port->txbufc) == serial_txbufsz )
    2.46          {
    2.47              /* Buffer is full: we spin, but could alternatively drop chars. */
    2.48              while ( !port->driver->tx_empty(port) )
    2.49                  cpu_relax();
    2.50              for ( i = 0; i < port->tx_fifo_size; i++ )
    2.51                  port->driver->putc(
    2.52 -                    port, port->txbuf[MASK_SERIAL_TXBUF_IDX(port->txbufc++)]);
    2.53 -            port->txbuf[MASK_SERIAL_TXBUF_IDX(port->txbufp++)] = c;
    2.54 +                    port, port->txbuf[mask_serial_txbuf_idx(port->txbufc++)]);
    2.55 +            port->txbuf[mask_serial_txbuf_idx(port->txbufp++)] = c;
    2.56          }
    2.57          else if ( ((port->txbufp - port->txbufc) == 0) &&
    2.58                    port->driver->tx_empty(port) )
    2.59 @@ -105,7 +115,7 @@ static void __serial_putc(struct serial_
    2.60          else
    2.61          {
    2.62              /* Normal case: buffer the character. */
    2.63 -            port->txbuf[MASK_SERIAL_TXBUF_IDX(port->txbufp++)] = c;
    2.64 +            port->txbuf[mask_serial_txbuf_idx(port->txbufp++)] = c;
    2.65          }
    2.66      }
    2.67      else if ( port->driver->tx_empty )
    2.68 @@ -200,7 +210,7 @@ char serial_getc(int handle)
    2.69              
    2.70              if ( port->rxbufp != port->rxbufc )
    2.71              {
    2.72 -                c = port->rxbuf[MASK_SERIAL_RXBUF_IDX(port->rxbufc++)];
    2.73 +                c = port->rxbuf[mask_serial_rxbuf_idx(port->rxbufc++)];
    2.74                  spin_unlock_irqrestore(&port->rx_lock, flags);
    2.75                  break;
    2.76              }
    2.77 @@ -336,7 +346,7 @@ void serial_start_sync(int handle)
    2.78              while ( !port->driver->tx_empty(port) )
    2.79                  cpu_relax();
    2.80              port->driver->putc(
    2.81 -                port, port->txbuf[MASK_SERIAL_TXBUF_IDX(port->txbufc++)]);
    2.82 +                port, port->txbuf[mask_serial_txbuf_idx(port->txbufc++)]);
    2.83          }
    2.84      }
    2.85  
    2.86 @@ -364,9 +374,9 @@ int serial_tx_space(int handle)
    2.87  {
    2.88      struct serial_port *port;
    2.89      if ( handle == -1 )
    2.90 -        return SERIAL_TXBUFSZ;
    2.91 +        return serial_txbufsz;
    2.92      port = &com[handle & SERHND_IDX];
    2.93 -    return SERIAL_TXBUFSZ - (port->txbufp - port->txbufc);
    2.94 +    return serial_txbufsz - (port->txbufp - port->txbufc);
    2.95  }
    2.96  
    2.97  void __devinit serial_init_preirq(void)
    2.98 @@ -431,7 +441,7 @@ void serial_async_transmit(struct serial
    2.99      BUG_ON(!port->driver->tx_empty);
   2.100      if ( port->txbuf == NULL )
   2.101          port->txbuf = alloc_xenheap_pages(
   2.102 -            get_order_from_bytes(SERIAL_TXBUFSZ));
   2.103 +            get_order_from_bytes(serial_txbufsz));
   2.104  }
   2.105  
   2.106  /*
     3.1 --- a/xen/include/xen/serial.h	Wed Apr 23 13:51:55 2008 +0100
     3.2 +++ b/xen/include/xen/serial.h	Wed Apr 23 14:06:51 2008 +0100
     3.3 @@ -16,12 +16,10 @@ typedef void (*serial_rx_fn)(char, struc
     3.4  void serial_set_rx_handler(int handle, serial_rx_fn fn);
     3.5  
     3.6  /* Number of characters we buffer for a polling receiver. */
     3.7 -#define SERIAL_RXBUFSZ 32
     3.8 -#define MASK_SERIAL_RXBUF_IDX(_i) ((_i)&(SERIAL_RXBUFSZ-1))
     3.9 +#define serial_rxbufsz 32
    3.10  
    3.11  /* Number of characters we buffer for an interrupt-driven transmitter. */
    3.12 -#define SERIAL_TXBUFSZ 16384
    3.13 -#define MASK_SERIAL_TXBUF_IDX(_i) ((_i)&(SERIAL_TXBUFSZ-1))
    3.14 +extern unsigned int serial_txbufsz;
    3.15  
    3.16  struct uart_driver;
    3.17  
    3.18 @@ -39,7 +37,7 @@ struct serial_port {
    3.19      /* Receiver callback functions (asynchronous receivers). */
    3.20      serial_rx_fn        rx_lo, rx_hi, rx;
    3.21      /* Receive data buffer (polling receivers). */
    3.22 -    char                rxbuf[SERIAL_RXBUFSZ];
    3.23 +    char                rxbuf[serial_rxbufsz];
    3.24      unsigned int        rxbufp, rxbufc;
    3.25      /* Serial I/O is concurrency-safe. */
    3.26      spinlock_t          rx_lock, tx_lock;