From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 60C79606A325 for ; Mon, 30 Nov 2026 10:18:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=OsrcIRcw; dkim=pass (2048-bit key) header.d=kernelriot.com header.i=@kernelriot.com header.a=rsa-sha256 header.s=kr2026 header.b=1vUKEQqN DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=ffm5469gnwmQW+mkuNW1jsjlEB6Zt3Q8PiaJSDEbeiE=; b=OsrcIRcw7btjj7 Xd4LYDOFsbNDB29ETPjJSlG1C5deYKKXUL1OvT/r++6p207Ka5KvBowF6NK/vPFIP5wvBIvUkJ3Cc uXJv0Yg5ZMgalLe4yWgI/VOaIfZ7SSMgfIT8vcN3p7qtU4SrhL+BU0OxAH1TnHfj13FJkbaB/kObK t+gCGExg+ZHUQvhhfFwttEA6fdpcTpZAmYBs2vI2JcJNb04AtdOIwi+GLPeICYLBpPfjvQ+Wo3lS+ +zPjpYUrVgkbcfJFwDp85QZ0D58up9QYdhgLct1lpQuaN2o8lXpJgLMPHrG+VCeDO7MA17IyKGI0I IQ9uhabMw6TOytP0hW4A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXySV-000000046o1-3457; Mon, 30 Nov 2026 10:18:07 +0000 Received: from mail.kernelriot.com ([74.208.142.49]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXyS9-000000046iA-1pCu for linux-arm-kernel@lists.infradead.org; Mon, 30 Nov 2026 10:17:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernelriot.com; s=kr2026; t=1796033864; bh=CXsdDdrj65TStPEbjbPpQrw2LdL2nBN95t0YX7JO/4o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding:From; b=1vUKEQqNe+673k/ZQkxQtT/bja8asl3fiC5jSMJ5bVnhgOCqm44+E/s5zRUyS/rDB SxK3+j3+WmUOVOJehBiD1Vq8GUaTtvbGVAb5r1bxzdAIqtg/82R8CyhfzfcrUpa0pS aGDbnQtMDfTQHRH/iMirrB3LGHp6+W4NYuXVeFEbRO7d88aGPKx/O8YrIletCv1lAx nxklbeBBTqcqE324FphM1/rF7Qj2ABC30xho+EMCsPi/q1DYN+260yCLtTnqmz/o5x 0ILqjr1dizPldHLWys4dXQ0wal4F3Wa9kDjP4kSXr4VoBgnxbcxcElzYXYMdbpAWjS 4mjcOqsZYYN0Q== Received: by mail.kernelriot.com (Postfix, from userid 995) id 5F4D781B0F; Mon, 30 Nov 2026 10:17:44 +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 , Sai Krishna , 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 v3 2/2] net: stmmac: dwmac-motorcomm: support Wake-on-LAN from S5 Date: Mon, 30 Nov 2026 07:17:00 -0300 Message-ID: <20261130101700.1715598-3-magnusleatti@kernelriot.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261130101700.1715598-1-magnusleatti@kernelriot.com> References: <20261130101700.1715598-1-magnusleatti@kernelriot.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261130_021745_512115_7B95C3C6 X-CRM114-Status: GOOD ( 18.77 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 "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. Suggested-by: Yao Zi Signed-off-by: Magnus Leatti Reviewed-by: Maxime Chevallier Reviewed-by: Yao Zi Tested-by: Giuseppe Nespolino --- .../ethernet/stmicro/stmmac/dwmac-motorcomm.c | 36 ++++++++++++++++++- 1 file changed, 35 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..41e440ed141e 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,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); + + if (!wake) + return; + + /* Reset re-enables OOB WoL; left alone, chip arms itself (eFuse MAC) */ + motorcomm_reset(priv); + + 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 +408,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