ia64/linux-2.6.18-xen.hg

changeset 246:d4f9453a3de7

Use module use count on accel plugin to prevent premature unload.
Signed-off-by: Kieran Mansley <kmansley@solarflare.com>
author Keir Fraser <keir@xensource.com>
date Wed Oct 03 15:02:07 2007 +0100 (2007-10-03)
parents e7a3f045cb60
children ac1f33f633ba
files drivers/xen/netback/accel.c drivers/xen/netback/common.h
line diff
     1.1 --- a/drivers/xen/netback/accel.c	Wed Oct 03 15:01:30 2007 +0100
     1.2 +++ b/drivers/xen/netback/accel.c	Wed Oct 03 15:02:07 2007 +0100
     1.3 @@ -187,8 +187,8 @@ static int netback_accelerator_cleanup_b
     1.4   *
     1.5   * This should only be allowed when there are no remaining users -
     1.6   * i.e. it is not necessary to go through and clear all the hooks, as
     1.7 - * they should have already been removed.  This is enforced through a
     1.8 - * usage count and BUG_ON(use!=0), but should be made more user-friendly
     1.9 + * they should have already been removed.  This is enforced by taking
    1.10 + * a module reference to the plugin while the interfaces are in use
    1.11   */
    1.12  void netback_disconnect_accelerator(int id, const char *eth_name)
    1.13  {
    1.14 @@ -227,7 +227,8 @@ void netback_probe_accelerators(struct b
    1.15  	 */
    1.16  	spin_lock_irqsave(&accelerators_lock, flags);
    1.17  	list_for_each_entry(accelerator, &accelerators_list, link) { 
    1.18 -		if (match_accelerator(dev, be, accelerator)) {
    1.19 +		if (match_accelerator(dev, be, accelerator) &&
    1.20 +		    try_module_get(accelerator->hooks->owner)) {
    1.21  			be->accelerator = accelerator;
    1.22  			atomic_inc(&be->accelerator->use_count);
    1.23  			be->accelerator->hooks->probe(dev);
    1.24 @@ -242,9 +243,10 @@ void netback_remove_accelerators(struct 
    1.25  				 struct xenbus_device *dev)
    1.26  {
    1.27  	/* Notify the accelerator (if any) of this device's removal */
    1.28 -	if ( be->accelerator ) {
    1.29 +	if (be->accelerator) {
    1.30  		be->accelerator->hooks->remove(dev);
    1.31  		atomic_dec(&be->accelerator->use_count);
    1.32 +		module_put(be->accelerator->hooks->owner);
    1.33  	}
    1.34  	be->accelerator = NULL;
    1.35  }
     2.1 --- a/drivers/xen/netback/common.h	Wed Oct 03 15:01:30 2007 +0100
     2.2 +++ b/drivers/xen/netback/common.h	Wed Oct 03 15:02:07 2007 +0100
     2.3 @@ -125,6 +125,7 @@ extern int netbk_copy_skb_mode;
     2.4  
     2.5  /* Function pointers into netback accelerator plugin modules */
     2.6  struct netback_accel_hooks {
     2.7 +	struct module *owner;
     2.8  	int  (*probe)(struct xenbus_device *dev);
     2.9  	int (*remove)(struct xenbus_device *dev);
    2.10  };