From: Yao Zi <me@ziyao.cc>
To: Magnus Leatti <magnusleatti@kernelriot.com>,
me@ziyao.cc, Maxime Chevallier <maxime.chevallier@bootlin.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Giuseppe Nespolino <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 2/2] net: stmmac: dwmac-motorcomm: support Wake-on-LAN from S5
Date: Mon, 16 Nov 2026 15:08:06 +0000 [thread overview]
Message-ID: <avscVrGbi7mFicuz@pie> (raw)
In-Reply-To: <20261116091757.1656602-3-magnusleatti@kernelriot.com>
On Mon, Nov 16, 2026 at 06:17:57AM -0300, Magnus Leatti wrote:
> The driver reports "Supports Wake-on: ug" and accepts "wol g", but a
> YT6801 in S5 ignores magic packets. At power-off stmmac_suspend() arms
> the PMT register, but the chip's out-of-band WoL block stays disabled
> as motorcomm_init() leaves it, the packet wake bit in WOL_CTRL is clear
> and PME is turned off.
>
> When powering off with Wake-on-LAN set, the interface up and wakeup
> enabled for the device, keep PME enabled and arm the chip after
> stmmac_suspend():
>
> - Enable OOB WoL. Without it the chip does not wake.
> - Write the MAC address in use to the first address filter again.
> Enabling OOB WoL reloads the factory address there. Without the
> rewrite the chip wakes on the factory address and ignores the one
> in use. The rewrite follows a 2 ms wait, as in the vendor driver:
> without the wait the reload lands after the rewrite.
> - Set the packet wake enable bit in WOL_CTRL. Without it the chip
> does not wake.
>
> The sequence follows the vendor driver, with two differences. The
> vendor also sets bit 9 of LPW_CTRL. The chip wakes without it, so it is
> left alone. The vendor puts the function in D3hot. Here it stays in D0.
> With MAC Wake-on-LAN phylink keeps the PHY running and phylib keeps
> polling it until power is removed. In D3hot the MDIO registers read as
> all-ones, the poll fails with -EBUSY and phylib warns from
> phy_error_precise(). That warning was seen 111 ms after entering D3hot
> on a normal power-off.
>
> The PHY is left at the negotiated speed. Reboot and kexec are not
> armed: OOB WoL can only be disabled again by a chip reset, so it is
> enabled only when powering off, and the next probe resets the chip. If
> the interface is down at power-off, the system does not wake.
>
> Suspend is not changed. Hibernation that powers off through the
> shutdown path arms the chip the same way. Neither was tested.
>
> Tested on a Celeron N3350 mini PC, magic packets sent from another host
> 75 s after power-off:
>
> net-next wol g no wake, 3 of 3
> patched wol g wake, 8 of 8 (28-31 s to ping)
> patched wol u wake on unicast, 1 of 1
> patched wol d no wake, 3 of 3
> patched wol g, interface down no wake, 1 of 1
> patched wol g, power/wakeup disabled no wake, 1 of 1
> patched wol g, reboot reboots, link back, 3 of 3
>
> The kernel log of each of these shutdowns, read back after the next
> boot, shows no warning from the shutdown path.
>
> A second board, a PSJ8500-N97 mini PC (Intel N97), behaves the same.
>
> Signed-off-by: Magnus Leatti <magnusleatti@kernelriot.com>
> ---
> .../ethernet/stmicro/stmmac/dwmac-motorcomm.c | 68 ++++++++++++++++++-
> 1 file changed, 65 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c
> index 1e142ad39e33..034547ad1e98 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c
[...]
> @@ -204,9 +207,51 @@ static int motorcomm_resume(struct device *dev, void *bsp_priv)
> return 0;
> }
>
> +/*
> + * Arm the chip to wake the system from S5. stmmac_suspend() has already
> + * programmed the PMT register of the GMAC. The rest lives in the wrapper.
> + */
> +static void motorcomm_arm_s5_wake(struct net_device *ndev)
> +{
> + struct stmmac_priv *spriv = netdev_priv(ndev);
> + struct dwmac_motorcomm_priv *priv = spriv->plat->bsp_priv;
> + u32 reg;
> +
> + /*
> + * motorcomm_init() disables OOB WoL right after the chip reset, as
> + * normal operation requires. With it disabled the chip ignores wake
> + * packets once the system is off. Once it has been enabled, only a
> + * chip reset disables it again, so enable it only when powering off.
> + */
> + reg = readl(priv->base + OOB_WOL_CTRL);
> + reg &= ~OOB_WOL_CTRL_DIS;
> + writel(reg, priv->base + OOB_WOL_CTRL);
> +
> + /*
> + * Enabling OOB WoL reloads the address from eFuse into the first
> + * MAC address filter. Write the address in use again, or the chip
> + * wakes on the factory address only. The reload is not immediate:
> + * without the wait, taken from the vendor driver, it overwrites
> + * the address written here.
> + */
> + usleep_range(2000, 3000);
> +
> + rtnl_lock();
> + phylink_rx_clk_stop_block(spriv->phylink);
> + stmmac_set_umac_addr(spriv, spriv->hw, ndev->dev_addr, 0);
Does the chip automatically enables WoL and loads MAC from eFuse on
power-on? If so, the driver's WoL behavior would vary if the software
alternates the NIC's MAC address, depending whether it's a cold boot or
a warm one.
Please confirm the chip's behavior on reset.
> + phylink_rx_clk_stop_unblock(spriv->phylink);
> + rtnl_unlock();
> +
> + reg = readl(priv->base + WOL_CTRL);
> + reg |= WOL_CTRL_PKT_EN;
> + writel(reg, priv->base + WOL_CTRL);
> +}
[...]
--
Thanks,
Yao Zi
Meow-mrrp-mrow, I'm a cat.
next prev parent reply other threads:[~2026-11-16 15:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 9:17 [PATCH net-next 0/2] net: stmmac: dwmac-motorcomm: shutdown hook and Wake-on-LAN from S5 Magnus Leatti
2026-11-16 9:17 ` [PATCH net-next 1/2] net: stmmac: dwmac-motorcomm: quiesce the device at shutdown Magnus Leatti
2026-11-16 14:33 ` Yao Zi
2026-11-16 14:58 ` Magnus Leatti
2026-11-16 9:17 ` [PATCH net-next 2/2] net: stmmac: dwmac-motorcomm: support Wake-on-LAN from S5 Magnus Leatti
2026-11-16 15:08 ` Yao Zi [this message]
2026-11-16 15:17 ` Yao Zi
2026-11-16 16:48 ` Magnus Leatti
2026-11-16 17:26 ` Yao Zi
2026-11-17 1:27 ` Andrew Lunn
2026-11-17 10:26 ` Yao Zi
2026-11-16 11:23 ` [PATCH net-next 0/2] net: stmmac: dwmac-motorcomm: shutdown hook and " Giuseppe Nespolino
2026-11-16 11:36 ` Magnus Leatti
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=avscVrGbi7mFicuz@pie \
--to=me@ziyao.cc \
--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=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.