[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231117154925.GF164483@vergenet.net>
Date: Fri, 17 Nov 2023 15:49:25 +0000
From: Simon Horman <horms@...nel.org>
To: Petr Machata <petrm@...dia.com>
Cc: "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
netdev@...r.kernel.org, Ido Schimmel <idosch@...dia.com>,
Amit Cohen <amcohen@...dia.com>, mlxsw@...dia.com,
Jiri Pirko <jiri@...dia.com>
Subject: Re: [PATCH net-next 02/14] devlink: Acquire device lock during netns
dismantle
On Wed, Nov 15, 2023 at 01:17:11PM +0100, Petr Machata wrote:
> From: Ido Schimmel <idosch@...dia.com>
>
> 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.
>
> For now, only do that when reload is triggered as part of netns
> dismantle. Subsequent patches will handle the case where reload is
> explicitly triggered by user space.
>
> Signed-off-by: Ido Schimmel <idosch@...dia.com>
> Reviewed-by: Jiri Pirko <jiri@...dia.com>
> Signed-off-by: Petr Machata <petrm@...dia.com>
Reviewed-by: Simon Horman <horms@...nel.org>
Powered by blists - more mailing lists