Skip to content

Commit f580aec

Browse files
vittyvkdavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent da47b45 commit f580aec

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

drivers/net/hyperv/hyperv_net.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,9 @@ struct net_device_context {
672672
/* Ethtool settings */
673673
u8 duplex;
674674
u32 speed;
675+
676+
/* the device is going away */
677+
bool start_remove;
675678
};
676679

677680
/* Per netvsc device */
@@ -682,7 +685,6 @@ struct netvsc_device {
682685

683686
atomic_t num_outstanding_sends;
684687
wait_queue_head_t wait_drain;
685-
bool start_remove;
686688
bool destroy;
687689

688690
/* Receive buffer allocated by us but manages by NetVSP */

drivers/net/hyperv/netvsc.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
7474
}
7575

7676
init_waitqueue_head(&net_device->wait_drain);
77-
net_device->start_remove = false;
7877
net_device->destroy = false;
7978
atomic_set(&net_device->open_cnt, 0);
8079
atomic_set(&net_device->vf_use_cnt, 0);
@@ -691,7 +690,7 @@ static void netvsc_send_completion(struct netvsc_device *net_device,
691690
wake_up(&net_device->wait_drain);
692691

693692
if (netif_tx_queue_stopped(netdev_get_tx_queue(ndev, q_idx)) &&
694-
!net_device->start_remove &&
693+
!net_device->nd_ctx->start_remove &&
695694
(hv_ringbuf_avail_percent(&channel->outbound) >
696695
RING_AVAIL_PERCENT_HIWATER || queue_sends < 1))
697696
netif_tx_wake_queue(netdev_get_tx_queue(

drivers/net/hyperv/netvsc_drv.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ static int netvsc_set_channels(struct net_device *net,
793793
goto out;
794794

795795
do_set:
796-
nvdev->start_remove = true;
796+
net_device_ctx->start_remove = true;
797797
rndis_filter_device_remove(dev);
798798

799799
nvdev->num_chn = channels->combined_count;
@@ -837,6 +837,7 @@ static int netvsc_set_channels(struct net_device *net,
837837

838838
out:
839839
netvsc_open(net);
840+
net_device_ctx->start_remove = false;
840841

841842
return ret;
842843

@@ -927,7 +928,7 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)
927928

928929
num_chn = nvdev->num_chn;
929930

930-
nvdev->start_remove = true;
931+
ndevctx->start_remove = true;
931932
rndis_filter_device_remove(hdev);
932933

933934
ndev->mtu = mtu;
@@ -943,6 +944,7 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)
943944

944945
out:
945946
netvsc_open(ndev);
947+
ndevctx->start_remove = false;
946948

947949
return ret;
948950
}
@@ -1358,6 +1360,9 @@ static int netvsc_probe(struct hv_device *dev,
13581360
}
13591361

13601362
hv_set_drvdata(dev, net);
1363+
1364+
net_device_ctx->start_remove = false;
1365+
13611366
INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_link_change);
13621367
INIT_WORK(&net_device_ctx->work, do_set_multicast);
13631368
INIT_WORK(&net_device_ctx->gwrk.dwrk, netvsc_notify_peers);
@@ -1419,9 +1424,10 @@ static int netvsc_remove(struct hv_device *dev)
14191424
return 0;
14201425
}
14211426

1422-
net_device->start_remove = true;
14231427

14241428
ndev_ctx = netdev_priv(net);
1429+
ndev_ctx->start_remove = true;
1430+
14251431
cancel_delayed_work_sync(&ndev_ctx->dwork);
14261432
cancel_work_sync(&ndev_ctx->work);
14271433

0 commit comments

Comments
 (0)