* [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; 4+ 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] 4+ messages in thread* Re: [PATCH net] net: macb: don't disable an IRQ wake that was never enabled 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 2026-11-24 6:12 ` Nicolai Buchwitz 0 siblings, 1 reply; 4+ messages in thread From: Théo Lebrun @ 2026-11-23 17:09 UTC (permalink / raw) To: Nicolai Buchwitz, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni Cc: Conor Dooley, Sergio Prado, netdev, Dom Cobley Hello Nicolai & Dom, On Mon Nov 23, 2026 at 4:38 PM CET, Nicolai Buchwitz wrote: > @@ -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; > } Your error handling is surprising to me: if we get asked to be a wakeup source and fail doing so, we should refuse and error out. This will in turn abort the system-wide suspend. The risk is that we might be the only wakeup source. We'd sleep for a really long time. What's the behavior on the platform you noticed the issue? I can think of two reasons that still make it work: - you have another wakeup source or - some other interrupt (PCI related) is your wakeup path. In my mind, we should instead propagate the enable_irq_wake() error in macb_suspend(). To go even further, we could move the enable_irq_wake() into macb_set_wol() to report early to userspace that WoL isn't supported. Lastly, if this is indeed a PCI related topic, then we need to special-case the enable_irq_wake() call. From my LLM report, many PCI MAC drivers only call device_set_wakeup_enable() at the set_wol request. Then everything is handled at the bus level at suspend: a pci_enable_wake() call made if the device is on the wakeup path. What do you think? Thanks, -- Théo Lebrun, Bootlin Embedded Linux and Kernel engineering https://bootlin.com ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: macb: don't disable an IRQ wake that was never enabled 2026-11-23 17:09 ` Théo Lebrun @ 2026-11-24 6:12 ` Nicolai Buchwitz 2026-11-24 10:20 ` Théo Lebrun 0 siblings, 1 reply; 4+ messages in thread From: Nicolai Buchwitz @ 2026-11-24 6:12 UTC (permalink / raw) To: Théo Lebrun Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Conor Dooley, Sergio Prado, netdev, Dom Cobley Hi Théo On 23.11.2026 18:09, Théo Lebrun wrote: > Hello Nicolai & Dom, > > On Mon Nov 23, 2026 at 4:38 PM CET, Nicolai Buchwitz wrote: >> @@ -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; >> } > > Your error handling is surprising to me: if we get asked to be a wakeup > source and fail doing so, we should refuse and error out. This will in > turn abort the system-wide suspend. > > The risk is that we might be the only wakeup source. We'd sleep for a > really long time. Agreed. This also would match the WAKE_ARP check, which already aborts suspend. We could arm the IRQ before touching the hardware and return the error, so the flag goes away too? > > What's the behavior on the platform you noticed the issue? I can think > of two reasons that still make it work: > - you have another wakeup source or Yes, the bootloader / rtc alarm / power button. The GIC is off as it is on rp1 too, which is in reset I guess. This makes WoL IMHO impoissible. > - some other interrupt (PCI related) is your wakeup path. > > In my mind, we should instead propagate the enable_irq_wake() error in > macb_suspend(). > > To go even further, we could move the enable_irq_wake() into > macb_set_wol() to report early to userspace that WoL isn't supported. There is another downstream patch I plan to upstream, which sets MACB_CAPS_NO_WOL for rp1. As this in kinda feature I planned for net-next and just fix the bug in net > > Lastly, if this is indeed a PCI related topic, then we need to > special-case the enable_irq_wake() call. From my LLM report, many PCI > MAC drivers only call device_set_wakeup_enable() at the set_wol > request. Then everything is handled at the bus level at suspend: a > pci_enable_wake() call made if the device is on the wakeup path. macb is a platform device behind rp1, which is a mfd. PCIe is down in S3 anyway? > [...] Thanks, Nicolai ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: macb: don't disable an IRQ wake that was never enabled 2026-11-24 6:12 ` Nicolai Buchwitz @ 2026-11-24 10:20 ` Théo Lebrun 0 siblings, 0 replies; 4+ messages in thread From: Théo Lebrun @ 2026-11-24 10:20 UTC (permalink / raw) To: Nicolai Buchwitz Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Conor Dooley, Sergio Prado, netdev, Dom Cobley On Tue Nov 24, 2026 at 7:12 AM CET, Nicolai Buchwitz wrote: > On 23.11.2026 18:09, Théo Lebrun wrote: >> On Mon Nov 23, 2026 at 4:38 PM CET, Nicolai Buchwitz wrote: >>> @@ -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; >>> } >> >> Your error handling is surprising to me: if we get asked to be a wakeup >> source and fail doing so, we should refuse and error out. This will in >> turn abort the system-wide suspend. >> >> The risk is that we might be the only wakeup source. We'd sleep for a >> really long time. > > Agreed. This also would match the WAKE_ARP check, which already aborts > suspend. We could arm the IRQ before touching the hardware and return > the > error, so the flag goes away too? About the irq_wake_enabled flag: yes it can go away. But for the error handling, I still prefer my suggestion that was later in the previous email, of moving enable_irq_wake() into macb_set_wol(). - One less error path in our suspend callback. - Signaling early to userspace that WoL isn't doable. >> What's the behavior on the platform you noticed the issue? I can think >> of two reasons that still make it work: >> - you have another wakeup source or > > Yes, the bootloader / rtc alarm / power button. The GIC is off as it is > on > rp1 too, which is in reset I guess. This makes WoL IMHO impoissible. It all depends on your platform and kernel! There are so many types of suspend and the one you do is dependent on your hardware design and your software implementation. Nothing prevents you from doing WoL on PCI MACs. - For proper suspend-to-RAM (S2R) you want your full SoC to be off, meaning your wakeup source must be signaling directly to the PMIC. - Otherwise you are stuck in a compromise of keeping your SoC partially active so that it can route the signal to the PMIC. That can still be labeled as S2R. - For suspend-to-idle (s2idle), you could have a setup where both the SoC and RP1 are still active, but PCI link is down. But again this needs to be hardware designed: wakeup signal routed so that the PCI link can go down, and an endpoint that has its power supply separate to the PCI link. - Or lastly you can do s2idle with the PCI link still runing. Here not many things are suspended (but it is also the fastest to resume). At this point you are pretty close to cpuidle, but with most peripherals disabled (if drivers implement it). I kind of have been carried away; I know a guy who gave some talks about suspend if you want to hear even more about it. Part 1 (suspend, runtime PM, their interactions) Video: https://www.youtube.com/watch?v=_jb6U40ZCZk Slides: https://bootlin.com/pub/conferences/2024/eosseu/lebrun-pm/lebrun-pm.pdf Part 2 ("how to reason about PM", RPM advanced features, power domains, PM QoS) Video: https://www.youtube.com/watch?v=G0Ji-XKRzUg Slides: https://bootlin.com/pub/conferences/2025/elce/tleb-pm2.pdf >> - some other interrupt (PCI related) is your wakeup path. >> >> In my mind, we should instead propagate the enable_irq_wake() error in >> macb_suspend(). >> >> To go even further, we could move the enable_irq_wake() into >> macb_set_wol() to report early to userspace that WoL isn't supported. > > There is another downstream patch I plan to upstream, which sets > MACB_CAPS_NO_WOL > for rp1. As this in kinda feature I planned for net-next and just fix > the bug in net Can we rely on enable_irq_wake() to fail at set_wol request? That is one less capability flag to worry about. >> Lastly, if this is indeed a PCI related topic, then we need to >> special-case the enable_irq_wake() call. From my LLM report, many PCI >> MAC drivers only call device_set_wakeup_enable() at the set_wol >> request. Then everything is handled at the bus level at suspend: a >> pci_enable_wake() call made if the device is on the wakeup path. > > macb is a platform device behind rp1, which is a mfd. PCIe is down in S3 > anyway? See above. :-) It probably is on the downstream (#7514) as that is by far the simplest option, but it isn't the only one. Thanks, -- Théo Lebrun, Bootlin Embedded Linux and Kernel engineering https://bootlin.com ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-24 10:20 UTC | newest] Thread overview: 4+ 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 2026-11-24 6:12 ` Nicolai Buchwitz 2026-11-24 10:20 ` 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