summaryrefslogtreecommitdiffstats
path: root/Documentation/netlink
diff options
context:
space:
mode:
authorIdo Schimmel <idosch@nvidia.com>2023-11-15 13:17:14 +0100
committerDavid S. Miller <davem@davemloft.net>2023-11-18 17:38:50 +0000
commitbf6b200bc80d18480f8d0fb61e185bb0587e633c (patch)
tree18f5d3e7ba5e30dae4ec3234645574592423de4c /Documentation/netlink
parentd32c38256db30a2d55b849e2c77342bc70d58c6e (diff)
downloadlinux-bf6b200bc80d18480f8d0fb61e185bb0587e633c.tar.gz
linux-bf6b200bc80d18480f8d0fb61e185bb0587e633c.tar.bz2
linux-bf6b200bc80d18480f8d0fb61e185bb0587e633c.zip
devlink: Acquire device lock during reload command
Device drivers register with devlink from their probe routines (under the device lock) by acquiring the devlink instance lock and calling devl_register(). Drivers that support a devlink reload usually implement the reload_{down, up}() operations in a similar fashion to their remove and probe routines, respectively. However, while the remove and probe routines are invoked with the device lock held, the reload operations are only invoked with the devlink instance lock held. It is therefore impossible for drivers to acquire the device lock from their reload operations, as this would result in lock inversion. The motivating use case for invoking the reload operations with the device lock held is in mlxsw which needs to trigger a PCI reset as part of the reload. The driver cannot call pci_reset_function() as this function acquires the device lock. Instead, it needs to call __pci_reset_function_locked which expects the device lock to be held. To that end, adjust devlink to always acquire the device lock before the devlink instance lock when performing a reload. Do that when reload is explicitly triggered by user space by specifying the 'DEVLINK_NL_FLAG_NEED_DEV_LOCK' flag in the pre_doit and post_doit operations of the reload command. A previous patch already handled the case where reload is invoked as part of netns dismantle. Signed-off-by: Ido Schimmel <idosch@nvidia.com> Reviewed-by: Jiri Pirko <jiri@nvidia.com> Signed-off-by: Petr Machata <petrm@nvidia.com> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'Documentation/netlink')
-rw-r--r--Documentation/netlink/specs/devlink.yaml4
1 files changed, 2 insertions, 2 deletions
diff --git a/Documentation/netlink/specs/devlink.yaml b/Documentation/netlink/specs/devlink.yaml
index 572d83a414d0..43067e1f63aa 100644
--- a/Documentation/netlink/specs/devlink.yaml
+++ b/Documentation/netlink/specs/devlink.yaml
@@ -1484,8 +1484,8 @@ operations:
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
- pre: devlink-nl-pre-doit
- post: devlink-nl-post-doit
+ pre: devlink-nl-pre-doit-dev-lock
+ post: devlink-nl-post-doit-dev-lock
request:
attributes:
- bus-name