ia64/xen-unstable

changeset 17864:d4dcd4d39952

Bring back console_start_log_everything() as a milder alternative to
console_start_sync(). Revert keyhandler logic to use it. The
difference now is that serial logic is updated to not drop characters
if inb a log_everything region. Still this is milder than a sync
region since the async buffer must be filled before we start to
busy-wait on each character.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jun 13 14:15:00 2008 +0100 (2008-06-13)
parents a41d14c3bf19
children a88e19526770
files xen/common/keyhandler.c xen/drivers/char/console.c xen/drivers/char/serial.c xen/include/xen/console.h xen/include/xen/serial.h
line diff
     1.1 --- a/xen/common/keyhandler.c	Fri Jun 13 13:55:50 2008 +0100
     1.2 +++ b/xen/common/keyhandler.c	Fri Jun 13 14:15:00 2008 +0100
     1.3 @@ -36,10 +36,10 @@ static void keypress_action(unsigned lon
     1.4  {
     1.5      keyhandler_t *h;
     1.6      unsigned char key = keypress_key;
     1.7 -    console_start_sync();
     1.8 +    console_start_log_everything();
     1.9      if ( (h = key_table[key].u.handler) != NULL )
    1.10          (*h)(key);
    1.11 -    console_end_sync();
    1.12 +    console_end_log_everything();
    1.13  }
    1.14  
    1.15  static DECLARE_TASKLET(keypress_tasklet, keypress_action, 0);
    1.16 @@ -50,10 +50,10 @@ void handle_keypress(unsigned char key, 
    1.17  
    1.18      if ( !in_irq() || (key_table[key].flags & KEYHANDLER_IRQ_CALLBACK) )
    1.19      {
    1.20 -        console_start_sync();
    1.21 +        console_start_log_everything();
    1.22          if ( (h = key_table[key].u.irq_handler) != NULL )
    1.23              (*h)(key, regs);
    1.24 -        console_end_sync();
    1.25 +        console_end_log_everything();
    1.26      }
    1.27      else
    1.28      {
    1.29 @@ -105,6 +105,9 @@ static void dump_registers(unsigned char
    1.30  {
    1.31      unsigned int cpu;
    1.32  
    1.33 +    /* We want to get everything out that we possibly can. */
    1.34 +    console_start_sync();
    1.35 +
    1.36      printk("'%c' pressed -> dumping registers\n", key);
    1.37  
    1.38      /* Get local execution state out immediately, in case we get stuck. */
    1.39 @@ -120,6 +123,8 @@ static void dump_registers(unsigned char
    1.40      }
    1.41  
    1.42      printk("\n");
    1.43 +
    1.44 +    console_end_sync();
    1.45  }
    1.46  
    1.47  static void dump_dom0_registers(unsigned char key)
     2.1 --- a/xen/drivers/char/console.c	Fri Jun 13 13:55:50 2008 +0100
     2.2 +++ b/xen/drivers/char/console.c	Fri Jun 13 14:15:00 2008 +0100
     2.3 @@ -635,6 +635,18 @@ int console_has(const char *device)
     2.4      return 0;
     2.5  }
     2.6  
     2.7 +void console_start_log_everything(void)
     2.8 +{
     2.9 +    serial_start_log_everything(sercon_handle);
    2.10 +    atomic_inc(&print_everything);
    2.11 +}
    2.12 +
    2.13 +void console_end_log_everything(void)
    2.14 +{
    2.15 +    serial_end_log_everything(sercon_handle);
    2.16 +    atomic_dec(&print_everything);
    2.17 +}
    2.18 +
    2.19  void console_force_unlock(void)
    2.20  {
    2.21      spin_lock_init(&console_lock);
     3.1 --- a/xen/drivers/char/serial.c	Fri Jun 13 13:55:50 2008 +0100
     3.2 +++ b/xen/drivers/char/serial.c	Fri Jun 13 14:15:00 2008 +0100
     3.3 @@ -108,19 +108,23 @@ static void __serial_putc(struct serial_
     3.4  
     3.5          if ( (port->txbufp - port->txbufc) == serial_txbufsz )
     3.6          {
     3.7 -#ifdef SERIAL_NEVER_DROP_CHARS
     3.8 -            /* Buffer is full: we spin waiting for space to appear. */
     3.9 -            int i;
    3.10 -            while ( !port->driver->tx_empty(port) )
    3.11 -                cpu_relax();
    3.12 -            for ( i = 0; i < port->tx_fifo_size; i++ )
    3.13 -                port->driver->putc(
    3.14 -                    port, port->txbuf[mask_serial_txbuf_idx(port->txbufc++)]);
    3.15 -            port->txbuf[mask_serial_txbuf_idx(port->txbufp++)] = c;
    3.16 -#else
    3.17 -            /* Buffer is full: drop characters until buffer is half empty. */
    3.18 -            port->tx_quench = 1;
    3.19 -#endif
    3.20 +            if ( port->tx_log_everything )
    3.21 +            {
    3.22 +                /* Buffer is full: we spin waiting for space to appear. */
    3.23 +                int i;
    3.24 +                while ( !port->driver->tx_empty(port) )
    3.25 +                    cpu_relax();
    3.26 +                for ( i = 0; i < port->tx_fifo_size; i++ )
    3.27 +                    port->driver->putc(
    3.28 +                        port,
    3.29 +                        port->txbuf[mask_serial_txbuf_idx(port->txbufc++)]);
    3.30 +                port->txbuf[mask_serial_txbuf_idx(port->txbufp++)] = c;
    3.31 +            }
    3.32 +            else
    3.33 +            {
    3.34 +                /* Buffer is full: drop chars until buffer is half empty. */
    3.35 +                port->tx_quench = 1;
    3.36 +            }
    3.37              return;
    3.38          }
    3.39  
    3.40 @@ -388,6 +392,37 @@ void serial_end_sync(int handle)
    3.41      spin_unlock_irqrestore(&port->tx_lock, flags);
    3.42  }
    3.43  
    3.44 +void serial_start_log_everything(int handle)
    3.45 +{
    3.46 +    struct serial_port *port;
    3.47 +    unsigned long flags;
    3.48 +
    3.49 +    if ( handle == -1 )
    3.50 +        return;
    3.51 +    
    3.52 +    port = &com[handle & SERHND_IDX];
    3.53 +
    3.54 +    spin_lock_irqsave(&port->tx_lock, flags);
    3.55 +    port->tx_log_everything++;
    3.56 +    port->tx_quench = 0;
    3.57 +    spin_unlock_irqrestore(&port->tx_lock, flags);
    3.58 +}
    3.59 +
    3.60 +void serial_end_log_everything(int handle)
    3.61 +{
    3.62 +    struct serial_port *port;
    3.63 +    unsigned long flags;
    3.64 +
    3.65 +    if ( handle == -1 )
    3.66 +        return;
    3.67 +    
    3.68 +    port = &com[handle & SERHND_IDX];
    3.69 +
    3.70 +    spin_lock_irqsave(&port->tx_lock, flags);
    3.71 +    port->tx_log_everything--;
    3.72 +    spin_unlock_irqrestore(&port->tx_lock, flags);
    3.73 +}
    3.74 +
    3.75  int serial_tx_space(int handle)
    3.76  {
    3.77      struct serial_port *port;
     4.1 --- a/xen/include/xen/console.h	Fri Jun 13 13:55:50 2008 +0100
     4.2 +++ b/xen/include/xen/console.h	Fri Jun 13 14:15:00 2008 +0100
     4.3 @@ -26,6 +26,9 @@ void console_force_lock(void);
     4.4  void console_start_sync(void);
     4.5  void console_end_sync(void);
     4.6  
     4.7 +void console_start_log_everything(void);
     4.8 +void console_end_log_everything(void);
     4.9 +
    4.10  /*
    4.11   * Steal output from the console. Returns +ve identifier, else -ve error.
    4.12   * Takes the handle of the serial line to steal, and steal callback function.
     5.1 --- a/xen/include/xen/serial.h	Fri Jun 13 13:55:50 2008 +0100
     5.2 +++ b/xen/include/xen/serial.h	Fri Jun 13 14:15:00 2008 +0100
     5.3 @@ -33,6 +33,7 @@ struct serial_port {
     5.4      char               *txbuf;
     5.5      unsigned int        txbufp, txbufc;
     5.6      bool_t              tx_quench;
     5.7 +    int                 tx_log_everything;
     5.8      /* Force synchronous transmit. */
     5.9      int                 sync;
    5.10      /* Receiver callback functions (asynchronous receivers). */
    5.11 @@ -97,6 +98,10 @@ void serial_force_unlock(int handle);
    5.12  void serial_start_sync(int handle);
    5.13  void serial_end_sync(int handle);
    5.14  
    5.15 +/* Start/end a region where we will wait rather than drop characters. */
    5.16 +void serial_start_log_everything(int handle);
    5.17 +void serial_end_log_everything(int handle);
    5.18 +
    5.19  /* Return number of bytes headroom in transmit buffer. */
    5.20  int serial_tx_space(int handle);
    5.21