Skip to content

Commit 19162fd

Browse files
dcuikuba-moo
authored andcommitted
hv_netvsc: Fix hibernation for mlx5 VF driver
mlx5_suspend()/resume() keep the network interface, so during hibernation netvsc_unregister_vf() and netvsc_register_vf() are not called, and hence netvsc_resume() should call netvsc_vf_changed() to switch the data path back to the VF after hibernation. Note: after we close and re-open the vmbus channel of the netvsc NIC in netvsc_suspend() and netvsc_resume(), the data path is implicitly switched to the netvsc NIC. Similarly, netvsc_suspend() should not call netvsc_unregister_vf(), otherwise the VF can no longer be used after hibernation. For mlx4, since the VF network interafce is explicitly destroyed and re-created during hibernation (see mlx4_suspend()/resume()), hv_netvsc already explicitly switches the data path from and to the VF automatically via netvsc_register_vf() and netvsc_unregister_vf(), so mlx4 doesn't need this fix. Note: mlx4 can still work with the fix because in netvsc_suspend()/resume() ndev_ctx->vf_netdev is NULL for mlx4. Fixes: 0efeea5 ("hv_netvsc: Add the support of hibernation") Signed-off-by: Dexuan Cui <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent e1f469c commit 19162fd

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

drivers/net/hyperv/netvsc_drv.c

+11-5
Original file line numberDiff line numberDiff line change
@@ -2587,8 +2587,8 @@ static int netvsc_remove(struct hv_device *dev)
25872587
static int netvsc_suspend(struct hv_device *dev)
25882588
{
25892589
struct net_device_context *ndev_ctx;
2590-
struct net_device *vf_netdev, *net;
25912590
struct netvsc_device *nvdev;
2591+
struct net_device *net;
25922592
int ret;
25932593

25942594
net = hv_get_drvdata(dev);
@@ -2604,10 +2604,6 @@ static int netvsc_suspend(struct hv_device *dev)
26042604
goto out;
26052605
}
26062606

2607-
vf_netdev = rtnl_dereference(ndev_ctx->vf_netdev);
2608-
if (vf_netdev)
2609-
netvsc_unregister_vf(vf_netdev);
2610-
26112607
/* Save the current config info */
26122608
ndev_ctx->saved_netvsc_dev_info = netvsc_devinfo_get(nvdev);
26132609

@@ -2623,6 +2619,7 @@ static int netvsc_resume(struct hv_device *dev)
26232619
struct net_device *net = hv_get_drvdata(dev);
26242620
struct net_device_context *net_device_ctx;
26252621
struct netvsc_device_info *device_info;
2622+
struct net_device *vf_netdev;
26262623
int ret;
26272624

26282625
rtnl_lock();
@@ -2635,6 +2632,15 @@ static int netvsc_resume(struct hv_device *dev)
26352632
netvsc_devinfo_put(device_info);
26362633
net_device_ctx->saved_netvsc_dev_info = NULL;
26372634

2635+
/* A NIC driver (e.g. mlx5) may keep the VF network interface across
2636+
* hibernation, but here the data path is implicitly switched to the
2637+
* netvsc NIC since the vmbus channel is closed and re-opened, so
2638+
* netvsc_vf_changed() must be used to switch the data path to the VF.
2639+
*/
2640+
vf_netdev = rtnl_dereference(net_device_ctx->vf_netdev);
2641+
if (vf_netdev && netvsc_vf_changed(vf_netdev) != NOTIFY_OK)
2642+
ret = -EINVAL;
2643+
26382644
rtnl_unlock();
26392645

26402646
return ret;

0 commit comments

Comments
 (0)