Skip to content

Commit 968d2cc

Browse files
hgao656kuba-moo
authored andcommitted
bnxt_en: Refactor bnxt_free_ctx_mem()
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>
1 parent 0b350b4 commit 968d2cc

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
@@ -8765,21 +8765,14 @@ static int bnxt_backing_store_cfg_v2(struct bnxt *bp, u32 ena)
87658765
return 0;
87668766
}
87678767

8768-
void bnxt_free_ctx_mem(struct bnxt *bp)
8768+
static void bnxt_free_one_ctx_mem(struct bnxt *bp,
8769+
struct bnxt_ctx_mem_type *ctxm)
87698770
{
8770-
struct bnxt_ctx_mem_info *ctx = bp->ctx;
8771-
u16 type;
8772-
8773-
if (!ctx)
8774-
return;
8775-
8776-
for (type = 0; type < BNXT_CTX_V2_MAX; type++) {
8777-
struct bnxt_ctx_mem_type *ctxm = &ctx->ctx_arr[type];
8778-
struct bnxt_ctx_pg_info *ctx_pg = ctxm->pg_info;
8779-
int i, n = 1;
8771+
struct bnxt_ctx_pg_info *ctx_pg;
8772+
int i, n = 1;
87808773

8781-
if (!ctx_pg)
8782-
continue;
8774+
ctx_pg = ctxm->pg_info;
8775+
if (ctx_pg) {
87838776
if (ctxm->instance_bmap)
87848777
n = hweight32(ctxm->instance_bmap);
87858778
for (i = 0; i < n; i++)
@@ -8789,6 +8782,18 @@ void bnxt_free_ctx_mem(struct bnxt *bp)
87898782
ctxm->pg_info = NULL;
87908783
ctxm->mem_valid = 0;
87918784
}
8785+
}
8786+
8787+
void bnxt_free_ctx_mem(struct bnxt *bp)
8788+
{
8789+
struct bnxt_ctx_mem_info *ctx = bp->ctx;
8790+
u16 type;
8791+
8792+
if (!ctx)
8793+
return;
8794+
8795+
for (type = 0; type < BNXT_CTX_V2_MAX; type++)
8796+
bnxt_free_one_ctx_mem(bp, &ctx->ctx_arr[type]);
87928797

87938798
ctx->flags &= ~BNXT_CTX_FLAG_INITED;
87948799
kfree(ctx);

0 commit comments

Comments
 (0)