[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC][patch] console_flush()
It occurs to me that since console_sync_start/stop use ++ and -- respectively, that it was designed to be "nested" and bracket code segments. If this is indeed desirable than perhaps we need another interface that simply flushed the console. The only real use I can see for it is to flush after the panic message rather than using console_sync_start() before it. Patch below. thoughts? -JX Signed-off-by: Jimi Xenidis <jimix@xxxxxxxxxxxxxx> --- diff -r d76a7a40f3a9 xen/drivers/char/console.c --- a/xen/drivers/char/console.c Fri Mar 31 17:44:26 2006 +0100 +++ b/xen/drivers/char/console.c Fri Mar 31 13:12:16 2006 -0500 @@ -526,6 +526,11 @@ void console_force_lock(void) spin_lock(&console_lock); } +void console_flush(void) +{ + serial_flush(sercon_handle); +} + void console_start_sync(void) { serial_start_sync(sercon_handle); @@ -684,7 +689,6 @@ void panic(const char *fmt, ...) va_end(args); /* Spit out multiline message in one go. */ - console_start_sync(); spin_lock_irqsave(&lock, flags); printk("\n****************************************\n"); printk("Panic on CPU %d:\n", smp_processor_id()); @@ -692,6 +696,7 @@ void panic(const char *fmt, ...) printk("****************************************\n\n"); printk("Reboot in five seconds...\n"); spin_unlock_irqrestore(&lock, flags); + console_flush(); debugger_trap_immediate(); diff -r d76a7a40f3a9 xen/drivers/char/serial.c --- a/xen/drivers/char/serial.c Fri Mar 31 17:44:26 2006 +0100 +++ b/xen/drivers/char/serial.c Fri Mar 31 13:12:16 2006 -0500 @@ -301,6 +301,30 @@ void serial_force_unlock(int handle) serial_start_sync(handle); } +static void serial_flush_locked(struct serial_port *port) +{ + while ( (port->txbufp - port->txbufc) != 0 ) + { + while ( !port->driver->tx_empty(port) ) + cpu_relax(); + port->driver->putc( + port, port->txbuf[MASK_SERIAL_TXBUF_IDX(port->txbufc++)]); + } +} + +void serial_flush(int handle) +{ + struct serial_port *port = &com[handle & SERHND_IDX]; + unsigned long flags; + + if ( handle == -1 ) + return; + + spin_lock_irqsave(&port->tx_lock, flags); + serial_flush_locked(port); + spin_unlock_irqrestore(&port->tx_lock, flags); +}; + void serial_start_sync(int handle) { struct serial_port *port = &com[handle & SERHND_IDX]; @@ -311,16 +335,8 @@ void serial_start_sync(int handle) spin_lock_irqsave(&port->tx_lock, flags); - if ( port->sync++ == 0 ) - { - while ( (port->txbufp - port->txbufc) != 0 ) - { - while ( !port->driver->tx_empty(port) ) - cpu_relax(); - port->driver->putc(- port, port->txbuf[MASK_SERIAL_TXBUF_IDX(port->txbufc+ +)]); - } - } + port->sync++; + serial_flush_locked(port); spin_unlock_irqrestore(&port->tx_lock, flags); } diff -r d76a7a40f3a9 xen/include/xen/console.h --- a/xen/include/xen/console.h Fri Mar 31 17:44:26 2006 +0100 +++ b/xen/include/xen/console.h Fri Mar 31 13:12:16 2006 -0500 @@ -22,6 +22,7 @@ void console_force_unlock(void); void console_force_unlock(void); void console_force_lock(void); +void console_flush(void); void console_start_sync(void); void console_end_sync(void); diff -r d76a7a40f3a9 xen/include/xen/serial.h --- a/xen/include/xen/serial.h Fri Mar 31 17:44:26 2006 +0100 +++ b/xen/include/xen/serial.h Fri Mar 31 13:12:16 2006 -0500 @@ -93,6 +93,7 @@ void serial_force_unlock(int handle); void serial_force_unlock(int handle);/* Start/end a synchronous region (temporarily disable interrupt- driven tx). */ +void serial_flush(int handle); void serial_start_sync(int handle); void serial_end_sync(int handle); _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |