]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ice: reorder PF/representor devlink port register/unregister flows
authorJiri Pirko <jiri@nvidia.com>
Mon, 26 Sep 2022 11:09:37 +0000 (13:09 +0200)
committerJakub Kicinski <kuba@kernel.org>
Tue, 27 Sep 2022 14:54:45 +0000 (07:54 -0700)
Make sure that netdevice is registered/unregistered while devlink port
is registered.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/intel/ice/ice_lib.c
drivers/net/ethernet/intel/ice/ice_main.c
drivers/net/ethernet/intel/ice/ice_repr.c

index 8a80da8e910e956c8efef86343114f07195a0d7b..938ba8c215cb07f85cb5bc840e3950128ab91983 100644 (file)
@@ -2988,9 +2988,6 @@ int ice_vsi_release(struct ice_vsi *vsi)
                clear_bit(ICE_VSI_NETDEV_REGISTERED, vsi->state);
        }
 
-       if (vsi->type == ICE_VSI_PF)
-               ice_devlink_destroy_pf_port(pf);
-
        if (test_bit(ICE_FLAG_RSS_ENA, pf->flags))
                ice_rss_clean(vsi);
 
@@ -3048,6 +3045,9 @@ int ice_vsi_release(struct ice_vsi *vsi)
                }
        }
 
+       if (vsi->type == ICE_VSI_PF)
+               ice_devlink_destroy_pf_port(pf);
+
        if (vsi->type == ICE_VSI_VF &&
            vsi->agg_node && vsi->agg_node->valid)
                vsi->agg_node->num_vsis--;
index 0ccc8a750374c554e00859207eaded4af436e325..747f27c4e761407a78cd08c1cb913197c958ba80 100644 (file)
@@ -4599,6 +4599,10 @@ static int ice_register_netdev(struct ice_pf *pf)
        if (!vsi || !vsi->netdev)
                return -EIO;
 
+       err = ice_devlink_create_pf_port(pf);
+       if (err)
+               goto err_devlink_create;
+
        err = register_netdev(vsi->netdev);
        if (err)
                goto err_register_netdev;
@@ -4606,17 +4610,13 @@ static int ice_register_netdev(struct ice_pf *pf)
        set_bit(ICE_VSI_NETDEV_REGISTERED, vsi->state);
        netif_carrier_off(vsi->netdev);
        netif_tx_stop_all_queues(vsi->netdev);
-       err = ice_devlink_create_pf_port(pf);
-       if (err)
-               goto err_devlink_create;
 
        devlink_port_type_eth_set(&pf->devlink_port, vsi->netdev);
 
        return 0;
-err_devlink_create:
-       unregister_netdev(vsi->netdev);
-       clear_bit(ICE_VSI_NETDEV_REGISTERED, vsi->state);
 err_register_netdev:
+       ice_devlink_destroy_pf_port(pf);
+err_devlink_create:
        free_netdev(vsi->netdev);
        vsi->netdev = NULL;
        clear_bit(ICE_VSI_NETDEV_ALLOCD, vsi->state);
index 0dac67cd9c77c975d69e71249046035e35b958d9..bd31748aae1b43b44da3de825a35f7124e22d21c 100644 (file)
@@ -377,10 +377,10 @@ static void ice_repr_rem(struct ice_vf *vf)
        if (!vf->repr)
                return;
 
-       ice_devlink_destroy_vf_port(vf);
        kfree(vf->repr->q_vector);
        vf->repr->q_vector = NULL;
        unregister_netdev(vf->repr->netdev);
+       ice_devlink_destroy_vf_port(vf);
        free_netdev(vf->repr->netdev);
        vf->repr->netdev = NULL;
 #ifdef CONFIG_ICE_SWITCHDEV