net: ipa: use autosuspend
Use runtime power management autosuspend.
Up until this point, we only suspended the IPA hardware for system
suspend; now we'll suspend it aggressively using runtime power
management, setting the initial autosuspend delay to half a second
of inactivity.
Replace pm_runtime_put() calls with pm_runtime_put_autosuspend(),
call pm_runtime_mark_last_busy() before each of those. In places
where we're shutting things down, or decrementing power references
for errors, use pm_runtime_put_noidle() instead.
Finally, remove ipa_runtime_idle(), so the ->runtime_suspend
callback will occur if idle.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
diff --git a/drivers/net/ipa/ipa_clock.c b/drivers/net/ipa/ipa_clock.c
index 149b24da..54d6849 100644
--- a/drivers/net/ipa/ipa_clock.c
+++ b/drivers/net/ipa/ipa_clock.c
@@ -32,6 +32,8 @@
* An IPA clock reference must be held for any access to IPA hardware.
*/
+#define IPA_AUTOSUSPEND_DELAY 500 /* milliseconds */
+
/**
* struct ipa_interconnect - IPA interconnect information
* @path: Interconnect path
@@ -267,11 +269,6 @@ static int ipa_runtime_resume(struct device *dev)
return 0;
}
-static int ipa_runtime_idle(struct device *dev)
-{
- return -EAGAIN;
-}
-
static int ipa_suspend(struct device *dev)
{
struct ipa *ipa = dev_get_drvdata(dev);
@@ -443,7 +440,8 @@ ipa_clock_init(struct device *dev, const struct ipa_clock_data *data)
if (ret)
goto err_kfree;
- pm_runtime_dont_use_autosuspend(dev);
+ pm_runtime_set_autosuspend_delay(dev, IPA_AUTOSUSPEND_DELAY);
+ pm_runtime_use_autosuspend(dev);
pm_runtime_enable(dev);
return clock;
@@ -459,9 +457,11 @@ ipa_clock_init(struct device *dev, const struct ipa_clock_data *data)
/* Inverse of ipa_clock_init() */
void ipa_clock_exit(struct ipa_clock *clock)
{
+ struct device *dev = clock->dev;
struct clk *clk = clock->core;
- pm_runtime_disable(clock->dev);
+ pm_runtime_disable(dev);
+ pm_runtime_dont_use_autosuspend(dev);
ipa_interconnect_exit(clock);
kfree(clock);
clk_put(clk);
@@ -472,5 +472,4 @@ const struct dev_pm_ops ipa_pm_ops = {
.resume = ipa_resume,
.runtime_suspend = ipa_runtime_suspend,
.runtime_resume = ipa_runtime_resume,
- .runtime_idle = ipa_runtime_idle,
};