Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: pavan.chebbi@broadcom.com
Cc: michael.chan@broadcom.com, kuba@kernel.org,
	andrew+netdev@lunn.ch, andrew.gospodarek@broadcom.com,
	davem@davemloft.net, edumazet@kernel.org, netdev@vger.kernel.org,
	pabeni@redhat.com
Subject: Re: [PATCH net-next] tg3: Add support for boards integrated with security SoCs
Date: Sun, 22 Nov 2026 15:11:23 +0000	[thread overview]
Message-ID: <179536028313.3135.4205213957657544366@kernel.org> (raw)
In-Reply-To: <20261118150247.1145764-1-pavan.chebbi@broadcom.com>

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

Critical: 0 · High: 0 · 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).

- [Medium] On Citadel boards, tg3_get_eeprom_hw_cfg()
  (drivers/net/ethernet/broadcom/tg3.c) can leak a registered…
- [Low] The existing comment '/* GPIO1 must be driven high for eeprom
  write protect */' in tg3_reset_hw()…

--

tg3: Add support for boards integrated with security SoCs

This patch adds support for Broadcom NetXtreme NX1 boards that are
integrated with security SoCs. The boards are identified by their PCI
subsystem IDs. On these boards the driver never drives GPIO1, does not
enable EEPROM write protection, and clears WOL_CAP so that Wake-on-LAN is
not advertised.

> diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
> index 95827df4cf6a1..9c431f76d4a52 100644
> --- a/drivers/net/ethernet/broadcom/tg3.c
> +++ b/drivers/net/ethernet/broadcom/tg3.c

[ ... ]

> @@ -10537,7 +10543,10 @@ static int tg3_reset_hw(struct tg3 *tp, bool reset_phy)
>  		tp->grc_local_ctrl |= tr32(GRC_LOCAL_CTRL) & gpio_mask;
>  
>  		/* GPIO1 must be driven high for eeprom write protect */
> -		if (tg3_flag(tp, EEPROM_WRITE_PROT))
> +		if (tg3_flag(tp, CITADEL))
> +			tp->grc_local_ctrl &= ~(GRC_LCLCTRL_GPIO_OE1 |
> +						GRC_LCLCTRL_GPIO_OUTPUT1);
> +		else if (tg3_flag(tp, EEPROM_WRITE_PROT))
>  			tp->grc_local_ctrl |= (GRC_LCLCTRL_GPIO_OE1 |
>  					       GRC_LCLCTRL_GPIO_OUTPUT1);
>  	}

[Severity: Low]
This isn't a bug, but the existing comment says GPIO1 must be driven high,
and it now sits directly above the new CITADEL branch. That branch does the
opposite and leaves GPIO1 undriven.

Could the comment be moved down to the EEPROM_WRITE_PROT branch? Another
option is a short comment explaining that Citadel boards must not drive
GPIO1 because the security SoC uses it as a mailbox.

[ ... ]

> @@ -15231,6 +15272,9 @@ static void tg3_get_eeprom_hw_cfg(struct tg3 *tp)
>  	tg3_flag_set(tp, EEPROM_WRITE_PROT);
>  	tg3_flag_set(tp, WOL_CAP);
>  
> +	if (tg3_is_citadel(tp))
> +		tg3_flag_set(tp, CITADEL);
> +
>  	if (tg3_asic_rev(tp) == ASIC_REV_5906) {
>  		if (!(tr32(PCIE_TRANSACTION_CFG) & PCIE_TRANS_CFG_LOM)) {
>  			tg3_flag_clear(tp, EEPROM_WRITE_PROT);
> @@ -15430,6 +15474,12 @@ static void tg3_get_eeprom_hw_cfg(struct tg3 *tp)
>  			tp->phy_flags |= TG3_PHYFLG_DISABLE_1G_HD_ADV;
>  	}
>  done:
> +	if (tg3_flag(tp, CITADEL)) {
> +		tg3_flag_clear(tp, EEPROM_WRITE_PROT);
> +		tg3_flag_clear(tp, WOL_CAP);
> +		tg3_flag_clear(tp, WOL_ENABLE);
> +	}
> +
>  	if (tg3_flag(tp, WOL_CAP))
>  		device_set_wakeup_enable(&tp->pdev->dev,
>  					 tg3_flag(tp, WOL_ENABLE));

[Severity: Medium]
Can this leak a registered wakeup_source on Citadel boards?

CITADEL is set early, but WOL_CAP is not cleared until the done: label. Two
earlier branches in tg3_get_eeprom_hw_cfg() can therefore still enable
wakeup on a Citadel board.

The first is the NIC SRAM path:

    if (tg3_flag(tp, WOL_CAP) &&
        (nic_cfg & NIC_SRAM_DATA_CFG_WOL_ENABLE)) {
        tg3_flag_set(tp, WOL_ENABLE);
        device_set_wakeup_enable(&tp->pdev->dev, true);
    }

The second is the ASIC_REV_5906 path before goto done:

    if ((val & VCPU_CFGSHDW_WOL_ENABLE) &&
        (val & VCPU_CFGSHDW_WOL_MAGPKT)) {
        tg3_flag_set(tp, WOL_ENABLE);
        device_set_wakeup_enable(&tp->pdev->dev, true);
    }

pci_pm_init() has already marked PME-capable devices can_wakeup, so
device_wakeup_enable() goes ahead. It calls wakeup_source_register(), which
creates a wakeupN device with pdev->dev as its parent. It then attaches the
source to dev->power.wakeup.

After the new block clears WOL_CAP, the else branch that follows runs:

    else
        device_set_wakeup_capable(&tp->pdev->dev, false);

device_set_wakeup_capable() only clears can_wakeup and removes the sysfs
attributes. dev->power.wakeup is left in place. After that,
device_wakeup_disable() returns early:

drivers/base/power/wakeup.c:device_wakeup_disable() {
	if (!dev || !dev->power.can_wakeup)
		return;

	ws = device_wakeup_detach(dev);
	wakeup_source_unregister(ws);
}

So the call from device_pm_remove() never frees the wakeup_source. Its
child device also keeps a reference on pdev->dev, so the pci_dev is never
released after removal.

Before this patch, nothing cleared WOL_CAP after a possible
device_set_wakeup_enable(true) call, so this ordering is new.

Would it work to clear WOL_CAP where CITADEL is set, before either branch
can enable wakeup?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118150247.1145764-1-pavan.chebbi%40broadcom.com

      reply	other threads:[~2026-11-22 15:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 15:02 [PATCH net-next] tg3: Add support for boards integrated with security SoCs Pavan Chebbi
2026-11-22 15:11 ` netdev-bot+sashiko [this message]

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=179536028313.3135.4205213957657544366@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