Skip to content

Commit 724c2d7

Browse files
Alex Elderdavem330
authored andcommitted
net: ipa: don't use ipa_clock_get() in "ipa_modem.c"
When we open or close the modem network device we need to ensure the hardware is powered. Replace the callers of ipa_clock_get() found in ipa_open() and ipa_stop() with calls to pm_runtime_get_sync(). If an error is returned, simply return that error to the caller (without any error or warning message). This could conceivably occur if the function was called while the system was suspended, but that really shouldn't happen. Replace corresponding calls to ipa_clock_put() with pm_runtime_put() also. If the modem crashes we also need to ensure the hardware is powered to recover. If getting power returns an error there's not much we can do, but at least report the error. (Ideally the remoteproc SSR code would ensure the AP was not suspended when it sends the notification, but that is not (yet) the case.) Signed-off-by: Alex Elder <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 799c5c2 commit 724c2d7

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

drivers/net/ipa/ipa_modem.c

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,30 +49,32 @@ static int ipa_open(struct net_device *netdev)
4949
{
5050
struct ipa_priv *priv = netdev_priv(netdev);
5151
struct ipa *ipa = priv->ipa;
52+
struct device *dev;
5253
int ret;
5354

54-
ret = ipa_clock_get(ipa);
55-
if (WARN_ON(ret < 0))
56-
goto err_clock_put;
55+
dev = &ipa->pdev->dev;
56+
ret = pm_runtime_get_sync(dev);
57+
if (ret < 0)
58+
goto err_power_put;
5759

5860
ret = ipa_endpoint_enable_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]);
5961
if (ret)
60-
goto err_clock_put;
62+
goto err_power_put;
6163

6264
ret = ipa_endpoint_enable_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_RX]);
6365
if (ret)
6466
goto err_disable_tx;
6567

6668
netif_start_queue(netdev);
6769

68-
(void)ipa_clock_put(ipa);
70+
(void)pm_runtime_put(dev);
6971

7072
return 0;
7173

7274
err_disable_tx:
7375
ipa_endpoint_disable_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]);
74-
err_clock_put:
75-
(void)ipa_clock_put(ipa);
76+
err_power_put:
77+
(void)pm_runtime_put(dev);
7678

7779
return ret;
7880
}
@@ -82,18 +84,20 @@ static int ipa_stop(struct net_device *netdev)
8284
{
8385
struct ipa_priv *priv = netdev_priv(netdev);
8486
struct ipa *ipa = priv->ipa;
87+
struct device *dev;
8588
int ret;
8689

87-
ret = ipa_clock_get(ipa);
88-
if (WARN_ON(ret < 0))
89-
goto out_clock_put;
90+
dev = &ipa->pdev->dev;
91+
ret = pm_runtime_get_sync(dev);
92+
if (ret < 0)
93+
goto out_power_put;
9094

9195
netif_stop_queue(netdev);
9296

9397
ipa_endpoint_disable_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_RX]);
9498
ipa_endpoint_disable_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]);
95-
out_clock_put:
96-
(void)ipa_clock_put(ipa);
99+
out_power_put:
100+
(void)pm_runtime_put(dev);
97101

98102
return 0;
99103
}
@@ -362,9 +366,11 @@ static void ipa_modem_crashed(struct ipa *ipa)
362366
struct device *dev = &ipa->pdev->dev;
363367
int ret;
364368

365-
ret = ipa_clock_get(ipa);
366-
if (WARN_ON(ret < 0))
367-
goto out_clock_put;
369+
ret = pm_runtime_get_sync(dev);
370+
if (ret < 0) {
371+
dev_err(dev, "error %d getting power to handle crash\n", ret);
372+
goto out_power_put;
373+
}
368374

369375
ipa_endpoint_modem_pause_all(ipa, true);
370376

@@ -391,8 +397,8 @@ static void ipa_modem_crashed(struct ipa *ipa)
391397
if (ret)
392398
dev_err(dev, "error %d zeroing modem memory regions\n", ret);
393399

394-
out_clock_put:
395-
(void)ipa_clock_put(ipa);
400+
out_power_put:
401+
(void)pm_runtime_put(dev);
396402
}
397403

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

0 commit comments

Comments
 (0)