From: Michael Chan <michael.chan@broadcom.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, andrew+netdev@lunn.ch,
pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com
Subject: [PATCH net-next v5 1/9] bnxt_en: Clear bp->total_irqs when disabling IRQs
Date: Thu, 19 Nov 2026 17:29:13 -0800 [thread overview]
Message-ID: <20261120012921.2537903-2-michael.chan@broadcom.com> (raw)
In-Reply-To: <20261120012921.2537903-1-michael.chan@broadcom.com>
bnxt_init_int_mode() and bnxt_clear_int_mode() will free bp->irq_tbl
but bp->total_irqs retains the old value. If a subsequent
reinitialization happens, bnxt_reserve_rings() may see that
bp->total_irqs does not match a new irqs_required. It will then
try to adjust if dynamic MSI-X is supported and call
bnxt_change_msix(). It will then crash when dereferencing the NULL
bp->irq_tbl.
Fix it by clearing bp->total_irqs when freeing bp->irq_tbl. Dynamic
MSI-X adjustments should only proceed if bp->irq_tbl is valid which
means that MSI-X has been initialized and can be adjusted.
bnxt_ulp_start() and bnxt_ulp_irq_restart() also need a similar check
before filling the ULP MSI-X entries.
Add a bp->irq_tbl_size to prevent OOB bp->irq_tbl[] array access in
case MSI-X capabilities change during re-init. For dynamic MSI-X,
allocate the biggest bp->irq_tbl that is configured in the NVRAM
without clamping it with maximum CP/NQ rings to allow dynamic MSI-X
to grow to the max.
In the AER path, if MSI-X capabilities change, bnxt_reserve_rings()
will initialize MSI-X if BNXT_NEW_RM() is true. Add a check in
bnxt_io_resume() to skip doing it again later.
Fixes: e68256c8a73c ("bnxt_en: Support dynamic MSIX")
Fixes: c2d20a3814d1 ("bnxt_en: delay pci_alloc_irq_vectors() in the AER path")
Reviewed-by: Andy Gospodarek <andrew.gospodarek@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
v5:
Fix a Sashiko issue: possible NULL bp->irq_tble issue in bnxt_ulp_start().
v4:
Clear bp->total_irqs in bnxt_clear_int_mode() to fix a possible NULL
bp->irq_tbl issue reported by Sashiko and Gregory Price on patch #8.
https://lore.kernel.org/netdev/20261016064427.496944-2-michael.chan@broadcom.com/
v3:
Added an additional Fixes tag.
https://lore.kernel.org/netdev/20261012220827.340998-2-michael.chan@broadcom.com/
v2:
https://lore.kernel.org/netdev/20260928041712.3467803-2-michael.chan@broadcom.com/
---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 19 +++++++++++++++----
drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 +
drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c | 7 ++++++-
3 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index e78cf7ad3cbc..0808911186c5 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -11529,6 +11529,12 @@ static int bnxt_change_msix(struct bnxt *bp, int total)
struct msi_map map;
int i;
+ if (!bp->irq_tbl)
+ return 0;
+
+ if (total > bp->irq_tbl_size)
+ return bp->total_irqs;
+
/* add MSIX to the end if needed */
for (i = bp->total_irqs; i < total; i++) {
map = pci_msix_alloc_irq_at(bp->pdev, i, NULL);
@@ -11672,12 +11678,13 @@ static int bnxt_init_int_mode(struct bnxt *bp)
tbl_size = total_vecs;
if (pci_msix_can_alloc_dyn(bp->pdev))
- tbl_size = max;
+ tbl_size = bp->max_irqs;
bp->irq_tbl = kzalloc_objs(*bp->irq_tbl, tbl_size);
if (!bp->irq_tbl) {
rc = -ENOMEM;
goto msix_setup_exit;
}
+ bp->irq_tbl_size = tbl_size;
for (i = 0; i < total_vecs; i++)
bp->irq_tbl[i].vector = pci_irq_vector(bp->pdev, i);
@@ -11700,6 +11707,8 @@ static int bnxt_init_int_mode(struct bnxt *bp)
netdev_err(bp->dev, "bnxt_init_int_mode err: %x\n", rc);
kfree(bp->irq_tbl);
bp->irq_tbl = NULL;
+ bp->total_irqs = 0;
+ bp->irq_tbl_size = 0;
pci_free_irq_vectors(bp->pdev);
return rc;
}
@@ -11710,6 +11719,8 @@ static void bnxt_clear_int_mode(struct bnxt *bp)
kfree(bp->irq_tbl);
bp->irq_tbl = NULL;
+ bp->total_irqs = 0;
+ bp->irq_tbl_size = 0;
}
int bnxt_reserve_rings(struct bnxt *bp, bool irq_re_init)
@@ -11751,7 +11762,7 @@ int bnxt_reserve_rings(struct bnxt *bp, bool irq_re_init)
if (irq_re_init && BNXT_NEW_RM(bp) && irqs_required != bp->total_irqs) {
irq_change = true;
- if (!pci_msix_can_alloc_dyn(bp->pdev)) {
+ if (!pci_msix_can_alloc_dyn(bp->pdev) || !bp->irq_tbl) {
bnxt_ulp_irq_stop(bp);
bnxt_clear_int_mode(bp);
irq_cleared = true;
@@ -15137,7 +15148,7 @@ int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs,
hwr.cp += bnxt_get_ulp_msix_num(bp);
hwr.cp = min_t(int, hwr.cp, bnxt_get_max_func_irqs(bp));
}
- if (hwr.cp > bp->total_irqs) {
+ if (bp->irq_tbl && hwr.cp > bp->total_irqs) {
int old_total = bp->total_irqs;
int total_msix = bnxt_change_msix(bp, hwr.cp);
@@ -17842,7 +17853,7 @@ static void bnxt_io_resume(struct pci_dev *pdev)
err = bnxt_open(netdev);
} else {
err = bnxt_reserve_rings(bp, true);
- if (!err)
+ if (!err && !bp->irq_tbl)
err = bnxt_init_int_mode(bp);
}
}
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index 41d05efd6307..75428a585577 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -2489,6 +2489,7 @@ struct bnxt {
*/
unsigned long *ring_affinity_set;
int max_irqs;
+ int irq_tbl_size;
int total_irqs;
int ulp_num_msix_want;
u8 mac_addr[ETH_ALEN];
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
index a515c368bac0..0c27a6ec69f7 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
@@ -334,6 +334,11 @@ void bnxt_ulp_start(struct bnxt *bp)
goto clear_flag_continue;
}
+ if (edev->ulp_tbl->msix_requested && !bp->irq_tbl) {
+ /* Stay stopped if there are no vectors */
+ mutex_unlock(&edev->en_dev_lock);
+ continue;
+ }
if (edev->ulp_tbl->msix_requested)
bnxt_fill_msix_vecs(bp, edev->msix_entries);
@@ -396,7 +401,7 @@ void bnxt_ulp_irq_restart(struct bnxt *bp, int err)
if (!ops || !ops->ulp_irq_restart)
return;
- if (!err) {
+ if (!err && bp->irq_tbl) {
ent = kzalloc_objs(*ent, ulp->msix_requested);
if (!ent)
return;
--
2.51.0
next prev parent reply other threads:[~2026-11-20 1:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 1:29 [PATCH net-next v5 0/9] bnxt_en: Ring accounting fixes Michael Chan
2026-11-20 1:29 ` Michael Chan [this message]
2026-11-20 1:29 ` [PATCH net-next v5 2/9] bnxt_en: Fix bnxt_reinit_features() when irq_re_init is true Michael Chan
2026-11-20 1:29 ` [PATCH net-next v5 3/9] bnxt_en: Refactor RSS table check logic Michael Chan
2026-11-20 1:29 ` [PATCH net-next v5 4/9] bnxt_en: Refactor IRQs required logic Michael Chan
2026-11-20 1:29 ` [PATCH net-next v5 5/9] bnxt_en: Reinit IRQ when configuring LRO/GRO/HDS Michael Chan
2026-11-20 1:29 ` [PATCH net-next v5 6/9] bnxt_en: Remove support for the old NITRO A0 chip Michael Chan
2026-11-20 1:29 ` [PATCH net-next v5 7/9] bnxt_en: Refactor bnxt_num_cp_to_tx()/bnxt_num_tx_to_cp() helpers Michael Chan
2026-11-20 1:29 ` [PATCH net-next v5 8/9] bnxt_en: Fix ring accounting/validation when rings are constrained by FW Michael Chan
2026-11-20 1:29 ` [PATCH net-next v5 9/9] bnxt_en: Fix ring accounting/validation when IRQs are constrained Michael Chan
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=20261120012921.2537903-2-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@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pavan.chebbi@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox