Skip to content

Commit 280f7b2

Browse files
Jiri Pirkodavem330
authored andcommitted
devlink: allow to call devl_param_driverinit_value_get() without holding instance lock
If the driver maintains following basic sane behavior, the devl_param_driverinit_value_get() function could be called without holding instance lock: 1) Driver ensures a call to devl_param_driverinit_value_get() cannot race with registering/unregistering the parameter with the same parameter ID. 2) Driver ensures a call to devl_param_driverinit_value_get() cannot race with devl_param_driverinit_value_set() call with the same parameter ID. 3) Driver ensures a call to devl_param_driverinit_value_get() cannot race with reload operation. By the nature of params usage, these requirements should be trivially achievable. If the driver for some off reason is not able to comply, it has to take the devlink->lock while calling devl_param_driverinit_value_get(). Remove the lock assertion and add comment describing the locking requirements. This fixes a splat in mlx5 driver introduced by the commit referenced in the "Fixes" tag. Lore: https://lore.kernel.org/netdev/[email protected]/ Reported-by: Kim Phillips <[email protected]> Fixes: 075935f ("devlink: protect devlink param list by instance lock") Signed-off-by: Jiri Pirko <[email protected]> Reviewed-by: Simon Horman <[email protected]> Acked-by: Jakub Kicinski <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Tested-by: Kim Phillips <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a72e17b commit 280f7b2

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

net/devlink/leftover.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9627,14 +9627,23 @@ EXPORT_SYMBOL_GPL(devlink_params_unregister);
96279627
*
96289628
* This function should be used by the driver to get driverinit
96299629
* configuration for initialization after reload command.
9630+
*
9631+
* Note that lockless call of this function relies on the
9632+
* driver to maintain following basic sane behavior:
9633+
* 1) Driver ensures a call to this function cannot race with
9634+
* registering/unregistering the parameter with the same parameter ID.
9635+
* 2) Driver ensures a call to this function cannot race with
9636+
* devl_param_driverinit_value_set() call with the same parameter ID.
9637+
* 3) Driver ensures a call to this function cannot race with
9638+
* reload operation.
9639+
* If the driver is not able to comply, it has to take the devlink->lock
9640+
* while calling this.
96309641
*/
96319642
int devl_param_driverinit_value_get(struct devlink *devlink, u32 param_id,
96329643
union devlink_param_value *val)
96339644
{
96349645
struct devlink_param_item *param_item;
96359646

9636-
lockdep_assert_held(&devlink->lock);
9637-
96389647
if (WARN_ON(!devlink_reload_supported(devlink->ops)))
96399648
return -EOPNOTSUPP;
96409649

0 commit comments

Comments
 (0)