Skip to content

Commit be4dfb3

Browse files
jgross1merwick
authored andcommitted
xen/netfront: fix waiting for xenbus state change
Commit 822fb18 ("xen-netfront: wait xenbus state change when load module manually") added a new wait queue to wait on for a state change when the module is loaded manually. Unfortunately there is no wakeup anywhere to stop that waiting. Instead of introducing a new wait queue rename the existing module_unload_q to module_wq and use it for both purposes (loading and unloading). As any state change of the backend might be intended to stop waiting do the wake_up_all() in any case when netback_changed() is called. Fixes: 822fb18 ("xen-netfront: wait xenbus state change when load module manually") Cc: <[email protected]> #4.18 Signed-off-by: Juergen Gross <[email protected]> Reviewed-by: Boris Ostrovsky <[email protected]> Signed-off-by: David S. Miller <[email protected]> (cherry picked from commit 8edfe2e) Orabug: 28671425 Signed-off-by: Liam Merwick <[email protected]> Reviewed-by: Darren Kenny <[email protected]> Tested-by: Boris Ostrovsky <[email protected]>
1 parent e91147f commit be4dfb3

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

drivers/net/xen-netfront.c

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ struct netfront_cb {
101101
/* IRQ name is queue name with "-tx" or "-rx" appended */
102102
#define IRQ_NAME_SIZE (QUEUE_NAME_SIZE + 3)
103103

104-
static DECLARE_WAIT_QUEUE_HEAD(module_load_q);
105-
static DECLARE_WAIT_QUEUE_HEAD(module_unload_q);
104+
static DECLARE_WAIT_QUEUE_HEAD(module_wq);
106105

107106
struct netfront_stats {
108107
u64 packets;
@@ -1630,11 +1629,11 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev)
16301629
netif_carrier_off(netdev);
16311630

16321631
xenbus_switch_state(dev, XenbusStateInitialising);
1633-
wait_event(module_load_q,
1634-
xenbus_read_driver_state(dev->otherend) !=
1635-
XenbusStateClosed &&
1636-
xenbus_read_driver_state(dev->otherend) !=
1637-
XenbusStateUnknown);
1632+
wait_event(module_wq,
1633+
xenbus_read_driver_state(dev->otherend) !=
1634+
XenbusStateClosed &&
1635+
xenbus_read_driver_state(dev->otherend) !=
1636+
XenbusStateUnknown);
16381637
return netdev;
16391638

16401639
exit:
@@ -2567,15 +2566,14 @@ static void netback_changed(struct xenbus_device *dev,
25672566

25682567
dev_dbg(&dev->dev, "%s\n", xenbus_strstate(backend_state));
25692568

2569+
wake_up_all(&module_wq);
2570+
25702571
switch (backend_state) {
25712572
case XenbusStateInitialising:
25722573
case XenbusStateInitialised:
25732574
case XenbusStateReconfiguring:
25742575
case XenbusStateReconfigured:
2575-
break;
2576-
25772576
case XenbusStateUnknown:
2578-
wake_up_all(&module_unload_q);
25792577
break;
25802578

25812579
case XenbusStateInitWait:
@@ -2591,12 +2589,10 @@ static void netback_changed(struct xenbus_device *dev,
25912589
break;
25922590

25932591
case XenbusStateClosed:
2594-
wake_up_all(&module_unload_q);
25952592
if (dev->state == XenbusStateClosed)
25962593
break;
25972594
/* Missed the backend's CLOSING state -- fallthrough */
25982595
case XenbusStateClosing:
2599-
wake_up_all(&module_unload_q);
26002596
xenbus_frontend_closed(dev);
26012597
break;
26022598
}
@@ -2729,14 +2725,14 @@ static int xennet_remove(struct xenbus_device *dev)
27292725

27302726
if (xenbus_read_driver_state(dev->otherend) != XenbusStateClosed) {
27312727
xenbus_switch_state(dev, XenbusStateClosing);
2732-
wait_event(module_unload_q,
2728+
wait_event(module_wq,
27332729
xenbus_read_driver_state(dev->otherend) ==
27342730
XenbusStateClosing ||
27352731
xenbus_read_driver_state(dev->otherend) ==
27362732
XenbusStateUnknown);
27372733

27382734
xenbus_switch_state(dev, XenbusStateClosed);
2739-
wait_event(module_unload_q,
2735+
wait_event(module_wq,
27402736
xenbus_read_driver_state(dev->otherend) ==
27412737
XenbusStateClosed ||
27422738
xenbus_read_driver_state(dev->otherend) ==

0 commit comments

Comments
 (0)