ia64/xen-unstable

changeset 8184:0a81c6edf2b1

Simplify console driver and avoid unnecessary spinning in the
transmit handler.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Dec 02 16:14:20 2005 +0100 (2005-12-02)
parents 7062c49e99af
children e13c994bdccb
files linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c linux-2.6-xen-sparse/drivers/xen/console/console.c linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c linux-2.6-xen-sparse/include/asm-xen/xencons.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c	Fri Dec 02 15:37:31 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c	Fri Dec 02 16:14:20 2005 +0100
     1.3 @@ -389,7 +389,6 @@ void pgd_free(pgd_t *pgd)
     1.4  }
     1.5  
     1.6  #ifndef CONFIG_XEN_SHADOW_MODE
     1.7 -asmlinkage int xprintk(const char *fmt, ...);
     1.8  void make_lowmem_page_readonly(void *va)
     1.9  {
    1.10  	pte_t *pte = virt_to_ptep(va);
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/console/console.c	Fri Dec 02 15:37:31 2005 +0100
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/console/console.c	Fri Dec 02 16:14:20 2005 +0100
     2.3 @@ -55,7 +55,6 @@
     2.4  #include <asm-xen/evtchn.h>
     2.5  #include <asm-xen/xencons.h>
     2.6  
     2.7 -#include "xencons_ring.h"
     2.8  /*
     2.9   * Modes:
    2.10   *  'xencons=off'  [XC_OFF]:     Console is disabled.
    2.11 @@ -247,7 +246,6 @@ void xencons_force_flush(void)
    2.12  	if (xen_start_info->flags & SIF_INITDOMAIN)
    2.13  		return;
    2.14  
    2.15 -
    2.16  	/* Spin until console data is flushed through to the daemon. */
    2.17  	while (wc != wp) {
    2.18  		int sent = 0;
    2.19 @@ -271,8 +269,7 @@ static struct tty_struct *xencons_tty;
    2.20  static int xencons_priv_irq;
    2.21  static char x_char;
    2.22  
    2.23 -/* Non-privileged receive callback. */
    2.24 -static void xencons_rx(char *buf, unsigned len, struct pt_regs *regs)
    2.25 +void xencons_rx(char *buf, unsigned len, struct pt_regs *regs)
    2.26  {
    2.27  	int           i;
    2.28  	unsigned long flags;
    2.29 @@ -311,10 +308,9 @@ static void xencons_rx(char *buf, unsign
    2.30  	spin_unlock_irqrestore(&xencons_lock, flags);
    2.31  }
    2.32  
    2.33 -/* Privileged and non-privileged transmit worker. */
    2.34  static void __xencons_tx_flush(void)
    2.35  {
    2.36 -	int sz, work_done = 0;
    2.37 +	int sent, sz, work_done = 0;
    2.38  
    2.39  	if (xen_start_info->flags & SIF_INITDOMAIN) {
    2.40  		if (x_char) {
    2.41 @@ -340,20 +336,18 @@ static void __xencons_tx_flush(void)
    2.42  		}
    2.43  
    2.44  		while (wc != wp) {
    2.45 -			int sent;
    2.46  			sz = wp - wc;
    2.47  			if (sz > (wbuf_size - WBUF_MASK(wc)))
    2.48  				sz = wbuf_size - WBUF_MASK(wc);
    2.49  			sent = xencons_ring_send(&wbuf[WBUF_MASK(wc)], sz);
    2.50 -			if (sent > 0) {
    2.51 -				wc += sent;
    2.52 -				work_done = 1;
    2.53 -			}
    2.54 +			if (sent == 0)
    2.55 +				break;
    2.56 +			wc += sent;
    2.57 +			work_done = 1;
    2.58  		}
    2.59  	}
    2.60  
    2.61 -	if (work_done && (xencons_tty != NULL))
    2.62 -	{
    2.63 +	if (work_done && (xencons_tty != NULL)) {
    2.64  		wake_up_interruptible(&xencons_tty->write_wait);
    2.65  		if ((xencons_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
    2.66  		    (xencons_tty->ldisc.write_wakeup != NULL))
    2.67 @@ -361,31 +355,26 @@ static void __xencons_tx_flush(void)
    2.68  	}
    2.69  }
    2.70  
    2.71 +void xencons_tx(void)
    2.72 +{
    2.73 +	unsigned long flags;
    2.74 +
    2.75 +	spin_lock_irqsave(&xencons_lock, flags);
    2.76 +	__xencons_tx_flush();
    2.77 +	spin_unlock_irqrestore(&xencons_lock, flags);
    2.78 +}
    2.79 +
    2.80  /* Privileged receive callback and transmit kicker. */
    2.81  static irqreturn_t xencons_priv_interrupt(int irq, void *dev_id,
    2.82                                            struct pt_regs *regs)
    2.83  {
    2.84 -	static char   rbuf[16];
    2.85 -	int           i, l;
    2.86 -	unsigned long flags;
    2.87 -
    2.88 -	spin_lock_irqsave(&xencons_lock, flags);
    2.89 +	static char rbuf[16];
    2.90 +	int         l;
    2.91  
    2.92 -	if (xencons_tty != NULL)
    2.93 -	{
    2.94 -		/* Receive work. */
    2.95 -		while ((l = HYPERVISOR_console_io(
    2.96 -			CONSOLEIO_read, 16, rbuf)) > 0)
    2.97 -			for (i = 0; i < l; i++)
    2.98 -				tty_insert_flip_char(xencons_tty, rbuf[i], 0);
    2.99 -		if (xencons_tty->flip.count != 0)
   2.100 -			tty_flip_buffer_push(xencons_tty);
   2.101 -	}
   2.102 +	while ((l = HYPERVISOR_console_io(CONSOLEIO_read, 16, rbuf)) > 0)
   2.103 +		xencons_rx(rbuf, l, regs);
   2.104  
   2.105 -	/* Transmit work. */
   2.106 -	__xencons_tx_flush();
   2.107 -
   2.108 -	spin_unlock_irqrestore(&xencons_lock, flags);
   2.109 +	xencons_tx();
   2.110  
   2.111  	return IRQ_HANDLED;
   2.112  }
   2.113 @@ -664,7 +653,8 @@ static int __init xencons_init(void)
   2.114  	if ((rc = tty_register_driver(DRV(xencons_driver))) != 0) {
   2.115  		printk("WARNING: Failed to register Xen virtual "
   2.116  		       "console driver as '%s%d'\n",
   2.117 -		       DRV(xencons_driver)->name, DRV(xencons_driver)->name_base);
   2.118 +		       DRV(xencons_driver)->name,
   2.119 +		       DRV(xencons_driver)->name_base);
   2.120  		put_tty_driver(xencons_driver);
   2.121  		xencons_driver = NULL;
   2.122  		return rc;
   2.123 @@ -681,8 +671,6 @@ static int __init xencons_init(void)
   2.124  			"console",
   2.125  			NULL);
   2.126  		BUG_ON(xencons_priv_irq < 0);
   2.127 -	} else {
   2.128 -		xencons_ring_register_receiver(xencons_rx);
   2.129  	}
   2.130  
   2.131  	printk("Xen virtual console successfully installed as %s%d\n",
     3.1 --- a/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c	Fri Dec 02 15:37:31 2005 +0100
     3.2 +++ b/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c	Fri Dec 02 16:14:20 2005 +0100
     3.3 @@ -19,11 +19,9 @@
     3.4  #include <linux/interrupt.h>
     3.5  #include <linux/sched.h>
     3.6  #include <linux/err.h>
     3.7 -#include "xencons_ring.h"
     3.8  #include <asm-xen/xen-public/io/console.h>
     3.9  
    3.10  static int xencons_irq;
    3.11 -static xencons_receiver_func *xencons_receiver;
    3.12  
    3.13  static inline struct xencons_interface *xencons_interface(void)
    3.14  {
    3.15 @@ -69,10 +67,8 @@ static irqreturn_t handle_input(int irq,
    3.16  	BUG_ON((prod - cons) > sizeof(intf->in));
    3.17  
    3.18  	while (cons != prod) {
    3.19 -		if (xencons_receiver != NULL)
    3.20 -			xencons_receiver(
    3.21 -				intf->in + MASK_XENCONS_IDX(cons++, intf->in),
    3.22 -				1, regs);
    3.23 +		xencons_rx(intf->in+MASK_XENCONS_IDX(cons,intf->in), 1, regs);
    3.24 +		cons++;
    3.25  	}
    3.26  
    3.27  	mb();
    3.28 @@ -80,12 +76,9 @@ static irqreturn_t handle_input(int irq,
    3.29  
    3.30  	notify_daemon();
    3.31  
    3.32 -	return IRQ_HANDLED;
    3.33 -}
    3.34 +	xencons_tx();
    3.35  
    3.36 -void xencons_ring_register_receiver(xencons_receiver_func *f)
    3.37 -{
    3.38 -	xencons_receiver = f;
    3.39 +	return IRQ_HANDLED;
    3.40  }
    3.41  
    3.42  int xencons_ring_init(void)
     4.1 --- a/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.h	Fri Dec 02 15:37:31 2005 +0100
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,23 +0,0 @@
     4.4 -#ifndef _XENCONS_RING_H
     4.5 -#define _XENCONS_RING_H
     4.6 -
     4.7 -asmlinkage int xprintk(const char *fmt, ...);
     4.8 -
     4.9 -int xencons_ring_init(void);
    4.10 -int xencons_ring_send(const char *data, unsigned len);
    4.11 -
    4.12 -typedef void (xencons_receiver_func)(
    4.13 -	char *buf, unsigned len, struct pt_regs *regs);
    4.14 -void xencons_ring_register_receiver(xencons_receiver_func *f);
    4.15 -
    4.16 -#endif /* _XENCONS_RING_H */
    4.17 -
    4.18 -/*
    4.19 - * Local variables:
    4.20 - *  c-file-style: "linux"
    4.21 - *  indent-tabs-mode: t
    4.22 - *  c-indent-level: 8
    4.23 - *  c-basic-offset: 8
    4.24 - *  tab-width: 8
    4.25 - * End:
    4.26 - */
     5.1 --- a/linux-2.6-xen-sparse/include/asm-xen/xencons.h	Fri Dec 02 15:37:31 2005 +0100
     5.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/xencons.h	Fri Dec 02 16:14:20 2005 +0100
     5.3 @@ -4,4 +4,11 @@
     5.4  void xencons_force_flush(void);
     5.5  void xencons_resume(void);
     5.6  
     5.7 +/* Interrupt work hooks. Receive data, or kick data out. */
     5.8 +void xencons_rx(char *buf, unsigned len, struct pt_regs *regs);
     5.9 +void xencons_tx(void);
    5.10 +
    5.11 +int xencons_ring_init(void);
    5.12 +int xencons_ring_send(const char *data, unsigned len);
    5.13 +
    5.14  #endif /* __ASM_XENCONS_H__ */