public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Kai-Heng Feng <kai.heng.feng@canonical.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	Linux PM <linux-pm@vger.kernel.org>
Subject: Re: How to get "wake up reason" for Suspend-to-Idle
Date: Wed, 17 Aug 2022 16:35:00 +0300	[thread overview]
Message-ID: <YvzuhPmTtn74iruB@black.fi.intel.com> (raw)
In-Reply-To: <CAAd53p7HDYz9b9rG236g4MVHAzksOKEOcDZW+MHYi4MoAbO99w@mail.gmail.com>

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?

  reply	other threads:[~2022-08-17 13:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2022-08-17 14:36       ` Kai-Heng Feng

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=YvzuhPmTtn74iruB@black.fi.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=kai.heng.feng@canonical.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    /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