Article View: linux.kernel.netdev
Article #25156Re: [PATCH net-next v3 2/2] net: stmmac: dwmac-motorcomm: support Wake-on-LAN from S5
From: netdev-bot+sashiko
Date: Tue, 01 Dec 2026 10:18
Date: Tue, 01 Dec 2026 10:18
195 lines
15318 bytes
15318 bytes
Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 3 · 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] In drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c,
motorcomm_shutdown() arms S5 wake on a board whose eFuse holds no MAC…
- [Medium] motorcomm_shutdown() takes a snapshot of netif_running(ndev),
spriv->wolopts and device_may_wakeup() under rtnl_lock() and stores it…
- [Medium] motorcomm_shutdown() starts the chip's self-arm sequence by
toggling SYS_RESET.
- [Low] motorcomm_shutdown() releases SYS_RESET and, with no settle delay
and no read-back, runs a read-modify-write on WOL_CTRL to set…
--
net: stmmac: dwmac-motorcomm: support Wake-on-LAN from S5
This adds a separate .shutdown callback to the YT6801 glue driver. On
power-off with magic packet WoL enabled, it removes the stmmac device and
resets the chip so that it re-arms OOB WoL by itself using the eFuse MAC.
It then sets WOL_CTRL_PKT_EN again, enables PME and puts the function in
D3hot.
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c
> index 63ce2301a0f69..41e440ed141e3 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c
[ ... ]
> @@ -363,6 +367,36 @@ static void motorcomm_remove(struct pci_dev *pdev)
> stmmac_dvr_remove(&pdev->dev);
> }
>
> +static void motorcomm_shutdown(struct pci_dev *pdev)
> +{
> + struct net_device *ndev = dev_get_drvdata(&pdev->dev);
> + struct stmmac_priv *spriv = netdev_priv(ndev);
> + struct dwmac_motorcomm_priv *priv = spriv->plat->bsp_priv;
> + bool wake;
> + u32 reg;
> +
> + /* Userspace is still running and may close the interface */
> + rtnl_lock();
> + wake = system_state == SYSTEM_POWER_OFF && netif_running(ndev) &&
> + (spriv->wolopts & WAKE_MAGIC) && device_may_wakeup(&pdev->dev);
> + rtnl_unlock();
> +
> + stmmac_dvr_remove(&pdev->dev);
[Severity: Medium]
Can the value of wake go stale between rtnl_unlock() and the netdev
teardown?
Userspace is still running during device_shutdown(). A request that was
blocked on rtnl can take it right after this rtnl_unlock() and complete
successfully. Examples are "ethtool -s <dev> wol d" or
"ip link set <dev> down":
phylink_ethtool_set_wol()
stmmac_mac_wol_set()
device_set_wakeup_enable(priv->device, !!wolopts);
...
priv->wolopts = wolopts;
After that, stmmac_dvr_remove()->unregister_netdev() runs. The old value
of wake is still used to reset the chip, set WOL_CTRL_PKT_EN, enable PME
and enter D3hot.
Could the machine then wake from S5 on a magic packet after WoL was
disabled or the interface was brought down? That would go against the
commit message note that "reboot, kexec and interface down stop at the
remove". The reverse case, enabling WoL in that window, would leave the
device unarmed.
Would it help to call netif_device_detach(ndev) in the same rtnl section
as the snapshot? Another option is to keep the wake decision and the
netdev teardown in one exclusion region.
> +
> + if (!wake)
> + return;
> +
> + /* Reset re-enables OOB WoL; left alone, chip arms itself (eFuse MAC) */
> + motorcomm_reset(priv);
[Severity: Medium]
What happens here on boards whose eFuse holds no MAC address?
motorcomm_probe() already handles that case by falling back to a random
address:
ret = motorcomm_efuse_read_mac(&pdev->dev, priv, res.mac);
if (ret == -ENOENT) {
dev_warn(&pdev->dev, "eFuse contains no valid MAC address\n");
dev_warn(&pdev->dev, "fallback to random MAC address\n");
eth_random_addr(res.mac);
The commit message says the chip arms itself with "the eFuse address
loaded into the first MAC filter". It also says "It wakes on the eFuse
address, not the software one".
On such a board the random MAC is the only address the network knows.
The wake decision above only checks system_state, netif_running(),
WAKE_MAGIC and device_may_wakeup(). Nothing records whether probe found
an eFuse MAC.
With "wol g" set, would this path silently arm the chip with an address
that a magic packet sent to the interface can never match? Should arming
be skipped, or at least warned about, when probe fell back to a random
MAC? Alternatively, should the commit message state this limitation?
> +
> + reg = readl(priv->base + WOL_CTRL);
> + reg |= WOL_CTRL_PKT_EN;
> + writel(reg, priv->base + WOL_CTRL);
[Severity: Low]
Is it safe to do this read-modify-write right after the reset is
released?
motorcomm_probe() follows the same motorcomm_reset() with a settle delay,
because the eFuse controller is still loading internal data:
motorcomm_reset(priv);
/*
* After system reset, the eFuse controller needs time to load
* its internal data. Without this delay, eFuse reads return
* all zeros, causing MAC address detection to fail.
*/
usleep_range(2000, 5000);
The commit message also describes the chip running its own arming
sequence for about 2-3 s after the reset.
If the eFuse autoload or the self-arm sequence writes WOL_CTRL after this
RMW, PKT_EN would be lost. Nothing reads the register back, so the driver
would still enter D3hot as if wake were armed.
On the other hand, the EPHY_CTRL RMW in motorcomm_reset() takes effect
immediately after the reset, and the patch was tested successfully. So
this depends on undocumented hardware behaviour.
Would a short delay or a read-back check here be worth adding?
> +
> + pci_wake_from_d3(pdev, true);
> + pci_set_power_state(pdev, PCI_D3hot);
> +}
[Severity: Medium]
Does the self-arm sequence started by motorcomm_reset() have time to
finish before power is removed?
The commit message says it takes "about 2-3 s" for the chip to bring the
PHY up, start the receiver, load the eFuse MAC into the first MAC filter
and get PMT ready. That was timed from userspace with no driver bound,
not across an S5 transition.
Here the function moves the device to D3hot and returns at once. Nothing
in the rest of kernel_power_off() waits for that window:
kernel/reboot.c:kernel_power_off() {
kernel_shutdown_prepare(SYSTEM_POWER_OFF);
do_kernel_power_off_prepare();
migrate_to_reboot_cpu();
syscore_shutdown();
pr_emerg("Power down\n");
pr_flush(1000, true);
kmsg_dump(KMSG_DUMP_SHUTDOWN);
machine_power_off();
}
The commit message also notes that after a power loss the chip doesn't
arm itself again until the next clean shutdown.
Suppose PERST# assertion or main-power removal interrupts the sequence.
Could the device be left with OOB WoL and PME enabled but no programmed
MAC filter or PMT, so that "wol g" fails silently?
Is there a completion indication that could be polled here? Or does the
hardware guarantee that the sequence survives the power transition?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130101700.1715598-1-magnusleatti%40kernelriot.com
Technical Details
Message-ID:
<179612030337.3146.5561100766700468211@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374933-linux-kernel-netdev=dewy.ruReferences:
<20261130101700.1715598-3-magnusleatti@kernelriot.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374933-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v3 2/2] net: stmmac: dwmac-motorcomm: support Wake-on-LAN from S5 Date: Tue, 01 Dec 2026 10:18:23 +0000 Organization: Usenet Network Message-ID: <179612030337.3146.5561100766700468211@kernel.org> References: <20261130101700.1715598-3-magnusleatti@kernelriot.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1683773"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:2OxOX1+jmd6VTRNrCDuRKCHh0xw= sha256:9w1G7CLn5zDuW+GRzmIhLGhHit1o5lpf+/A4A9+Kt6M= sha1:3KrJtXewwLWEDzbf7Y2pUJjY1hU= sha256:dZSwCpFjrH3ojEziUz6qeY7FzvaNWodDRXv09gFZtM0= 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 5ECA1117323; Tue, 1 Dec 2026 13:18:45 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.5 X-Spam-Status: No, score=-3.5 tagged_above=-9999 required=6.31 tests=[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, URIBL_BLOCKED=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 jBEFsMaaTp-e; Tue, 1 Dec 2026 13:18:41 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-374933-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 3271E11716E; Tue, 1 Dec 2026 13:18:32 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id C6F7322FF3; Tue, 1 Dec 2026 10:18:29 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail; t=1796120306; b=UQhxp3s84Ij9cM/XE++rkMIiCsWpoyYKPjRXX+Ler0DgYNpPirPsJmypJP1ULfxcmSDf 9qc9gGWoVfAfNyxiLjgcv7PEeJQn6Wembunk/PW+3WPYUHT8C6h4VIhIRbCGInUNN+wtc YRVwrA9dO1ylaEdc4mlIjuNalJ1NHgka09QDGrZGbma3RNYbyRlQ/xmKWP7d5/TA6pkHw 5oEBbsPhWpxGz2aVP9CQo6onv/8Az4sf43wVsz3qrMCmfvl7YZBgU2mvvHS+W/I8nz8VF 5XxHxE1Fl3QBx/5Yf0qkD8vxeZLqQrkSP9xJj2hAOUXiHS6yGAqIDzZAb3/hvF1d96w== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796120306; 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=a5ScZQ9UmMcB4Q1GQFANn2QD8IasoD3LyQb5K5YA5v4=; b=j7cY8x7eRu6apzWt0g1KtyYfjr2P/JDH70DnDjS7vzIoS1dIXi1rEGcAst/1VulOEJiQ pIWQP0uYHi1QI/xAGcOKV9sG4pCKHTUde9pjXyphHFSbhpzD5Me6FXygburiRUIeuhYPZ 0k0bL5CalWrSaLqvDaUXeH5tlxELFcovdxs/IqNgnEJ01V5xwavbfV3TPXlWbLi78eO5Y sXMUYU9q5ayFObYhfjfNsYOnzYKaIjB/jD8L5FAkBS92UTDkja5kndXNW3R2pZpbb85Z7 KwoUw++h3vNdjgVtyo7UMJy7Ht7ZH3mDUr+SlSYGvSfNQqy3MUtlgoMCDFZ00I0NVhQ== 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=bkk7AQJO; arc=fail 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 1BD90606A33E; Tue, 1 Dec 2026 10:18:26 +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=bkk7AQJO 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=1796120305; b=Op6lQzlmEXVthrch5Nfj6mWEsEZp6fr1TkAHeZjd6lBaIvIAahwuDExL7MBHDztvoNjF FbEMoJvonGyPnFZYWXnSVFJoggs2AJ91fywVVSXNhS79vEMYq920ZckN61ziqW4UWOfgy c34Hqp1aJh8adKuCdOP7HCNExwtIDDlzyO8ryV7mOC5kh31IL6xhwuP/VGdHQtZElRjwf C4fC+p39RiQ2u8k8SCXrIGGJpNtNLhKuLY5SgHRGhhPzS7VJkdJ3nJ5vcSM+u8helQ/BG rwmCxQBxc5Il9l65TWIQPsoOS+49xmgaKLjpLhnDy9eXpe1TR8cgfPiYbxxWx7rOo6Q== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796120305; 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=a5ScZQ9UmMcB4Q1GQFANn2QD8IasoD3LyQb5K5YA5v4=; b=SCCe6BpzbjM6gu9Gk7FekGvQn+RSjOWn2fodbd0J7dSVyq+xhvxUbhowPREdpQYVImvd uHlHVF8/2COjMeLEVrESm1HERC5o4lZTXNZuCtYuyX+1adxaFSz7OaSLwNrLwIVDeKnBd P2vm2kS941gwJRL9f87FfcG7X2oO7TK2Hged9DGU2qmgq7mDebUsCihoKNBhKdWLaNBCz Jv1lQPzyQxfYxxaylnwuiZTttRiIiZOYFVZDPbSayPgrOKCqXo6rmAVAQ182qz0SQV7xs ZpMgguaJZkJFvY4hBYYD0Tz0OS0f1lMmzthiYURhfrEgWWJbeuYVtwZBP+03P4HHT7Q== 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=bkk7AQJO; 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 3DB59606A32E; Tue, 1 Dec 2026 10:18:25 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id D34F81F00924; Tue, 1 Dec 2026 10:18:23 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796120304; bh=a5ScZQ9UmMcB4Q1GQFANn2QD8IasoD3LyQb5K5YA5v4=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=bkk7AQJOo3l0roSdFgJ0j48ohriyfoXUevDUaykuHF74C43iDiqY8gRhCMkjTJMr5 gQDXTSOCAZEorrvbuqIAuq3QkaSGRCwWrQdHq+ymz/UK+MSRITi1phxEHceuUguZm4 s6mZVbcCR707aSui+gRUpbcv5TiqbWoz8TEAzAszv47k8LMWb8si1nd6xdrvTcCbae tCI0h33ib0QYr9AjeRfR7DXnvoZF3bcwM+l0PpF9PZSebHWIibT4MpWh7DFoXhqWs4 6azxxa/JoISAHdRuP6dFhp7YBHr5jAsCABXI9IF5EThUHh/Vtyiqeaj3oTG9/RDCvO hx4oo0ajTq84w== X-Cc: me@ziyao.cc, maxime.chevallier@bootlin.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, saikrishnag@marvell.com, g.nespolino@gmail.com, netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-In-Reply-To: <20261130101700.1715598-3-magnusleatti@kernelriot.com> X-sashiko-severity: Medium 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