[RFC PATCH v2 1/2] amba: Allow AMBA drivers to use their own runtime PM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The AMBA bus driver defines runtime Power Management functions which
disable and unprepare AMBA bus clock. This is problematic for runtime PM
because unpreparing a clock might sleep so it is not interrupt safe.

However some drivers may want to implement runtime PM functions in
interrupt-safe way (see pm_runtime_irq_safe()). If such driver
implements its own runtime PM functions then assume it will handle the
runtime PM completely and it will replace our clock handling.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@xxxxxxxxxxx>
---
 drivers/amba/bus.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index 3cf61a127ee5..38461430b7cf 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -94,9 +94,18 @@ static int amba_pm_runtime_suspend(struct device *dev)
 	struct amba_device *pcdev = to_amba_device(dev);
 	int ret = pm_generic_runtime_suspend(dev);
 
-	if (ret == 0 && dev->driver)
+	if (ret == 0 && dev->driver) {
+		/*
+		 * If driver handles runtime suspend don't duplicate
+		 * the work here.
+		 */
+		if (dev->driver->pm && dev->driver->pm->runtime_suspend)
+			goto out;
+
 		clk_disable_unprepare(pcdev->pclk);
+	}
 
+out:
 	return ret;
 }
 
@@ -106,12 +115,16 @@ static int amba_pm_runtime_resume(struct device *dev)
 	int ret;
 
 	if (dev->driver) {
+		if (dev->driver->pm && dev->driver->pm->runtime_resume)
+			goto out;
+
 		ret = clk_prepare_enable(pcdev->pclk);
 		/* Failure is probably fatal to the system, but... */
 		if (ret)
 			return ret;
 	}
 
+out:
 	return pm_generic_runtime_resume(dev);
 }
 #endif
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux PCI]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux