Skip to content

Commit 822fb18

Browse files
liangxiao1davem330
authored andcommitted
xen-netfront: wait xenbus state change when load module manually
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]>
1 parent 25432eb commit 822fb18

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
@@ -87,6 +87,7 @@ struct netfront_cb {
8787
/* IRQ name is queue name with "-tx" or "-rx" appended */
8888
#define IRQ_NAME_SIZE (QUEUE_NAME_SIZE + 3)
8989

90+
static DECLARE_WAIT_QUEUE_HEAD(module_load_q);
9091
static DECLARE_WAIT_QUEUE_HEAD(module_unload_q);
9192

9293
struct netfront_stats {
@@ -1330,6 +1331,11 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev)
13301331
netif_carrier_off(netdev);
13311332

13321333
xenbus_switch_state(dev, XenbusStateInitialising);
1334+
wait_event(module_load_q,
1335+
xenbus_read_driver_state(dev->otherend) !=
1336+
XenbusStateClosed &&
1337+
xenbus_read_driver_state(dev->otherend) !=
1338+
XenbusStateUnknown);
13331339
return netdev;
13341340

13351341
exit:

0 commit comments

Comments
 (0)