Re: [PATCH net-next v2 2/2] net: stmmac: dwmac-motorcomm: support Wake-on-LAN from S5
From: Maxime Chevallier
Date: Tue Nov 24 2026 - 12:04:18 EST
On 11/20/26 11:27, Magnus Leatti wrote:
> "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@xxxxxxxx>
> Signed-off-by: Magnus Leatti <magnusleatti@xxxxxxxxxxxxxx>
My PCI-fu isn't that great, but LGTM. I would have liked to test, but
my motorcomm PCIe card let out the magic smoke yesterday :(
Reviewed-by: Maxime Chevallier <maxime.chevallier@xxxxxxxxxxx>
Maxime
> ---
> .../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,
> },