Netdev List
 help / color / mirror / Atom feed
From: "Théo Lebrun" <theo.lebrun@bootlin.com>
To: "Nicolai Buchwitz" <nb@tipi-net.de>
Cc: "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>,
	"Conor Dooley" <conor.dooley@microchip.com>,
	"Sergio Prado" <sergio.prado@e-labworks.com>,
	<netdev@vger.kernel.org>, "Dom Cobley" <popcornmix@gmail.com>
Subject: Re: [PATCH net] net: macb: don't disable an IRQ wake that was never enabled
Date: Tue, 24 Nov 2026 11:20:04 +0100	[thread overview]
Message-ID: <DN3D5TEGSJJK.2RDM2BPVIQF1B@bootlin.com> (raw)
In-Reply-To: <36b47d8ba8e6c52ac3ccdeea0f057e06@tipi-net.de>

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


      reply	other threads:[~2026-11-24 10:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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=DN3D5TEGSJJK.2RDM2BPVIQF1B@bootlin.com \
    --to=theo.lebrun@bootlin.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=conor.dooley@microchip.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=nb@tipi-net.de \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=popcornmix@gmail.com \
    --cc=sergio.prado@e-labworks.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