]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
bnxt_en: Refactor bnxt_free_ctx_mem()
authorHongguang Gao <hongguang.gao@broadcom.com>
Fri, 15 Nov 2024 15:14:29 +0000 (07:14 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:34:38 +0000 (15:34 -0500)
[ Upstream commit 968d2cc07c2fc9a508a53bd2de61200f50206fbc ]

Add a new function bnxt_free_one_ctx_mem() to free one context
memory type.  bnxt_free_ctx_mem() now calls the new function in
the loop to free each context memory type.  There is no change in
behavior.  Later patches will further make use of the new function.

Signed-off-by: Hongguang Gao <hongguang.gao@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Link: https://patch.msgid.link/20241115151438.550106-4-michael.chan@broadcom.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Stable-dep-of: 5204943a4c6e ("bnxt_en: Fix warning in bnxt_dl_reload_down()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt.c

index abf8984ac5e2095abc48ac4b14b722e415864ff7..5409ad3cee1923739dba00ccd8d6b62963158900 100644 (file)
@@ -8872,21 +8872,14 @@ static int bnxt_backing_store_cfg_v2(struct bnxt *bp, u32 ena)
        return 0;
 }
 
-void bnxt_free_ctx_mem(struct bnxt *bp)
+static void bnxt_free_one_ctx_mem(struct bnxt *bp,
+                                 struct bnxt_ctx_mem_type *ctxm)
 {
-       struct bnxt_ctx_mem_info *ctx = bp->ctx;
-       u16 type;
-
-       if (!ctx)
-               return;
-
-       for (type = 0; type < BNXT_CTX_V2_MAX; type++) {
-               struct bnxt_ctx_mem_type *ctxm = &ctx->ctx_arr[type];
-               struct bnxt_ctx_pg_info *ctx_pg = ctxm->pg_info;
-               int i, n = 1;
+       struct bnxt_ctx_pg_info *ctx_pg;
+       int i, n = 1;
 
-               if (!ctx_pg)
-                       continue;
+       ctx_pg = ctxm->pg_info;
+       if (ctx_pg) {
                if (ctxm->instance_bmap)
                        n = hweight32(ctxm->instance_bmap);
                for (i = 0; i < n; i++)
@@ -8896,6 +8889,18 @@ void bnxt_free_ctx_mem(struct bnxt *bp)
                ctxm->pg_info = NULL;
                ctxm->mem_valid = 0;
        }
+}
+
+void bnxt_free_ctx_mem(struct bnxt *bp)
+{
+       struct bnxt_ctx_mem_info *ctx = bp->ctx;
+       u16 type;
+
+       if (!ctx)
+               return;
+
+       for (type = 0; type < BNXT_CTX_V2_MAX; type++)
+               bnxt_free_one_ctx_mem(bp, &ctx->ctx_arr[type]);
 
        ctx->flags &= ~BNXT_CTX_FLAG_INITED;
        kfree(ctx);