diff options
author | Vitaly Kuznetsov <vkuznets@redhat.com> | 2016-05-13 07:55:20 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-05-16 13:26:00 -0400 |
commit | f580aec4bfd7babe51f086e599400027def08ed8 (patch) | |
tree | 4508dc7ba0f197cb62cd82ce66f73eda4e79aa3c | |
parent | da47b4572056487fd7941c26f73b3e8815ff712a (diff) |
hv_netvsc: move start_remove flag to net_device_context
struct netvsc_device is destroyed on mtu change so keeping the
protection flag there is not a good idea. Move it to struct
net_device_context which is preserved.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/hyperv/hyperv_net.h | 4 | ||||
-rw-r--r-- | drivers/net/hyperv/netvsc.c | 3 | ||||
-rw-r--r-- | drivers/net/hyperv/netvsc_drv.c | 12 |
3 files changed, 13 insertions, 6 deletions
diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h index 6700a4dca7c8..18e9cc8ea47b 100644 --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h | |||
@@ -672,6 +672,9 @@ struct net_device_context { | |||
672 | /* Ethtool settings */ | 672 | /* Ethtool settings */ |
673 | u8 duplex; | 673 | u8 duplex; |
674 | u32 speed; | 674 | u32 speed; |
675 | |||
676 | /* the device is going away */ | ||
677 | bool start_remove; | ||
675 | }; | 678 | }; |
676 | 679 | ||
677 | /* Per netvsc device */ | 680 | /* Per netvsc device */ |
@@ -682,7 +685,6 @@ struct netvsc_device { | |||
682 | 685 | ||
683 | atomic_t num_outstanding_sends; | 686 | atomic_t num_outstanding_sends; |
684 | wait_queue_head_t wait_drain; | 687 | wait_queue_head_t wait_drain; |
685 | bool start_remove; | ||
686 | bool destroy; | 688 | bool destroy; |
687 | 689 | ||
688 | /* Receive buffer allocated by us but manages by NetVSP */ | 690 | /* Receive buffer allocated by us but manages by NetVSP */ |
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index eddce3cdafa8..5e2017bb93f1 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c | |||
@@ -74,7 +74,6 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device) | |||
74 | } | 74 | } |
75 | 75 | ||
76 | init_waitqueue_head(&net_device->wait_drain); | 76 | init_waitqueue_head(&net_device->wait_drain); |
77 | net_device->start_remove = false; | ||
78 | net_device->destroy = false; | 77 | net_device->destroy = false; |
79 | atomic_set(&net_device->open_cnt, 0); | 78 | atomic_set(&net_device->open_cnt, 0); |
80 | atomic_set(&net_device->vf_use_cnt, 0); | 79 | atomic_set(&net_device->vf_use_cnt, 0); |
@@ -691,7 +690,7 @@ static void netvsc_send_completion(struct netvsc_device *net_device, | |||
691 | wake_up(&net_device->wait_drain); | 690 | wake_up(&net_device->wait_drain); |
692 | 691 | ||
693 | if (netif_tx_queue_stopped(netdev_get_tx_queue(ndev, q_idx)) && | 692 | if (netif_tx_queue_stopped(netdev_get_tx_queue(ndev, q_idx)) && |
694 | !net_device->start_remove && | 693 | !net_device->nd_ctx->start_remove && |
695 | (hv_ringbuf_avail_percent(&channel->outbound) > | 694 | (hv_ringbuf_avail_percent(&channel->outbound) > |
696 | RING_AVAIL_PERCENT_HIWATER || queue_sends < 1)) | 695 | RING_AVAIL_PERCENT_HIWATER || queue_sends < 1)) |
697 | netif_tx_wake_queue(netdev_get_tx_queue( | 696 | netif_tx_wake_queue(netdev_get_tx_queue( |
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index ba3f3f3d48ef..b3fa2cdcb3f6 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c | |||
@@ -793,7 +793,7 @@ static int netvsc_set_channels(struct net_device *net, | |||
793 | goto out; | 793 | goto out; |
794 | 794 | ||
795 | do_set: | 795 | do_set: |
796 | nvdev->start_remove = true; | 796 | net_device_ctx->start_remove = true; |
797 | rndis_filter_device_remove(dev); | 797 | rndis_filter_device_remove(dev); |
798 | 798 | ||
799 | nvdev->num_chn = channels->combined_count; | 799 | nvdev->num_chn = channels->combined_count; |
@@ -837,6 +837,7 @@ static int netvsc_set_channels(struct net_device *net, | |||
837 | 837 | ||
838 | out: | 838 | out: |
839 | netvsc_open(net); | 839 | netvsc_open(net); |
840 | net_device_ctx->start_remove = false; | ||
840 | 841 | ||
841 | return ret; | 842 | return ret; |
842 | 843 | ||
@@ -927,7 +928,7 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu) | |||
927 | 928 | ||
928 | num_chn = nvdev->num_chn; | 929 | num_chn = nvdev->num_chn; |
929 | 930 | ||
930 | nvdev->start_remove = true; | 931 | ndevctx->start_remove = true; |
931 | rndis_filter_device_remove(hdev); | 932 | rndis_filter_device_remove(hdev); |
932 | 933 | ||
933 | ndev->mtu = mtu; | 934 | ndev->mtu = mtu; |
@@ -943,6 +944,7 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu) | |||
943 | 944 | ||
944 | out: | 945 | out: |
945 | netvsc_open(ndev); | 946 | netvsc_open(ndev); |
947 | ndevctx->start_remove = false; | ||
946 | 948 | ||
947 | return ret; | 949 | return ret; |
948 | } | 950 | } |
@@ -1358,6 +1360,9 @@ static int netvsc_probe(struct hv_device *dev, | |||
1358 | } | 1360 | } |
1359 | 1361 | ||
1360 | hv_set_drvdata(dev, net); | 1362 | hv_set_drvdata(dev, net); |
1363 | |||
1364 | net_device_ctx->start_remove = false; | ||
1365 | |||
1361 | INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_link_change); | 1366 | INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_link_change); |
1362 | INIT_WORK(&net_device_ctx->work, do_set_multicast); | 1367 | INIT_WORK(&net_device_ctx->work, do_set_multicast); |
1363 | INIT_WORK(&net_device_ctx->gwrk.dwrk, netvsc_notify_peers); | 1368 | INIT_WORK(&net_device_ctx->gwrk.dwrk, netvsc_notify_peers); |
@@ -1419,9 +1424,10 @@ static int netvsc_remove(struct hv_device *dev) | |||
1419 | return 0; | 1424 | return 0; |
1420 | } | 1425 | } |
1421 | 1426 | ||
1422 | net_device->start_remove = true; | ||
1423 | 1427 | ||
1424 | ndev_ctx = netdev_priv(net); | 1428 | ndev_ctx = netdev_priv(net); |
1429 | ndev_ctx->start_remove = true; | ||
1430 | |||
1425 | cancel_delayed_work_sync(&ndev_ctx->dwork); | 1431 | cancel_delayed_work_sync(&ndev_ctx->dwork); |
1426 | cancel_work_sync(&ndev_ctx->work); | 1432 | cancel_work_sync(&ndev_ctx->work); |
1427 | 1433 | ||