From: ulf.hansson@linaro.org (Ulf Hansson)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] PM / Runtime: Defer resuming of the device in pm_runtime_force_resume()
Date: Thu, 21 Apr 2016 12:34:02 +0200 [thread overview]
Message-ID: <1461234842-22820-1-git-send-email-ulf.hansson@linaro.org> (raw)
When the pm_runtime_force_suspend|resume() helpers were invented, we still
had CONFIG_PM_RUNTIME and CONFIG_PM_SLEEP as separate Kconfig options.
To make sure these helpers worked for all combinations and without
introducing too much of complexity, the device was always resumed in
pm_runtime_force_resume().
More precisely, when CONFIG_PM_SLEEP was set and CONFIG_PM_RUNTIME was
unset, we needed to resume the device as the subsystem/driver couldn't
rely on using runtime PM to do it.
As the CONFIG_PM_RUNTIME option was merged into CONFIG_PM a while ago, it
removed this combination, of using CONFIG_PM_SLEEP without the earlier
CONFIG_PM_RUNTIME.
For this reason we can now rely on the subsystem/driver to use runtime PM
to resume the device, instead of forcing that to be done in all cases. In
other words, let's defer this to a later point when it's actually needed.
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
Note, this patch is based upon another not yet queued patch [1]. The reason is
simply because that [1] is a more important patch as it fixes a problem. It was
posted to linux-pm April 8th and I expect it (or a new revision of it) to be
applied before $subject patch.
[1]
https://patchwork.kernel.org/patch/8782851
---
drivers/base/power/runtime.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index b746904..a190ca0 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -1506,6 +1506,17 @@ int pm_runtime_force_resume(struct device *dev)
goto out;
}
+ /*
+ * The PM core increases the runtime PM usage count in the system PM
+ * prepare phase. If the count is greather than 1 at this point, someone
+ * else has also increased it. In such case, let's make sure to runtime
+ * resume the device as that is likely what is expected. In other case
+ * we trust the subsystem/driver to runtime resume the device when it's
+ * actually needed.
+ */
+ if (atomic_read(&dev->power.usage_count) < 2)
+ goto out;
+
ret = pm_runtime_set_active(dev);
if (ret)
goto out;
--
1.9.1
next reply other threads:[~2016-04-21 10:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-21 10:34 Ulf Hansson [this message]
2016-04-21 17:31 ` [PATCH] PM / Runtime: Defer resuming of the device in pm_runtime_force_resume() Laurent Pinchart
2016-04-21 20:57 ` Laurent Pinchart
2016-04-22 20:27 ` Kevin Hilman
2016-04-25 8:15 ` Ulf Hansson
2016-04-25 13:32 ` Ulf Hansson
2016-04-25 16:52 ` Laurent Pinchart
2016-04-27 14:23 ` Ulf Hansson
2016-05-12 19:01 ` Laurent Pinchart
2016-05-12 20:28 ` Rafael J. Wysocki
2016-05-13 13:59 ` Ulf Hansson
2016-04-21 19:23 ` Rafael J. Wysocki
2016-04-22 6:58 ` Ulf Hansson
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=1461234842-22820-1-git-send-email-ulf.hansson@linaro.org \
--to=ulf.hansson@linaro.org \
--cc=linux-arm-kernel@lists.infradead.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).