Skip to content

Commit 5670c2a

Browse files
krzkRussell King
authored andcommitted
ARM: 8201/1: amba: Don't unprepare the clocks if device driver wants IRQ safe runtime PM v12
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()). In such case the AMBA bus driver should only disable/enable the clock in runtime suspend and resume callbacks. Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent f560e32 commit 5670c2a

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

‎drivers/amba/bus.c‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,12 @@ static int amba_pm_runtime_suspend(struct device *dev)
9595
struct amba_device *pcdev = to_amba_device(dev);
9696
int ret = pm_generic_runtime_suspend(dev);
9797

98-
if (ret == 0 && dev->driver)
99-
clk_disable_unprepare(pcdev->pclk);
98+
if (ret == 0 && dev->driver) {
99+
if (pm_runtime_is_irq_safe(dev))
100+
clk_disable(pcdev->pclk);
101+
else
102+
clk_disable_unprepare(pcdev->pclk);
103+
}
100104

101105
return ret;
102106
}
@@ -107,15 +111,18 @@ static int amba_pm_runtime_resume(struct device *dev)
107111
int ret;
108112

109113
if (dev->driver) {
110-
ret = clk_prepare_enable(pcdev->pclk);
114+
if (pm_runtime_is_irq_safe(dev))
115+
ret = clk_enable(pcdev->pclk);
116+
else
117+
ret = clk_prepare_enable(pcdev->pclk);
111118
/* Failure is probably fatal to the system, but... */
112119
if (ret)
113120
return ret;
114121
}
115122

116123
return pm_generic_runtime_resume(dev);
117124
}
118-
#endif
125+
#endif /* CONFIG_PM */
119126

120127
static const struct dev_pm_ops amba_pm = {
121128
.suspend = pm_generic_suspend,

0 commit comments

Comments
 (0)