* How to get "wake up reason" for Suspend-to-Idle
@ 2022-08-17 7:08 Kai-Heng Feng
2022-08-17 10:30 ` Mika Westerberg
0 siblings, 1 reply; 5+ messages in thread
From: Kai-Heng Feng @ 2022-08-17 7:08 UTC (permalink / raw)
To: Rafael J. Wysocki; +Cc: Mika Westerberg, Linux PM
We are seeing laptops wake up when Thunderbolt dock gets plugged, or
even wake up on AC plugging.
On Windows these events are logged with "Wakeup Reason", and if the
wakeup event is from unplugging AC, the system will be put to suspend
again.
So I wonder if it's possible to get the "Wakeup Reason" under Linux?
'/sys/power/wakeup_count' seems to be insufficient for this purpose.
Kai-Heng
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to get "wake up reason" for Suspend-to-Idle
2022-08-17 7:08 How to get "wake up reason" for Suspend-to-Idle Kai-Heng Feng
@ 2022-08-17 10:30 ` Mika Westerberg
2022-08-17 12:53 ` Kai-Heng Feng
0 siblings, 1 reply; 5+ messages in thread
From: Mika Westerberg @ 2022-08-17 10:30 UTC (permalink / raw)
To: Kai-Heng Feng; +Cc: Rafael J. Wysocki, Linux PM
Hi,
On Wed, Aug 17, 2022 at 03:08:18PM +0800, Kai-Heng Feng wrote:
> We are seeing laptops wake up when Thunderbolt dock gets plugged, or
> even wake up on AC plugging.
>
> On Windows these events are logged with "Wakeup Reason", and if the
> wakeup event is from unplugging AC, the system will be put to suspend
> again.
>
> So I wonder if it's possible to get the "Wakeup Reason" under Linux?
>
> '/sys/power/wakeup_count' seems to be insufficient for this purpose.
I don't know if there is a way but unfortunately several systems (or
their firmware) are expecting Windows style "dark resume" so they pretty
much wake up each time something gets plugged or even unplugged to these
ports. Linux does not have similar mechanism at the moment but I think
at least if you have lid closed it will eventually go back to s2idle.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to get "wake up reason" for Suspend-to-Idle
2022-08-17 10:30 ` Mika Westerberg
@ 2022-08-17 12:53 ` Kai-Heng Feng
2022-08-17 13:35 ` Mika Westerberg
0 siblings, 1 reply; 5+ messages in thread
From: Kai-Heng Feng @ 2022-08-17 12:53 UTC (permalink / raw)
To: Mika Westerberg; +Cc: Rafael J. Wysocki, Linux PM
On Wed, Aug 17, 2022 at 6:30 PM Mika Westerberg
<mika.westerberg@linux.intel.com> wrote:
>
> Hi,
>
> On Wed, Aug 17, 2022 at 03:08:18PM +0800, Kai-Heng Feng wrote:
> > We are seeing laptops wake up when Thunderbolt dock gets plugged, or
> > even wake up on AC plugging.
> >
> > On Windows these events are logged with "Wakeup Reason", and if the
> > wakeup event is from unplugging AC, the system will be put to suspend
> > again.
> >
> > So I wonder if it's possible to get the "Wakeup Reason" under Linux?
> >
> > '/sys/power/wakeup_count' seems to be insufficient for this purpose.
>
> I don't know if there is a way but unfortunately several systems (or
> their firmware) are expecting Windows style "dark resume" so they pretty
> much wake up each time something gets plugged or even unplugged to these
> ports. Linux does not have similar mechanism at the moment but I think
> at least if you have lid closed it will eventually go back to s2idle.
ChromeOS also developed their own version of dark resume [1], which
checks '/sys/power/wakeup_count' to decide if the system should go
back to suspend again.
However, if there's any spurious wakeup event occurs during s2idle
like [2], checking 'wakeup_count' alone will put the system back to
suspend, and the system will stuck in a wakeup/suspend loop.
So I think it's safer to implement the mechanism in the kernel, by
implementing .suspend_again() callback for s2idle just like what S3
does.
However, to make the right decision on suspend or wakeup we need a
concrete "wakeup reason", but I wonder how do we achieve that?
[1] https://chromium.googlesource.com/chromiumos/platform2/+/HEAD/power_manager/docs/dark_resume.md
[2] https://bugzilla.kernel.org/show_bug.cgi?id=216295
Kai-Heng
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to get "wake up reason" for Suspend-to-Idle
2022-08-17 12:53 ` Kai-Heng Feng
@ 2022-08-17 13:35 ` Mika Westerberg
2022-08-17 14:36 ` Kai-Heng Feng
0 siblings, 1 reply; 5+ messages in thread
From: Mika Westerberg @ 2022-08-17 13:35 UTC (permalink / raw)
To: Kai-Heng Feng; +Cc: Rafael J. Wysocki, Linux PM
On Wed, Aug 17, 2022 at 08:53:00PM +0800, Kai-Heng Feng wrote:
> On Wed, Aug 17, 2022 at 6:30 PM Mika Westerberg
> <mika.westerberg@linux.intel.com> wrote:
> >
> > Hi,
> >
> > On Wed, Aug 17, 2022 at 03:08:18PM +0800, Kai-Heng Feng wrote:
> > > We are seeing laptops wake up when Thunderbolt dock gets plugged, or
> > > even wake up on AC plugging.
> > >
> > > On Windows these events are logged with "Wakeup Reason", and if the
> > > wakeup event is from unplugging AC, the system will be put to suspend
> > > again.
> > >
> > > So I wonder if it's possible to get the "Wakeup Reason" under Linux?
> > >
> > > '/sys/power/wakeup_count' seems to be insufficient for this purpose.
> >
> > I don't know if there is a way but unfortunately several systems (or
> > their firmware) are expecting Windows style "dark resume" so they pretty
> > much wake up each time something gets plugged or even unplugged to these
> > ports. Linux does not have similar mechanism at the moment but I think
> > at least if you have lid closed it will eventually go back to s2idle.
>
> ChromeOS also developed their own version of dark resume [1], which
> checks '/sys/power/wakeup_count' to decide if the system should go
> back to suspend again.
Right.
> However, if there's any spurious wakeup event occurs during s2idle
> like [2], checking 'wakeup_count' alone will put the system back to
> suspend, and the system will stuck in a wakeup/suspend loop.
>
> So I think it's safer to implement the mechanism in the kernel, by
> implementing .suspend_again() callback for s2idle just like what S3
> does.
> However, to make the right decision on suspend or wakeup we need a
> concrete "wakeup reason", but I wonder how do we achieve that?
>
> [1] https://chromium.googlesource.com/chromiumos/platform2/+/HEAD/power_manager/docs/dark_resume.md
> [2] https://bugzilla.kernel.org/show_bug.cgi?id=216295
Do we know why the AER event happens in the first place? I think that's
where we should look first. Perhaps there is something missing int the
Linux AER implementation that causes this?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to get "wake up reason" for Suspend-to-Idle
2022-08-17 13:35 ` Mika Westerberg
@ 2022-08-17 14:36 ` Kai-Heng Feng
0 siblings, 0 replies; 5+ messages in thread
From: Kai-Heng Feng @ 2022-08-17 14:36 UTC (permalink / raw)
To: Mika Westerberg; +Cc: Rafael J. Wysocki, Linux PM
On Wed, Aug 17, 2022 at 9:34 PM Mika Westerberg
<mika.westerberg@linux.intel.com> wrote:
>
> On Wed, Aug 17, 2022 at 08:53:00PM +0800, Kai-Heng Feng wrote:
> > On Wed, Aug 17, 2022 at 6:30 PM Mika Westerberg
> > <mika.westerberg@linux.intel.com> wrote:
> > >
> > > Hi,
> > >
> > > On Wed, Aug 17, 2022 at 03:08:18PM +0800, Kai-Heng Feng wrote:
> > > > We are seeing laptops wake up when Thunderbolt dock gets plugged, or
> > > > even wake up on AC plugging.
> > > >
> > > > On Windows these events are logged with "Wakeup Reason", and if the
> > > > wakeup event is from unplugging AC, the system will be put to suspend
> > > > again.
> > > >
> > > > So I wonder if it's possible to get the "Wakeup Reason" under Linux?
> > > >
> > > > '/sys/power/wakeup_count' seems to be insufficient for this purpose.
> > >
> > > I don't know if there is a way but unfortunately several systems (or
> > > their firmware) are expecting Windows style "dark resume" so they pretty
> > > much wake up each time something gets plugged or even unplugged to these
> > > ports. Linux does not have similar mechanism at the moment but I think
> > > at least if you have lid closed it will eventually go back to s2idle.
> >
> > ChromeOS also developed their own version of dark resume [1], which
> > checks '/sys/power/wakeup_count' to decide if the system should go
> > back to suspend again.
>
> Right.
>
> > However, if there's any spurious wakeup event occurs during s2idle
> > like [2], checking 'wakeup_count' alone will put the system back to
> > suspend, and the system will stuck in a wakeup/suspend loop.
> >
> > So I think it's safer to implement the mechanism in the kernel, by
> > implementing .suspend_again() callback for s2idle just like what S3
> > does.
> > However, to make the right decision on suspend or wakeup we need a
> > concrete "wakeup reason", but I wonder how do we achieve that?
> >
> > [1] https://chromium.googlesource.com/chromiumos/platform2/+/HEAD/power_manager/docs/dark_resume.md
> > [2] https://bugzilla.kernel.org/show_bug.cgi?id=216295
>
> Do we know why the AER event happens in the first place? I think that's
> where we should look first. Perhaps there is something missing int the
> Linux AER implementation that causes this?
The AER happens at Physical Layer as soon as the device hit D3cold, so
I don't know what really happens at such low level.
Here's my proposed solution:
https://lore.kernel.org/linux-pci/20220727013255.269815-1-kai.heng.feng@canonical.com/
Anyway, it's just an example to show why I think it's better to
implement "dark resume" in kernel instead of deferring it to the
userspace.
Kai-Heng
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-08-17 14:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-17 7:08 How to get "wake up reason" for Suspend-to-Idle Kai-Heng Feng
2022-08-17 10:30 ` Mika Westerberg
2022-08-17 12:53 ` Kai-Heng Feng
2022-08-17 13:35 ` Mika Westerberg
2022-08-17 14:36 ` Kai-Heng Feng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox