🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #16656

Re: [PATCH net v2 2/4] tg3: Select PLL clock when preparing for shutdown

#16656
From: netdev-bot+sashiko
Date: Sun, 15 Nov 2026 12:58
212 lines
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
Technical Details
Message-ID: <179474752179.2199510.16313103373279878088@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder2.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363703-linux-kernel-netdev=dewy.ru
References: <20261111123917.910416-3-pavan.chebbi@broadcom.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder2.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363703-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2 2/4] tg3: Select PLL clock when preparing for shutdown
Date: Sun, 15 Nov 2026 12:58:41 +0000
Organization: Usenet Network
Message-ID: <179474752179.2199510.16313103373279878088@kernel.org>
References: <20261111123917.910416-3-pavan.chebbi@broadcom.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="1803475"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:yx8srMhzn2o8B1HBxoLo00rh7NM= sha256:+ip2TMFJwPg/J+vpC/uzEgOgHAp1ZlWlVeD2Hi37YP0= sha1:NDl2/oe4pKcLuEddPhbr5rYb3mc= sha256:ze3IJo1uYAiwx4YwgkiKROk2emL0GyacuUNg8KxGYdQ=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id B66D511496A; Sun, 15 Nov 2026 15:59:05 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id a4X9YsMRkSLX; Sun, 15 Nov 2026 15:58:57 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-363703-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 253681149C0; Sun, 15 Nov 2026 15:58:48 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 8B6AC2CD12; Sun, 15 Nov 2026 12:58:44 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794747524; b=nJzwjGMXvZme4zcIOo6a47imL/1tfNEeMea/Rqru0FmJVSF222qsZS2/97uRTuzbfryL q9CS4AHtI14bdaY0EqCbNcV3Y2U/NVdIVjboI+Kwo5F4LYDK4xb3G/YaugHBva35GpGCX ZrWn4jvn5X4d3D5i4ik5/5Q+VGBc+pCsbWYgAbrdTuAHgTobRdeN/Dj8XsPBhSsIqidQ3 l8Gu8PcfoUh9ZXb56GOquTPbg+Lhj6tD6WOxYrEJsVNLOLkS+ZEyC8pDyqsrqg+r2wY5t RLpaU4RO0ZsnhXVtCdFPJoB3uWpaFm1yAztmvqF40HbcZ0HGRz8b2a5ri/w7HdQRCwg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794747524; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=R1LBefYw6pp3k9OMIlREqlnnnc7IHJT38Apio1SkC6E=; b=RS4DT+AfNj3ZSBP4pZAx0FeILqSUzS5HdSxXOv9S8+X68ilE1Lfs6kLbvJLF07J57nbt Wjnuj9lU3SXDetBRIcGIjjsniFjyEngHAcSvO6caeEIpq3hkHI2V3EFoUt4cF8BMvkJIC Hj97cy8UUoC65zZlItk8gHHe6eFNWMpEZ0KeJEK8LVVZIZdqfKd4zhKknks4ay6O7TJ/L BVagNcw6h9Vzx8zif8pM7S1OFA0dQwG4WQFzBSiDAHrASyhUeWWUkuw12wyM46ONCmdKn zi4HQtg3lEIOigLDkWs31b2DqvZYwrTTOlX9JQ5YznYFHUcj8Vzwf679yQrEdOozFKQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Rk3xz81z; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E78C606A31F; Sun, 15 Nov 2026 12:58:44 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Rk3xz81z
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794747523; b=Fts3fXEuEGrRyYbQSgaQ2ZAy+UKn3RCSBGgmsNRrzMKxj8N1WX+GI6A4a3TFBJMs61iq YEKh3qINlWi6rCqtjBfFc85UnMNeAeBkG1/vPGQgPZG3oBg3aCH0RGw9rra0lL2YSkxr/ kgl9oFEE8PAO+wLywEU64LoytOPsuFUL78ZWloJbKwAr6N4+mc4etPRsHHGf1Cc7yV9wR smgW6oLsT66W8sqwBt6b+Ji9Pv9z+mTiophnRGThRfzVrqLobFzhhDiV6sP0DNYfeNIoZ tRXtgUr5a6a7i1IFkZlaTOOBwNjthUr2nSrGNn+w/6hSfG2GOGTpfI0Z9HTAuPlh9WA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794747523; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=R1LBefYw6pp3k9OMIlREqlnnnc7IHJT38Apio1SkC6E=; b=A6KNRgAokAWnQ6jvE/1qWjKADtE9oRA2eXSc3hvwto699uP372vYnu6Jxxnf5DBcOHu9 +UHURpW7dNNhCANpP/arWKc45pTyzIq9nsRng9lI4l4WC0wq9dWMTNsvkcZeKdeGUnJJu cfMXAUphW58mLDAACzj3RqofwolDeB8olxmsHp0LtPgSxUMUPwzBM3WDCG4Nhzrc02YjB +ve4ZZoeVag6KSz0ydJIKjffBHyt5yUAKkPJjjWNyyUqoAd7t1Qsr8sB1/qpuxnmSBHXP XYSTHp3VWDrvfp+xeDUmEsshzXFDg+CGt85ymh2rFQG65C29/+UJ5uV/hT4FUMjMcOQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Rk3xz81z; arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4DBE8606A31A for <netdev@vger.kernel.org>; Sun, 15 Nov 2026 12:58:43 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B9C41F000C4; Sun, 15 Nov 2026 12:58:42 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794747522; bh=R1LBefYw6pp3k9OMIlREqlnnnc7IHJT38Apio1SkC6E=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Rk3xz81zYCWjPxEX2WOJFuVDU64iiLAHM+cFIYnktClzHMPtKuCwi70UWYuQLkY9j sqz9oLQWVWbO3Q9DVPrIpOaPMJ7WZzfgbBNDiBAW+RnenQ2zBnMZw3hc1mS9mYY0g8 FrROc9c5rPUFUkpSM281ehR2lZAgYt4WSds6bGwkSuojS0kvHyKIN1yU3idfpCBNjg HQcoj1syRI9HDvQasO/6649HvgDxkjTtg67sF7JGtsZpaXt5i6mDJyM0WTYVsxI5hv hwHtGSV1OO2losuwW1pfcXjTi/js4rP5ggMOhrm8Jkt8MmfqEeJohmXeyfsRV8SG/g 788Se2ifl6sdQ==
X-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, shravya.k-n@broadcom.com, vishvambar.panth-s@broadcom.com
X-In-Reply-To: <20261111123917.910416-3-pavan.chebbi@broadcom.com>
X-sashiko-severity: High
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list