netdevsim: Disable VFs on nsim_dev_reload_destroy() call
authorDmytro Linkin <dlinkin@nvidia.com>
Wed, 2 Jun 2021 12:17:15 +0000 (15:17 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 2 Jun 2021 21:08:36 +0000 (14:08 -0700)
Move VFs disabling from device release() to nsim_dev_reload_destroy() to
make VFs disabling and ports removal simultaneous.
This is a requirement for VFs ports implemented in next patches.

Signed-off-by: Dmytro Linkin <dlinkin@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/netdevsim/bus.c
drivers/net/netdevsim/dev.c
drivers/net/netdevsim/netdevsim.h

index 4bd7ef3c04bea78671aeeb262dc8ca51220fbe99..d5c547c35e2f88db17e7e886f686eafd95c4134e 100644 (file)
@@ -37,7 +37,7 @@ static int nsim_bus_dev_vfs_enable(struct nsim_bus_dev *nsim_bus_dev,
        return 0;
 }
 
-static void nsim_bus_dev_vfs_disable(struct nsim_bus_dev *nsim_bus_dev)
+void nsim_bus_dev_vfs_disable(struct nsim_bus_dev *nsim_bus_dev)
 {
        nsim_bus_dev->num_vfs = 0;
 }
@@ -233,9 +233,6 @@ static const struct attribute_group *nsim_bus_dev_attr_groups[] = {
 
 static void nsim_bus_dev_release(struct device *dev)
 {
-       struct nsim_bus_dev *nsim_bus_dev = to_nsim_bus_dev(dev);
-
-       nsim_bus_dev_vfs_disable(nsim_bus_dev);
 }
 
 static struct device_type nsim_bus_dev_type = {
index 12df93a34bfd6a85909c6e03f056f505749835bf..cd50c05b1e6e183149b462166aa051f4c5d84e1c 100644 (file)
@@ -1182,6 +1182,12 @@ static void nsim_dev_reload_destroy(struct nsim_dev *nsim_dev)
        if (devlink_is_reload_failed(devlink))
                return;
        debugfs_remove(nsim_dev->take_snapshot);
+
+       mutex_lock(&nsim_dev->nsim_bus_dev->vfs_lock);
+       if (nsim_dev->nsim_bus_dev->num_vfs)
+               nsim_bus_dev_vfs_disable(nsim_dev->nsim_bus_dev);
+       mutex_unlock(&nsim_dev->nsim_bus_dev->vfs_lock);
+
        nsim_dev_port_del_all(nsim_dev);
        nsim_dev_psample_exit(nsim_dev);
        nsim_dev_health_exit(nsim_dev);
index 12f56f2f85e8746d465524cb0bb2ccf0bb94189d..a1b49c8c01759605bc0b0df8e8183651b941c7ec 100644 (file)
@@ -276,6 +276,7 @@ ssize_t nsim_bus_dev_max_vfs_read(struct file *file,
 ssize_t nsim_bus_dev_max_vfs_write(struct file *file,
                                   const char __user *data,
                                   size_t count, loff_t *ppos);
+void nsim_bus_dev_vfs_disable(struct nsim_bus_dev *nsim_bus_dev);
 
 #if IS_ENABLED(CONFIG_XFRM_OFFLOAD)
 void nsim_ipsec_init(struct netdevsim *ns);