From: shand@chelmsford.uk.xensource.com Date: Mon, 12 Jun 2006 16:56:20 +0000 (+0100) Subject: Fix race in device resume path - need to ensure we add the watch only X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~15972^2~7 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=9f640de2b067a6b299b941941b4b6de7c33d2715;p=xen.git 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 --- diff --git a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c index 6a026774d4..b0fc28d04c 100644 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c @@ -157,8 +157,6 @@ static void netif_disconnect_backend(struct netfront_info *); 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 xenbus_device *dev, 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(struct net_device *dev) 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_device *dev) spin_unlock_irq(&np->tx_lock); } -static void show_device(struct netfront_info *np) -{ -#ifdef DEBUG - if (np) { - IPRINTK("\n", - np->handle, - netif_carrier_ok(np->netdev) ? "on" : "off", - netif_running(np->netdev) ? "open" : "closed", - np->evtchn, - np->tx, - np->rx); - } else - IPRINTK("\n"); -#endif -} - static void netif_uninit(struct net_device *dev) { struct netfront_info *np = netdev_priv(dev); diff --git a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c index b03957e983..3bef9b3084 100644 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c @@ -806,6 +806,7 @@ static int resume_dev(struct device *dev, void *data) 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, void *data) 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, void *data) 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)