]> git.baikalelectronics.ru Git - kernel.git/commitdiff
netvsc: make sure napi enabled before vmbus_open
authorstephen hemminger <stephen@networkplumber.org>
Wed, 3 May 2017 23:59:21 +0000 (16:59 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 4 May 2017 15:08:36 +0000 (11:08 -0400)
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>
drivers/net/hyperv/netvsc.c
drivers/net/hyperv/rndis_filter.c

index 15749d359e600062efd659c04966d316d586a110..652453d9fb088fd5103665e12884d87ff08465c3 100644 (file)
@@ -1322,6 +1322,10 @@ 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,
@@ -1329,6 +1333,7 @@ int netvsc_device_add(struct hv_device *device,
                         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;
        }
@@ -1336,9 +1341,6 @@ int netvsc_device_add(struct hv_device *device,
        /* 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
index ab92c3c9595178c6e8ca47c332d153f79bd38672..f9d5b0b8209a7ffffa07984ba6d942ddb011610b 100644 (file)
@@ -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);