ia64/xen-unstable

changeset 7258:5eda9308b0ca

Remove bind_evtchn_to_irq/unbind_evtchn_from_irq from the
evtchn kernel interface. Fix error path in bind_evtchn_to_irqhandler.
Fix backend drivers to avoid double freeing IRQs.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Oct 07 11:54:38 2005 +0100 (2005-10-07)
parents 2a3e10a132a2
children e31e64e00ac3
files linux-2.6-xen-sparse/arch/ia64/xen/drivers/evtchn_ia64.c linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c linux-2.6-xen-sparse/drivers/xen/blkback/interface.c linux-2.6-xen-sparse/drivers/xen/netback/interface.c linux-2.6-xen-sparse/include/asm-xen/evtchn.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/drivers/evtchn_ia64.c	Fri Oct 07 11:16:28 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/drivers/evtchn_ia64.c	Fri Oct 07 11:54:38 2005 +0100
     1.3 @@ -67,12 +67,6 @@ void unbind_evtchn_from_irqhandler(unsig
     1.4      evtchns[evtchn].handler = NULL;
     1.5  }
     1.6  
     1.7 -void unbind_evtchn_from_irq(unsigned int evtchn)
     1.8 -{
     1.9 -	printk("unbind_evtchn_from_irq called... FIXME??\n");
    1.10 -	while(1);
    1.11 -}
    1.12 -
    1.13  irqreturn_t evtchn_interrupt(int irq, void *dev_id, struct pt_regs *regs)
    1.14  {
    1.15      u32            l1, l2;
     2.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c	Fri Oct 07 11:16:28 2005 +0100
     2.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c	Fri Oct 07 11:54:38 2005 +0100
     2.3 @@ -296,7 +296,7 @@ void unbind_ipi_from_irq(int ipi)
     2.4  }
     2.5  EXPORT_SYMBOL(unbind_ipi_from_irq);
     2.6  
     2.7 -int bind_evtchn_to_irq(unsigned int evtchn)
     2.8 +static int bind_evtchn_to_irq(unsigned int evtchn)
     2.9  {
    2.10  	int irq;
    2.11  
    2.12 @@ -314,9 +314,8 @@ int bind_evtchn_to_irq(unsigned int evtc
    2.13      
    2.14  	return irq;
    2.15  }
    2.16 -EXPORT_SYMBOL(bind_evtchn_to_irq);
    2.17  
    2.18 -void unbind_evtchn_from_irq(unsigned int irq)
    2.19 +static void unbind_evtchn_from_irq(unsigned int irq)
    2.20  {
    2.21  	evtchn_op_t op = { .cmd = EVTCHNOP_close };
    2.22  	int evtchn = irq_to_evtchn[irq];
    2.23 @@ -333,7 +332,6 @@ void unbind_evtchn_from_irq(unsigned int
    2.24  
    2.25  	spin_unlock(&irq_mapping_update_lock);
    2.26  }
    2.27 -EXPORT_SYMBOL(unbind_evtchn_from_irq);
    2.28  
    2.29  int bind_evtchn_to_irqhandler(
    2.30  	unsigned int evtchn,
    2.31 @@ -347,8 +345,10 @@ int bind_evtchn_to_irqhandler(
    2.32  
    2.33  	irq = bind_evtchn_to_irq(evtchn);
    2.34  	retval = request_irq(irq, handler, irqflags, devname, dev_id);
    2.35 -	if (retval != 0)
    2.36 +	if (retval != 0) {
    2.37  		unbind_evtchn_from_irq(irq);
    2.38 +		return retval;
    2.39 +	}
    2.40  
    2.41  	return irq;
    2.42  }
     3.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Fri Oct 07 11:16:28 2005 +0100
     3.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Fri Oct 07 11:54:38 2005 +0100
     3.3 @@ -74,6 +74,10 @@ int blkif_map(blkif_t *blkif, unsigned l
     3.4  		.u.bind_interdomain.remote_dom = blkif->domid,
     3.5  		.u.bind_interdomain.remote_port = evtchn };
     3.6  
     3.7 +	/* Already connected through? */
     3.8 +	if (blkif->irq)
     3.9 +		return 0;
    3.10 +
    3.11  	if ( (blkif->blk_ring_area = alloc_vm_area(PAGE_SIZE)) == NULL )
    3.12  		return -ENOMEM;
    3.13  
    3.14 @@ -107,8 +111,12 @@ static void free_blkif(void *arg)
    3.15  {
    3.16  	blkif_t *blkif = (blkif_t *)arg;
    3.17  
    3.18 -	if (blkif->irq)
    3.19 -		unbind_evtchn_from_irqhandler(blkif->irq, blkif);
    3.20 +	/* Already disconnected? */
    3.21 +	if (!blkif->irq)
    3.22 +		return;
    3.23 +
    3.24 +	unbind_evtchn_from_irqhandler(blkif->irq, blkif);
    3.25 +	blkif->irq = 0;
    3.26  
    3.27  	vbd_free(&blkif->vbd);
    3.28  
     4.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Fri Oct 07 11:16:28 2005 +0100
     4.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Fri Oct 07 11:54:38 2005 +0100
     4.3 @@ -183,6 +183,10 @@ int netif_map(netif_t *netif, unsigned l
     4.4  		.u.bind_interdomain.remote_dom = netif->domid,
     4.5  		.u.bind_interdomain.remote_port = evtchn };
     4.6  
     4.7 +	/* Already connected through? */
     4.8 +	if (netif->irq)
     4.9 +		return 0;
    4.10 +
    4.11  	netif->comms_area = alloc_vm_area(2*PAGE_SIZE);
    4.12  	if (netif->comms_area == NULL)
    4.13  		return -ENOMEM;
    4.14 @@ -227,13 +231,12 @@ static void free_netif_callback(void *ar
    4.15  {
    4.16  	netif_t *netif = (netif_t *)arg;
    4.17  
    4.18 -	/*
    4.19 -	 * This can't be done in netif_disconnect() because at that point
    4.20 -	 * there may be outstanding requests in the network stack whose
    4.21 -	 * asynchronous responses must still be notified to the remote driver.
    4.22 -	 */
    4.23 -	if (netif->irq)
    4.24 -		unbind_evtchn_from_irqhandler(netif->irq, netif);
    4.25 +	/* Already disconnected? */
    4.26 +	if (!netif->irq)
    4.27 +		return;
    4.28 +
    4.29 +	unbind_evtchn_from_irqhandler(netif->irq, netif);
    4.30 +	netif->irq = 0;
    4.31  
    4.32  	unregister_netdev(netif->dev);
    4.33  
     5.1 --- a/linux-2.6-xen-sparse/include/asm-xen/evtchn.h	Fri Oct 07 11:16:28 2005 +0100
     5.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/evtchn.h	Fri Oct 07 11:54:38 2005 +0100
     5.3 @@ -52,14 +52,6 @@ extern int  bind_ipi_to_irq(int ipi);
     5.4  extern void unbind_ipi_from_irq(int ipi);
     5.5  
     5.6  /*
     5.7 - * Dynamically bind an event-channel port to Linux IRQ space.
     5.8 - * BIND:   Returns IRQ or error.
     5.9 - * UNBIND: Takes IRQ to unbind from; automatically closes the event channel.
    5.10 - */
    5.11 -extern int  bind_evtchn_to_irq(unsigned int evtchn);
    5.12 -extern void unbind_evtchn_from_irq(unsigned int irq);
    5.13 -
    5.14 -/*
    5.15   * Dynamically bind an event-channel port to an IRQ-like callback handler.
    5.16   * On some platforms this may not be implemented via the Linux IRQ subsystem.
    5.17   * The IRQ argument passed to the callback handler is the same as returned