diff mbox

[3/9] amba: Keep PM domain powered during ->probe()

Message ID 1426261429-31883-4-git-send-email-ulf.hansson@linaro.org
State New
Headers show

Commit Message

Ulf Hansson March 13, 2015, 3:43 p.m. UTC
To sucessfully probe some devices their corresponding PM domains may
need to be powered.

Use the dev_pm_domain_get|put() APIs, to control the behavior of the PM
domain.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/amba/bus.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Ulf Hansson March 16, 2015, 8:37 a.m. UTC | #1
On 13 March 2015 at 17:03, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
> On Fri, Mar 13, 2015 at 04:43:43PM +0100, Ulf Hansson wrote:
>> To sucessfully probe some devices their corresponding PM domains may
>> need to be powered.
>>
>> Use the dev_pm_domain_get|put() APIs, to control the behavior of the PM
>> domain.
>
> Given that AMBA gets the runtime PM status across a probe, none of this
> should be necessary, as generic PM domains ensures that if runtime PM
> is active for any device bound to the PM domain, the PM domain will be
> powered up.

This patch is needed to enable us to do the revert in patch 9. Since
otherwise amba drivers will probe their devices when the attached PM
domain may be powered off.

That should have been better explained in the commit message.

Kind regards
Uffe

>
> In that respect, AMBA is a model of how runtime PM should've been done
> for stuff like platform devices. :)
>
> --
> FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
> according to speedtest.net.
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index f009936..19182b0 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -241,8 +241,15 @@  static int amba_probe(struct device *dev)
 		if (ret == -EPROBE_DEFER)
 			break;
 
+		ret = dev_pm_domain_get(dev->pm_domain);
+		if (ret) {
+			dev_pm_domain_detach(dev, true);
+			break;
+		}
+
 		ret = amba_get_enable_pclk(pcdev);
 		if (ret) {
+			dev_pm_domain_put(dev->pm_domain);
 			dev_pm_domain_detach(dev, true);
 			break;
 		}
@@ -252,6 +259,7 @@  static int amba_probe(struct device *dev)
 		pm_runtime_enable(dev);
 
 		ret = pcdrv->probe(pcdev, id);
+		dev_pm_domain_put(dev->pm_domain);
 		if (ret == 0)
 			break;