# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1208956011 -3600
# Node ID a7ddd6bcd564965af54a9df236d89503a76923e1
# Parent ee8fe9aa9c5551d95c2540be146290ede3c246a7
New boot parameter 'serial_tx_buffer=<size>' to change serial
transmit buffer size from default of 16kB.
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
xen/drivers/char/console.c | 2 +-
xen/drivers/char/serial.c | 36 +++++++++++++++++++++++-------------
xen/include/xen/serial.h | 8 +++-----
3 files changed, 27 insertions(+), 19 deletions(-)
diff -r ee8fe9aa9c55 -r a7ddd6bcd564 xen/drivers/char/console.c
--- a/xen/drivers/char/console.c Wed Apr 23 13:51:55 2008 +0100
+++ b/xen/drivers/char/console.c Wed Apr 23 14:06:51 2008 +0100
@@ -322,7 +322,7 @@ static long guest_console_write(XEN_GUES
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;
diff -r ee8fe9aa9c55 -r a7ddd6bcd564 xen/drivers/char/serial.c
--- a/xen/drivers/char/serial.c Wed Apr 23 13:51:55 2008 +0100
+++ b/xen/drivers/char/serial.c Wed Apr 23 14:06:51 2008 +0100
@@ -15,6 +15,16 @@
#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_p
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_p
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_
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_
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;
- port = &com[handle & SERHND_IDX];
- return SERIAL_TXBUFSZ - (port->txbufp - port->txbufc);
+ return serial_txbufsz;
+ port = &com[handle & SERHND_IDX];
+ return serial_txbufsz - (port->txbufp - port->txbufc);
}
void __devinit serial_init_preirq(void)
@@ -431,7 +441,7 @@ void serial_async_transmit(struct serial
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));
}
/*
diff -r ee8fe9aa9c55 -r a7ddd6bcd564 xen/include/xen/serial.h
--- a/xen/include/xen/serial.h Wed Apr 23 13:51:55 2008 +0100
+++ b/xen/include/xen/serial.h Wed Apr 23 14:06:51 2008 +0100
@@ -16,12 +16,10 @@ void serial_set_rx_handler(int handle, s
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;
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|