Skip to content

Commit a51c9b1

Browse files
dmertmankuba-moo
authored andcommitted
ice: check for unregistering correct number of devlink params
On module load, the ice driver checks for the lack of a specific PF capability to determine if it should reduce the number of devlink params to register. One situation when this test returns true is when the driver loads in safe mode. The same check is not present on the unload path when devlink params are unregistered. This results in the driver triggering a WARN_ON in the kernel devlink code. The current check and code path uses a reduction in the number of elements reported in the list of params. This is fragile and not good for future maintaining. Change the parameters to be held in two lists, one always registered and one dependent on the check. Add a symmetrical check in the unload path so that the correct parameters are unregistered as well. Fixes: 109eb29 ("ice: Add tx_scheduling_layers devlink param") CC: Lukasz Czapnik <[email protected]> Reviewed-by: Przemek Kitszel <[email protected]> Signed-off-by: Dave Ertman <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Tested-by: Pucha Himasekhar Reddy <[email protected]> Signed-off-by: Jacob Keller <[email protected]> Link: https://lore.kernel.org/r/20240528-net-2024-05-28-intel-net-fixes-v1-8-dc8593d2bbc6@intel.com Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 2a6d8f2 commit a51c9b1

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

drivers/net/ethernet/intel/ice/devlink/devlink.c

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,7 +1388,7 @@ enum ice_param_id {
13881388
ICE_DEVLINK_PARAM_ID_TX_SCHED_LAYERS,
13891389
};
13901390

1391-
static const struct devlink_param ice_devlink_params[] = {
1391+
static const struct devlink_param ice_dvl_rdma_params[] = {
13921392
DEVLINK_PARAM_GENERIC(ENABLE_ROCE, BIT(DEVLINK_PARAM_CMODE_RUNTIME),
13931393
ice_devlink_enable_roce_get,
13941394
ice_devlink_enable_roce_set,
@@ -1397,6 +1397,9 @@ static const struct devlink_param ice_devlink_params[] = {
13971397
ice_devlink_enable_iw_get,
13981398
ice_devlink_enable_iw_set,
13991399
ice_devlink_enable_iw_validate),
1400+
};
1401+
1402+
static const struct devlink_param ice_dvl_sched_params[] = {
14001403
DEVLINK_PARAM_DRIVER(ICE_DEVLINK_PARAM_ID_TX_SCHED_LAYERS,
14011404
"tx_scheduling_layers",
14021405
DEVLINK_PARAM_TYPE_U8,
@@ -1464,21 +1467,31 @@ int ice_devlink_register_params(struct ice_pf *pf)
14641467
{
14651468
struct devlink *devlink = priv_to_devlink(pf);
14661469
struct ice_hw *hw = &pf->hw;
1467-
size_t params_size;
1470+
int status;
14681471

1469-
params_size = ARRAY_SIZE(ice_devlink_params);
1472+
status = devl_params_register(devlink, ice_dvl_rdma_params,
1473+
ARRAY_SIZE(ice_dvl_rdma_params));
1474+
if (status)
1475+
return status;
14701476

1471-
if (!hw->func_caps.common_cap.tx_sched_topo_comp_mode_en)
1472-
params_size--;
1477+
if (hw->func_caps.common_cap.tx_sched_topo_comp_mode_en)
1478+
status = devl_params_register(devlink, ice_dvl_sched_params,
1479+
ARRAY_SIZE(ice_dvl_sched_params));
14731480

1474-
return devl_params_register(devlink, ice_devlink_params,
1475-
params_size);
1481+
return status;
14761482
}
14771483

14781484
void ice_devlink_unregister_params(struct ice_pf *pf)
14791485
{
1480-
devl_params_unregister(priv_to_devlink(pf), ice_devlink_params,
1481-
ARRAY_SIZE(ice_devlink_params));
1486+
struct devlink *devlink = priv_to_devlink(pf);
1487+
struct ice_hw *hw = &pf->hw;
1488+
1489+
devl_params_unregister(devlink, ice_dvl_rdma_params,
1490+
ARRAY_SIZE(ice_dvl_rdma_params));
1491+
1492+
if (hw->func_caps.common_cap.tx_sched_topo_comp_mode_en)
1493+
devl_params_unregister(devlink, ice_dvl_sched_params,
1494+
ARRAY_SIZE(ice_dvl_sched_params));
14821495
}
14831496

14841497
#define ICE_DEVLINK_READ_BLK_SIZE (1024 * 1024)

0 commit comments

Comments
 (0)