Skip to content

Commit

Permalink
hv_netvsc: Fix unwanted wakeup in netvsc_attach()
Browse files Browse the repository at this point in the history
When netvsc_attach() is called by operations like changing MTU, etc.,
an extra wakeup may happen while netvsc_attach() calling
rndis_filter_device_add() which sends rndis messages when queue is
stopped in netvsc_detach(). The completion message will wake up queue 0.

We can reproduce the issue by changing MTU etc., then the wake_queue
counter from "ethtool -S" will increase beyond stop_queue counter:
     stop_queue: 0
     wake_queue: 1
The issue causes queue wake up, and counter increment, no other ill
effects in current code. So we didn't see any network problem for now.

To fix this, initialize tx_disable to true, and set it to false when
the NIC is ready to be attached or registered.

Fixes: 7b2ee50 ("hv_netvsc: common detach logic")
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Haiyang Zhang authored and David S. Miller committed Feb 24, 2020
1 parent eae7172 commit f6f13c1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/hyperv/netvsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static struct netvsc_device *alloc_net_device(void)

init_waitqueue_head(&net_device->wait_drain);
net_device->destroy = false;
net_device->tx_disable = false;
net_device->tx_disable = true;

net_device->max_pkt = RNDIS_MAX_PKT_DEFAULT;
net_device->pkt_align = RNDIS_PKT_ALIGN_DEFAULT;
Expand Down
3 changes: 3 additions & 0 deletions drivers/net/hyperv/netvsc_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,7 @@ static int netvsc_attach(struct net_device *ndev,
}

/* In any case device is now ready */
nvdev->tx_disable = false;
netif_device_attach(ndev);

/* Note: enable and attach happen when sub-channels setup */
Expand Down Expand Up @@ -2476,6 +2477,8 @@ static int netvsc_probe(struct hv_device *dev,
else
net->max_mtu = ETH_DATA_LEN;

nvdev->tx_disable = false;

ret = register_netdevice(net);
if (ret != 0) {
pr_err("Unable to register netdev.\n");
Expand Down

0 comments on commit f6f13c1

Please sign in to comment.