spi/pl022: Simplify use of runtime pm
Subsystems (2)
PATCH v2 1/1 spi/pl022: Simplify use of runtime pm
From: Ulf Hansson <[email protected]>
In probe the pm_runtime_resume is not needed since the amba bus has already set the device in "resumed" state by using pm_runtime_set_active.
Additionally more simplifications is done in probe by removing pm_runtime_put_autosuspend. pm_runtime_put_autosuspend does in probe functions have same effect as doing pm_runtime_put. This due to upper layer in driver core is preventing the device from being runtime suspended by a pm_runtime_get*.
Finally, removing pm_runtime_disable from the remove function can be done since it is already handled by the amba bus.
---
V2: Clearification added in commit message
--- drivers/spi/spi-pl022.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/spi/spi-pl022.c +2 -6
@@ -2188,8 +2188,6 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id)printk (KERN_INFO "pl022: mapped registers from 0x%08x to %p\n" , adev->res.start, pl022->virtbase); -pm_runtime_resume (dev); - pl022->clk =clk_get (&adev->dev,NULL );if (IS_ERR (pl022->clk)) { status =PTR_ERR (pl022->clk);
@@ -2250,10 +2248,9 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id)pm_runtime_set_autosuspend_delay (dev, platform_info->autosuspend_delay);pm_runtime_use_autosuspend (dev); -pm_runtime_put_autosuspend (dev); - }else { -pm_runtime_put (dev); } +pm_runtime_put (dev); +return 0 ; err_spi_register:
@@ -2302,7 +2299,6 @@ pl022_remove(struct amba_device *adev)clk_disable (pl022->clk);clk_unprepare (pl022->clk);clk_put (pl022->clk); -pm_runtime_disable (&adev->dev);iounmap (pl022->virtbase);amba_release_regions (adev);tasklet_disable (&pl022->pump_transfers);
Signature · 1 line
1.7.10
PATCH v2 1/1 spi/pl022: Simplify use of runtime pm
Quoted 10 lines · Ulf Hansson
In probe the
pm_runtime_resumeis not needed since the amba bus has already set the device in "resumed" state by usingpm_runtime_set_active.Additionally more simplifications is done in probe by removing
pm_runtime_put_autosuspend.pm_runtime_put_autosuspenddoes in probe functions have same effect as doingpm_runtime_put. This due to upper layer in driver core is preventing the device from being runtime suspended by a pm_runtime_get*.
Quoted 4 lines
Finally, removing
pm_runtime_disablefrom the remove function can be done since it is already handled by the amba bus.Signed-off-by Ulf Hansson <[email protected]>
What's the bloody point?
Here:
commit 92b97f0aaccbf9de4a29696e6253bf82e8850d1d
Author: Russell King <[email protected]> Date: Sun Aug 14 09:13:48 2011 +0100
PM: add runtime PM support to core Primecell driver
Add runtime PM support to the core Primecell driver, following the PCI model of how this is done.
Rather than having every driver fiddle about with enabling runtime PM, that's dealt with in the core and instead, drivers just do a put() in their probe and a balancing get() in their remove function to activate runtime PM for the device.
As we're dealing with enabling runtime PM in the core, fix up spi-pl022 as it must not enable and disable runtime PM itself anymore.
I added runtime PM support to the core primecell driver. The SPI PL022 driver already had it, so I fixed it up correctly at that time. That was, to ensure that it had a call to pm_runtime_put() at the end of its probe function, and pm_runtime_get_noresume() at the beginning of its remove function - and checked that there were appropraite calls elsewhere.
Then:
commit 53e4acea0e819a6a8513e10a0773f2259ede0481
Author: Chris Blair <[email protected]> Date: Tue Nov 8 08:54:46 2011 +0000
spi/pl022: add support for pm_runtime autosuspend
Adds support for configuring the spi bus to use autosuspend for runtime power management. This can reduce the latency in starting an spi transfer by not suspending the device immediately following completion of a transfer. If another transfer then takes place before the autosuspend timeout, the call to resume the device can return immediately rather than needing to risk sleeping in order to resume the device.
added support for autosuspend to this. That change looks fine.
Then we get to:
commit 2fb30d1147c599f5657e8c62c862f9a0f58d9d99
Author: Linus Walleij <[email protected]> Date: Tue Jun 12 16:14:51 2012 +0200
spi/pl022: enable runtime PM
If we're gonna use runtime PM it's a pretty good idea to actually enable it in probe() and disable it in remove() too, so it gets used for real. Up until now we only fooled around with the reference count.
which is total bollocks whatever way you look at it, and undoes my changes when I moved this stuff into the bus layer (like PCI does.) This then sparked another "fix":
commit 6887237cd7da904184dab2750504040c68f3a080
Author: Michel JAOUEN <[email protected]> Date: Fri Aug 17 17:28:41 2012 +0200
spi/pl022: fix spi-pl022 pm enable at probe
amba drivers does not need to enable pm runtime at probe. amba_probe already enables pm runtime.
This rids this warning in the ux500 boot log:
ssp-pl022 ssp0: Unbalanced pm_runtime_enable!
because of the now crapped up runtime PM initialization.
Really, Linus, what are you thinking?
Both 6887237cd7da904184dab2750504040c68f3a080 and 2fb30d1147c599f5657e8c62c862f9a0f58d9d99 need reverting. Once that's done, I suggest Ulf then builds upon a sane base instead of the crappy base we have today.