From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.208.142.49 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795170506; b=FeeuCSQsbaSuYwYztB5QVRi4+VFVPNvR2wBjchQlEAouFn6ru4nGwkr2F7Zk03KtQDEe euTrkDeKaOGQShIZ0UR0H91qsn7fHi3hajWnYepJMR+p5hXh9M16PKwnkZZGDlqWD6bK+ Y+7AJyWBiVwLC/kkxwazSmB+pZ04vN5Ahyy45+N2UqKNWiiukbSHgy3q8PBgZrPjLM2Xx owD0pf23Udmxdlp7G8ZKZ6d0FQ876dpOt6OMrq+Vb58dCuhtojfsdKp+6n58w59zQ0kTz U56MbRczq3pGgtjeqGZ3aUfgfSUm5B21BVy10WWur+IRqLAihqv+mCZKzNPL3+2F2eQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795170506; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=7Znv3S/0Risx4b0ZeRoP9GV1/qanj0FzXDAXhm0/Ink=; b=J+pl3RW/RmZUetMwe+f/CqDTb4ai27g7+m4DSZhCSjmXtaY0mFLc22wLV7iEIMHpNjCd sTjtbCNSvNJHaYsJHZJmuEY4vHzbRZWq0GIKcta34qa+GduO4GhpIbqGhnfAF9dnWClbq v284EVyMXU1555gEQ/+ynUQHXxqSV7DjcAkckeSxgI70kC91gYJoiutLP7tIMB0BLnfDA SgLzKzlf19avO16u2S1JM/LyIHYlHCOfoaC4sCGHUBwcKGoMBUMNWAT/za+xgr6neMPsr 8BrtzsichETmeLBeYSLROz28ZTbx6Zc88qoJX1uEa1oDctF0H8k0P0kgEs9WEPW2FGg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=kernelriot.com; spf=pass smtp.mailfrom=kernelriot.com; dkim=pass header.d=kernelriot.com header.i=@kernelriot.com header.a=rsa-sha256 header.s=kr2026 header.b=gF+a1XOk; arc=none smtp.remote-ip=74.208.142.49 Received: from mail.kernelriot.com (mail.kernelriot.com [74.208.142.49]) (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 2E15D60A260C; Fri, 20 Nov 2026 10:28:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2E15D60A260C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=kernelriot.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kernelriot.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernelriot.com header.i=@kernelriot.com header.a=rsa-sha256 header.s=kr2026 header.b=gF+a1XOk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernelriot.com; s=kr2026; t=1795170505; bh=F37o9lPF5fbkfJltDpqXKh37zda6M0/QtC4EdaHujzs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding:From; b=gF+a1XOkePhDL3DAVJAIDmYVUlHP/FgaKmR4N7xyWaGLU7TI1JSBSmO0tt6lf8JsP MDCtpH+SlqVxtj9xgNB46eptXDypNoUWifPSA7AhnymU//comVUbXk7kkNGeYjP1Ma MgVvTU1aCMmQCG2eXT1nvPxFQNO3L4VlBPgPiIyXGI+JxKev9yqoP06KK0RgFy30CP S54sQczd1d+/B3W8MdJJbx11vTRuGqlK3W8pWNgqg55Wf4wycUWzoSdAgqLXsw8eb+ BIh8/0USwQR4tqFiCnmIUzkxXVtqXsryHO3/DxUourvLI6G8LHuarVnslng1dY5lNP TLN6ZbujgAwEw== Received: by mail.kernelriot.com (Postfix, from userid 995) id 7D9D78D804; Fri, 20 Nov 2026 10:28:25 +0000 (UTC) From: Magnus Leatti To: Yao Zi , Maxime Chevallier , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Maxime Coquelin , Alexandre Torgue , Giuseppe Nespolino , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 2/2] net: stmmac: dwmac-motorcomm: support Wake-on-LAN from S5 Date: Fri, 20 Nov 2026 07:27:54 -0300 Message-ID: <20261120102754.778283-3-magnusleatti@kernelriot.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261120102754.778283-1-magnusleatti@kernelriot.com> References: <20261120102754.778283-1-magnusleatti@kernelriot.com> 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 Content-Transfer-Encoding: 8bit "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 Signed-off-by: Magnus Leatti --- .../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 #include #include +#include #include #include @@ -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