ice: move devlink locking outside the port creation
authorMichal Swiatkowski <michal.swiatkowski@linux.intel.com>
Mon, 10 Jun 2024 07:44:32 +0000 (09:44 +0200)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Fri, 21 Jun 2024 14:45:38 +0000 (07:45 -0700)
In case of subfunction lock will be taken for whole port creation and
removing. Do the same in VF case.

Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Tested-by: Sujai Buvaneswaran <sujai.buvaneswaran@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/ice/devlink/devlink.c
drivers/net/ethernet/intel/ice/devlink/devlink_port.c
drivers/net/ethernet/intel/ice/ice_eswitch.c
drivers/net/ethernet/intel/ice/ice_repr.c

index 704e9ad5144e8c2844b6343c63126d1724ad0f08..f774781ab514185d041b6c69c40f94167d3c36d8 100644 (file)
@@ -794,10 +794,8 @@ int ice_devlink_rate_init_tx_topology(struct devlink *devlink, struct ice_vsi *v
 
        tc_node = pi->root->children[0];
        mutex_lock(&pi->sched_lock);
-       devl_lock(devlink);
        for (i = 0; i < tc_node->num_children; i++)
                ice_traverse_tx_tree(devlink, tc_node->children[i], tc_node, pf);
-       devl_unlock(devlink);
        mutex_unlock(&pi->sched_lock);
 
        return 0;
index 13e6790d3cae79ef7bcccc4da2ac3dcc0ec96576..c9fbeebf7fb941d8b72e9767e0c15b031d28b360 100644 (file)
@@ -407,7 +407,7 @@ int ice_devlink_create_vf_port(struct ice_vf *vf)
        devlink_port_attrs_set(devlink_port, &attrs);
        devlink = priv_to_devlink(pf);
 
-       err = devlink_port_register(devlink, devlink_port, vsi->idx);
+       err = devl_port_register(devlink, devlink_port, vsi->idx);
        if (err) {
                dev_err(dev, "Failed to create devlink port for VF %d, error %d\n",
                        vf->vf_id, err);
@@ -426,5 +426,5 @@ int ice_devlink_create_vf_port(struct ice_vf *vf)
 void ice_devlink_destroy_vf_port(struct ice_vf *vf)
 {
        devl_rate_leaf_destroy(&vf->devlink_port);
-       devlink_port_unregister(&vf->devlink_port);
+       devl_port_unregister(&vf->devlink_port);
 }
index b102db8b829a9474bbb224c897cbf34b1d27f402..7b57a6561a5a6b150dbaf6e5b4b860aa4896a196 100644 (file)
@@ -423,6 +423,7 @@ static void ice_eswitch_start_reprs(struct ice_pf *pf)
 int
 ice_eswitch_attach(struct ice_pf *pf, struct ice_vf *vf)
 {
+       struct devlink *devlink = priv_to_devlink(pf);
        struct ice_repr *repr;
        int err;
 
@@ -437,7 +438,9 @@ ice_eswitch_attach(struct ice_pf *pf, struct ice_vf *vf)
 
        ice_eswitch_stop_reprs(pf);
 
+       devl_lock(devlink);
        repr = ice_repr_add_vf(vf);
+       devl_unlock(devlink);
        if (IS_ERR(repr)) {
                err = PTR_ERR(repr);
                goto err_create_repr;
@@ -460,7 +463,9 @@ ice_eswitch_attach(struct ice_pf *pf, struct ice_vf *vf)
 err_xa_alloc:
        ice_eswitch_release_repr(pf, repr);
 err_setup_repr:
+       devl_lock(devlink);
        ice_repr_rem_vf(repr);
+       devl_unlock(devlink);
 err_create_repr:
        if (xa_empty(&pf->eswitch.reprs))
                ice_eswitch_disable_switchdev(pf);
@@ -484,6 +489,7 @@ void ice_eswitch_detach(struct ice_pf *pf, struct ice_vf *vf)
                ice_eswitch_disable_switchdev(pf);
 
        ice_eswitch_release_repr(pf, repr);
+       devl_lock(devlink);
        ice_repr_rem_vf(repr);
 
        if (xa_empty(&pf->eswitch.reprs)) {
@@ -491,12 +497,11 @@ void ice_eswitch_detach(struct ice_pf *pf, struct ice_vf *vf)
                 * no point in keeping the nodes
                 */
                ice_devlink_rate_clear_tx_topology(ice_get_main_vsi(pf));
-               devl_lock(devlink);
                devl_rate_nodes_destroy(devlink);
-               devl_unlock(devlink);
        } else {
                ice_eswitch_start_reprs(pf);
        }
+       devl_unlock(devlink);
 }
 
 /**
index fe83f305cc7d6814110a4c31b632f7d6cd88ded5..35a6ac8c0466540853eae6690def786df1fce9a5 100644 (file)
@@ -285,9 +285,7 @@ ice_repr_reg_netdev(struct net_device *netdev)
 
 static void ice_repr_remove_node(struct devlink_port *devlink_port)
 {
-       devl_lock(devlink_port->devlink);
        devl_rate_leaf_destroy(devlink_port);
-       devl_unlock(devlink_port->devlink);
 }
 
 /**