linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] PM / Domains: Sync runtime PM status with genpd after probe
@ 2015-03-20 14:55 Ulf Hansson
  2015-03-21  0:14 ` Kevin Hilman
  0 siblings, 1 reply; 2+ messages in thread
From: Ulf Hansson @ 2015-03-20 14:55 UTC (permalink / raw)
  To: Rafael J. Wysocki, Kevin Hilman, Ulf Hansson, linux-pm
  Cc: Len Brown, Pavel Machek, Geert Uytterhoeven, Dmitry Torokhov,
	Russell King, linux-arm-kernel, Russell King

From: Russell King <rmk+kernel@arm.linux.org.uk>

Buses which currently supports attaching devices to their PM domains,
will invoke the dev_pm_domain_attach() API from their ->probe()
callbacks. During the attach procedure, genpd power up the PM domain.

In those scenarios where the bus/driver don't need to access its device
during probe, it may leave it in runtime PM suspended state since
that's also the default state. In that way, no notifications through
the runtime PM callbacks will reach the PM domain during probe.

For genpd, the consequence from the above scenario means the PM domain
will remain powered. Therefore, implement the struct dev_pm_domain's
->sync() callback, which is invoked from driver core after the
bus/driver has probed the device. It allows genpd to power off the PM
domain if it's unused.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
[Ulf: Updated patch according to updates in driver core]
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---

Changes in v2:
	- I picked up Russell's earlier patch [1] and updated it to fit the
	changes [2] proposed to be done to the driver core.

	[1]: [PATCH 3/9] pm: domains: sync runtime PM status with PM domains
	after probe

	[2]: [PATCH v3] driver core / PM: Add PM domain callbacks for device
	setup/cleanup
	http://www.spinics.net/lists/arm-kernel/msg407394.html

---
 drivers/base/power/domain.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 45937f8..295ff71 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -2130,6 +2130,17 @@ 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;
+
+	pd = dev_to_genpd(dev);
+	if (IS_ERR(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.
@@ -2196,6 +2207,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;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH V2] PM / Domains: Sync runtime PM status with genpd after probe
  2015-03-20 14:55 [PATCH V2] PM / Domains: Sync runtime PM status with genpd after probe Ulf Hansson
@ 2015-03-21  0:14 ` Kevin Hilman
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Hilman @ 2015-03-21  0:14 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Rafael J. Wysocki, linux-pm, Len Brown, Pavel Machek,
	Geert Uytterhoeven, Dmitry Torokhov, Russell King,
	linux-arm-kernel, Russell King

Ulf Hansson <ulf.hansson@linaro.org> writes:

> From: Russell King <rmk+kernel@arm.linux.org.uk>
>
> Buses which currently supports attaching devices to their PM domains,
> will invoke the dev_pm_domain_attach() API from their ->probe()
> callbacks. During the attach procedure, genpd power up the PM domain.
>
> In those scenarios where the bus/driver don't need to access its device
> during probe, it may leave it in runtime PM suspended state since
> that's also the default state. In that way, no notifications through
> the runtime PM callbacks will reach the PM domain during probe.
>
> For genpd, the consequence from the above scenario means the PM domain
> will remain powered. Therefore, implement the struct dev_pm_domain's
> ->sync() callback, which is invoked from driver core after the
> bus/driver has probed the device. It allows genpd to power off the PM
> domain if it's unused.
>
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
> [Ulf: Updated patch according to updates in driver core]
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> ---
>
> Changes in v2:
> 	- I picked up Russell's earlier patch [1] and updated it to fit the
> 	changes [2] proposed to be done to the driver core.
>
> 	[1]: [PATCH 3/9] pm: domains: sync runtime PM status with PM domains
> 	after probe
>
> 	[2]: [PATCH v3] driver core / PM: Add PM domain callbacks for device
> 	setup/cleanup
> 	http://www.spinics.net/lists/arm-kernel/msg407394.html

Ah, I hadn't seen this when I reviewed Rafael's v3 and suggested
Russell's patch be reworked.  This is just what I had in mind.

Acked-by: Kevin Hilman <khilman@linaro.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-03-21  0:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-20 14:55 [PATCH V2] PM / Domains: Sync runtime PM status with genpd after probe Ulf Hansson
2015-03-21  0:14 ` Kevin Hilman

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).