Skip to content

Commit 9addffa

Browse files
Cosmin RatiuPaolo Abeni
authored andcommitted
net/mlx5: HWS, use lock classes for bwc locks
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 <[email protected]> Signed-off-by: Yevgeny Kliteynik <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 45bcbd4 commit 9addffa

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_context.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ struct mlx5hws_context {
4646
struct mlx5hws_send_engine *send_queue;
4747
size_t queues;
4848
struct mutex *bwc_send_queue_locks; /* protect BWC queues */
49+
struct lock_class_key *bwc_lock_class_keys;
4950
struct list_head tbl_list;
5051
struct mlx5hws_context_debug_info debug_info;
5152
struct xarray peer_ctx_xa;

drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_send.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -947,8 +947,12 @@ static void hws_send_queues_bwc_locks_destroy(struct mlx5hws_context *ctx)
947947
if (!mlx5hws_context_bwc_supported(ctx))
948948
return;
949949

950-
for (i = 0; i < bwc_queues; i++)
950+
for (i = 0; i < bwc_queues; i++) {
951951
mutex_destroy(&ctx->bwc_send_queue_locks[i]);
952+
lockdep_unregister_key(ctx->bwc_lock_class_keys + i);
953+
}
954+
955+
kfree(ctx->bwc_lock_class_keys);
952956
kfree(ctx->bwc_send_queue_locks);
953957
}
954958

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

980-
for (i = 0; i < bwc_queues; i++)
984+
ctx->bwc_lock_class_keys = kcalloc(bwc_queues,
985+
sizeof(*ctx->bwc_lock_class_keys),
986+
GFP_KERNEL);
987+
if (!ctx->bwc_lock_class_keys)
988+
goto err_lock_class_keys;
989+
990+
for (i = 0; i < bwc_queues; i++) {
981991
mutex_init(&ctx->bwc_send_queue_locks[i]);
992+
lockdep_register_key(ctx->bwc_lock_class_keys + i);
993+
}
982994

983995
return 0;
996+
997+
err_lock_class_keys:
998+
kfree(ctx->bwc_send_queue_locks);
999+
return -ENOMEM;
9841000
}
9851001

9861002
int mlx5hws_send_queues_open(struct mlx5hws_context *ctx,

0 commit comments

Comments
 (0)