From: Rosen Penev <rosenp@gmail.com>
To: linux-scsi@vger.kernel.org
Cc: Saurav Kashyap <skashyap@marvell.com>,
Javed Hasan <jhasan@marvell.com>,
GR-QLogic-Storage-Upstream@marvell.com (maintainer:BROADCOM
BNX2FC 10 GIGABIT FCOE DRIVER),
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH 2/3] scsi: bnx2fc: no double pointer for io_bdt_pool
Date: Thu, 30 Apr 2026 14:02:44 -0700 [thread overview]
Message-ID: <20260430210245.29840-3-rosenp@gmail.com> (raw)
In-Reply-To: <20260430210245.29840-1-rosenp@gmail.com>
Instead of allocating a double pointer, allocate a single and avoid
extra malloc and free. It's not needed anyway.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/scsi/bnx2fc/bnx2fc.h | 2 +-
drivers/scsi/bnx2fc/bnx2fc_io.c | 25 +++++--------------------
2 files changed, 6 insertions(+), 21 deletions(-)
diff --git a/drivers/scsi/bnx2fc/bnx2fc.h b/drivers/scsi/bnx2fc/bnx2fc.h
index 30d8b563db0c..9a5de1048542 100644
--- a/drivers/scsi/bnx2fc/bnx2fc.h
+++ b/drivers/scsi/bnx2fc/bnx2fc.h
@@ -280,7 +280,7 @@ struct bnx2fc_cmd_mgr {
u16 next_idx;
struct list_head *free_list;
spinlock_t *free_list_lock;
- struct io_bdt **io_bdt_pool;
+ struct io_bdt *io_bdt_pool;
struct bnx2fc_cmd *cmds[];
};
diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
index 4810999976b6..6773f8d5d84e 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
@@ -242,7 +242,7 @@ struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_alloc(struct bnx2fc_hba *hba)
}
cmgr->hba = hba;
- cmgr->io_bdt_pool = (struct io_bdt **)(cmgr->cmds + num_ios);
+ cmgr->io_bdt_pool = (struct io_bdt *)(cmgr->cmds + num_ios);
cmgr->free_list = (struct list_head *)(cmgr->io_bdt_pool + num_ios);
cmgr->free_list_lock = (spinlock_t *)(cmgr->free_list + arr_sz);
@@ -280,19 +280,10 @@ struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_alloc(struct bnx2fc_hba *hba)
io_req++;
}
- for (i = 0; i < num_ios; i++) {
- cmgr->io_bdt_pool[i] = kmalloc_obj(struct io_bdt);
- if (!cmgr->io_bdt_pool[i]) {
- printk(KERN_ERR PFX "failed to alloc "
- "io_bdt_pool[%d]\n", i);
- goto mem_err;
- }
- }
-
/* Allocate an map fcoe_bdt_ctx structures */
bd_tbl_sz = BNX2FC_MAX_BDS_PER_CMD * sizeof(struct fcoe_bd_ctx);
for (i = 0; i < num_ios; i++) {
- bdt_info = cmgr->io_bdt_pool[i];
+ bdt_info = &cmgr->io_bdt_pool[i];
bdt_info->bd_tbl = dma_alloc_coherent(&hba->pcidev->dev,
bd_tbl_sz,
&bdt_info->bd_tbl_dma,
@@ -325,7 +316,7 @@ void bnx2fc_cmd_mgr_free(struct bnx2fc_cmd_mgr *cmgr)
bd_tbl_sz = BNX2FC_MAX_BDS_PER_CMD * sizeof(struct fcoe_bd_ctx);
for (i = 0; i < num_ios; i++) {
- bdt_info = cmgr->io_bdt_pool[i];
+ bdt_info = &cmgr->io_bdt_pool[i];
if (bdt_info->bd_tbl) {
dma_free_coherent(&hba->pcidev->dev, bd_tbl_sz,
bdt_info->bd_tbl,
@@ -334,12 +325,6 @@ void bnx2fc_cmd_mgr_free(struct bnx2fc_cmd_mgr *cmgr)
}
}
- /* Destroy io_bdt pool */
- for (i = 0; i < num_ios; i++) {
- kfree(cmgr->io_bdt_pool[i]);
- cmgr->io_bdt_pool[i] = NULL;
- }
-
for (i = 0; i < num_possible_cpus() + 1; i++) {
struct bnx2fc_cmd *tmp, *io_req;
@@ -415,7 +400,7 @@ struct bnx2fc_cmd *bnx2fc_elstm_alloc(struct bnx2fc_rport *tgt, int type)
/* Bind io_bdt for this io_req */
/* Have a static link between io_req and io_bdt_pool */
- bd_tbl = io_req->bd_tbl = cmd_mgr->io_bdt_pool[xid];
+ bd_tbl = io_req->bd_tbl = &cmd_mgr->io_bdt_pool[xid];
bd_tbl->io_req = io_req;
/* Hold the io_req against deletion */
@@ -468,7 +453,7 @@ struct bnx2fc_cmd *bnx2fc_cmd_alloc(struct bnx2fc_rport *tgt)
/* Bind io_bdt for this io_req */
/* Have a static link between io_req and io_bdt_pool */
- bd_tbl = io_req->bd_tbl = cmd_mgr->io_bdt_pool[xid];
+ bd_tbl = io_req->bd_tbl = &cmd_mgr->io_bdt_pool[xid];
bd_tbl->io_req = io_req;
/* Hold the io_req against deletion */
--
2.54.0
next prev parent reply other threads:[~2026-04-30 21:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-30 21:02 [PATCH 0/3] scsi: bnx2fc: simplify allocation Rosen Penev
2026-04-30 21:02 ` [PATCH 1/3] scsi: bnx2fc: simplify allocation of cmgr Rosen Penev
2026-04-30 21:02 ` Rosen Penev [this message]
2026-04-30 21:02 ` [PATCH 3/3] scsi: bnx2fc: tgt_ofld_list to FAM Rosen Penev
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=20260430210245.29840-3-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=GR-QLogic-Storage-Upstream@marvell.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=jhasan@marvell.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=skashyap@marvell.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox