Netdev List
 help / color / mirror / Atom feed
From: Magnus Leatti <magnusleatti@kernelriot.com>
To: 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: [PATCH net-next 1/2] net: stmmac: dwmac-motorcomm: quiesce the device at shutdown
Date: Mon, 16 Nov 2026 06:17:56 -0300	[thread overview]
Message-ID: <20261116091757.1656602-2-magnusleatti@kernelriot.com> (raw)
In-Reply-To: <20261116091757.1656602-1-magnusleatti@kernelriot.com>

The driver has no .shutdown hook. At reboot, kexec and power-off the
MAC and the DMA engine are left running.

Add a shutdown hook that calls stmmac_suspend(). With Wake-on-LAN off
it detaches the netdev and stops the DMA, the MAC and the PHY. With
Wake-on-LAN set it stops the DMA, arms the PMT register and keeps the
receiver and the PHY up, as it does for suspend. That is not enough to
wake this chip from S5, so the system still does not wake.

stmmac_suspend() ends in stmmac_pci_plat_suspend(), which enables PME
if wakeup is enabled for the device. Disable it again, since nothing
arms the chip.

A failed resume leaves the netdev detached with NAPI disabled. Skip the
hook in that state: stmmac_suspend() must not run a second time.

Signed-off-by: Magnus Leatti <magnusleatti@kernelriot.com>
---
 .../ethernet/stmicro/stmmac/dwmac-motorcomm.c | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c
index 42f0b11a7b60..1e142ad39e33 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c
@@ -204,6 +204,27 @@ static int motorcomm_resume(struct device *dev, void *bsp_priv)
 	return 0;
 }
 
+static void motorcomm_shutdown(struct pci_dev *pdev)
+{
+	struct net_device *ndev = dev_get_drvdata(&pdev->dev);
+
+	/*
+	 * A failed resume leaves the netdev detached with NAPI disabled, and
+	 * stmmac_suspend() must not run on it a second time.
+	 */
+	if (!netif_device_present(ndev))
+		return;
+
+	/* Stop the device before reboot, kexec or power-off */
+	stmmac_suspend(&pdev->dev);
+
+	/*
+	 * stmmac_pci_plat_suspend() enables PME if wakeup is enabled for the
+	 * device. Nothing arms the chip to wake the system, so undo that.
+	 */
+	pci_wake_from_d3(pdev, false);
+}
+
 static struct plat_stmmacenet_data *
 motorcomm_default_plat_data(struct pci_dev *pdev)
 {
@@ -374,6 +395,7 @@ static struct pci_driver dwmac_motorcomm_pci_driver = {
 	.id_table = dwmac_motorcomm_pci_id_table,
 	.probe = motorcomm_probe,
 	.remove = motorcomm_remove,
+	.shutdown = motorcomm_shutdown,
 	.driver = {
 		.pm = &stmmac_simple_pm_ops,
 	},
-- 
2.56.1


  reply	other threads:[~2026-11-16  9:18 UTC|newest]

Thread overview: 3+ 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 ` Magnus Leatti [this message]
2026-11-16  9:17 ` [PATCH net-next 2/2] net: stmmac: dwmac-motorcomm: support " 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=20261116091757.1656602-2-magnusleatti@kernelriot.com \
    --to=magnusleatti@kernelriot.com \
    --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=maxime.chevallier@bootlin.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=me@ziyao.cc \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox