From: xiechao_linux@163.com (Chao)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/9] PM / Domains: Enable genpd to support ->get|put() callbacks
Date: Mon, 16 Mar 2015 10:11:24 +0800 (CST) [thread overview]
Message-ID: <1158a1f5.a8f5.14c205997e0.Coremail.xiechao_linux@163.com> (raw)
In-Reply-To: <1426261429-31883-3-git-send-email-ulf.hansson@linaro.org>
At 2015-03-13 23:43:42, "Ulf Hansson" <ulf.hansson@linaro.org> wrote:
>To provide users control over whether the power should be maintained,
>implement the ->get|put() callbacks for genpd's PM domain.
>
>A usage count variable keeps track of the number of users. A positive
>value tells genpd to keep supplying power and also to power up if it's
>the first user.
>
>Once the usage count reaches zero, genpd tries to power off its PM
>domain.
>
>Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
>---
> drivers/base/power/domain.c | 26 +++++++++++++++++++++++++-
> include/linux/pm_domain.h | 1 +
> 2 files changed, 26 insertions(+), 1 deletion(-)
>
>diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
>index 45937f8..7314459 100644
>--- a/drivers/base/power/domain.c
>+++ b/drivers/base/power/domain.c
>@@ -495,10 +495,12 @@ static int pm_genpd_poweroff(struct generic_pm_domain *genpd)
> * (2) The domain is waiting for its master to power up.
> * (3) One of the domain's devices is being resumed right now.
> * (4) System suspend is in progress.
>+ * (5) The usage_count > 0, since it tells us to stay powered.
> */
> if (genpd->status == GPD_STATE_POWER_OFF
> || genpd->status == GPD_STATE_WAIT_MASTER
>- || genpd->resume_count > 0 || genpd->prepared_count > 0)
>+ || genpd->resume_count > 0 || genpd->prepared_count > 0
>+ || atomic_read(&genpd->usage_count) > 0)
> return 0;
>
> if (atomic_read(&genpd->sd_count) > 0)
>@@ -1377,6 +1379,25 @@ EXPORT_SYMBOL_GPL(pm_genpd_syscore_poweron);
>
> #endif /* CONFIG_PM_SLEEP */
>
>+static int genpd_get(struct dev_pm_domain *domain)
>+{
>+ struct generic_pm_domain *genpd = pd_to_genpd(domain);
>+
>+ atomic_inc(&genpd->usage_count);
>+
>+ return pm_genpd_poweron(genpd);
>+}
>+
>+static void genpd_put(struct dev_pm_domain *domain)
>+{
>+ struct generic_pm_domain *genpd = pd_to_genpd(domain);
>+
>+ if (!atomic_dec_and_test(&genpd->usage_count))
>+ return;
>+
>+ genpd_queue_power_off_work(genpd);
>+}
>+
> static struct generic_pm_domain_data *genpd_alloc_dev_data(struct device *dev,
> struct generic_pm_domain *genpd,
> struct gpd_timing_data *td)
>@@ -1874,10 +1895,13 @@ void pm_genpd_init(struct generic_pm_domain *genpd,
> genpd->status = is_off ? GPD_STATE_POWER_OFF : GPD_STATE_ACTIVE;
> init_waitqueue_head(&genpd->status_wait_queue);
> genpd->poweroff_task = NULL;
>+ atomic_set(&genpd->usage_count, 0);
> genpd->resume_count = 0;
> genpd->device_count = 0;
> genpd->max_off_time_ns = -1;
> genpd->max_off_time_changed = true;
>+ genpd->domain.get = genpd_get;
>+ genpd->domain.put = genpd_put;
What is the difference that call pm_runtime_get/put when probe device?
When the device is attached to the power domain.
We can still use pm_runtime_get/put to power on/shutdown the power domain and make the device probed correctly with power domain on.
>--
>1.9.1
>
>
>_______________________________________________
>linux-arm-kernel mailing list
>linux-arm-kernel at lists.infradead.org
>http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2015-03-16 2:11 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-13 15:43 [PATCH 0/9] PM / Domains: Don't leave unused PM domains powered after ->probe() Ulf Hansson
2015-03-13 15:43 ` [PATCH 1/9] PM / Domains: Add dev_pm_domain_get|put() APIs Ulf Hansson
2015-03-14 1:31 ` Rafael J. Wysocki
2015-03-16 9:26 ` Ulf Hansson
2015-03-17 3:01 ` Rafael J. Wysocki
2015-03-17 9:27 ` Ulf Hansson
2015-03-17 14:45 ` Rafael J. Wysocki
2015-03-17 14:25 ` Russell King - ARM Linux
2015-03-18 1:16 ` Rafael J. Wysocki
2015-03-17 14:40 ` Ulf Hansson
2015-03-18 1:09 ` Rafael J. Wysocki
2015-03-18 13:41 ` Ulf Hansson
2015-03-18 15:02 ` [PATCH] driver core / PM: Add callbacks for PM domain initialization/cleanup Rafael J. Wysocki
2015-03-19 8:49 ` Ulf Hansson
2015-03-19 11:45 ` Rafael J. Wysocki
2015-03-19 13:16 ` Ulf Hansson
2015-03-19 13:29 ` Greg Kroah-Hartman
2015-03-19 14:21 ` Rafael J. Wysocki
2015-03-19 14:12 ` Greg Kroah-Hartman
2015-03-19 15:24 ` Rafael J. Wysocki
2015-03-19 14:20 ` Alan Stern
2015-03-19 14:45 ` Ulf Hansson
2015-03-19 15:44 ` Rafael J. Wysocki
2015-03-19 15:37 ` Ulf Hansson
2015-03-19 16:04 ` Rafael J. Wysocki
2015-03-19 15:48 ` Ulf Hansson
2015-03-19 16:18 ` Rafael J. Wysocki
2015-03-19 16:58 ` [PATCH] driver core / PM: Add PM domain callbacks for device setup/cleanup Rafael J. Wysocki
2015-03-19 21:51 ` [PATCH v2] " Rafael J. Wysocki
2015-03-19 22:42 ` Dmitry Torokhov
2015-03-20 0:43 ` Rafael J. Wysocki
2015-03-20 0:43 ` Dmitry Torokhov
2015-03-20 7:45 ` Ulf Hansson
2015-03-20 11:37 ` Ulf Hansson
2015-03-20 12:31 ` Rafael J. Wysocki
2015-03-20 12:57 ` [PATCH v3] " Rafael J. Wysocki
2015-03-20 12:59 ` Rafael J. Wysocki
2015-03-20 13:44 ` Ulf Hansson
2015-03-21 0:09 ` Kevin Hilman
2015-03-21 1:00 ` Rafael J. Wysocki
2015-03-22 11:46 ` Greg Kroah-Hartman
2015-03-19 14:46 ` [PATCH] driver core / PM: Add callbacks for PM domain initialization/cleanup Geert Uytterhoeven
2015-03-18 15:09 ` [PATCH 1/9] PM / Domains: Add dev_pm_domain_get|put() APIs Rafael J. Wysocki
2015-03-13 15:43 ` [PATCH 2/9] PM / Domains: Enable genpd to support ->get|put() callbacks Ulf Hansson
2015-03-16 2:11 ` Chao [this message]
2015-03-13 15:43 ` [PATCH 3/9] amba: Keep PM domain powered during ->probe() Ulf Hansson
2015-03-13 16:03 ` Russell King - ARM Linux
2015-03-16 8:37 ` Ulf Hansson
2015-03-13 15:43 ` [PATCH 4/9] drivercore / platform: " Ulf Hansson
2015-03-13 15:43 ` [PATCH 5/9] i2c: core: " Ulf Hansson
2015-03-13 15:43 ` [PATCH 6/9] spi: " Ulf Hansson
2015-03-13 15:43 ` [PATCH 7/9] mmc: core: Attach PM domain prior probing of SDIO func driver Ulf Hansson
2015-03-17 5:04 ` Aaron Lu
2015-03-13 15:43 ` [PATCH 8/9] mmmc: core: Keep PM domain powered during ->probe() " Ulf Hansson
2015-03-13 16:10 ` Russell King - ARM Linux
2015-03-16 8:24 ` Ulf Hansson
2015-03-13 15:43 ` [PATCH 9/9] Revert "PM / Domains: Power on the PM domain right after attach completes" Ulf Hansson
2015-03-16 9:07 ` Geert Uytterhoeven
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=1158a1f5.a8f5.14c205997e0.Coremail.xiechao_linux@163.com \
--to=xiechao_linux@163.com \
--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).