[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] Fix race in device resume path - need to ensure we add the watch only



# HG changeset patch
# User shand@xxxxxxxxxxxxxxxxxxxxxxxxxxx
# Node ID 6bffed2aa78b2a4d213c4d70378135d33565dbc3
# Parent  c230dbe793d623d67ca1d486c0c1a8db5c7cab94
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@xxxxxxxxxxxxx>
---
 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c   |   21 ----------------
 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c |   22 ++++++++++-------
 2 files changed, 15 insertions(+), 28 deletions(-)

diff -r c230dbe793d6 -r 6bffed2aa78b 
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Mon Jun 12 
14:17:05 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Mon Jun 12 
17:56:20 2006 +0100
@@ -157,8 +157,6 @@ static void close_netdev(struct netfront
 static void close_netdev(struct netfront_info *);
 static void netif_free(struct netfront_info *);
 
-static void show_device(struct netfront_info *);
-
 static void network_connect(struct net_device *);
 static void network_tx_buf_gc(struct net_device *);
 static void network_alloc_rx_buffers(struct net_device *);
@@ -411,7 +409,6 @@ static void backend_changed(struct xenbu
                network_connect(netdev);
                xenbus_switch_state(dev, XenbusStateConnected);
                (void)send_fake_arp(netdev);
-               show_device(np);
                break;
 
        case XenbusStateClosing:
@@ -605,7 +602,7 @@ static void network_alloc_rx_buffers(str
                np->grant_rx_ref[id] = ref;
                gnttab_grant_foreign_transfer_ref(ref,
                                                  np->xbdev->otherend_id,
-                                                 __pa(skb->head) >> 
PAGE_SHIFT);
+                                                 __pa(skb->head)>>PAGE_SHIFT);
                RING_GET_REQUEST(&np->rx, req_prod + i)->gref = ref;
                np->rx_pfn_array[i] = virt_to_mfn(skb->head);
 
@@ -1166,22 +1163,6 @@ static void network_connect(struct net_d
        spin_unlock_irq(&np->tx_lock);
 }
 
-static void show_device(struct netfront_info *np)
-{
-#ifdef DEBUG
-       if (np) {
-               IPRINTK("<vif handle=%u %s(%s) evtchn=%u tx=%p rx=%p>\n",
-                       np->handle,
-                       netif_carrier_ok(np->netdev) ? "on" : "off",
-                       netif_running(np->netdev) ? "open" : "closed",
-                       np->evtchn,
-                       np->tx,
-                       np->rx);
-       } else
-               IPRINTK("<vif NULL>\n");
-#endif
-}
-
 static void netif_uninit(struct net_device *dev)
 {
        struct netfront_info *np = netdev_priv(dev);
diff -r c230dbe793d6 -r 6bffed2aa78b 
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c    Mon Jun 12 
14:17:05 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c    Mon Jun 12 
17:56:20 2006 +0100
@@ -806,6 +806,7 @@ static int resume_dev(struct device *dev
 
        if (dev->driver == NULL)
                return 0;
+
        drv = to_xenbus_driver(dev->driver);
        xdev = container_of(dev, struct xenbus_device, dev);
 
@@ -816,6 +817,18 @@ static int resume_dev(struct device *dev
                       dev->bus_id, err);
                return err;
        }
+        
+       xdev->state = XenbusStateInitialising;
+        
+       if (drv->resume) {
+               err = drv->resume(xdev);
+                if (err) { 
+                        printk(KERN_WARNING
+                               "xenbus: resume %s failed: %i\n", 
+                               dev->bus_id, err);
+                        return err; 
+                }
+        }
 
        err = watch_otherend(xdev);
        if (err) {
@@ -825,14 +838,7 @@ static int resume_dev(struct device *dev
                return err;
        }
 
-       xdev->state = XenbusStateInitialising;
-
-       if (drv->resume)
-               err = drv->resume(xdev);
-       if (err)
-               printk(KERN_WARNING
-                      "xenbus: resume %s failed: %i\n", dev->bus_id, err);
-       return err;
+       return 0; 
 }
 
 void xenbus_suspend(void)

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.