Skip to content

Commit

Permalink
net/mlx5: HWS, use lock classes for bwc locks
Browse files Browse the repository at this point in the history
The HWS BWC API uses one lock per queue and usually acquires one of
them, except when doing changes which require locking all queues in
order. Naturally, lockdep isn't too happy about acquiring the same lock
class multiple times, so inform it that each queue lock is a different
class to avoid false positives.

Fixes: 2ca6259 ("net/mlx5: HWS, added send engine and context handling")
Signed-off-by: Cosmin Ratiu <cratiu@nvidia.com>
Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
Cosmin Ratiu authored and Paolo Abeni committed Oct 17, 2024
1 parent 45bcbd4 commit 9addffa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct mlx5hws_context {
struct mlx5hws_send_engine *send_queue;
size_t queues;
struct mutex *bwc_send_queue_locks; /* protect BWC queues */
struct lock_class_key *bwc_lock_class_keys;
struct list_head tbl_list;
struct mlx5hws_context_debug_info debug_info;
struct xarray peer_ctx_xa;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -947,8 +947,12 @@ static void hws_send_queues_bwc_locks_destroy(struct mlx5hws_context *ctx)
if (!mlx5hws_context_bwc_supported(ctx))
return;

for (i = 0; i < bwc_queues; i++)
for (i = 0; i < bwc_queues; i++) {
mutex_destroy(&ctx->bwc_send_queue_locks[i]);
lockdep_unregister_key(ctx->bwc_lock_class_keys + i);
}

kfree(ctx->bwc_lock_class_keys);
kfree(ctx->bwc_send_queue_locks);
}

Expand Down Expand Up @@ -977,10 +981,22 @@ static int hws_bwc_send_queues_init(struct mlx5hws_context *ctx)
if (!ctx->bwc_send_queue_locks)
return -ENOMEM;

for (i = 0; i < bwc_queues; i++)
ctx->bwc_lock_class_keys = kcalloc(bwc_queues,
sizeof(*ctx->bwc_lock_class_keys),
GFP_KERNEL);
if (!ctx->bwc_lock_class_keys)
goto err_lock_class_keys;

for (i = 0; i < bwc_queues; i++) {
mutex_init(&ctx->bwc_send_queue_locks[i]);
lockdep_register_key(ctx->bwc_lock_class_keys + i);
}

return 0;

err_lock_class_keys:
kfree(ctx->bwc_send_queue_locks);
return -ENOMEM;
}

int mlx5hws_send_queues_open(struct mlx5hws_context *ctx,
Expand Down

0 comments on commit 9addffa

Please sign in to comment.