From: Adrian Hunter <adrian.hunter@intel.com>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
Linux PM <linux-pm@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Tushar Nimkar <quic_tnimkar@quicinc.com>,
Adrian Hunter <adrian.hunter@intel.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Nitin Rawat <quic_nitirawa@quicinc.com>,
Peter Wang <peter.wang@mediatek.com>,
Alan Stern <stern@rowland.harvard.edu>,
Ulf Hansson <ulf.hansson@linaro.org>
Subject: Re: [PATCH v1 1/2] PM: runtime: Do not call __rpm_callback() from rpm_idle()
Date: Mon, 5 Dec 2022 09:45:06 +0200 [thread overview]
Message-ID: <cea65857-071f-e68e-9825-b88d64eeca81@intel.com> (raw)
In-Reply-To: <4789678.31r3eYUQgx@kreacher>
On 2/12/22 16:30, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Calling __rpm_callback() from rpm_idle() after adding device links
> support to the former is a clear mistake.
>
> Not only it causes rpm_idle() to carry out unnecessary actions, but it
> is also against the assumption regarding the stability of PM-runtime
> status accross __rpm_callback() invocations, because rpm_suspend() and
accross -> across
> rpm_resume() may run in parallel with __rpm_callback() when it is called
> by rpm_idle() and the device's PM-runtime status can be updated by any
> of them.
>
> Fixes: 21d5c57b3726 ("PM / runtime: Use device links")
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> drivers/base/power/runtime.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> Index: linux-pm/drivers/base/power/runtime.c
> ===================================================================
> --- linux-pm.orig/drivers/base/power/runtime.c
> +++ linux-pm/drivers/base/power/runtime.c
> @@ -484,7 +484,17 @@ static int rpm_idle(struct device *dev,
>
> dev->power.idle_notification = true;
>
> - retval = __rpm_callback(callback, dev);
> + if (dev->power.irq_safe)
> + spin_unlock(&dev->power.lock);
> + else
> + spin_unlock_irq(&dev->power.lock);
> +
> + retval = callback(dev);
> +
> + if (dev->power.irq_safe)
> + spin_lock(&dev->power.lock);
> + else
> + spin_lock_irq(&dev->power.lock);
>
> dev->power.idle_notification = false;
> wake_up_all(&dev->power.wait_queue);
>
>
>
next prev parent reply other threads:[~2022-12-05 7:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-02 14:28 [PATCH v1 0/2] PM: runtime: Fix rpm_idle() and relocate rpm_callback() Rafael J. Wysocki
2022-12-02 14:30 ` [PATCH v1 1/2] PM: runtime: Do not call __rpm_callback() from rpm_idle() Rafael J. Wysocki
2022-12-05 7:45 ` Adrian Hunter [this message]
2022-12-05 14:45 ` Rafael J. Wysocki
2022-12-05 12:07 ` Ulf Hansson
2022-12-05 12:13 ` Rafael J. Wysocki
2022-12-05 12:46 ` Ulf Hansson
2022-12-05 12:51 ` Rafael J. Wysocki
2022-12-02 14:32 ` [PATCH v1 2/2] PM: runtime: Relocate rpm_callback() right after __rpm_callback() Rafael J. Wysocki
2022-12-05 8:13 ` Adrian Hunter
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=cea65857-071f-e68e-9825-b88d64eeca81@intel.com \
--to=adrian.hunter@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=peter.wang@mediatek.com \
--cc=quic_nitirawa@quicinc.com \
--cc=quic_tnimkar@quicinc.com \
--cc=rafael@kernel.org \
--cc=rjw@rjwysocki.net \
--cc=stern@rowland.harvard.edu \
--cc=ulf.hansson@linaro.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