Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: michael.chan@broadcom.com
Cc: davem@davemloft.net, 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: Re: [PATCH net-next v5 1/9] bnxt_en: Clear bp->total_irqs when disabling IRQs
Date: Tue, 24 Nov 2026 02:10:49 +0000	[thread overview]
Message-ID: <179548624915.3135.3359343024461356242@kernel.org> (raw)
In-Reply-To: <20261120012921.2537903-2-michael.chan@broadcom.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 1 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] The new '!bp->irq_tbl' guard in bnxt_ulp_start() (bnxt_ulp.c) is
  read without the lock that serializes writers of bp->irq_tbl.
- [Medium] bnxt_ulp_start()
  (drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c) now leaves a…
- [Low] The commit message understates the behaviour change, and a code
  comment is now wrong.

--

bnxt_en: Clear bp->total_irqs when disabling IRQs

When bp->irq_tbl is freed, this patch now clears bp->total_irqs and the
new bp->irq_tbl_size. Dynamic MSI-X adjustment and filling of the ULP
MSI-X entries now only happen when bp->irq_tbl is valid. It also sizes
the dynamic MSI-X table from bp->max_irqs and skips a second
bnxt_init_int_mode() in bnxt_io_resume().

> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index e78cf7ad3cbc8..0808911186c51 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c

[ ... ]

> @@ -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;

[ ... ]

> @@ -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);
>  		}
>  	}

[Severity: Low]

The commit message says:

  In the AER path, if MSI-X capabilities change, bnxt_reserve_rings()
  will initialize MSI-X if BNXT_NEW_RM() is true.

Does this only happen when capabilities change? bnxt_clear_int_mode()
now sets bp->total_irqs = 0. So when bp->irq_tbl is NULL and a
reservation is needed, this condition in bnxt_reserve_rings() is always
true:

    if (irq_re_init && BNXT_NEW_RM(bp) && irqs_required != bp->total_irqs) {

The new "|| !bp->irq_tbl" branch is then taken, so bnxt_clear_int_mode(),
__bnxt_reserve_rings() and bnxt_init_int_mode() all run there.

bnxt_io_slot_reset() calls bnxt_clear_reservations(bp, true), so a
reservation is always needed in bnxt_io_resume(). The new !bp->irq_tbl
check in bnxt_io_resume() therefore matters on every NEW_RM AER resume,
not only when capabilities change.

The FW reset path through bnxt_hwrm_if_change() -> bnxt_open() works the
same way. The comment in bnxt_hwrm_if_change() still says:

    /* IRQ will be initialized later in bnxt_request_irq()*/
    bnxt_clear_int_mode(bp);

For NEW_RM firmware, MSI-X now seems to be set up earlier, in
bnxt_open() -> __bnxt_open_nic() -> bnxt_reserve_rings(bp, true). Could
the commit message and that comment be updated to match?

[ ... ]

> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
> index a515c368bac01..0c27a6ec69f77 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;
> +		}

[Severity: Medium]

When bp->irq_tbl is NULL, this path skips adrv->resume() and leaves
BNXT_EN_FLAG_ULP_STOPPED set. What resumes the ULP once the vectors
come back?

bnxt_ulp_start() looks like the only place that calls adrv->resume() or
clears BNXT_EN_FLAG_ULP_STOPPED. Its callers (bnxt_io_resume(),
bnxt_fw_reset_task(), bnxt_resume(), bnxt_dl_reload_up(),
bnxt_ulp_restart()) are one-shot recovery points. bnxt_open() only
queues BNXT_RESTART_ULP_SP_EVENT when BNXT_STATE_FW_RESET_DET is set.

One possible sequence:

1. With static MSI-X, ethtool -L on a running device takes the
   irq_cleared path in bnxt_reserve_rings(), and bnxt_init_int_mode()
   fails (pci_alloc_irq_vectors() shortfall or allocation failure). The
   open fails and the netdev is left closed with bp->irq_tbl == NULL.

2. A PM suspend/resume or a devlink DRIVER_REINIT reload runs while the
   device is down. bnxt_suspend() or bnxt_dl_reload_down() calls
   bnxt_ulp_stop(). Then bnxt_resume() or bnxt_dl_reload_up() calls
   bnxt_ulp_start() with !netif_running(), which takes this early
   continue.

3. The user opens the netdev. bnxt_reserve_rings() or
   bnxt_setup_int_mode() rebuilds bp->irq_tbl, but bnxt_ulp_irq_restart()
   does nothing because the RDMA device is still suspended.

Does bnxt_re then stay suspended until the next FW reset, AER, PM
resume or devlink reload, or until the driver is reloaded? The commit
message only says the check is needed "before filling the ULP MSI-X
entries". It doesn't mention that the ULP stays stopped.

[Severity: High]

Is this check safe against concurrent writers of bp->irq_tbl? Here
bnxt_ulp_start() holds only bp->auxdev_lock and edev->en_dev_lock.
bnxt_clear_int_mode(), bnxt_init_int_mode() and bnxt_change_msix() run
under rtnl and the netdev instance lock, and take neither of those
mutexes.

Every caller of bnxt_ulp_start() calls it after dropping rtnl and the
netdev lock. For example, in bnxt_io_resume():

    netdev_unlock(netdev);
    rtnl_unlock();
    if (!err) {
        bnxt_ulp_start(bp);

On a static MSI-X NEW_RM device:

CPU0                              CPU1
bnxt_io_resume()
  netif_device_attach()
  rtnl_unlock()
  bnxt_ulp_start()
    bp->irq_tbl != NULL, passes
                                  bnxt_set_channels()
                                    bnxt_reserve_rings(bp, true)
                                      bnxt_ulp_irq_stop()
                                      bnxt_clear_int_mode()
                                        kfree(bp->irq_tbl)
                                        bp->irq_tbl = NULL
    bnxt_fill_msix_vecs()
      ent[i].vector = bp->irq_tbl[i].vector;

Can this cause a NULL dereference or a read of the freed table in
bnxt_fill_msix_vecs()? Stale vectors would then be passed to bnxt_re
through adrv->resume(). bnxt_restore_pf_fw_resources() is another path
into the same writers.

The lockless read of bp->irq_tbl was already there before this patch.
But the new check is meant to stop NULL bp->irq_tbl dereferences while
filling the ULP MSI-X entries. Would it make sense to do the check and
copy the vectors under the netdev instance lock, or under another lock
that the writers also take?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120012921.2537903-1-michael.chan%40broadcom.com

  reply	other threads:[~2026-11-24  2:10 UTC|newest]

Thread overview: 14+ 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 ` [PATCH net-next v5 1/9] bnxt_en: Clear bp->total_irqs when disabling IRQs Michael Chan
2026-11-24  2:10   ` netdev-bot+sashiko [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-24  2:10   ` netdev-bot+sashiko
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-24  2:10   ` netdev-bot+sashiko
2026-11-20  1:29 ` [PATCH net-next v5 9/9] bnxt_en: Fix ring accounting/validation when IRQs are constrained Michael Chan
2026-11-24  2:10   ` netdev-bot+sashiko

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=179548624915.3135.3359343024461356242@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew.gospodarek@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=michael.chan@broadcom.com \
    --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