]> xenbits.xensource.com Git - xen.git/commitdiff
New boot parameter 'serial_tx_buffer=<size>' to change serial
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 23 Apr 2008 13:06:51 +0000 (14:06 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 23 Apr 2008 13:06:51 +0000 (14:06 +0100)
transmit buffer size from default of 16kB.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
xen/drivers/char/console.c
xen/drivers/char/serial.c
xen/include/xen/serial.h

index b2d1a7d820b75e69c6fd185e8972d337e1612233..feef9a5506513d6ff1eb75f209ea7401b6009051 100644 (file)
@@ -322,7 +322,7 @@ static long guest_console_write(XEN_GUEST_HANDLE(char) buffer, int count)
 
     while ( count > 0 )
     {
-        while ( serial_tx_space(sercon_handle) < (SERIAL_TXBUFSZ / 2) )
+        while ( serial_tx_space(sercon_handle) < (serial_txbufsz / 2) )
         {
             if ( hypercall_preempt_check() )
                 break;
index 2cbb475dab254cd8e7c6b14bf0500dd1de75e028..cf2df9b3df8bb6b95fda6d1e675a0ebe280fd8b1 100644 (file)
 #include <xen/mm.h>
 #include <xen/serial.h>
 
+unsigned int serial_txbufsz = 16384;
+static void __init parse_serial_tx_buffer(const char *s)
+{
+    serial_txbufsz = max((unsigned int)parse_size_and_unit(s, NULL), 512u);
+}
+custom_param("serial_tx_buffer", parse_serial_tx_buffer);
+
+#define mask_serial_rxbuf_idx(_i) ((_i)&(serial_rxbufsz-1))
+#define mask_serial_txbuf_idx(_i) ((_i)&(serial_txbufsz-1))
+
 static struct serial_port com[2] = {
     { .rx_lock = SPIN_LOCK_UNLOCKED, .tx_lock = SPIN_LOCK_UNLOCKED }, 
     { .rx_lock = SPIN_LOCK_UNLOCKED, .tx_lock = SPIN_LOCK_UNLOCKED }
@@ -36,8 +46,8 @@ void serial_rx_interrupt(struct serial_port *port, struct cpu_user_regs *regs)
             fn = port->rx_hi;
         else if ( !(c & 0x80) && (port->rx_lo != NULL) )
             fn = port->rx_lo;
-        else if ( (port->rxbufp - port->rxbufc) != SERIAL_RXBUFSZ )
-            port->rxbuf[MASK_SERIAL_RXBUF_IDX(port->rxbufp++)] = c;            
+        else if ( (port->rxbufp - port->rxbufc) != serial_rxbufsz )
+            port->rxbuf[mask_serial_rxbuf_idx(port->rxbufp++)] = c;            
     }
 
     spin_unlock_irqrestore(&port->rx_lock, flags);
@@ -72,7 +82,7 @@ void serial_tx_interrupt(struct serial_port *port, struct cpu_user_regs *regs)
             if ( port->txbufc == port->txbufp )
                 break;
             port->driver->putc(
-                port, port->txbuf[MASK_SERIAL_TXBUF_IDX(port->txbufc++)]);
+                port, port->txbuf[mask_serial_txbuf_idx(port->txbufc++)]);
         }
     }
 
@@ -86,15 +96,15 @@ static void __serial_putc(struct serial_port *port, char c)
     if ( (port->txbuf != NULL) && !port->sync )
     {
         /* Interrupt-driven (asynchronous) transmitter. */
-        if ( (port->txbufp - port->txbufc) == SERIAL_TXBUFSZ )
+        if ( (port->txbufp - port->txbufc) == serial_txbufsz )
         {
             /* Buffer is full: we spin, but could alternatively drop chars. */
             while ( !port->driver->tx_empty(port) )
                 cpu_relax();
             for ( i = 0; i < port->tx_fifo_size; i++ )
                 port->driver->putc(
-                    port, port->txbuf[MASK_SERIAL_TXBUF_IDX(port->txbufc++)]);
-            port->txbuf[MASK_SERIAL_TXBUF_IDX(port->txbufp++)] = c;
+                    port, port->txbuf[mask_serial_txbuf_idx(port->txbufc++)]);
+            port->txbuf[mask_serial_txbuf_idx(port->txbufp++)] = c;
         }
         else if ( ((port->txbufp - port->txbufc) == 0) &&
                   port->driver->tx_empty(port) )
@@ -105,7 +115,7 @@ static void __serial_putc(struct serial_port *port, char c)
         else
         {
             /* Normal case: buffer the character. */
-            port->txbuf[MASK_SERIAL_TXBUF_IDX(port->txbufp++)] = c;
+            port->txbuf[mask_serial_txbuf_idx(port->txbufp++)] = c;
         }
     }
     else if ( port->driver->tx_empty )
@@ -200,7 +210,7 @@ char serial_getc(int handle)
             
             if ( port->rxbufp != port->rxbufc )
             {
-                c = port->rxbuf[MASK_SERIAL_RXBUF_IDX(port->rxbufc++)];
+                c = port->rxbuf[mask_serial_rxbuf_idx(port->rxbufc++)];
                 spin_unlock_irqrestore(&port->rx_lock, flags);
                 break;
             }
@@ -336,7 +346,7 @@ void serial_start_sync(int handle)
             while ( !port->driver->tx_empty(port) )
                 cpu_relax();
             port->driver->putc(
-                port, port->txbuf[MASK_SERIAL_TXBUF_IDX(port->txbufc++)]);
+                port, port->txbuf[mask_serial_txbuf_idx(port->txbufc++)]);
         }
     }
 
@@ -364,9 +374,9 @@ int serial_tx_space(int handle)
 {
     struct serial_port *port;
     if ( handle == -1 )
-        return SERIAL_TXBUFSZ;
+        return serial_txbufsz;
     port = &com[handle & SERHND_IDX];
-    return SERIAL_TXBUFSZ - (port->txbufp - port->txbufc);
+    return serial_txbufsz - (port->txbufp - port->txbufc);
 }
 
 void __devinit serial_init_preirq(void)
@@ -431,7 +441,7 @@ void serial_async_transmit(struct serial_port *port)
     BUG_ON(!port->driver->tx_empty);
     if ( port->txbuf == NULL )
         port->txbuf = alloc_xenheap_pages(
-            get_order_from_bytes(SERIAL_TXBUFSZ));
+            get_order_from_bytes(serial_txbufsz));
 }
 
 /*
index 75a07c93395bd04addd72c7ef8ba7518d2beb64d..1608cf53e3832c5dada0102a2809afed06135270 100644 (file)
@@ -16,12 +16,10 @@ typedef void (*serial_rx_fn)(char, struct cpu_user_regs *);
 void serial_set_rx_handler(int handle, serial_rx_fn fn);
 
 /* Number of characters we buffer for a polling receiver. */
-#define SERIAL_RXBUFSZ 32
-#define MASK_SERIAL_RXBUF_IDX(_i) ((_i)&(SERIAL_RXBUFSZ-1))
+#define serial_rxbufsz 32
 
 /* Number of characters we buffer for an interrupt-driven transmitter. */
-#define SERIAL_TXBUFSZ 16384
-#define MASK_SERIAL_TXBUF_IDX(_i) ((_i)&(SERIAL_TXBUFSZ-1))
+extern unsigned int serial_txbufsz;
 
 struct uart_driver;
 
@@ -39,7 +37,7 @@ struct serial_port {
     /* Receiver callback functions (asynchronous receivers). */
     serial_rx_fn        rx_lo, rx_hi, rx;
     /* Receive data buffer (polling receivers). */
-    char                rxbuf[SERIAL_RXBUFSZ];
+    char                rxbuf[serial_rxbufsz];
     unsigned int        rxbufp, rxbufc;
     /* Serial I/O is concurrency-safe. */
     spinlock_t          rx_lock, tx_lock;