Netdev List
 help / color / mirror / Atom feed
* [PATCH net] net: macb: don't disable an IRQ wake that was never enabled
@ 2026-11-23 15:38 Nicolai Buchwitz
  2026-11-23 17:09 ` Théo Lebrun
  0 siblings, 1 reply; 2+ messages in thread
From: Nicolai Buchwitz @ 2026-11-23 15:38 UTC (permalink / raw)
  To: Théo Lebrun, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni
  Cc: Conor Dooley, Sergio Prado, netdev, Dom Cobley, Nicolai Buchwitz

From: Dom Cobley <popcornmix@gmail.com>

If the irqchip has neither an .irq_set_wake callback nor the
IRQCHIP_SKIP_SET_WAKE flag, enable_irq_wake() returns -ENXIO and
macb_resume() later tries to drop a wake reference it never acquired:

  Unbalanced IRQ 108 wake disable
  WARNING: CPU: 0 PID: 1013 at irq_set_irq_wake+0x168/0x238
  ...
   irq_set_irq_wake+0x168/0x238 (P)
   macb_resume+0x23c/0x4b8
   platform_pm_resume+0x30/0x70

Record whether arming the queue 0 IRQ for wake succeeded, warn on
failure, and only disarm it on resume if it was armed.

Fixes: 3e2a5e153906 ("net: macb: add wake-on-lan support via magic packet")
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
---
Seen on Raspberry Pi 5, where the RP1 irqchip has no wake support.
Tested on a CM5 with WoL enabled and a suspend/resume cycle.
---
 drivers/net/ethernet/cadence/macb.h      |  1 +
 drivers/net/ethernet/cadence/macb_main.c | 12 ++++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
index b7b4b6a38298..bd4f04ac8356 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -1221,6 +1221,7 @@ struct macb_ptp_info {
 struct macb_pm_data {
 	u32 scrt2;
 	u32 usrio;
+	bool irq_wake_enabled;
 };
 
 struct macb_usrio_config {
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 5ad0e32e2b40..f2d29428fa78 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -6517,6 +6517,7 @@ static int __maybe_unused macb_suspend(struct device *dev)
 	unsigned long flags;
 	u32 tmp, ifa_local;
 	unsigned int q;
+	int err;
 
 	if (!device_may_wakeup(&bp->netdev->dev))
 		phy_exit(bp->phy);
@@ -6589,7 +6590,11 @@ static int __maybe_unused macb_suspend(struct device *dev)
 		}
 		spin_unlock_irqrestore(&bp->lock, flags);
 
-		enable_irq_wake(bp->queues[0].irq);
+		err = enable_irq_wake(bp->queues[0].irq);
+		if (err)
+			netdev_warn(netdev, "Unable to enable IRQ %d as a wake source (error %d)\n",
+				    bp->queues[0].irq, err);
+		bp->pm_data.irq_wake_enabled = !err;
 	}
 
 	netif_device_detach(netdev);
@@ -6655,7 +6660,10 @@ static int __maybe_unused macb_resume(struct device *dev)
 		macb_queue_isr_clear(bp, bp->queues, -1);
 		spin_unlock_irqrestore(&bp->lock, flags);
 
-		disable_irq_wake(bp->queues[0].irq);
+		if (bp->pm_data.irq_wake_enabled) {
+			disable_irq_wake(bp->queues[0].irq);
+			bp->pm_data.irq_wake_enabled = false;
+		}
 
 		/* Now make sure we disable phy before moving
 		 * to common restore path

---
base-commit: dd206ec7ed36be3883d08def9eca8faab7a38ee5
change-id: 20261123-nb-macb-irq-wake-net-8e23e4a0be54

Best regards,
--  
Nicolai Buchwitz <nb@tipi-net.de>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-23 17:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 15:38 [PATCH net] net: macb: don't disable an IRQ wake that was never enabled Nicolai Buchwitz
2026-11-23 17:09 ` Théo Lebrun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox