Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by netdev-bot+sashiko
Sun, 15 Nov 2026 12:58
Re: [PATCH net v2 2/4] tg3: Select PLL clock when preparing for shutdown
Author: netdev-bot+sashiko
Date: Sun, 15 Nov 2026 12:58
Date: Sun, 15 Nov 2026 12:58
212 lines
15494 bytes
15494 bytes
Thank you for your contribution! Sashiko AI review found 5 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 4
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 workaround is skipped on system suspend when the interface
is administratively down but Wake-on-LAN is armed.
- [Low] Claim: the commit message says the bit is set 'On system suspend
or power off', but tg3_power_down() is also reached from…
- [Low] The clear in tg3_resume() (line 18277) sits behind `if
(!netif_running(dev)) goto unlock;`.
- [Low] In tg3_resume(), the new tg3_ncsi_pll_tlp_clk(tp, false) (line
18277) does a BAR0 read-modify-write of TG3_CPMU_PLL_CTRL_STAT.
- [Low] tg3_ncsi_pll_tlp_clk() returns silently if tg3_ape_lock(tp,
TG3_APE_LOCK_GPIO) fails.
--
tg3: Select PLL clock when preparing for shutdown
This commit works around a 5720 hardware issue where the device may fail
to wake on a single magic packet after being linked at 1G. It sets
CPMU_PLL_TLP_CLCK_SRC_NCSI_PLL in TG3_CPMU_PLL_CTRL_STAT on suspend or
power off when Wake-on-LAN is enabled and the last link speed was 1G. The
bit is cleared on resume and at probe.
> diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
> index 2cf9d2ea069b5..98338c0792e84 100644
> --- a/drivers/net/ethernet/broadcom/tg3.c
> +++ b/drivers/net/ethernet/broadcom/tg3.c
> @@ -4267,8 +4267,38 @@ static void tg3_power_down_prepare(struct tg3 *tp)
> return;
> }
>
> +static void tg3_ncsi_pll_tlp_clk(struct tg3 *tp, bool enable)
> +{
> + u32 val;
> +
> + if (tg3_asic_rev(tp) != ASIC_REV_5720)
> + return;
> +
> + /* The register is shared by both functions of the device. */
> + if (tg3_ape_lock(tp, TG3_APE_LOCK_GPIO))
> + return;
[Severity: Low]
If the lock can't be taken, should this failure be reported somewhere?
On 5720 ENABLE_APE is set, so tg3_ape_lock() busy-waits for about 1ms and
then returns -EBUSY. If that happens, the workaround is silently skipped
on the power-down path. On the probe and resume paths, the bit silently
stays set. Nothing retries and nothing is logged.
On the suspend, resume and shutdown paths, rtnl_lock keeps the two PCI
functions from competing for the lock. tg3_frob_aux_power_5717() also
returns silently when this lock fails. But contention from the APE/NCSI
firmware, or from peer paths during probe that don't hold rtnl, isn't
ruled out.
Would a netdev_warn() or a bounded retry make an intermittent WoL failure
from this easier to diagnose?
> +
> + val = tr32(TG3_CPMU_PLL_CTRL_STAT);
[ ... ]
> static void tg3_power_down(struct tg3 *tp)
> {
> + tg3_wol_select_pll_clk(tp);
> pci_wake_from_d3(tp->pdev, tg3_flag(tp, WOL_ENABLE));
> pci_set_power_state(tp->pdev, PCI_D3hot);
> }
[Severity: Low]
This probably isn't a bug, but the commit message says "On system suspend
or power off". tg3_power_down() is also reached from tg3_shutdown() on
restart, halt and kexec on any system not listed in
tg3_restart_snp_quirk_table:
tg3_shutdown()
if (!dmi_first_match(tg3_restart_snp_quirk_table) ||
system_state == SYSTEM_POWER_OFF) {
tg3_power_down(tp);
So the non-default TLP clock source can stay set across a warm reboot
until tg3 probes the device again.
The subject line says "shutdown", which covers every .shutdown reason, and
the bit can already stay set the same way after power off followed by a
WoL wake. This may only be a wording issue.
Could the commit message mention the reboot case too?
[ ... ]
> @@ -18222,6 +18254,7 @@ static int tg3_suspend(struct device *device)
> tg3_full_unlock(tp);
>
> tg3_power_down_prepare(tp);
> + tg3_wol_select_pll_clk(tp);
[Severity: High]
Is the workaround missed when the interface is down but Wake-on-LAN is
armed?
tg3_suspend() exits before it gets here:
if (!netif_running(dev))
goto unlock;
However, tg3_close() has already armed WoL for the closed interface:
tg3_close()
tg3_stop(tp);
if (pci_device_is_present(tp->pdev)) {
tg3_power_down_prepare(tp);
...
That sets MAC_MODE_MAGIC_PKT_ENABLE and puts the PHY into WoL mode.
link_config.active_speed keeps the speed recorded by the tg3_setup_phy()
call in that path. On 5720, if TG3_PHYFLG_KEEP_LINK_ON_PWRDN is set,
tg3_phy_copper_begin() leaves the link untouched, so the PHY can stay
linked at 1G.
The PCI core then puts the WoL-armed 5720 into D3hot with PME enabled.
This happens on S3 suspend, and also on platform-mode hibernation, where
.poweroff is tg3_suspend through SIMPLE_DEV_PM_OPS.
CPMU_PLL_TLP_CLCK_SRC_NCSI_PLL is never set on that path.
Isn't this the case the commit message describes: "On system suspend or
power off with Wake-on-LAN enabled, if the last link speed recorded before
power down was 1G"?
The two paths are also inconsistent. tg3_shutdown() calls tg3_power_down()
after dev_close() whether or not the interface was running. So a closed
interface gets the workaround on power off but not on suspend.
If the closed case gets handled, it would also need a matching clear in
tg3_open() or tg3_power_up(). tg3_resume() returns early for a closed
interface, and tg3_open() never clears the bit.
>
> unlock:
> rtnl_unlock();
> @@ -18241,6 +18274,8 @@ static int tg3_resume(struct device *device)
>
> netif_device_attach(dev);
>
> + tg3_ncsi_pll_tlp_clk(tp, false);
[Severity: Low]
Can the bit stay set after hibernation restore?
This clear sits after the same netif_running() early exit as the set in
tg3_suspend(). During restore, though, the set and the clear run in
different kernels.
The restore (boot) kernel runs .freeze, which is tg3_suspend(). If the
5720 interface is up there at 1G with WoL enabled, the bit gets set in
hardware. WOL_ENABLE can come from NVRAM at probe.
The image kernel then runs .restore, which is tg3_resume(). If the
interface was down in the image kernel, this clear is skipped. Neither
tg3_open() nor tg3_power_up() clears the bit, and probe does not run
again.
That would leave the bit set during normal operation, which doesn't match
"The setting is cleared on resume and at probe". Would clearing it
unconditionally before the netif_running() check, or in tg3_open(), avoid
this?
[Severity: Low]
This read-modify-write of a BAR0 register now runs before
tg3_restart_hw()->tg3_init_hw(). tg3_init_hw() first does this:
tg3_init_hw()
/* Chip may have been just powered on. If so, the boot code may still
* be running initialization. Wait for it to finish to avoid races in
* accessing the hardware.
*/
tg3_enable_register_access(tp);
tg3_poll_fw(tp);
pci_restore_state() does not restore TG3PCI_MISC_HOST_CTRL, and its swap
settings affect how register data is presented.
If MISC_HOST_CTRL was reset across the D3 to D0 transition, could
tr32()/tw32() here act on the wrong bits? And if bootcode is still
initializing, could the read-modify-write race with it?
Before this patch, tg3_resume() only touched APE (BAR2) registers before
tg3_restart_hw(). Would it be safer to move the clear after
tg3_restart_hw(), or to call tg3_enable_register_access() and
tg3_poll_fw() first?
>
> netdev_lock(dev);
> tg3_full_lock(tp, 0);
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261111123917.910416-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