Skip to content

Commit 1aac309

Browse files
Alex Elderdavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4af14db commit 1aac309

File tree

6 files changed

+40
-25
lines changed

6 files changed

+40
-25
lines changed

drivers/net/ipa/ipa_clock.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
* An IPA clock reference must be held for any access to IPA hardware.
3333
*/
3434

35+
#define IPA_AUTOSUSPEND_DELAY 500 /* milliseconds */
36+
3537
/**
3638
* struct ipa_interconnect - IPA interconnect information
3739
* @path: Interconnect path
@@ -267,11 +269,6 @@ static int ipa_runtime_resume(struct device *dev)
267269
return 0;
268270
}
269271

270-
static int ipa_runtime_idle(struct device *dev)
271-
{
272-
return -EAGAIN;
273-
}
274-
275272
static int ipa_suspend(struct device *dev)
276273
{
277274
struct ipa *ipa = dev_get_drvdata(dev);
@@ -443,7 +440,8 @@ ipa_clock_init(struct device *dev, const struct ipa_clock_data *data)
443440
if (ret)
444441
goto err_kfree;
445442

446-
pm_runtime_dont_use_autosuspend(dev);
443+
pm_runtime_set_autosuspend_delay(dev, IPA_AUTOSUSPEND_DELAY);
444+
pm_runtime_use_autosuspend(dev);
447445
pm_runtime_enable(dev);
448446

449447
return clock;
@@ -459,9 +457,11 @@ ipa_clock_init(struct device *dev, const struct ipa_clock_data *data)
459457
/* Inverse of ipa_clock_init() */
460458
void ipa_clock_exit(struct ipa_clock *clock)
461459
{
460+
struct device *dev = clock->dev;
462461
struct clk *clk = clock->core;
463462

464-
pm_runtime_disable(clock->dev);
463+
pm_runtime_disable(dev);
464+
pm_runtime_dont_use_autosuspend(dev);
465465
ipa_interconnect_exit(clock);
466466
kfree(clock);
467467
clk_put(clk);
@@ -472,5 +472,4 @@ const struct dev_pm_ops ipa_pm_ops = {
472472
.resume = ipa_resume,
473473
.runtime_suspend = ipa_runtime_suspend,
474474
.runtime_resume = ipa_runtime_resume,
475-
.runtime_idle = ipa_runtime_idle,
476475
};

drivers/net/ipa/ipa_interrupt.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ static irqreturn_t ipa_isr_thread(int irq, void *dev_id)
116116
iowrite32(pending, ipa->reg_virt + offset);
117117
}
118118
out_power_put:
119-
(void)pm_runtime_put(dev);
119+
pm_runtime_mark_last_busy(dev);
120+
(void)pm_runtime_put_autosuspend(dev);
120121

121122
return IRQ_HANDLED;
122123
}

drivers/net/ipa/ipa_main.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -766,14 +766,15 @@ static int ipa_probe(struct platform_device *pdev)
766766
if (ret)
767767
goto err_deconfig;
768768
done:
769-
(void)pm_runtime_put(dev);
769+
pm_runtime_mark_last_busy(dev);
770+
(void)pm_runtime_put_autosuspend(dev);
770771

771772
return 0;
772773

773774
err_deconfig:
774775
ipa_deconfig(ipa);
775776
err_power_put:
776-
(void)pm_runtime_put(dev);
777+
pm_runtime_put_noidle(dev);
777778
ipa_modem_exit(ipa);
778779
err_table_exit:
779780
ipa_table_exit(ipa);
@@ -797,9 +798,10 @@ static int ipa_remove(struct platform_device *pdev)
797798
{
798799
struct ipa *ipa = dev_get_drvdata(&pdev->dev);
799800
struct ipa_clock *clock = ipa->clock;
801+
struct device *dev = &pdev->dev;
800802
int ret;
801803

802-
ret = pm_runtime_get_sync(&pdev->dev);
804+
ret = pm_runtime_get_sync(dev);
803805
if (WARN_ON(ret < 0))
804806
goto out_power_put;
805807

@@ -818,8 +820,7 @@ static int ipa_remove(struct platform_device *pdev)
818820

819821
ipa_deconfig(ipa);
820822
out_power_put:
821-
(void)pm_runtime_put(&pdev->dev);
822-
823+
pm_runtime_put_noidle(dev);
823824
ipa_modem_exit(ipa);
824825
ipa_table_exit(ipa);
825826
ipa_endpoint_exit(ipa);

drivers/net/ipa/ipa_modem.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,15 @@ static int ipa_open(struct net_device *netdev)
6767

6868
netif_start_queue(netdev);
6969

70-
(void)pm_runtime_put(dev);
70+
pm_runtime_mark_last_busy(dev);
71+
(void)pm_runtime_put_autosuspend(dev);
7172

7273
return 0;
7374

7475
err_disable_tx:
7576
ipa_endpoint_disable_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]);
7677
err_power_put:
77-
(void)pm_runtime_put(dev);
78+
pm_runtime_put_noidle(dev);
7879

7980
return ret;
8081
}
@@ -97,7 +98,8 @@ static int ipa_stop(struct net_device *netdev)
9798
ipa_endpoint_disable_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_RX]);
9899
ipa_endpoint_disable_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]);
99100
out_power_put:
100-
(void)pm_runtime_put(dev);
101+
pm_runtime_mark_last_busy(dev);
102+
(void)pm_runtime_put_autosuspend(dev);
101103

102104
return 0;
103105
}
@@ -145,7 +147,7 @@ ipa_start_xmit(struct sk_buff *skb, struct net_device *netdev)
145147
*/
146148
ipa_power_modem_queue_stop(ipa);
147149

148-
(void)pm_runtime_put(dev);
150+
pm_runtime_put_noidle(dev);
149151

150152
return NETDEV_TX_BUSY;
151153
}
@@ -154,7 +156,8 @@ ipa_start_xmit(struct sk_buff *skb, struct net_device *netdev)
154156

155157
ret = ipa_endpoint_skb_tx(endpoint, skb);
156158

157-
(void)pm_runtime_put(dev);
159+
pm_runtime_mark_last_busy(dev);
160+
(void)pm_runtime_put_autosuspend(dev);
158161

159162
if (ret) {
160163
if (ret != -E2BIG)
@@ -398,7 +401,8 @@ static void ipa_modem_crashed(struct ipa *ipa)
398401
dev_err(dev, "error %d zeroing modem memory regions\n", ret);
399402

400403
out_power_put:
401-
(void)pm_runtime_put(dev);
404+
pm_runtime_mark_last_busy(dev);
405+
(void)pm_runtime_put_autosuspend(dev);
402406
}
403407

404408
static int ipa_modem_notify(struct notifier_block *nb, unsigned long action,

drivers/net/ipa/ipa_smp2p.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ static irqreturn_t ipa_smp2p_modem_setup_ready_isr(int irq, void *dev_id)
174174
WARN(ret != 0, "error %d from ipa_setup()\n", ret);
175175

176176
out_power_put:
177-
(void)pm_runtime_put(dev);
177+
pm_runtime_mark_last_busy(dev);
178+
(void)pm_runtime_put_autosuspend(dev);
178179
out_mutex_unlock:
179180
mutex_unlock(&smp2p->mutex);
180181

@@ -211,10 +212,13 @@ static void ipa_smp2p_irq_exit(struct ipa_smp2p *smp2p, u32 irq)
211212
/* Drop the clock reference if it was taken in ipa_smp2p_notify() */
212213
static void ipa_smp2p_clock_release(struct ipa *ipa)
213214
{
215+
struct device *dev = &ipa->pdev->dev;
216+
214217
if (!ipa->smp2p->clock_on)
215218
return;
216219

217-
(void)pm_runtime_put(&ipa->pdev->dev);
220+
pm_runtime_mark_last_busy(dev);
221+
(void)pm_runtime_put_autosuspend(dev);
218222
ipa->smp2p->clock_on = false;
219223
}
220224

drivers/net/ipa/ipa_uc.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ static void ipa_uc_response_hdlr(struct ipa *ipa, enum ipa_irq_id irq_id)
154154
case IPA_UC_RESPONSE_INIT_COMPLETED:
155155
if (ipa->uc_clocked) {
156156
ipa->uc_loaded = true;
157-
(void)pm_runtime_put(dev);
157+
pm_runtime_mark_last_busy(dev);
158+
(void)pm_runtime_put_autosuspend(dev);
158159
ipa->uc_clocked = false;
159160
} else {
160161
dev_warn(dev, "unexpected init_completed response\n");
@@ -179,10 +180,15 @@ void ipa_uc_config(struct ipa *ipa)
179180
/* Inverse of ipa_uc_config() */
180181
void ipa_uc_deconfig(struct ipa *ipa)
181182
{
183+
struct device *dev = &ipa->pdev->dev;
184+
182185
ipa_interrupt_remove(ipa->interrupt, IPA_IRQ_UC_1);
183186
ipa_interrupt_remove(ipa->interrupt, IPA_IRQ_UC_0);
184-
if (ipa->uc_clocked)
185-
(void)pm_runtime_put(&ipa->pdev->dev);
187+
if (!ipa->uc_clocked)
188+
return;
189+
190+
pm_runtime_mark_last_busy(dev);
191+
(void)pm_runtime_put_autosuspend(dev);
186192
}
187193

188194
/* Take a proxy clock reference for the microcontroller */

0 commit comments

Comments
 (0)