direct-io.hg

changeset 4535:36b47a20cf62

bitkeeper revision 1.1159.258.94 (425efd27VCIdiye1vxlHLWe8PRt9gA)

Add a xencons_bufsz= option to allow a larger than usual console
buffer to be allocated. Reduces chance of console output being
truncated.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Apr 14 23:30:47 2005 +0000 (2005-04-14)
parents c1b75b4f338c
children 22de1b327a43 8c272f9d3213
files linux-2.6.11-xen-sparse/drivers/xen/console/console.c
line diff
     1.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/console/console.c	Thu Apr 14 20:49:01 2005 +0000
     1.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/console/console.c	Thu Apr 14 23:30:47 2005 +0000
     1.3 @@ -44,6 +44,7 @@
     1.4  #include <linux/slab.h>
     1.5  #include <linux/init.h>
     1.6  #include <linux/console.h>
     1.7 +#include <linux/bootmem.h>
     1.8  #include <asm/io.h>
     1.9  #include <asm/irq.h>
    1.10  #include <asm/uaccess.h>
    1.11 @@ -77,11 +78,21 @@ static int __init xencons_setup(char *st
    1.12  __setup("xencons=", xencons_setup);
    1.13  
    1.14  /* The kernel and user-land drivers share a common transmit buffer. */
    1.15 -#define WBUF_SIZE     4096
    1.16 -#define WBUF_MASK(_i) ((_i)&(WBUF_SIZE-1))
    1.17 -static char wbuf[WBUF_SIZE];
    1.18 +static unsigned int wbuf_size = 4096;
    1.19 +#define WBUF_MASK(_i) ((_i)&(wbuf_size-1))
    1.20 +static char *wbuf;
    1.21  static unsigned int wc, wp; /* write_cons, write_prod */
    1.22  
    1.23 +static int __init xencons_bufsz_setup(char *str)
    1.24 +{
    1.25 +    unsigned int goal;
    1.26 +    goal = simple_strtoul(str, NULL, 0);
    1.27 +    while ( wbuf_size < goal )
    1.28 +        wbuf_size <<= 1;
    1.29 +    return 1;
    1.30 +}
    1.31 +__setup("xencons_bufsz=", xencons_bufsz_setup);
    1.32 +
    1.33  /* This lock protects accesses to the common transmit buffer. */
    1.34  static spinlock_t xencons_lock = SPIN_LOCK_UNLOCKED;
    1.35  
    1.36 @@ -114,7 +125,7 @@ static void kcons_write(
    1.37      
    1.38      for ( i = 0; i < count; i++ )
    1.39      {
    1.40 -        if ( (wp - wc) >= (WBUF_SIZE - 1) )
    1.41 +        if ( (wp - wc) >= (wbuf_size - 1) )
    1.42              break;
    1.43          if ( (wbuf[WBUF_MASK(wp++)] = s[i]) == '\n' )
    1.44              wbuf[WBUF_MASK(wp++)] = '\r';
    1.45 @@ -195,6 +206,8 @@ void xen_console_init(void)
    1.46      else
    1.47          strcpy(kcons_info.name, "tty");
    1.48  
    1.49 +    wbuf = alloc_bootmem(wbuf_size);
    1.50 +
    1.51      register_console(&kcons_info);
    1.52      return __RETCODE;
    1.53  }
    1.54 @@ -246,8 +259,8 @@ void xencons_force_flush(void)
    1.55              continue;
    1.56          if ( sz > sizeof(msg.msg) )
    1.57              sz = sizeof(msg.msg);
    1.58 -        if ( sz > (WBUF_SIZE - WBUF_MASK(wc)) )
    1.59 -            sz = WBUF_SIZE - WBUF_MASK(wc);
    1.60 +        if ( sz > (wbuf_size - WBUF_MASK(wc)) )
    1.61 +            sz = wbuf_size - WBUF_MASK(wc);
    1.62  
    1.63          msg.type    = CMSG_CONSOLE;
    1.64          msg.subtype = CMSG_CONSOLE_DATA;
    1.65 @@ -315,8 +328,8 @@ static void __xencons_tx_flush(void)
    1.66          while ( wc != wp )
    1.67          {
    1.68              sz = wp - wc;
    1.69 -            if ( sz > (WBUF_SIZE - WBUF_MASK(wc)) )
    1.70 -                sz = WBUF_SIZE - WBUF_MASK(wc);
    1.71 +            if ( sz > (wbuf_size - WBUF_MASK(wc)) )
    1.72 +                sz = wbuf_size - WBUF_MASK(wc);
    1.73              kcons_write_dom0(NULL, &wbuf[WBUF_MASK(wc)], sz);
    1.74              wc += sz;
    1.75              work_done = 1;
    1.76 @@ -344,8 +357,8 @@ static void __xencons_tx_flush(void)
    1.77              sz = wp - wc;
    1.78              if ( sz > sizeof(msg.msg) )
    1.79                  sz = sizeof(msg.msg);
    1.80 -            if ( sz > (WBUF_SIZE - WBUF_MASK(wc)) )
    1.81 -                sz = WBUF_SIZE - WBUF_MASK(wc);
    1.82 +            if ( sz > (wbuf_size - WBUF_MASK(wc)) )
    1.83 +                sz = wbuf_size - WBUF_MASK(wc);
    1.84  
    1.85              msg.type    = CMSG_CONSOLE;
    1.86              msg.subtype = CMSG_CONSOLE_DATA;
    1.87 @@ -409,7 +422,7 @@ static irqreturn_t xencons_priv_interrup
    1.88  
    1.89  static int xencons_write_room(struct tty_struct *tty)
    1.90  {
    1.91 -    return WBUF_SIZE - (wp - wc);
    1.92 +    return wbuf_size - (wp - wc);
    1.93  }
    1.94  
    1.95  static int xencons_chars_in_buffer(struct tty_struct *tty)
    1.96 @@ -468,7 +481,7 @@ static void xencons_flush_buffer(struct 
    1.97  static inline int __xencons_put_char(int ch)
    1.98  {
    1.99      char _ch = (char)ch;
   1.100 -    if ( (wp - wc) == WBUF_SIZE )
   1.101 +    if ( (wp - wc) == wbuf_size )
   1.102          return 0;
   1.103      wbuf[WBUF_MASK(wp++)] = _ch;
   1.104      return 1;