Re: [PATCH net-next 1/2] net: stmmac: dwmac-motorcomm: quiesce the device at shutdown

From
Yao Zi <me@ziyao.cc>
Date
2026-11-16 14:34:27
Also in
linux-arm-kernel, lkml
Reply to
Magnus Leatti, 2026-11-16
On Mon, Nov 16, 2026 at 06:17:56AM -0300, Magnus Leatti wrote:
quoted hunk ↗ jump to hunk
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 <redacted>
---
 .../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);
I think this is abusing the API, and all the other changes in this patch
are working around its side effects. So here's my NAK.

We do want to fix the problem though to ensure the device is stopped
upon shutdown, especially iirc, many YT6801 NICs in addon card form are
totally supplied by 3v3aux, thus S5 alone won't reset the NIC reliably.
But this should be done in a cleaner way.
quoted hunk ↗ jump to hunk
+	/*
+	 * 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
-- 
Thanks,
Yao Zi

Meow-mrrp-mrow, I'm a cat.
Thread (15 messages) 15 messages, 5 authors, last reply 1d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help