Skip to content

Commit

Permalink
netvsc: make sure napi enabled before vmbus_open
Browse files Browse the repository at this point in the history
This fixes a race where vmbus callback for new packet arriving
could occur before NAPI is initialized.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
stephen hemminger authored and David S. Miller committed May 4, 2017
1 parent 5900eca commit 2be0f26
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions drivers/net/hyperv/netvsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1322,23 +1322,25 @@ int netvsc_device_add(struct hv_device *device,
nvchan->channel = device->channel;
}

/* Enable NAPI handler before init callbacks */
netif_napi_add(ndev, &net_device->chan_table[0].napi,
netvsc_poll, NAPI_POLL_WEIGHT);

/* Open the channel */
ret = vmbus_open(device->channel, ring_size * PAGE_SIZE,
ring_size * PAGE_SIZE, NULL, 0,
netvsc_channel_cb,
net_device->chan_table);

if (ret != 0) {
netif_napi_del(&net_device->chan_table[0].napi);
netdev_err(ndev, "unable to open channel: %d\n", ret);
goto cleanup;
}

/* Channel is opened */
netdev_dbg(ndev, "hv_netvsc channel opened successfully\n");

/* Enable NAPI handler for init callbacks */
netif_napi_add(ndev, &net_device->chan_table[0].napi,
netvsc_poll, NAPI_POLL_WEIGHT);
napi_enable(&net_device->chan_table[0].napi);

/* Writing nvdev pointer unlocks netvsc_send(), make sure chn_table is
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/hyperv/rndis_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ static void netvsc_sc_open(struct vmbus_channel *new_sc)
if (ret == 0)
napi_enable(&nvchan->napi);
else
netdev_err(ndev, "sub channel open failed (%d)\n", ret);
netif_napi_del(&nvchan->napi);

if (refcount_dec_and_test(&nvscdev->sc_offered))
complete(&nvscdev->channel_init_wait);
Expand Down

0 comments on commit 2be0f26

Please sign in to comment.