🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
1 messages
1 total messages Started by netdev-bot+sashiko Sun, 22 Nov 2026 15:11
Re: [PATCH net-next] tg3: Add support for boards integrated with security SoCs
#20448
Author: netdev-bot+sashiko
Date: Sun, 22 Nov 2026 15:11
139 lines
12839 bytes
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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads