From: Russell King <rmk+kernel@arm.linux.org.uk>
To: Andrew Lunn <andrew@lunn.ch>, Jason Cooper <jason@lakedaemon.net>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Len Brown <len.brown@intel.com>,
linux-pm@vger.kernel.org
Subject: [PATCH 3/9] pm: domains: sync runtime PM status with PM domains after probe
Date: Thu, 12 Mar 2015 18:31:05 +0000 [thread overview]
Message-ID: <E1YW7sv-0003mA-JP@rmk-PC.arm.linux.org.uk> (raw)
In-Reply-To: <20150312183020.GU8656@n2100.arm.linux.org.uk>
Synchronise the PM domain status with runtime PM's status after a
platform device has been probed. This augments the solution in commit
2ed127697eb1 ("PM / Domains: Power on the PM domain right after attach
completes").
The above commit added a call to power up the PM domain when a device
attaches to the domain in order to match the behaviour required by
drivers that make no use of runtime PM. The assumption is that the
device driver will cause a runtime PM transition, which will synchronise
the PM domain state with the runtime PM state.
However, by default, runtime PM will assume that the device is initially
suspended, and some drivers may make use of this should they not need to
touch the hardware during probe.
In order to allow such drivers, trigger the PM domain code to check
whether the PM domain can be suspended after the probe function, undoing
the effect of the power-on prior to the probe.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
drivers/base/platform.c | 2 ++
drivers/base/power/common.c | 15 +++++++++++++++
drivers/base/power/domain.c | 23 +++++++++++++++++++++++
include/linux/pm.h | 1 +
include/linux/pm_domain.h | 4 ++++
5 files changed, 45 insertions(+)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 9421fed40905..552d1affc060 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -512,6 +512,8 @@ static int platform_drv_probe(struct device *_dev)
ret = drv->probe(dev);
if (ret)
dev_pm_domain_detach(_dev, true);
+ else
+ dev_pm_domain_sync(_dev);
}
if (drv->prevent_deferred_probe && ret == -EPROBE_DEFER) {
diff --git a/drivers/base/power/common.c b/drivers/base/power/common.c
index b0f138806bbc..8c739a14d3c7 100644
--- a/drivers/base/power/common.c
+++ b/drivers/base/power/common.c
@@ -134,3 +134,18 @@ void dev_pm_domain_detach(struct device *dev, bool power_off)
dev->pm_domain->detach(dev, power_off);
}
EXPORT_SYMBOL_GPL(dev_pm_domain_detach);
+
+/**
+ * dev_pm_domain_sync - synchronise the PM domain state with its devices
+ * @dev: device corresponding with domain
+ *
+ * Synchronise the PM domain state with the recently probed device, which
+ * may be in a variety of PM states. This ensures that a device which
+ * enables runtime PM in suspended state, and never transitions to active
+ * in its probe handler is properly suspended after the probe.
+ */
+void dev_pm_domain_sync(struct device *dev)
+{
+ if (dev->pm_domain && dev->pm_domain->sync)
+ dev->pm_domain->sync(dev);
+}
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 11a1023fa64a..13ae3355dff7 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -2157,6 +2157,28 @@ static void genpd_dev_pm_detach(struct device *dev, bool power_off)
genpd_queue_power_off_work(pd);
}
+static void genpd_dev_pm_sync(struct device *dev)
+{
+ struct generic_pm_domain *pd = NULL, *gpd;
+
+ if (!dev->pm_domain)
+ return;
+
+ mutex_lock(&gpd_list_lock);
+ list_for_each_entry(gpd, &gpd_list, gpd_list_node) {
+ if (&gpd->domain == dev->pm_domain) {
+ pd = gpd;
+ break;
+ }
+ }
+ mutex_unlock(&gpd_list_lock);
+
+ if (!pd)
+ return;
+
+ genpd_queue_power_off_work(pd);
+}
+
/**
* genpd_dev_pm_attach - Attach a device to its PM domain using DT.
* @dev: Device to attach.
@@ -2223,6 +2245,7 @@ int genpd_dev_pm_attach(struct device *dev)
}
dev->pm_domain->detach = genpd_dev_pm_detach;
+ dev->pm_domain->sync = genpd_dev_pm_sync;
pm_genpd_poweron(pd);
return 0;
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 8b5976364619..676ca4055239 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -607,6 +607,7 @@ extern int dev_pm_put_subsys_data(struct device *dev);
struct dev_pm_domain {
struct dev_pm_ops ops;
void (*detach)(struct device *dev, bool power_off);
+ void (*sync)(struct device *dev);
};
/*
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index a9edab2c787a..8d58b30e23ac 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -319,12 +319,16 @@ static inline int of_genpd_add_provider_onecell(struct device_node *np,
#ifdef CONFIG_PM
extern int dev_pm_domain_attach(struct device *dev, bool power_on);
extern void dev_pm_domain_detach(struct device *dev, bool power_off);
+void dev_pm_domain_sync(struct device *dev);
#else
static inline int dev_pm_domain_attach(struct device *dev, bool power_on)
{
return -ENODEV;
}
static inline void dev_pm_domain_detach(struct device *dev, bool power_off) {}
+static inline void dev_pm_domain_sync(struct device *dev)
+{
+}
#endif
#endif /* _LINUX_PM_DOMAIN_H */
--
1.8.3.1
next prev parent reply other threads:[~2015-03-12 18:31 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-12 18:30 [FOR DISCUSSION 0/9] Dove PMU support Russell King - ARM Linux
2015-03-12 18:30 ` [PATCH 1/9] pm: domains: quieten down generic pm domains Russell King
2015-03-13 8:46 ` Ulf Hansson
2015-03-13 15:57 ` Kevin Hilman
2015-03-12 18:31 ` [PATCH 2/9] pm: domains: avoid potential oops in pm_genpd_remove_device() Russell King
2015-03-13 8:56 ` Ulf Hansson
2015-03-13 9:20 ` Russell King - ARM Linux
2015-03-13 12:45 ` Geert Uytterhoeven
2015-03-14 1:27 ` Rafael J. Wysocki
2015-03-13 13:23 ` Russell King - ARM Linux
2015-03-13 16:33 ` Kevin Hilman
2015-03-13 16:58 ` Russell King - ARM Linux
2015-03-12 18:31 ` Russell King [this message]
2015-03-12 23:25 ` [PATCH 3/9] pm: domains: sync runtime PM status with PM domains after probe Rafael J. Wysocki
2015-03-13 9:30 ` Ulf Hansson
2015-03-13 10:14 ` Russell King - ARM Linux
2015-03-13 10:42 ` Ulf Hansson
2015-03-13 13:39 ` Russell King - ARM Linux
2015-03-13 16:45 ` Kevin Hilman
[not found] ` <20150312183020.GU8656-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2015-03-13 11:57 ` [FOR DISCUSSION 0/9] Dove PMU support Arnd Bergmann
2015-03-13 12:11 ` Russell King - ARM Linux
2015-03-13 12:26 ` Arnd Bergmann
2015-03-13 12:32 ` Russell King - ARM Linux
2015-03-13 12:47 ` Arnd Bergmann
2015-03-13 16:23 ` [PATCH 04/10] pm: domains: sync runtime PM status with PM domains after probe Russell King
[not found] ` <E1YWSN5-0006G5-Ld-eh5Bv4kxaXIANfyc6IWni62ZND6+EDdj@public.gmane.org>
2015-03-13 17:33 ` Kevin Hilman
2015-03-13 16:22 ` [FOR DISCUSSION 0/10] Dove PMU support Russell King - ARM Linux
2015-03-13 16:23 ` [PATCH 01/10] pm: domains: quieten down generic pm domains Russell King
2015-03-13 17:10 ` Kevin Hilman
2015-03-13 16:23 ` [PATCH 02/10] pm: domains: factor out code to get the generic PM domain from a struct device Russell King
2015-03-13 17:20 ` Kevin Hilman
2015-03-13 17:35 ` Russell King - ARM Linux
2015-03-13 16:23 ` [PATCH 03/10] pm: domains: avoid potential oops in pm_genpd_remove_device() Russell King
2015-03-13 17:28 ` Kevin Hilman
2015-03-19 21:59 ` [FOR DISCUSSION 0/9] Dove PMU support Rafael J. Wysocki
2015-03-19 22:02 ` Rafael J. Wysocki
2015-03-20 12:16 ` Russell King - ARM Linux
2015-03-20 12:44 ` Rafael J. Wysocki
2015-03-20 17:19 ` Russell King - ARM Linux
2015-03-20 17:20 ` [PATCH 1/3] pm: domains: quieten down generic pm domains Russell King
2015-03-20 17:20 ` [PATCH 2/3] pm: domains: factor out code to get the generic PM domain from a struct device Russell King
2015-03-23 13:28 ` Ulf Hansson
2015-03-23 15:17 ` Russell King - ARM Linux
2015-03-24 0:29 ` Rafael J. Wysocki
2015-03-26 15:20 ` Russell King - ARM Linux
2015-03-26 16:00 ` Russell King - ARM Linux
2015-03-20 17:20 ` [PATCH 3/3] pm: domains: avoid potential oops in pm_genpd_remove_device() Russell King
2015-03-23 13:32 ` 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=E1YW7sv-0003mA-JP@rmk-PC.arm.linux.org.uk \
--to=rmk+kernel@arm.linux.org.uk \
--cc=andrew@lunn.ch \
--cc=gregkh@linuxfoundation.org \
--cc=jason@lakedaemon.net \
--cc=len.brown@intel.com \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=sebastian.hesselbarth@gmail.com \
/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).