summaryrefslogtreecommitdiffstats
path: root/drivers/net/ipa/ipa_smp2p.c
diff options
context:
space:
mode:
authorAlex Elder <elder@linaro.org>2021-08-10 21:26:58 +0200
committerDavid S. Miller <davem@davemloft.net>2021-08-11 14:31:55 +0200
commit7ebd168c3bfc3ebf113545170c2bb28d02f0ba15 (patch)
treed3e3d328ea10b9e964b5bd72ff2a965f029d6937 /drivers/net/ipa/ipa_smp2p.c
parentMerge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next (diff)
downloadlinux-7ebd168c3bfc3ebf113545170c2bb28d02f0ba15.tar.xz
linux-7ebd168c3bfc3ebf113545170c2bb28d02f0ba15.zip
net: ipa: have ipa_clock_get() return a value
We currently assume no errors occur when enabling or disabling the IPA core clock and interconnects. And although this commit exposes errors that could occur, we generally assume this won't happen in practice. This commit changes ipa_clock_get() and ipa_clock_put() so each returns a value. The values returned are meant to mimic what the runtime power management functions return, so we can set up error handling here before we make the switch. Have ipa_clock_get() increment the reference count even if it returns an error, to match the behavior of pm_runtime_get(). More details follow. When taking a reference in ipa_clock_get(), return 0 for the first reference, 1 for subsequent references, or a negative error code if an error occurs. Note that if ipa_clock_get() returns an error, we must not touch hardware; in some cases such errors now cause entire blocks of code to be skipped. When dropping a reference in ipa_clock_put(), we return 0 or an error code. The error would come from ipa_clock_disable(), which now returns what ipa_interconnect_disable() returns (either 0 or a negative error code). For now, callers ignore the return value; if an error occurs, a message will have already been logged, and little more can actually be done to improve the situation. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ipa/ipa_smp2p.c')
-rw-r--r--drivers/net/ipa/ipa_smp2p.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/drivers/net/ipa/ipa_smp2p.c b/drivers/net/ipa/ipa_smp2p.c
index 0d15438a79e2..f84d6523636e 100644
--- a/drivers/net/ipa/ipa_smp2p.c
+++ b/drivers/net/ipa/ipa_smp2p.c
@@ -150,24 +150,26 @@ static void ipa_smp2p_panic_notifier_unregister(struct ipa_smp2p *smp2p)
static irqreturn_t ipa_smp2p_modem_setup_ready_isr(int irq, void *dev_id)
{
struct ipa_smp2p *smp2p = dev_id;
+ int ret;
mutex_lock(&smp2p->mutex);
- if (!smp2p->disabled) {
- int ret;
-
- /* The clock needs to be active for setup */
- ipa_clock_get(smp2p->ipa);
+ if (smp2p->disabled)
+ goto out_mutex_unlock;
+ smp2p->disabled = true; /* If any others arrive, ignore them */
- ret = ipa_setup(smp2p->ipa);
- if (ret)
- dev_err(&smp2p->ipa->pdev->dev,
- "error %d from ipa_setup()\n", ret);
- smp2p->disabled = true;
+ /* The clock needs to be active for setup */
+ ret = ipa_clock_get(smp2p->ipa);
+ if (WARN_ON(ret < 0))
+ goto out_clock_put;
- ipa_clock_put(smp2p->ipa);
- }
+ /* An error here won't cause driver shutdown, so warn if one occurs */
+ ret = ipa_setup(smp2p->ipa);
+ WARN(ret != 0, "error %d from ipa_setup()\n", ret);
+out_clock_put:
+ (void)ipa_clock_put(smp2p->ipa);
+out_mutex_unlock:
mutex_unlock(&smp2p->mutex);
return IRQ_HANDLED;
@@ -206,7 +208,7 @@ static void ipa_smp2p_clock_release(struct ipa *ipa)
if (!ipa->smp2p->clock_on)
return;
- ipa_clock_put(ipa);
+ (void)ipa_clock_put(ipa);
ipa->smp2p->clock_on = false;
}