Skip to content

Commit f603701

Browse files
liangxiao1ZhengShunQian
authored andcommitted
xen-netfront: wait xenbus state change when load module manually
[ Upstream commit 822fb18 ] When loading module manually, after call xenbus_switch_state to initializes the state of the netfront device, the driver state did not change so fast that may lead no dev created in latest kernel. This patch adds wait to make sure xenbus knows the driver is not in closed/unknown state. Current state: [vm]# ethtool eth0 Settings for eth0: Link detected: yes [vm]# modprobe -r xen_netfront [vm]# modprobe xen_netfront [vm]# ethtool eth0 Settings for eth0: Cannot get device settings: No such device Cannot get wake-on-lan settings: No such device Cannot get message level: No such device Cannot get link status: No such device No data available With the patch installed. [vm]# ethtool eth0 Settings for eth0: Link detected: yes [vm]# modprobe -r xen_netfront [vm]# modprobe xen_netfront [vm]# ethtool eth0 Settings for eth0: Link detected: yes Signed-off-by: Xiao Liang <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 37dcf61 commit f603701

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/net/xen-netfront.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ struct netfront_cb {
8686
/* IRQ name is queue name with "-tx" or "-rx" appended */
8787
#define IRQ_NAME_SIZE (QUEUE_NAME_SIZE + 3)
8888

89+
static DECLARE_WAIT_QUEUE_HEAD(module_load_q);
8990
static DECLARE_WAIT_QUEUE_HEAD(module_unload_q);
9091

9192
struct netfront_stats {
@@ -1335,6 +1336,11 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev)
13351336
netif_carrier_off(netdev);
13361337

13371338
xenbus_switch_state(dev, XenbusStateInitialising);
1339+
wait_event(module_load_q,
1340+
xenbus_read_driver_state(dev->otherend) !=
1341+
XenbusStateClosed &&
1342+
xenbus_read_driver_state(dev->otherend) !=
1343+
XenbusStateUnknown);
13381344
return netdev;
13391345

13401346
exit:

0 commit comments

Comments
 (0)