aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/irq/pm.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2014-08-29 08:00:16 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-09-01 07:48:59 -0400
commit9ce7a25849e80cfb264f4995f832b932c1987e1a (patch)
treec7f7301049b93dda90c16b1e8b09e29cdb0bc189 /kernel/irq/pm.c
parentb76f16748fa61801b1a1fd3ffb6f25ee228a35e0 (diff)
genirq: Simplify wakeup mechanism
Currently we suspend wakeup interrupts by lazy disabling them and check later whether the interrupt has fired, but that's not sufficient for suspend to idle as there is no way to check that once we transitioned into the CPU idle state. So we change the mechanism in the following way: 1) Leave the wakeup interrupts enabled across suspend 2) Add a check to irq_may_run() which is called at the beginning of each flow handler whether the interrupt is an armed wakeup source. This check is basically free as it just extends the existing check for IRQD_IRQ_INPROGRESS. So no new conditional in the hot path. If the IRQD_WAKEUP_ARMED flag is set, then the interrupt is disabled, marked as pending/suspended and the pm core is notified about the wakeup event. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> [ rjw: syscore.c and put irq_pm_check_wakeup() into pm.c ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'kernel/irq/pm.c')
-rw-r--r--kernel/irq/pm.c55
1 files changed, 29 insertions, 26 deletions
diff --git a/kernel/irq/pm.c b/kernel/irq/pm.c
index 766930eaeed9..3ca532592704 100644
--- a/kernel/irq/pm.c
+++ b/kernel/irq/pm.c
@@ -9,10 +9,24 @@
9#include <linux/irq.h> 9#include <linux/irq.h>
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/interrupt.h> 11#include <linux/interrupt.h>
12#include <linux/suspend.h>
12#include <linux/syscore_ops.h> 13#include <linux/syscore_ops.h>
13 14
14#include "internals.h" 15#include "internals.h"
15 16
17bool irq_pm_check_wakeup(struct irq_desc *desc)
18{
19 if (irqd_is_wakeup_armed(&desc->irq_data)) {
20 irqd_clear(&desc->irq_data, IRQD_WAKEUP_ARMED);
21 desc->istate |= IRQS_SUSPENDED | IRQS_PENDING;
22 desc->depth++;
23 irq_disable(desc);
24 pm_system_wakeup();
25 return true;
26 }
27 return false;
28}
29
16/* 30/*
17 * Called from __setup_irq() with desc->lock held after @action has 31 * Called from __setup_irq() with desc->lock held after @action has
18 * been installed in the action chain. 32 * been installed in the action chain.
@@ -54,8 +68,16 @@ static bool suspend_device_irq(struct irq_desc *desc, int irq)
54 if (!desc->action || desc->no_suspend_depth) 68 if (!desc->action || desc->no_suspend_depth)
55 return false; 69 return false;
56 70
57 if (irqd_is_wakeup_set(&desc->irq_data)) 71 if (irqd_is_wakeup_set(&desc->irq_data)) {
58 irqd_set(&desc->irq_data, IRQD_WAKEUP_ARMED); 72 irqd_set(&desc->irq_data, IRQD_WAKEUP_ARMED);
73 /*
74 * We return true here to force the caller to issue
75 * synchronize_irq(). We need to make sure that the
76 * IRQD_WAKEUP_ARMED is visible before we return from
77 * suspend_device_irqs().
78 */
79 return true;
80 }
59 81
60 desc->istate |= IRQS_SUSPENDED; 82 desc->istate |= IRQS_SUSPENDED;
61 __disable_irq(desc, irq); 83 __disable_irq(desc, irq);
@@ -79,9 +101,13 @@ static bool suspend_device_irq(struct irq_desc *desc, int irq)
79 * for this purpose. 101 * for this purpose.
80 * 102 *
81 * So we disable all interrupts and mark them IRQS_SUSPENDED except 103 * So we disable all interrupts and mark them IRQS_SUSPENDED except
82 * for those which are unused and those which are marked as not 104 * for those which are unused, those which are marked as not
83 * suspendable via an interrupt request with the flag IRQF_NO_SUSPEND 105 * suspendable via an interrupt request with the flag IRQF_NO_SUSPEND
84 * set. 106 * set and those which are marked as active wakeup sources.
107 *
108 * The active wakeup sources are handled by the flow handler entry
109 * code which checks for the IRQD_WAKEUP_ARMED flag, suspends the
110 * interrupt and notifies the pm core about the wakeup.
85 */ 111 */
86void suspend_device_irqs(void) 112void suspend_device_irqs(void)
87{ 113{
@@ -173,26 +199,3 @@ void resume_device_irqs(void)
173 resume_irqs(false); 199 resume_irqs(false);
174} 200}
175EXPORT_SYMBOL_GPL(resume_device_irqs); 201EXPORT_SYMBOL_GPL(resume_device_irqs);
176
177/**
178 * check_wakeup_irqs - check if any wake-up interrupts are pending
179 */
180int check_wakeup_irqs(void)
181{
182 struct irq_desc *desc;
183 int irq;
184
185 for_each_irq_desc(irq, desc) {
186 /*
187 * Only interrupts which are marked as wakeup source
188 * and have not been disabled before the suspend check
189 * can abort suspend.
190 */
191 if (irqd_is_wakeup_set(&desc->irq_data)) {
192 if (desc->depth == 1 && desc->istate & IRQS_PENDING)
193 return -EBUSY;
194 }
195 }
196
197 return 0;
198}