From: ulf.hansson@linaro.org (Ulf Hansson)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 1/9] PM / Domains: Add dev_pm_domain_get|put() APIs
Date: Mon, 13 Oct 2014 16:02:02 +0200 [thread overview]
Message-ID: <1413208930-26019-2-git-send-email-ulf.hansson@linaro.org> (raw)
In-Reply-To: <1413208930-26019-1-git-send-email-ulf.hansson@linaro.org>
There may be more than one device in a PM domain which then will be
probed at different points in time.
Depending on timing and runtime PM support, in for the device related
driver/subsystem, a PM domain may be advised to power off after a
successful probe sequence.
A general requirement for a device within a PM domain, is that the
PM domain must stay powered during the probe sequence. To cope with
such requirement, let's add the dev_pm_domain_get|put() APIs.
These APIs are intended to be invoked from subsystem-level code and the
calls between get/put needs to be balanced.
dev_pm_domain_get(), tells the PM domain that it needs to increase a
usage count and to keep supplying power. dev_pm_domain_put(), does the
opposite.
For a PM domain to support this feature, it must implement the optional
->get|put() callbacks.
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
drivers/base/power/common.c | 40 ++++++++++++++++++++++++++++++++++++++++
include/linux/pm.h | 2 ++
include/linux/pm_domain.h | 4 ++++
3 files changed, 46 insertions(+)
diff --git a/drivers/base/power/common.c b/drivers/base/power/common.c
index b0f1388..b4f0c8c 100644
--- a/drivers/base/power/common.c
+++ b/drivers/base/power/common.c
@@ -134,3 +134,43 @@ 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_get - Increase usage count to keep a PM domain powered.
+ * @domain: The PM domain to operate on.
+ *
+ * This function will not by itself increase the usage count, that's up to each
+ * PM domain implementation to support. Typically it should be invoked from
+ * subsystem level code prior drivers starts probing.
+ *
+ * Do note, it's optional to implement the ->get() callback for a PM domain.
+ *
+ * Returns 0 on successfully increased usage count or negative error code.
+ */
+int dev_pm_domain_get(struct dev_pm_domain *domain)
+{
+ int ret = 0;
+
+ if (domain && domain->get)
+ ret = domain->get(domain);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(dev_pm_domain_get);
+
+/**
+ * dev_pm_domain_put - Decrease usage count to allow a PM domain to power off.
+ * @domain: The PM domain to operate on.
+ *
+ * This function will not by itself decrease the usage count, that's up to each
+ * PM domain implementation to support. Typically it should be invoked from
+ * subsystem level code after drivers has finished probing.
+ *
+ * Do note, it's optional to implement the ->put() callback for a PM domain.
+ */
+void dev_pm_domain_put(struct dev_pm_domain *domain)
+{
+ if (domain && domain->put)
+ domain->put(domain);
+}
+EXPORT_SYMBOL_GPL(dev_pm_domain_put);
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 383fd68..f71900d 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -620,6 +620,8 @@ 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);
+ int (*get)(struct dev_pm_domain *domain);
+ void (*put)(struct dev_pm_domain *domain);
};
/*
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index 73e938b..8e2806f 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -304,12 +304,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);
+extern int dev_pm_domain_get(struct dev_pm_domain *domain);
+extern void dev_pm_domain_put(struct dev_pm_domain *domain);
#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 int dev_pm_domain_get(struct dev_pm_domain *domain) { return 0; }
+static inline void dev_pm_domain_put(struct dev_pm_domain *domain) {}
#endif
#endif /* _LINUX_PM_DOMAIN_H */
--
1.9.1
next prev parent reply other threads:[~2014-10-13 14:02 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-13 14:02 [PATCH v3 0/9] PM / Domains: Fix race conditions during boot Ulf Hansson
2014-10-13 14:02 ` Ulf Hansson [this message]
2014-10-13 14:02 ` [PATCH v3 2/9] PM / Domains: Enable genpd to support ->get|put() callbacks Ulf Hansson
2014-10-13 14:02 ` [PATCH v3 3/9] amba: Keep PM domain powered during ->probe() Ulf Hansson
2014-10-13 14:02 ` [PATCH v3 4/9] drivercore / platform: " Ulf Hansson
2014-10-30 20:47 ` Kevin Hilman
2014-10-31 0:07 ` Dmitry Torokhov
2014-10-31 9:23 ` Ulf Hansson
2014-11-01 0:21 ` Rafael J. Wysocki
2014-10-31 9:19 ` Ulf Hansson
2014-10-13 14:02 ` [PATCH v3 5/9] i2c: core: " Ulf Hansson
2014-10-13 14:02 ` [PATCH v3 6/9] spi: " Ulf Hansson
2014-10-13 14:02 ` [PATCH v3 7/9] mmc: core: Attach PM domain prior probing of SDIO func driver Ulf Hansson
2014-10-13 14:02 ` [PATCH v3 8/9] mmmc: core: Keep PM domain powered during ->probe() " Ulf Hansson
2014-10-13 14:02 ` [PATCH v3 9/9] PM / Domains: Remove pm_genpd_dev_need_restore() API Ulf Hansson
2014-10-24 16:12 ` [PATCH v3 0/9] PM / Domains: Fix race conditions during boot Kevin Hilman
2014-10-24 16:18 ` Mark Brown
2014-10-30 20:46 ` Kevin Hilman
2014-10-30 23:56 ` Mark Brown
2014-10-31 9:16 ` Ulf Hansson
2014-11-01 0:20 ` Rafael J. Wysocki
2014-11-01 1:08 ` pm_runtime_enable() in ->probe() (was: Re: [PATCH v3 0/9] PM / Domains: Fix race conditions during boot) Rafael J. Wysocki
2014-11-01 1:14 ` Rafael J. Wysocki
2014-11-03 17:00 ` pm_runtime_enable() in ->probe() Kevin Hilman
2014-11-03 23:55 ` Rafael J. Wysocki
2014-11-03 14:03 ` [PATCH v3 0/9] PM / Domains: Fix race conditions during boot Ulf Hansson
2014-11-04 1:43 ` Rafael J. Wysocki
2014-11-04 8:20 ` Geert Uytterhoeven
2014-11-04 13:32 ` Rafael J. Wysocki
2014-11-04 8:54 ` Ulf Hansson
2014-11-04 9:05 ` Dmitry Torokhov
2014-11-04 9:24 ` Ulf Hansson
2014-11-04 13:56 ` Rafael J. Wysocki
2014-11-04 17:01 ` Ulf Hansson
2014-11-04 18:29 ` Dmitry Torokhov
2014-11-04 21:38 ` Rafael J. Wysocki
2014-11-05 8:17 ` Ulf Hansson
2014-11-04 13:52 ` Rafael J. Wysocki
2014-11-04 13:51 ` Rafael J. Wysocki
2014-11-04 16:42 ` Ulf Hansson
2014-11-07 17:25 ` Grygorii Strashko
2014-11-11 11:05 ` Ulf Hansson
2014-11-12 18:01 ` Grygorii Strashko
2014-11-13 2:07 ` Rafael J. Wysocki
2014-11-13 20:13 ` Grygorii Strashko
2014-11-13 14:05 ` Pavel Machek
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=1413208930-26019-2-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).