[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z4aRvfqeIGAIerDX@lzaremba-mobl.ger.corp.intel.com>
Date: Tue, 14 Jan 2025 17:33:01 +0100
From: Larysa Zaremba <larysa.zaremba@...el.com>
To: Tariq Toukan <tariqt@...dia.com>
CC: "David S. Miller" <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, Eric Dumazet <edumazet@...gle.com>, "Andrew
Lunn" <andrew+netdev@...n.ch>, <netdev@...r.kernel.org>, Saeed Mahameed
<saeedm@...dia.com>, Gal Pressman <gal@...dia.com>, Leon Romanovsky
<leonro@...dia.com>, Mark Bloch <mbloch@...dia.com>, Moshe Shemesh
<moshe@...dia.com>, Yishai Hadas <yishaih@...dia.com>, Michael Guralnik
<michaelgur@...dia.com>
Subject: Re: [PATCH net 2/8] net/mlx5: Fix a lockdep warning as part of the
write combining test
On Mon, Jan 13, 2025 at 05:40:48PM +0200, Tariq Toukan wrote:
> From: Yishai Hadas <yishaih@...dia.com>
>
> Fix a lockdep warning [1] observed during the write combining test.
>
> The warning indicates a potential nested lock scenario that could lead
> to a deadlock.
>
> However, this is a false positive alarm because the SF lock and its
> parent lock are distinct ones.
>
> The lockdep confusion arises because the locks belong to the same object
> class (i.e., struct mlx5_core_dev).
>
> To resolve this, the code has been refactored to avoid taking both
> locks. Instead, only the parent lock is acquired.
>
[...]
>
> Fixes: d98995b4bf98 ("net/mlx5: Reimplement write combining test")
> Signed-off-by: Yishai Hadas <yishaih@...dia.com>
> Reviewed-by: Michael Guralnik <michaelgur@...dia.com>
> Signed-off-by: Tariq Toukan <tariqt@...dia.com>
Reviewed-by: Larysa Zaremba <larysa.zaremba@...el.com>
> ---
> drivers/net/ethernet/mellanox/mlx5/core/wc.c | 24 ++++++++++----------
> 1 file changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/wc.c b/drivers/net/ethernet/mellanox/mlx5/core/wc.c
> index 1bed75eca97d..740b719e7072 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/wc.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/wc.c
> @@ -382,6 +382,7 @@ static void mlx5_core_test_wc(struct mlx5_core_dev *mdev)
>
> bool mlx5_wc_support_get(struct mlx5_core_dev *mdev)
> {
> + struct mutex *wc_state_lock = &mdev->wc_state_lock;
> struct mlx5_core_dev *parent = NULL;
>
> if (!MLX5_CAP_GEN(mdev, bf)) {
> @@ -400,32 +401,31 @@ bool mlx5_wc_support_get(struct mlx5_core_dev *mdev)
> */
> goto out;
>
> - mutex_lock(&mdev->wc_state_lock);
> -
> - if (mdev->wc_state != MLX5_WC_STATE_UNINITIALIZED)
> - goto unlock;
> -
> #ifdef CONFIG_MLX5_SF
> - if (mlx5_core_is_sf(mdev))
> + if (mlx5_core_is_sf(mdev)) {
> parent = mdev->priv.parent_mdev;
> + wc_state_lock = &parent->wc_state_lock;
> + }
> #endif
>
> - if (parent) {
> - mutex_lock(&parent->wc_state_lock);
> + mutex_lock(wc_state_lock);
>
> + if (mdev->wc_state != MLX5_WC_STATE_UNINITIALIZED)
> + goto unlock;
> +
> + if (parent) {
> mlx5_core_test_wc(parent);
>
> mlx5_core_dbg(mdev, "parent set wc_state=%d\n",
> parent->wc_state);
> mdev->wc_state = parent->wc_state;
>
> - mutex_unlock(&parent->wc_state_lock);
> + } else {
> + mlx5_core_test_wc(mdev);
> }
>
> - mlx5_core_test_wc(mdev);
> -
> unlock:
> - mutex_unlock(&mdev->wc_state_lock);
> + mutex_unlock(wc_state_lock);
> out:
> mlx5_core_dbg(mdev, "wc_state=%d\n", mdev->wc_state);
>
> --
> 2.45.0
>
>
Powered by blists - more mailing lists