* [PATCH net-next v2 0/2] net: stmmac: dwmac-motorcomm: shutdown hook and Wake-on-LAN from S5
@ 2026-11-20 10:27 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-20 10:27 ` [PATCH net-next v2 2/2] net: stmmac: dwmac-motorcomm: support Wake-on-LAN from S5 Magnus Leatti
0 siblings, 2 replies; 3+ messages in thread
From: Magnus Leatti @ 2026-11-20 10:27 UTC (permalink / raw)
To: Yao Zi, Maxime Chevallier, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Maxime Coquelin, Alexandre Torgue, Giuseppe Nespolino, netdev,
linux-stm32, linux-arm-kernel, linux-kernel
YT6801 accepts "ethtool -s eth0 wol g" today, but ignores magic packets.
This series makes S5 Wake-on-LAN work. My patches here touches only the
glue.
v1 called stmmac_suspend() from .shutdown and Yao rejected that [1].
This is the design proposed by Yao, remove the device at shutdown, reset
the chip and let it arm itself.
Patch 1 just wires .shutdown to the existing remove.
Patch 2 arms WoL: after remove, it resets the chip, restores the cleared
packet-wake bit, enables PME and drops to D3hot.
Changes from v1:
- Wake uses the eFuse address, not whatever the driver programmed.
r8169 works the same way.
- Magic Packets only.
- D3hot now. No more polling so D3hot is clean.
Tested on a Celeron N3350 mini pc, NIC soldered, net-next at
6964ff21c5d8 with storm fix [2].
net-next wol g no wake, 3 of 3
patched wol g no wake on the address in use,
wake on the eFuse address, 5 of 5
patched wol g, 15 min off same, 1 of 1
patched wol ug same, 1 of 1
patched wol u, unicast frames no wake, 1 of 1
patched wol d no wake, 1 of 1
patched wol g, interface down no wake, 1 of 1
patched wol g, wakeup disabled no wake, 1 of 1
patched wol g, reboot reboots, link back, 3 of 3
patched wol g, kexec new kernel, link back, 1 of 1
patched wol g, hibernate same, resumes, link back, 2 of 2
patched wol g, cable out, in no wake, 2 of 2
19 patched shutdowns, all clean.
Hibernate on this box ends in a normal power-off (S4 is off in the
BIOS), so it goes through .shutdown and arms the same way.
The last row is a true power loss: So if power drops, it just won't
wake. Meaning: It needs to be shut down cleanly through the driver
again. FWIW the vendor driver does the same: wakes after a normal
power-off, sleeps through everything after a power loss. So its a
hardware thing and not something a driver can fix.
Giuseppe, your Tested-by was for the v1 design so I couldn't carry it
over :(. I'm sorry, could you test again?
Sashiko's nagging on patch 1 of v1 [3] came from calling
stmmac_suspend() in .shutdown. v2 doesn't, so it's gone.
BTW stmmac has an old bug here: if a resume fails, NAPI stays off, and
then closing the interface just hangs in napi_disable().
Changes in v2:
- .shutdown no longer calls stmmac_suspend(). It removes the device.
- A reset arms the chip, no more OOB WoL or MAC address writes.
- D3hot at power-off, v1 stayed in D0.
- Magic packet only, on the eFuse address.
- The wake condition is read under RTNL.
- Added Suggested-by Yao on both patches.
v1: https://lore.kernel.org/netdev/20261116091757.1656602-1-magnusleatti@kernelriot.com/
[1] https://lore.kernel.org/netdev/avsTEglKKD_wl_Fi@pie/
[2] https://lore.kernel.org/netdev/20261113103236.2184751-1-maxime.chevallier@bootlin.com/
[3] https://lore.kernel.org/netdev/179499351041.3136.14889707783816630750@kernel.org/
Magnus Leatti (2):
net: stmmac: dwmac-motorcomm: remove the device at shutdown
net: stmmac: dwmac-motorcomm: support Wake-on-LAN from S5
.../ethernet/stmicro/stmmac/dwmac-motorcomm.c | 37 +++++++++++++++++++
1 file changed, 37 insertions(+)
base-commit: 2208ab00f4f213ade91ab775e7f8c4dacdcc856e
--
2.56.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH net-next v2 1/2] net: stmmac: dwmac-motorcomm: remove the device at shutdown
2026-11-20 10:27 [PATCH net-next v2 0/2] net: stmmac: dwmac-motorcomm: shutdown hook and Wake-on-LAN from S5 Magnus Leatti
@ 2026-11-20 10:27 ` Magnus Leatti
2026-11-20 10:27 ` [PATCH net-next v2 2/2] net: stmmac: dwmac-motorcomm: support Wake-on-LAN from S5 Magnus Leatti
1 sibling, 0 replies; 3+ messages in thread
From: Magnus Leatti @ 2026-11-20 10:27 UTC (permalink / raw)
To: Yao Zi, Maxime Chevallier, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Maxime Coquelin, Alexandre Torgue, Giuseppe Nespolino, netdev,
linux-stm32, linux-arm-kernel, linux-kernel
No .shutdown here, so reboot, kexec and power-off leave the MAC and
DMA running. This chip keeps its registers through S5 too.
Hook .shutdown to stmmac_dvr_remove(): interface closed, DMA and MAC
stopped, PHY dropped.
Suggested-by: Yao Zi <me@ziyao.cc>
Signed-off-by: Magnus Leatti <magnusleatti@kernelriot.com>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c
index 42f0b11a7b60..63ce2301a0f6 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c
@@ -374,6 +374,7 @@ static struct pci_driver dwmac_motorcomm_pci_driver = {
.id_table = dwmac_motorcomm_pci_id_table,
.probe = motorcomm_probe,
.remove = motorcomm_remove,
+ .shutdown = motorcomm_remove,
.driver = {
.pm = &stmmac_simple_pm_ops,
},
--
2.56.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH net-next v2 2/2] net: stmmac: dwmac-motorcomm: support Wake-on-LAN from S5
2026-11-20 10:27 [PATCH net-next v2 0/2] net: stmmac: dwmac-motorcomm: shutdown hook and Wake-on-LAN from S5 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-20 10:27 ` Magnus Leatti
1 sibling, 0 replies; 3+ messages in thread
From: Magnus Leatti @ 2026-11-20 10:27 UTC (permalink / raw)
To: Yao Zi, Maxime Chevallier, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Maxime Coquelin, Alexandre Torgue, Giuseppe Nespolino, netdev,
linux-stm32, linux-arm-kernel, linux-kernel
"wol g" is accepted, but the chip sleeps right through magic packets
in S5: motorcomm_init() turns OOB WoL off and nothing turns it back on
at power-off.
Turns out the chip can just arm itself. Hit it with a reset, OOB WoL
comes right back on, and about 2-3 s later it has the PHY up, receiver
running, the eFuse address loaded into the first MAC filter, and PMT
ready for magic packets. Timed that from userspace without a driver
bound.
So on a power-off with "wol g": remove, reset, set WOL_CTRL_PKT_EN
again because the reset clears it, enable PME, D3hot.
Notes:
- It wakes on the eFuse address, not the software one. Same as r8169.
- Magic packets only. "wol u", reboot, kexec and interface down stop
at the remove.
- Hibernation that powers off through .shutdown arms too, and resume
copes without a reset. Tried twice: woke on the packet, link back.
- After a power loss (cable out and back in, BIOS set to stay off) it
won't wake until the next clean shutdown. The vendor driver does
the same, so that's the hardware.
With this the box wakes on a magic packet to the eFuse address, 5 of
5. Without it, 0 of 3.
Suggested-by: Yao Zi <me@ziyao.cc>
Signed-off-by: Magnus Leatti <magnusleatti@kernelriot.com>
---
.../ethernet/stmicro/stmmac/dwmac-motorcomm.c | 38 ++++++++++++++++++-
1 file changed, 37 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c
index 63ce2301a0f6..34abbdb645ec 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c
@@ -12,6 +12,7 @@
#include <linux/iopoll.h>
#include <linux/module.h>
#include <linux/pci.h>
+#include <linux/rtnetlink.h>
#include <linux/slab.h>
#include <linux/stmmac.h>
@@ -27,6 +28,9 @@
#define EPHY_CTRL 0x1004
/* Clearing this bit asserts resets for internal MDIO bus and PHY */
#define EPHY_MDIO_PHY_RESET BIT(0)
+#define WOL_CTRL 0x100c
+/* Magic and remote wake-up packet enable */
+#define WOL_CTRL_PKT_EN BIT(1)
#define OOB_WOL_CTRL 0x1010
#define OOB_WOL_CTRL_DIS BIT(0)
#define MGMT_INT_CTRL0 0x1100
@@ -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);
+
+ if (!wake)
+ return;
+
+ /* Reset re-enables OOB WoL; left alone, chip arms itself (eFuse MAC) */
+ motorcomm_reset(priv);
+
+ /* 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);
+
+ pci_wake_from_d3(pdev, true);
+ pci_set_power_state(pdev, PCI_D3hot);
+}
+
static const struct pci_device_id dwmac_motorcomm_pci_id_table[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_MOTORCOMM, 0x6801) },
{ },
@@ -374,7 +410,7 @@ static struct pci_driver dwmac_motorcomm_pci_driver = {
.id_table = dwmac_motorcomm_pci_id_table,
.probe = motorcomm_probe,
.remove = motorcomm_remove,
- .shutdown = motorcomm_remove,
+ .shutdown = motorcomm_shutdown,
.driver = {
.pm = &stmmac_simple_pm_ops,
},
--
2.56.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-20 10:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-20 10:27 [PATCH net-next v2 0/2] net: stmmac: dwmac-motorcomm: shutdown hook and Wake-on-LAN from S5 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-20 10:27 ` [PATCH net-next v2 2/2] net: stmmac: dwmac-motorcomm: support Wake-on-LAN from S5 Magnus Leatti
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®