Skip to content

Commit 48c3e65

Browse files
hgao656gregkh
authored andcommitted
bnxt_en: Refactor bnxt_free_ctx_mem()
[ Upstream commit 968d2cc ] 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: 5204943 ("bnxt_en: Fix warning in bnxt_dl_reload_down()") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 2b8503d commit 48c3e65

File tree

1 file changed

+18
-13
lines changed
  • drivers/net/ethernet/broadcom/bnxt

1 file changed

+18
-13
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8872,21 +8872,14 @@ static int bnxt_backing_store_cfg_v2(struct bnxt *bp, u32 ena)
88728872
return 0;
88738873
}
88748874

8875-
void bnxt_free_ctx_mem(struct bnxt *bp)
8875+
static void bnxt_free_one_ctx_mem(struct bnxt *bp,
8876+
struct bnxt_ctx_mem_type *ctxm)
88768877
{
8877-
struct bnxt_ctx_mem_info *ctx = bp->ctx;
8878-
u16 type;
8879-
8880-
if (!ctx)
8881-
return;
8882-
8883-
for (type = 0; type < BNXT_CTX_V2_MAX; type++) {
8884-
struct bnxt_ctx_mem_type *ctxm = &ctx->ctx_arr[type];
8885-
struct bnxt_ctx_pg_info *ctx_pg = ctxm->pg_info;
8886-
int i, n = 1;
8878+
struct bnxt_ctx_pg_info *ctx_pg;
8879+
int i, n = 1;
88878880

8888-
if (!ctx_pg)
8889-
continue;
8881+
ctx_pg = ctxm->pg_info;
8882+
if (ctx_pg) {
88908883
if (ctxm->instance_bmap)
88918884
n = hweight32(ctxm->instance_bmap);
88928885
for (i = 0; i < n; i++)
@@ -8896,6 +8889,18 @@ void bnxt_free_ctx_mem(struct bnxt *bp)
88968889
ctxm->pg_info = NULL;
88978890
ctxm->mem_valid = 0;
88988891
}
8892+
}
8893+
8894+
void bnxt_free_ctx_mem(struct bnxt *bp)
8895+
{
8896+
struct bnxt_ctx_mem_info *ctx = bp->ctx;
8897+
u16 type;
8898+
8899+
if (!ctx)
8900+
return;
8901+
8902+
for (type = 0; type < BNXT_CTX_V2_MAX; type++)
8903+
bnxt_free_one_ctx_mem(bp, &ctx->ctx_arr[type]);
88998904

89008905
ctx->flags &= ~BNXT_CTX_FLAG_INITED;
89018906
kfree(ctx);

0 commit comments

Comments
 (0)