Commit 724c2d74 authored by Alex Elder's avatar Alex Elder Committed by David S. Miller

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: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 799c5c24
...@@ -49,15 +49,17 @@ static int ipa_open(struct net_device *netdev) ...@@ -49,15 +49,17 @@ static int ipa_open(struct net_device *netdev)
{ {
struct ipa_priv *priv = netdev_priv(netdev); struct ipa_priv *priv = netdev_priv(netdev);
struct ipa *ipa = priv->ipa; struct ipa *ipa = priv->ipa;
struct device *dev;
int ret; int ret;
ret = ipa_clock_get(ipa); dev = &ipa->pdev->dev;
if (WARN_ON(ret < 0)) ret = pm_runtime_get_sync(dev);
goto err_clock_put; if (ret < 0)
goto err_power_put;
ret = ipa_endpoint_enable_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]); ret = ipa_endpoint_enable_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]);
if (ret) if (ret)
goto err_clock_put; goto err_power_put;
ret = ipa_endpoint_enable_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_RX]); ret = ipa_endpoint_enable_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_RX]);
if (ret) if (ret)
...@@ -65,14 +67,14 @@ static int ipa_open(struct net_device *netdev) ...@@ -65,14 +67,14 @@ static int ipa_open(struct net_device *netdev)
netif_start_queue(netdev); netif_start_queue(netdev);
(void)ipa_clock_put(ipa); (void)pm_runtime_put(dev);
return 0; return 0;
err_disable_tx: err_disable_tx:
ipa_endpoint_disable_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]); ipa_endpoint_disable_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]);
err_clock_put: err_power_put:
(void)ipa_clock_put(ipa); (void)pm_runtime_put(dev);
return ret; return ret;
} }
...@@ -82,18 +84,20 @@ static int ipa_stop(struct net_device *netdev) ...@@ -82,18 +84,20 @@ static int ipa_stop(struct net_device *netdev)
{ {
struct ipa_priv *priv = netdev_priv(netdev); struct ipa_priv *priv = netdev_priv(netdev);
struct ipa *ipa = priv->ipa; struct ipa *ipa = priv->ipa;
struct device *dev;
int ret; int ret;
ret = ipa_clock_get(ipa); dev = &ipa->pdev->dev;
if (WARN_ON(ret < 0)) ret = pm_runtime_get_sync(dev);
goto out_clock_put; if (ret < 0)
goto out_power_put;
netif_stop_queue(netdev); netif_stop_queue(netdev);
ipa_endpoint_disable_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_RX]); ipa_endpoint_disable_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_RX]);
ipa_endpoint_disable_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]); ipa_endpoint_disable_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]);
out_clock_put: out_power_put:
(void)ipa_clock_put(ipa); (void)pm_runtime_put(dev);
return 0; return 0;
} }
...@@ -362,9 +366,11 @@ static void ipa_modem_crashed(struct ipa *ipa) ...@@ -362,9 +366,11 @@ static void ipa_modem_crashed(struct ipa *ipa)
struct device *dev = &ipa->pdev->dev; struct device *dev = &ipa->pdev->dev;
int ret; int ret;
ret = ipa_clock_get(ipa); ret = pm_runtime_get_sync(dev);
if (WARN_ON(ret < 0)) if (ret < 0) {
goto out_clock_put; dev_err(dev, "error %d getting power to handle crash\n", ret);
goto out_power_put;
}
ipa_endpoint_modem_pause_all(ipa, true); ipa_endpoint_modem_pause_all(ipa, true);
...@@ -391,8 +397,8 @@ static void ipa_modem_crashed(struct ipa *ipa) ...@@ -391,8 +397,8 @@ static void ipa_modem_crashed(struct ipa *ipa)
if (ret) if (ret)
dev_err(dev, "error %d zeroing modem memory regions\n", ret); dev_err(dev, "error %d zeroing modem memory regions\n", ret);
out_clock_put: out_power_put:
(void)ipa_clock_put(ipa); (void)pm_runtime_put(dev);
} }
static int ipa_modem_notify(struct notifier_block *nb, unsigned long action, static int ipa_modem_notify(struct notifier_block *nb, unsigned long action,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment