ia64/xen-unstable

changeset 19543:81d6b5762c40

New option conring_size= to allow larger console ring.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Apr 14 14:52:27 2009 +0100 (2009-04-14)
parents cbaae05c2902
children 94ffd85005c5
files xen/arch/ia64/xen/xensetup.c xen/arch/x86/setup.c xen/drivers/char/console.c xen/include/xen/console.h
line diff
     1.1 --- a/xen/arch/ia64/xen/xensetup.c	Tue Apr 14 11:21:45 2009 +0100
     1.2 +++ b/xen/arch/ia64/xen/xensetup.c	Tue Apr 14 14:52:27 2009 +0100
     1.3 @@ -374,7 +374,6 @@ void __init start_kernel(void)
     1.4          ns16550_init(0, &ns16550_com1);
     1.5          ns16550_init(1, &ns16550_com2);
     1.6      }
     1.7 -    serial_init_preirq();
     1.8  
     1.9  #ifdef CONFIG_VGA
    1.10      /* Plug in a default VGA mode */
    1.11 @@ -390,7 +389,7 @@ void __init start_kernel(void)
    1.12                                          ia64_boot_param->console_info.num_cols;
    1.13  #endif
    1.14  
    1.15 -    init_console();
    1.16 +    console_init_preirq();
    1.17  
    1.18      if (running_on_sim || ia64_boot_param->domain_start == 0 ||
    1.19                            ia64_boot_param->domain_size == 0) {
    1.20 @@ -648,7 +647,7 @@ printk("num_online_cpus=%d, max_cpus=%d\
    1.21                  ns16550_init(0, &ns16550_com1);
    1.22              }
    1.23          }
    1.24 -        serial_init_postirq();
    1.25 +        console_init_postirq();
    1.26      }
    1.27  
    1.28      expose_p2m_init();
     2.1 --- a/xen/arch/x86/setup.c	Tue Apr 14 11:21:45 2009 +0100
     2.2 +++ b/xen/arch/x86/setup.c	Tue Apr 14 14:52:27 2009 +0100
     2.3 @@ -463,9 +463,7 @@ void __init __start_xen(unsigned long mb
     2.4      ns16550.io_base = 0x2f8;
     2.5      ns16550.irq     = 3;
     2.6      ns16550_init(1, &ns16550);
     2.7 -    serial_init_preirq();
     2.8 -
     2.9 -    init_console();
    2.10 +    console_init_preirq();
    2.11  
    2.12      printk("Command line: %s\n", cmdline);
    2.13  
    2.14 @@ -958,7 +956,7 @@ void __init __start_xen(unsigned long mb
    2.15  
    2.16      initialize_keytable();
    2.17  
    2.18 -    serial_init_postirq();
    2.19 +    console_init_postirq();
    2.20  
    2.21      for_each_present_cpu ( i )
    2.22      {
     3.1 --- a/xen/drivers/char/console.c	Tue Apr 14 11:21:45 2009 +0100
     3.2 +++ b/xen/drivers/char/console.c	Tue Apr 14 14:52:27 2009 +0100
     3.3 @@ -58,10 +58,16 @@ boolean_param("console_to_ring", opt_con
     3.4  static int opt_console_timestamps;
     3.5  boolean_param("console_timestamps", opt_console_timestamps);
     3.6  
     3.7 -#define CONRING_SIZE 16384
     3.8 -#define CONRING_IDX_MASK(i) ((i)&(CONRING_SIZE-1))
     3.9 -static char conring[CONRING_SIZE];
    3.10 -static uint32_t conringc, conringp;
    3.11 +/* conring_size: allows a large console ring than default (16kB). */
    3.12 +static uint32_t opt_conring_size;
    3.13 +static void parse_conring_size(char *s)
    3.14 +{ opt_conring_size = parse_size_and_unit(s, NULL); }
    3.15 +custom_param("conring_size", parse_conring_size);
    3.16 +
    3.17 +#define _CONRING_SIZE 16384
    3.18 +#define CONRING_IDX_MASK(i) ((i)&(conring_size-1))
    3.19 +static char _conring[_CONRING_SIZE], *conring = _conring;
    3.20 +static uint32_t conring_size = _CONRING_SIZE, conringc, conringp;
    3.21  
    3.22  static int sercon_handle = -1;
    3.23  
    3.24 @@ -178,8 +184,8 @@ static void putchar_console_ring(int c)
    3.25  {
    3.26      ASSERT(spin_is_locked(&console_lock));
    3.27      conring[CONRING_IDX_MASK(conringp++)] = c;
    3.28 -    if ( (uint32_t)(conringp - conringc) > CONRING_SIZE )
    3.29 -        conringc = conringp - CONRING_SIZE;
    3.30 +    if ( (uint32_t)(conringp - conringc) > conring_size )
    3.31 +        conringc = conringp - conring_size;
    3.32  }
    3.33  
    3.34  long read_console_ring(struct xen_sysctl_readconsole *op)
    3.35 @@ -199,8 +205,8 @@ long read_console_ring(struct xen_sysctl
    3.36      {
    3.37          idx = CONRING_IDX_MASK(c);
    3.38          len = conringp - c;
    3.39 -        if ( (idx + len) > CONRING_SIZE )
    3.40 -            len = CONRING_SIZE - idx;
    3.41 +        if ( (idx + len) > conring_size )
    3.42 +            len = conring_size - idx;
    3.43          if ( (sofar + len) > max )
    3.44              len = max - sofar;
    3.45          if ( copy_to_guest_offset(str, sofar, &conring[idx], len) )
    3.46 @@ -212,8 +218,8 @@ long read_console_ring(struct xen_sysctl
    3.47      if ( op->clear )
    3.48      {
    3.49          spin_lock_irq(&console_lock);
    3.50 -        if ( (uint32_t)(conringp - c) > CONRING_SIZE )
    3.51 -            conringc = conringp - CONRING_SIZE;
    3.52 +        if ( (uint32_t)(conringp - c) > conring_size )
    3.53 +            conringc = conringp - conring_size;
    3.54          else
    3.55              conringc = c;
    3.56          spin_unlock_irq(&console_lock);
    3.57 @@ -544,10 +550,12 @@ void printk(const char *fmt, ...)
    3.58      local_irq_restore(flags);
    3.59  }
    3.60  
    3.61 -void __init init_console(void)
    3.62 +void __init console_init_preirq(void)
    3.63  {
    3.64      char *p;
    3.65  
    3.66 +    serial_init_preirq();
    3.67 +
    3.68      /* Where should console output go? */
    3.69      for ( p = opt_console; p != NULL; p = strchr(p, ',') )
    3.70      {
    3.71 @@ -587,6 +595,37 @@ void __init init_console(void)
    3.72      }
    3.73  }
    3.74  
    3.75 +void __init console_init_postirq(void)
    3.76 +{
    3.77 +    char *ring;
    3.78 +    unsigned int i;
    3.79 +
    3.80 +    serial_init_postirq();
    3.81 +
    3.82 +    /* Round size down to a power of two. */
    3.83 +    while ( opt_conring_size & (opt_conring_size - 1) )
    3.84 +        opt_conring_size &= opt_conring_size - 1;
    3.85 +    if ( opt_conring_size < conring_size )
    3.86 +        return;
    3.87 +    
    3.88 +    ring = xmalloc_bytes(opt_conring_size);
    3.89 +    if ( ring == NULL )
    3.90 +    {
    3.91 +        printk("Unable to allocate console ring of %u bytes.\n",
    3.92 +               opt_conring_size);
    3.93 +        return;
    3.94 +    }
    3.95 +
    3.96 +    spin_lock_irq(&console_lock);
    3.97 +    for ( i = conringc ; i != conringp; i++ )
    3.98 +        ring[i & (opt_conring_size - 1)] = conring[i & (conring_size - 1)];
    3.99 +    conring_size = opt_conring_size;
   3.100 +    conring = ring;
   3.101 +    spin_unlock_irq(&console_lock);
   3.102 +
   3.103 +    printk("Allocated console ring of %u bytes.\n", opt_conring_size);
   3.104 +}
   3.105 +
   3.106  void __init console_endboot(void)
   3.107  {
   3.108      int i, j;
     4.1 --- a/xen/include/xen/console.h	Tue Apr 14 11:21:45 2009 +0100
     4.2 +++ b/xen/include/xen/console.h	Tue Apr 14 14:52:27 2009 +0100
     4.3 @@ -14,7 +14,8 @@
     4.4  struct xen_sysctl_readconsole;
     4.5  long read_console_ring(struct xen_sysctl_readconsole *op);
     4.6  
     4.7 -void init_console(void);
     4.8 +void console_init_preirq(void);
     4.9 +void console_init_postirq(void);
    4.10  void console_endboot(void);
    4.11  int console_has(const char *device);
    4.12