]> git.itanic.dy.fi Git - linux-stable/commit
devlink: Fix devlink parallel commands processing
authorShay Drory <shayd@nvidia.com>
Tue, 12 Mar 2024 10:52:38 +0000 (12:52 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 13 Mar 2024 08:31:40 +0000 (08:31 +0000)
commitd7d75124965aee23e5e4421d78376545cf070b0a
tree3f41d8c9ce7a4cf0fa42f8651c84a532dfe3ea13
parent343041b59b7810f9cdca371f445dd43b35c740b1
devlink: Fix devlink parallel commands processing

Commit 870c7ad4a52b ("devlink: protect devlink->dev by the instance
lock") added devlink instance locking inside a loop that iterates over
all the registered devlink instances on the machine in the pre-doit
phase. This can lead to serialization of devlink commands over
different devlink instances.

For example: While the first devlink instance is executing firmware
flash, all commands to other devlink instances on the machine are
forced to wait until the first devlink finishes.

Therefore, in the pre-doit phase, take the devlink instance lock only
for the devlink instance the command is targeting. Devlink layer is
taking a reference on the devlink instance, ensuring the devlink->dev
pointer is valid. This reference taking was introduced by commit
a380687200e0 ("devlink: take device reference for devlink object").
Without this commit, it would not be safe to access devlink->dev
lockless.

Fixes: 870c7ad4a52b ("devlink: protect devlink->dev by the instance lock")
Signed-off-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/devlink/netlink.c