direct-io.hg

changeset 10328:6bffed2aa78b

Fix race in device resume path - need to ensure we add the watch only
after the device-specific resume code has run. Also removed some unused /
usless code from netfront.c.

Signed-off-by: Steven Hand <steven@xensource.com>
author shand@chelmsford.uk.xensource.com
date Mon Jun 12 17:56:20 2006 +0100 (2006-06-12)
parents c230dbe793d6
children bb89ec7765c7
files linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Mon Jun 12 14:17:05 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Mon Jun 12 17:56:20 2006 +0100
     1.3 @@ -157,8 +157,6 @@ static void netif_disconnect_backend(str
     1.4  static void close_netdev(struct netfront_info *);
     1.5  static void netif_free(struct netfront_info *);
     1.6  
     1.7 -static void show_device(struct netfront_info *);
     1.8 -
     1.9  static void network_connect(struct net_device *);
    1.10  static void network_tx_buf_gc(struct net_device *);
    1.11  static void network_alloc_rx_buffers(struct net_device *);
    1.12 @@ -411,7 +409,6 @@ static void backend_changed(struct xenbu
    1.13  		network_connect(netdev);
    1.14  		xenbus_switch_state(dev, XenbusStateConnected);
    1.15  		(void)send_fake_arp(netdev);
    1.16 -		show_device(np);
    1.17  		break;
    1.18  
    1.19  	case XenbusStateClosing:
    1.20 @@ -605,7 +602,7 @@ static void network_alloc_rx_buffers(str
    1.21  		np->grant_rx_ref[id] = ref;
    1.22  		gnttab_grant_foreign_transfer_ref(ref,
    1.23  						  np->xbdev->otherend_id,
    1.24 -						  __pa(skb->head) >> PAGE_SHIFT);
    1.25 +						  __pa(skb->head)>>PAGE_SHIFT);
    1.26  		RING_GET_REQUEST(&np->rx, req_prod + i)->gref = ref;
    1.27  		np->rx_pfn_array[i] = virt_to_mfn(skb->head);
    1.28  
    1.29 @@ -1166,22 +1163,6 @@ static void network_connect(struct net_d
    1.30  	spin_unlock_irq(&np->tx_lock);
    1.31  }
    1.32  
    1.33 -static void show_device(struct netfront_info *np)
    1.34 -{
    1.35 -#ifdef DEBUG
    1.36 -	if (np) {
    1.37 -		IPRINTK("<vif handle=%u %s(%s) evtchn=%u tx=%p rx=%p>\n",
    1.38 -			np->handle,
    1.39 -			netif_carrier_ok(np->netdev) ? "on" : "off",
    1.40 -			netif_running(np->netdev) ? "open" : "closed",
    1.41 -			np->evtchn,
    1.42 -			np->tx,
    1.43 -			np->rx);
    1.44 -	} else
    1.45 -		IPRINTK("<vif NULL>\n");
    1.46 -#endif
    1.47 -}
    1.48 -
    1.49  static void netif_uninit(struct net_device *dev)
    1.50  {
    1.51  	struct netfront_info *np = netdev_priv(dev);
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Mon Jun 12 14:17:05 2006 +0100
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Mon Jun 12 17:56:20 2006 +0100
     2.3 @@ -806,6 +806,7 @@ static int resume_dev(struct device *dev
     2.4  
     2.5  	if (dev->driver == NULL)
     2.6  		return 0;
     2.7 +
     2.8  	drv = to_xenbus_driver(dev->driver);
     2.9  	xdev = container_of(dev, struct xenbus_device, dev);
    2.10  
    2.11 @@ -816,6 +817,18 @@ static int resume_dev(struct device *dev
    2.12  		       dev->bus_id, err);
    2.13  		return err;
    2.14  	}
    2.15 +        
    2.16 +	xdev->state = XenbusStateInitialising;
    2.17 +        
    2.18 +	if (drv->resume) {
    2.19 +		err = drv->resume(xdev);
    2.20 +                if (err) { 
    2.21 +                        printk(KERN_WARNING
    2.22 +                               "xenbus: resume %s failed: %i\n", 
    2.23 +                               dev->bus_id, err);
    2.24 +                        return err; 
    2.25 +                }
    2.26 +        }
    2.27  
    2.28  	err = watch_otherend(xdev);
    2.29  	if (err) {
    2.30 @@ -825,14 +838,7 @@ static int resume_dev(struct device *dev
    2.31  		return err;
    2.32  	}
    2.33  
    2.34 -	xdev->state = XenbusStateInitialising;
    2.35 -
    2.36 -	if (drv->resume)
    2.37 -		err = drv->resume(xdev);
    2.38 -	if (err)
    2.39 -		printk(KERN_WARNING
    2.40 -		       "xenbus: resume %s failed: %i\n", dev->bus_id, err);
    2.41 -	return err;
    2.42 +	return 0; 
    2.43  }
    2.44  
    2.45  void xenbus_suspend(void)