From: Loic Poulain <loic.poulain@linaro.org>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>,
Linux PM <linux-pm@vger.kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [RESEND PATCH] PM: wakeup: Wakeup accounting for interrupts
Date: Thu, 27 Jan 2022 10:02:58 +0100 [thread overview]
Message-ID: <CAMZdPi-72Yo3z6sM7Do7PxcfqQamXfoEG-9vj4SC=GqZj5-gVg@mail.gmail.com> (raw)
In-Reply-To: <CAJZ5v0hJzZpLv69coibEApT9zOxZ43mmOixNo5TZtizbUCFSTA@mail.gmail.com>
Hi Rafael,
On Wed, 26 Jan 2022 at 19:23, Rafael J. Wysocki <rafael@kernel.org> wrote:
>
> On Mon, Jan 24, 2022 at 10:14 AM Loic Poulain <loic.poulain@linaro.org> wrote:
> >
> > Most of the time, system wakeup is caused by a wakeup-enabled
> > interrupt, but the accounting is not done for the related wakeup
> > source, causing 'wrong' values reported by device's wakeup attributes
> > and debugfs stats (debug/wakeup_sources).
> >
> > This change reports a wakeup event for any wakeup-sources the irq is
> > attached with.
> >
> > Note: This only works for drivers explicitly attaching the irq to
> > a given device (e.g. with dev_pm_set_wake_irq).
> >
> > Note2: Some drivers call pm_wakeup_event() in their irq handler, but
> > not all, moreover, an interrupt can be disabled while being flagged
> > as wakeup source, and so accounting must be performed. This solution
> > ensures that accounting will always be done for the interrupt waking
> > up the host.
> >
> > Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
> > ---
> > drivers/base/power/wakeup.c | 11 +++++++++++
> > 1 file changed, 11 insertions(+)
> >
> > diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
> > index 99bda0da..2d75e057 100644
> > --- a/drivers/base/power/wakeup.c
> > +++ b/drivers/base/power/wakeup.c
> > @@ -952,8 +952,19 @@ void pm_wakeup_clear(bool reset)
> > void pm_system_irq_wakeup(unsigned int irq_number)
> > {
> > if (pm_wakeup_irq == 0) {
> > + struct wakeup_source *ws;
> > + int srcuidx;
> > +
> > pm_wakeup_irq = irq_number;
> > pm_system_wakeup();
> > +
> > + /* wakeup accounting */
> > + srcuidx = srcu_read_lock(&wakeup_srcu);
>
> This is called from interrupt context, so srcu_read_lock() cannot be used here.
AFAIU from srcu.h, it is not prohibited, right? and we are not
blocking while locked here.
Regards,
Loic
>
>
> > + list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
> > + if (ws->wakeirq && ws->wakeirq->irq == irq_number)
> > + pm_wakeup_ws_event(ws, 0, false);
> > + }
> > + srcu_read_unlock(&wakeup_srcu, srcuidx);
> > }
> > }
> >
> > --
> > 2.7.4
> >
next prev parent reply other threads:[~2022-01-27 8:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-24 9:26 [RESEND PATCH] PM: wakeup: Wakeup accounting for interrupts Loic Poulain
2022-01-26 18:22 ` Rafael J. Wysocki
2022-01-27 9:02 ` Loic Poulain [this message]
2022-01-27 19:04 ` Rafael J. Wysocki
2022-01-28 10:08 ` Loic Poulain
2022-02-16 16:59 ` Rafael J. Wysocki
2022-02-16 17:48 ` Loic Poulain
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='CAMZdPi-72Yo3z6sM7Do7PxcfqQamXfoEG-9vj4SC=GqZj5-gVg@mail.gmail.com' \
--to=loic.poulain@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=len.brown@intel.com \
--cc=linux-pm@vger.kernel.org \
--cc=pavel@ucw.cz \
--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;
as well as URLs for NNTP newsgroup(s).