From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D34F81F00924; Tue, 1 Dec 2026 10:18:23 +0000 (UTC) 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== Subject: Re: [PATCH net-next v3 2/2] net: stmmac: dwmac-motorcomm: support Wake-on-LAN from S5 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, 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 Date: Tue, 01 Dec 2026 10:18:23 +0000 Message-ID: <179612030337.3146.5561100766700468211@kernel.org> In-Reply-To: <20261130101700.1715598-3-magnusleatti@kernelriot.com> References: <20261130101700.1715598-3-magnusleatti@kernelriot.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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 wol d" or "ip link set 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