From: netdev-bot+sashiko@kernel.org
To: magnusleatti@kernelriot.com
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, 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
Subject: Re: [PATCH net-next v2 2/2] net: stmmac: dwmac-motorcomm: support Wake-on-LAN from S5
Date: Tue, 24 Nov 2026 10:57:46 +0000 [thread overview]
Message-ID: <179551786682.3135.159994678754691253@kernel.org> (raw)
In-Reply-To: <20261120102754.778283-3-magnusleatti@kernelriot.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · 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-LAN even when the eFuse holds no…
- [Medium] motorcomm_shutdown() makes its wake decision under rtnl (lines
379-382), then drops rtnl before stmmac_dvr_remove() ->…
- [Low] motorcomm_shutdown() calls motorcomm_reset() (line 391) and then
immediately reads, modifies and writes WOL_CTRL (lines 394-396), with…
--
net: stmmac: dwmac-motorcomm: support Wake-on-LAN from S5
This adds a dedicated .shutdown callback to the Motorcomm YT6801 glue
driver. On power-off with magic packet WoL enabled, it removes the stmmac
device, then resets the chip so that it re-arms OOB WoL from its eFuse MAC.
After that it sets WOL_CTRL_PKT_EN, enables PME and puts the device into
D3hot.
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c
> index 63ce2301a0f69..34abbdb645ecb 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c
[ ... ]
> @@ -363,6 +367,38 @@ 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();
> +
> + /* The netdev is unregistered after this. priv and its mapping stay. */
> + stmmac_dvr_remove(&pdev->dev);
[Severity: Medium]
Can wake become stale between rtnl_unlock() and stmmac_dvr_remove()?
The comment above says userspace is still running, and device_shutdown()
does not freeze tasks. Once rtnl is dropped, another CPU can take it and
run "ip link set down" (dev_close()) or "ethtool -s ethX wol d":
phylink_ethtool_set_wol()
stmmac_mac_wol_set()
device_set_wakeup_enable(priv->device, !!wolopts);
...
priv->wolopts = wolopts;
Writes to the power/wakeup sysfs attribute don't take rtnl at all.
In each of these cases wake still holds the earlier value of true. The code
below would then still reset the chip, set WOL_CTRL_PKT_EN and call
pci_wake_from_d3(pdev, true).
Could the machine then power on from a magic packet after WoL was turned
off or the interface was taken down? That seems to go against this part of
the commit message:
- Magic packets only. "wol u", reboot, kexec and interface down stop
at the remove.
Would it help to call netif_device_detach() under rtnl before unlocking, or
to check the wakeup settings again after the netdev is unregistered?
> +
> + 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:
drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c:motorcomm_probe() {
...
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);
...
}
That result isn't stored anywhere, and the wake decision in
motorcomm_shutdown() doesn't check for it.
The commit message says that after this reset the chip loads the eFuse
address into the first MAC filter and wakes only on that address. With an
empty eFuse there is no address to load.
Wake is still armed, and ethtool still reports "Wake-on: g". A magic packet
sent to the netdev's address can't match, because that address is random
and changes on every boot. The user gets no warning.
Should the shutdown path skip arming, or at least warn, when probe fell
back to a random MAC?
The commit message also says:
- It wakes on the eFuse address, not the software one. Same as r8169.
That is only true when the eFuse is programmed. rtl_shutdown() writes the
reported permanent address back into the receive filter before arming:
drivers/net/ethernet/realtek/r8169_main.c:rtl_shutdown() {
...
/* Restore original MAC address */
rtl_rar_set(tp, tp->dev->perm_addr);
if (system_state == SYSTEM_POWER_OFF && !tp->dash_enabled)
pci_prepare_to_sleep(pdev);
}
So r8169 always wakes on the address it reports as permanent, including a
random fallback. Could the r8169 comparison be qualified?
> +
> + /* The reset has cleared it. Without it the chip does not wake. */
> + reg = readl(priv->base + WOL_CTRL);
> + reg |= WOL_CTRL_PKT_EN;
> + writel(reg, priv->base + WOL_CTRL);
[Severity: Low]
Is it safe to change WOL_CTRL immediately after motorcomm_reset(), with no
delay?
motorcomm_probe() does the same reset and then waits:
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 says the chip keeps changing its own state for
about 2-3 s after the reset.
On some boards that post-reset load might write WOL_CTRL, for example
through an eFuse patch entry. Could it then overwrite WOL_CTRL_PKT_EN, so
the device powers off with packet wake disabled?
The 5 of 5 result shows this works on the board that was tested. Even so,
should this path use the same post-reset delay as probe, or read the
register back after writing it?
> +
> + pci_wake_from_d3(pdev, true);
> + pci_set_power_state(pdev, PCI_D3hot);
> +}
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120102754.778283-1-magnusleatti%40kernelriot.com
prev parent reply other threads:[~2026-11-24 10:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 10:27 [PATCH net-next v2 0/2] net: stmmac: dwmac-motorcomm: shutdown hook and " Magnus Leatti
2026-11-20 10:27 ` [PATCH net-next v2 1/2] net: stmmac: dwmac-motorcomm: remove the device at shutdown Magnus Leatti
2026-11-24 10:57 ` netdev-bot+sashiko
2026-11-20 10:27 ` [PATCH net-next v2 2/2] net: stmmac: dwmac-motorcomm: support Wake-on-LAN from S5 Magnus Leatti
2026-11-24 10:57 ` 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=179551786682.3135.159994678754691253@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=g.nespolino@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=magnusleatti@kernelriot.com \
--cc=maxime.chevallier@bootlin.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=me@ziyao.cc \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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
all inboxes | Powered by JetHome®