ia64/xen-unstable

changeset 8452:27ea8232fe79

Reorganizes network frontend device unregister and removal, so that
occur in the right order and succeed.

Now on Closing state we:
- stop queue
- unbind irq
- unregister the device

On removal:
- end foreign access to TX and RX pages (we cannot do this before)
- free_netdev, doing the last stage of destroying an allocated device

Makes xm-test network "03_attach_detach_multiple_pos" pass:
http://xmtest.dague.org/cgi-bin/display?view=single&testid=1068

Signed-off-by: Murillo F. Bernardes <mfb@br.ibm.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed Dec 28 15:07:43 2005 +0100 (2005-12-28)
parents ebe84a7f2a8b
children 0e47bcdac69d
files linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Wed Dec 28 15:07:16 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Wed Dec 28 15:07:43 2005 +0100
     1.3 @@ -1209,34 +1209,15 @@ static int netfront_remove(struct xenbus
     1.4  
     1.5  	DPRINTK("%s\n", dev->nodename);
     1.6  
     1.7 -	netif_free(info);
     1.8 -	kfree(info);
     1.9 +	netif_disconnect_backend(info);
    1.10 +	free_netdev(info->netdev);
    1.11  
    1.12  	return 0;
    1.13  }
    1.14  
    1.15  
    1.16 -static void netif_free(struct netfront_info *info)
    1.17 -{
    1.18 -	netif_disconnect_backend(info);
    1.19 -	close_netdev(info);
    1.20 -}
    1.21 -
    1.22 -
    1.23  static void close_netdev(struct netfront_info *info)
    1.24  {
    1.25 -	if (info->netdev) {
    1.26 -#ifdef CONFIG_PROC_FS
    1.27 -		xennet_proc_delif(info->netdev);
    1.28 -#endif
    1.29 -		unregister_netdev(info->netdev);
    1.30 -		info->netdev = NULL;
    1.31 -	}
    1.32 -}
    1.33 -
    1.34 -
    1.35 -static void netif_disconnect_backend(struct netfront_info *info)
    1.36 -{
    1.37  	/* Stop old i/f to prevent errors whilst we rebuild the state. */
    1.38  	spin_lock_irq(&info->tx_lock);
    1.39  	spin_lock(&info->rx_lock);
    1.40 @@ -1245,18 +1226,36 @@ static void netif_disconnect_backend(str
    1.41  	spin_unlock(&info->rx_lock);
    1.42  	spin_unlock_irq(&info->tx_lock);
    1.43  
    1.44 +#ifdef CONFIG_PROC_FS
    1.45 +	xennet_proc_delif(info->netdev);
    1.46 +#endif
    1.47 +
    1.48 +	if (info->irq)
    1.49 +		unbind_from_irqhandler(info->irq, info->netdev);
    1.50 +	info->evtchn = info->irq = 0;
    1.51 +
    1.52 +	del_timer_sync(&info->rx_refill_timer);
    1.53 +
    1.54 +	unregister_netdev(info->netdev);
    1.55 +}
    1.56 +
    1.57 +
    1.58 +static void netif_disconnect_backend(struct netfront_info *info)
    1.59 +{
    1.60  	end_access(info->tx_ring_ref, info->tx.sring);
    1.61  	end_access(info->rx_ring_ref, info->rx.sring);
    1.62  	info->tx_ring_ref = GRANT_INVALID_REF;
    1.63  	info->rx_ring_ref = GRANT_INVALID_REF;
    1.64  	info->tx.sring = NULL;
    1.65  	info->rx.sring = NULL;
    1.66 +}
    1.67  
    1.68 -	if (info->irq)
    1.69 -		unbind_from_irqhandler(info->irq, info->netdev);
    1.70 -	info->evtchn = info->irq = 0;
    1.71  
    1.72 -	del_timer_sync(&info->rx_refill_timer);
    1.73 +static void netif_free(struct netfront_info *info)
    1.74 +{
    1.75 +	close_netdev(info);
    1.76 +	netif_disconnect_backend(info);
    1.77 +	free_netdev(info->netdev);
    1.78  }
    1.79  
    1.80