Skip to content

Commit 9bab0b7

Browse files
Ian CampbellKAGA-KOKO
authored andcommitted
genirq: Add IRQF_RESUME_EARLY and resume such IRQs earlier
This adds a mechanism to resume selected IRQs during syscore_resume instead of dpm_resume_noirq. Under Xen we need to resume IRQs associated with IPIs early enough that the resched IPI is unmasked and we can therefore schedule ourselves out of the stop_machine where the suspend/resume takes place. This issue was introduced by 676dc3c "xen: Use IRQF_FORCE_RESUME". Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Cc: Rafael J. Wysocki <rjw@sisk.pl> Cc: Jeremy Fitzhardinge <Jeremy.Fitzhardinge@citrix.com> Cc: xen-devel <xen-devel@lists.xensource.com> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Link: http://lkml.kernel.org/r/1318713254.11016.52.camel@dagon.hellion.org.uk Cc: stable@kernel.org (at least to 2.6.32.y) Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent 32cffdd commit 9bab0b7

3 files changed

Lines changed: 45 additions & 8 deletions

File tree

‎drivers/xen/events.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ int bind_ipi_to_irqhandler(enum ipi_vector ipi,
10211021
if (irq < 0)
10221022
return irq;
10231023

1024-
irqflags |= IRQF_NO_SUSPEND | IRQF_FORCE_RESUME;
1024+
irqflags |= IRQF_NO_SUSPEND | IRQF_FORCE_RESUME | IRQF_EARLY_RESUME;
10251025
retval = request_irq(irq, handler, irqflags, devname, dev_id);
10261026
if (retval != 0) {
10271027
unbind_from_irq(irq);

‎include/linux/interrupt.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
* IRQF_NO_SUSPEND - Do not disable this IRQ during suspend
6060
* IRQF_FORCE_RESUME - Force enable it on resume even if IRQF_NO_SUSPEND is set
6161
* IRQF_NO_THREAD - Interrupt cannot be threaded
62+
* IRQF_EARLY_RESUME - Resume IRQ early during syscore instead of at device
63+
* resume time.
6264
*/
6365
#define IRQF_DISABLED 0x00000020
6466
#define IRQF_SAMPLE_RANDOM 0x00000040
@@ -72,6 +74,7 @@
7274
#define IRQF_NO_SUSPEND 0x00004000
7375
#define IRQF_FORCE_RESUME 0x00008000
7476
#define IRQF_NO_THREAD 0x00010000
77+
#define IRQF_EARLY_RESUME 0x00020000
7578

7679
#define IRQF_TIMER (__IRQF_TIMER | IRQF_NO_SUSPEND | IRQF_NO_THREAD)
7780

‎kernel/irq/pm.c‎

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/irq.h>
1010
#include <linux/module.h>
1111
#include <linux/interrupt.h>
12+
#include <linux/syscore_ops.h>
1213

1314
#include "internals.h"
1415

@@ -39,25 +40,58 @@ void suspend_device_irqs(void)
3940
}
4041
EXPORT_SYMBOL_GPL(suspend_device_irqs);
4142

42-
/**
43-
* resume_device_irqs - enable interrupt lines disabled by suspend_device_irqs()
44-
*
45-
* Enable all interrupt lines previously disabled by suspend_device_irqs() that
46-
* have the IRQS_SUSPENDED flag set.
47-
*/
48-
void resume_device_irqs(void)
43+
static void resume_irqs(bool want_early)
4944
{
5045
struct irq_desc *desc;
5146
int irq;
5247

5348
for_each_irq_desc(irq, desc) {
5449
unsigned long flags;
50+
bool is_early = desc->action &&
51+
desc->action->flags & IRQF_EARLY_RESUME;
52+
53+
if (is_early != want_early)
54+
continue;
5555

5656
raw_spin_lock_irqsave(&desc->lock, flags);
5757
__enable_irq(desc, irq, true);
5858
raw_spin_unlock_irqrestore(&desc->lock, flags);
5959
}
6060
}
61+
62+
/**
63+
* irq_pm_syscore_ops - enable interrupt lines early
64+
*
65+
* Enable all interrupt lines with %IRQF_EARLY_RESUME set.
66+
*/
67+
static void irq_pm_syscore_resume(void)
68+
{
69+
resume_irqs(true);
70+
}
71+
72+
static struct syscore_ops irq_pm_syscore_ops = {
73+
.resume = irq_pm_syscore_resume,
74+
};
75+
76+
static int __init irq_pm_init_ops(void)
77+
{
78+
register_syscore_ops(&irq_pm_syscore_ops);
79+
return 0;
80+
}
81+
82+
device_initcall(irq_pm_init_ops);
83+
84+
/**
85+
* resume_device_irqs - enable interrupt lines disabled by suspend_device_irqs()
86+
*
87+
* Enable all non-%IRQF_EARLY_RESUME interrupt lines previously
88+
* disabled by suspend_device_irqs() that have the IRQS_SUSPENDED flag
89+
* set as well as those with %IRQF_FORCE_RESUME.
90+
*/
91+
void resume_device_irqs(void)
92+
{
93+
resume_irqs(false);
94+
}
6195
EXPORT_SYMBOL_GPL(resume_device_irqs);
6296

6397
/**

0 commit comments

Comments
 (0)