All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Chan <michael.chan@broadcom.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, andrew+netdev@lunn.ch,
	andrew.gospodarek@broadcom.com, shruti.parab@broadcom.com,
	hongguang.gao@broadcom.com
Subject: [PATCH net-next v2 03/11] bnxt_en: Refactor bnxt_free_ctx_mem()
Date: Fri, 15 Nov 2024 07:14:29 -0800	[thread overview]
Message-ID: <20241115151438.550106-4-michael.chan@broadcom.com> (raw)
In-Reply-To: <20241115151438.550106-1-michael.chan@broadcom.com>

From: Hongguang Gao <hongguang.gao@broadcom.com>

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>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 31 +++++++++++++----------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 0143d976c5fe..8c79b88c92b0 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -8765,21 +8765,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++)
@@ -8789,6 +8782,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);
-- 
2.30.1


  parent reply	other threads:[~2024-11-15 15:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-15 15:14 [PATCH net-next v2 00/11] bnxt_en: Add context memory dump to coredump Michael Chan
2024-11-15 15:14 ` [PATCH net-next v2 01/11] bnxt_en: Update firmware interface spec to 1.10.3.85 Michael Chan
2024-11-15 15:14 ` [PATCH net-next v2 02/11] bnxt_en: Add mem_valid bit to struct bnxt_ctx_mem_type Michael Chan
2024-11-15 15:14 ` Michael Chan [this message]
2024-11-15 15:14 ` [PATCH net-next v2 04/11] bnxt_en: Add a 'force' parameter to bnxt_free_ctx_mem() Michael Chan
2024-11-15 15:14 ` [PATCH net-next v2 05/11] bnxt_en: Allocate backing store memory for FW trace logs Michael Chan
2024-11-15 15:14 ` [PATCH net-next v2 06/11] bnxt_en: Manage the FW trace context memory Michael Chan
2024-11-15 15:14 ` [PATCH net-next v2 07/11] bnxt_en: Do not free FW log " Michael Chan
2024-11-15 15:14 ` [PATCH net-next v2 08/11] bnxt_en: Add functions to copy host " Michael Chan
2024-11-15 15:14 ` [PATCH net-next v2 09/11] bnxt_en: Add 2 parameters to bnxt_fill_coredump_seg_hdr() Michael Chan
2024-11-15 15:14 ` [PATCH net-next v2 10/11] bnxt_en: Add a new ethtool -W dump flag Michael Chan
2024-11-15 15:14 ` [PATCH net-next v2 11/11] bnxt_en: Add FW trace coredump segments to the coredump Michael Chan
2024-11-19  4:00 ` [PATCH net-next v2 00/11] bnxt_en: Add context memory dump to coredump patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241115151438.550106-4-michael.chan@broadcom.com \
    --to=michael.chan@broadcom.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew.gospodarek@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hongguang.gao@broadcom.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shruti.parab@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.