net/mlx5: HWS, denote how refcounts are protected
authorYevgeny Kliteynik <kliteyn@nvidia.com>
Thu, 2 Jan 2025 18:14:02 +0000 (20:14 +0200)
committerJakub Kicinski <kuba@kernel.org>
Tue, 7 Jan 2025 00:33:39 +0000 (16:33 -0800)
Some HWS structs have refcounts that are just u32.
Comment how they are protected and add '__must_hold()'
annotation where applicable.

Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
Reviewed-by: Erez Shitrit <erezsh@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20250102181415.1477316-4-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/action.h
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/cmd.h
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/definer.h
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/pat_arg.h
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/table.c

index e8f562c..4669c9f 100644 (file)
@@ -70,12 +70,12 @@ struct mlx5hws_action_default_stc {
        struct mlx5hws_pool_chunk nop_dw6;
        struct mlx5hws_pool_chunk nop_dw7;
        struct mlx5hws_pool_chunk default_hit;
-       u32 refcount;
+       u32 refcount; /* protected by context ctrl lock */
 };
 
 struct mlx5hws_action_shared_stc {
        struct mlx5hws_pool_chunk stc_chunk;
-       u32 refcount;
+       u32 refcount; /* protected by context ctrl lock */
 };
 
 struct mlx5hws_actions_apply_data {
index 038f588..610c63d 100644 (file)
@@ -63,7 +63,7 @@ struct mlx5hws_cmd_forward_tbl {
        u8 type;
        u32 ft_id;
        u32 fg_id;
-       u32 refcount;
+       u32 refcount; /* protected by context ctrl lock */
 };
 
 struct mlx5hws_cmd_rtc_create_attr {
index 9432d50..5c1a208 100644 (file)
@@ -785,7 +785,7 @@ struct mlx5hws_definer_cache {
 
 struct mlx5hws_definer_cache_item {
        struct mlx5hws_definer definer;
-       u32 refcount;
+       u32 refcount; /* protected by context ctrl lock */
        struct list_head list_node;
 };
 
index 27ca933..8ddb519 100644 (file)
@@ -31,7 +31,7 @@ struct mlx5hws_pattern_cache_item {
                u8 *data;
                u16 num_of_actions;
        } mh_data;
-       u32 refcount;
+       u32 refcount; /* protected by pattern_cache lock */
        struct list_head ptrn_list_node;
 };
 
index 9576e02..5b18373 100644 (file)
@@ -37,6 +37,7 @@ static void hws_table_set_cap_attr(struct mlx5hws_table *tbl,
 }
 
 static int hws_table_up_default_fdb_miss_tbl(struct mlx5hws_table *tbl)
+__must_hold(&tbl->ctx->ctrl_lock)
 {
        struct mlx5hws_cmd_ft_create_attr ft_attr = {0};
        struct mlx5hws_cmd_set_fte_attr fte_attr = {0};
@@ -70,7 +71,6 @@ static int hws_table_up_default_fdb_miss_tbl(struct mlx5hws_table *tbl)
                return -EINVAL;
        }
 
-       /* ctx->ctrl_lock must be held here */
        ctx->common_res[tbl_type].default_miss = default_miss;
        ctx->common_res[tbl_type].default_miss->refcount++;
 
@@ -79,6 +79,7 @@ static int hws_table_up_default_fdb_miss_tbl(struct mlx5hws_table *tbl)
 
 /* Called under ctx->ctrl_lock */
 static void hws_table_down_default_fdb_miss_tbl(struct mlx5hws_table *tbl)
+__must_hold(&tbl->ctx->ctrl_lock)
 {
        struct mlx5hws_cmd_forward_tbl *default_miss;
        struct mlx5hws_context *ctx = tbl->ctx;