Article View: linux.kernel.netdev
Article #21715Re: [PATCH net-next v2 2/2] net: stmmac: dwmac-motorcomm: support Wake-on-LAN from S5
From: netdev-bot+sashiko
Date: Tue, 24 Nov 2026 10:57
Date: Tue, 24 Nov 2026 10:57
184 lines
14559 bytes
14559 bytes
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
Technical Details
Message-ID:
<179551786682.3135.159994678754691253@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-370262-linux-kernel-netdev=dewy.ruReferences:
<20261120102754.778283-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-370262-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev 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 Organization: Usenet Network Message-ID: <179551786682.3135.159994678754691253@kernel.org> References: <20261120102754.778283-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="4117459"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:8w+E4ZmzwR4MTDK0e/7js4AnEnI= sha256:t2KiFOG9IXGQrscciI4LRl7dsr/G81HdoaOclDjHxtU= sha1:e6iEgK8OH4LsB+5e7PG6c4GnIa8= sha256:74ZoruCYHN9vcWyuS8N20xW6anRgcdQohMhvCQggKos= 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 ABB5B125DF5; Tue, 24 Nov 2026 13:58:18 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.501 X-Spam-Status: No, score=-3.501 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] 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 q91wBZFQ_vSX; Tue, 24 Nov 2026 13:58:14 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-370262-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id BF5A9125DFB; Tue, 24 Nov 2026 13:58:06 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id B9642606898; Tue, 24 Nov 2026 10:58:05 +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=1795517869; b=Mu7bYcNMKAr33IKbOD08DgaMMjpXq5oFakOonmc0QtuiU0TNm41RS9qnaeBCELnTsPKg sOCtz1CPmJHyVtmtH4pgdm6IDPqvYwhOmxYExqKYhHGai+pQefXruwAWVpmb09qr2Xml/ rU4xYv6U8l2bxBew0bk///QEG9wKIDBWnqhHWlzvClZMGY1akZruGVEmXv8+UtYWvnEX0 Rwo8PiqDbIsVnJUdoGtzQkPyLXQheAn2bWxZuM9a16MP6StrzqswPU6ySAPosxb4MW+E3 iYrDiX2lds4PZ6IKBC/2hPW7qMMKJWLeIIbGhSlQz1S1VEEGeBhd8ymJvIMNQVn6Ygg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795517869; 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=CD1+BsfXviNOBTgjoME+T6ZfemLBj36tB/SHsRAzkTg=; b=v0SHGrEAHOm70k+KSrw7lFzQaDhA1WRy3v0AGvG+C9Uj9J1/7BkGipT4UIA2W/Bb7lHa EVFR/5O1BQvd0cEKrWs3zSgC1K8s9TkTjnMg+yBf+5cN3FtlZ5QSy51QCLmHdSH7gkBAk HQjcD3VyTU7pbZlCX6EzVq6ySdvtRvtIcnsO0hRmyEhDfRkfamGMr3mwqROoKIL1YOea4 GxvSlRQ0JNtUZ646J2zZsUFC/9m6E+C0cLirtj0ewm2pn6ImGLW8MDDSu5gHQqtFxqP/L mIur+QALA2ARciVxfbFZi29lEPKv6frH8xaDfj+VzQPCDzdWCAGufUDRb4wtmUzCrww== 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=lYRtUeJj; 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 9FF7A60A2619; Tue, 24 Nov 2026 10:57:49 +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=lYRtUeJj 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=1795517868; b=kOH9lft6h+0o1IjoKLxPA6Hu3IrxYa96ACInv1tEpXd8T/4KD2PCIwLpC2a7uII/U075 r2s4qv9B0/3RNCl0aENyhMsBnfNfqeKtT8QXHO7GXumFohQf3VOiomIsyqgjKlGWtVBGV +poiOia37eYpxVIYsycGspWjdRn+OfaYbLfMn9plhwulHjixiXqK2uRQLTuuYjPQH7TaE mA+/KPTf+d5Gc0b+emZEFsxt1Jw12D2/GBgXV1GvqNg+esnpaWnO6wgjzrLNyqEOxWubN Rz/WFPjKY1q4JBuOxjmmUYiJJ8YZwqBeEmSY48iRXWckCyJPBJSR9IeujWRz8nNSHgw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795517868; 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=CD1+BsfXviNOBTgjoME+T6ZfemLBj36tB/SHsRAzkTg=; b=1/7hRmugxwpTOtJ0EkWHCcjEd7BMWMHfVQ/xCL3gEBmpsbvAmRv5zfGN3DUPKMCwhwqE 9dLfpSQmbilUr3CNEFzsxRiP9Osvj66tj/I+p7f2iZMT4mw94bKlMQzoeq2VMtleTr+yg EdGuu1CKwC+B9LDfzaMYJW6WxnhSD8DZDNq1IOzOEZ9L4It4512A81Evd332fhmHsMNv5 WDD2cmqghQN4NtmVFlP8fDzcSJDF7RPjsoDwgURpLJFabcsoQOi1LD/WucmuZxcM/B9p4 8wbmwK4i8Fp77S4ZHoIhfmjj3e8NjqAzTFOP21qLKltzlKMVlJncKIUUye2dEFpqe1w== 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=lYRtUeJj; 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 C0D1660A260F; Tue, 24 Nov 2026 10:57:48 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44A6C1F01570; Tue, 24 Nov 2026 10:57:47 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795517868; bh=CD1+BsfXviNOBTgjoME+T6ZfemLBj36tB/SHsRAzkTg=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=lYRtUeJj7MdN89+2/w7nlvHajXR8f0kw6Vuz7SLCW+utbIqoNTx9k2r0F/dO5/UKN lQqjhsXXgPxkG3vDSj18705imI3JOR4/wA1bMHC7fAE2VCaA+OQ1NZsb5dcsrKXi2K yulNE/vd7P/aYRAAhPUG26Tj9M8EUoo4rhmFtZMsQcr3QvqExdLOjtxMx8GH0bypkV O0g/J12wS5KvkIO8HeHWDsIx3fEXyA8USJKlwRaa6FWPQtkOysxKabgZxvU843ZrmJ f5xYxamrVnLVnI4dO6p/lyndVrehHYheWNVxrf6varNujVu3y+9p1fM++XswpnOCi2 YXmQXTvbYVvRw== 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, 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: <20261120102754.778283-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