Skip to content

Commit c43adc7

Browse files
Alex Elderdavem330
authored andcommitted
net: ipa: don't use ipa_clock_get() in "ipa_smp2p.c"
If the "modem-init" Device Tree property is present for a platform, the modem performs early IPA hardware initialization, and signals this is complete with an "ipa-setup-ready" SMP2P interrupt. This triggers a call to ipa_setup(), which requires the hardware to be powered. Replace the call to ipa_clock_get() in this case with a call to pm_runtime_get_sync(). And replace the corresponding calls to ipa_clock_put() with calls to pm_runtime_put() instead. There is a chance we get an error when taking this power reference. This is an unlikely scenario, where system suspend is initiated just before the modem signals it has finished initializing the IPA hardware. For now we'll just accept that this could occur, and report it if it does. Signed-off-by: Alex Elder <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4c6a4da commit c43adc7

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

drivers/net/ipa/ipa_smp2p.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "ipa_smp2p.h"
1717
#include "ipa.h"
1818
#include "ipa_uc.h"
19-
#include "ipa_clock.h"
2019

2120
/**
2221
* DOC: IPA SMP2P communication with the modem
@@ -153,6 +152,7 @@ static void ipa_smp2p_panic_notifier_unregister(struct ipa_smp2p *smp2p)
153152
static irqreturn_t ipa_smp2p_modem_setup_ready_isr(int irq, void *dev_id)
154153
{
155154
struct ipa_smp2p *smp2p = dev_id;
155+
struct device *dev;
156156
int ret;
157157

158158
mutex_lock(&smp2p->mutex);
@@ -161,17 +161,20 @@ static irqreturn_t ipa_smp2p_modem_setup_ready_isr(int irq, void *dev_id)
161161
goto out_mutex_unlock;
162162
smp2p->disabled = true; /* If any others arrive, ignore them */
163163

164-
/* The clock needs to be active for setup */
165-
ret = ipa_clock_get(smp2p->ipa);
166-
if (WARN_ON(ret < 0))
167-
goto out_clock_put;
164+
/* Power needs to be active for setup */
165+
dev = &smp2p->ipa->pdev->dev;
166+
ret = pm_runtime_get_sync(dev);
167+
if (ret < 0) {
168+
dev_err(dev, "error %d getting power for setup\n", ret);
169+
goto out_power_put;
170+
}
168171

169172
/* An error here won't cause driver shutdown, so warn if one occurs */
170173
ret = ipa_setup(smp2p->ipa);
171174
WARN(ret != 0, "error %d from ipa_setup()\n", ret);
172175

173-
out_clock_put:
174-
(void)ipa_clock_put(smp2p->ipa);
176+
out_power_put:
177+
(void)pm_runtime_put(dev);
175178
out_mutex_unlock:
176179
mutex_unlock(&smp2p->mutex);
177180

@@ -211,7 +214,7 @@ static void ipa_smp2p_clock_release(struct ipa *ipa)
211214
if (!ipa->smp2p->clock_on)
212215
return;
213216

214-
(void)ipa_clock_put(ipa);
217+
(void)pm_runtime_put(&ipa->pdev->dev);
215218
ipa->smp2p->clock_on = false;
216219
}
217220

0 commit comments

Comments
 (0)