summaryrefslogtreecommitdiff
path: root/drivers/net/ipa/ipa_main.c
diff options
context:
space:
mode:
authorAlex Elder <elder@linaro.org>2020-09-17 20:39:24 +0300
committerDavid S. Miller <davem@davemloft.net>2020-09-19 03:47:07 +0300
commit3c6ccdde0fe37efaa3d1ae7a141a31b4e054ab03 (patch)
treec597f63af576bde5c275cc5c4f614e76defd4188 /drivers/net/ipa/ipa_main.c
parent8529b4b0dca31244aae495dbbe0013b5a4b2a6ee (diff)
downloadlinux-3c6ccdde0fe37efaa3d1ae7a141a31b4e054ab03.tar.xz
net: ipa: repurpose CLOCK_HELD flag
The previous patch causes a system resume to be triggered when a packet is available for receipt on a suspended RX endpoint. The CLOCK_HELD flag was previously used to indicate that an extra clock reference was held, preventing suspend. But we no longer need such a flag: - We take an initial reference in ipa_config(). - That reference is held until ipa_suspend() releases it. - A subsequent system resume leads to a reference getting re-acquired in ipa_resume(). - This can repeat until ultimately the module is removed, where ipa_remove() releases the reference. We no longer need a special flag to determine whether this extra reference is held--it is, provided probe has completed successfully and the driver is not suspended (or removed). On the other hand, once suspended, it's possible for more than one endpoint to trip the IPA SUSPEND interrupt, and we only want to trigger the system resume once. So repurpose the Boolean CLOCK_HELD flag to record whether the IPA SUSPEND handler should initiate a system resume. The flag will be be cleared each time ipa_suspend() is called, *before* any endpoints are suspended. And it will be set inside the IPA SUSPEND interrupt handler exactly once per suspend. Rename the flag IPA_FLAG_RESUMED to reflect its new purpose. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ipa/ipa_main.c')
-rw-r--r--drivers/net/ipa/ipa_main.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c
index 4e2508bb1bf8..1044758b501d 100644
--- a/drivers/net/ipa/ipa_main.c
+++ b/drivers/net/ipa/ipa_main.c
@@ -86,7 +86,7 @@ static void ipa_suspend_handler(struct ipa *ipa, enum ipa_irq_id irq_id)
* More than one endpoint could signal this; if so, ignore
* all but the first.
*/
- if (!test_and_set_bit(IPA_FLAG_CLOCK_HELD, ipa->flags))
+ if (!test_and_set_bit(IPA_FLAG_RESUMED, ipa->flags))
pm_wakeup_dev_event(&ipa->pdev->dev, 0, true);
/* Acknowledge/clear the suspend interrupt on all endpoints */
@@ -518,7 +518,6 @@ static int ipa_config(struct ipa *ipa, const struct ipa_data *data)
* is held after initialization completes, and won't get dropped
* unless/until a system suspend request arrives.
*/
- __set_bit(IPA_FLAG_CLOCK_HELD, ipa->flags);
ipa_clock_get(ipa);
ipa_hardware_config(ipa);
@@ -554,7 +553,6 @@ err_endpoint_deconfig:
err_hardware_deconfig:
ipa_hardware_deconfig(ipa);
ipa_clock_put(ipa);
- __clear_bit(IPA_FLAG_CLOCK_HELD, ipa->flags);
return ret;
}
@@ -572,7 +570,6 @@ static void ipa_deconfig(struct ipa *ipa)
ipa_endpoint_deconfig(ipa);
ipa_hardware_deconfig(ipa);
ipa_clock_put(ipa);
- __clear_bit(IPA_FLAG_CLOCK_HELD, ipa->flags);
}
static int ipa_firmware_load(struct device *dev)
@@ -778,7 +775,6 @@ static int ipa_probe(struct platform_device *pdev)
dev_set_drvdata(dev, ipa);
ipa->modem_rproc = rproc;
ipa->clock = clock;
- __clear_bit(IPA_FLAG_CLOCK_HELD, ipa->flags);
ipa->version = data->version;
ret = ipa_reg_init(ipa);
@@ -908,10 +904,15 @@ static int ipa_suspend(struct device *dev)
{
struct ipa *ipa = dev_get_drvdata(dev);
+ /* When a suspended RX endpoint has a packet ready to receive, we
+ * get an IPA SUSPEND interrupt. We trigger a system resume in
+ * that case, but only on the first such interrupt since suspend.
+ */
+ __clear_bit(IPA_FLAG_RESUMED, ipa->flags);
+
ipa_endpoint_suspend(ipa);
ipa_clock_put(ipa);
- __clear_bit(IPA_FLAG_CLOCK_HELD, ipa->flags);
return 0;
}
@@ -933,7 +934,6 @@ static int ipa_resume(struct device *dev)
/* This clock reference will keep the IPA out of suspend
* until we get a power management suspend request.
*/
- __set_bit(IPA_FLAG_CLOCK_HELD, ipa->flags);
ipa_clock_get(ipa);
ipa_endpoint_resume(ipa);