Skip to content

Commit b9c532c

Browse files
Alex Elderdavem330
authored andcommitted
net: ipa: distinguish system from runtime suspend
Add a new flag that is set when the hardware is suspended due to a system suspend operation, distingishing it from runtime suspend. Use it in the SUSPEND IPA interrupt handler to determine whether to trigger a system resume because of the event. Define new suspend and resume power management callback functions to set and clear the new flag, respectively. Signed-off-by: Alex Elder <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d430fe4 commit b9c532c

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

drivers/net/ipa/ipa_clock.c

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,12 @@ struct ipa_interconnect {
4747
/**
4848
* enum ipa_power_flag - IPA power flags
4949
* @IPA_POWER_FLAG_RESUMED: Whether resume from suspend has been signaled
50+
* @IPA_POWER_FLAG_SYSTEM: Hardware is system (not runtime) suspended
5051
* @IPA_POWER_FLAG_COUNT: Number of defined power flags
5152
*/
5253
enum ipa_power_flag {
5354
IPA_POWER_FLAG_RESUMED,
55+
IPA_POWER_FLAG_SYSTEM,
5456
IPA_POWER_FLAG_COUNT, /* Last; not a flag */
5557
};
5658

@@ -281,6 +283,27 @@ int ipa_clock_put(struct ipa *ipa)
281283
return pm_runtime_put(&ipa->pdev->dev);
282284
}
283285

286+
static int ipa_suspend(struct device *dev)
287+
{
288+
struct ipa *ipa = dev_get_drvdata(dev);
289+
290+
__set_bit(IPA_POWER_FLAG_SYSTEM, ipa->clock->flags);
291+
292+
return pm_runtime_force_suspend(dev);
293+
}
294+
295+
static int ipa_resume(struct device *dev)
296+
{
297+
struct ipa *ipa = dev_get_drvdata(dev);
298+
int ret;
299+
300+
ret = pm_runtime_force_resume(dev);
301+
302+
__clear_bit(IPA_POWER_FLAG_SYSTEM, ipa->clock->flags);
303+
304+
return ret;
305+
}
306+
284307
/* Return the current IPA core clock rate */
285308
u32 ipa_clock_rate(struct ipa *ipa)
286309
{
@@ -299,12 +322,13 @@ u32 ipa_clock_rate(struct ipa *ipa)
299322
*/
300323
static void ipa_suspend_handler(struct ipa *ipa, enum ipa_irq_id irq_id)
301324
{
302-
/* Just report the event, and let system resume handle the rest.
303-
* More than one endpoint could signal this; if so, ignore
304-
* all but the first.
325+
/* To handle an IPA interrupt we will have resumed the hardware
326+
* just to handle the interrupt, so we're done. If we are in a
327+
* system suspend, trigger a system resume.
305328
*/
306-
if (!test_and_set_bit(IPA_POWER_FLAG_RESUMED, ipa->clock->flags))
307-
pm_wakeup_dev_event(&ipa->pdev->dev, 0, true);
329+
if (!__test_and_set_bit(IPA_POWER_FLAG_RESUMED, ipa->clock->flags))
330+
if (test_bit(IPA_POWER_FLAG_SYSTEM, ipa->clock->flags))
331+
pm_wakeup_dev_event(&ipa->pdev->dev, 0, true);
308332

309333
/* Acknowledge/clear the suspend interrupt on all endpoints */
310334
ipa_interrupt_suspend_clear_all(ipa->interrupt);
@@ -390,8 +414,8 @@ void ipa_clock_exit(struct ipa_clock *clock)
390414
}
391415

392416
const struct dev_pm_ops ipa_pm_ops = {
393-
.suspend = pm_runtime_force_suspend,
394-
.resume = pm_runtime_force_resume,
417+
.suspend = ipa_suspend,
418+
.resume = ipa_resume,
395419
.runtime_suspend = ipa_runtime_suspend,
396420
.runtime_resume = ipa_runtime_resume,
397421
.runtime_idle = ipa_runtime_idle,

0 commit comments

Comments
 (0)