Skip to contentSkip to conversation

Patch Upstream: genirq: Add IRQF_RESUME_EARLY and resume such IRQs earlier

DISCUSSION Greg KH 2 participants 5 messages Nov 1, 2011 – Nov 2, 2011 1 message not in the archive

lore
Share & tools
lore

Greg KH

author
#1 lore raw
In reply to a message not in the archive

If someone wants this in .32-stable, can they provide me a backported version, as this doesn't backport very easily (i.e. I tried and failed.)

thanks,

greg k-h

Quoted 143 lines · Gregs git-bot

commit: 9bab0b7fbaceec47d32db51cd9e59c82fb071f5a
From: Ian Campbell <[email protected]>
Date: Mon, 3 Oct 2011 15:37:00 +0100
Subject: 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 676dc3cf5bc3 "xen: Use IRQF_FORCE_RESUME".

Cc Rafael J. Wysocki <[email protected]>
Cc Jeremy Fitzhardinge <[email protected]>
Cc xen-devel <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc [email protected] (at least to 2.6.32.y)
---
 drivers/xen/events.c      |    2 +-
 include/linux/interrupt.h |    3 ++
 kernel/irq/pm.c           |   48 ++++++++++++++++++++++++++++++++++++++------
 3 files changed, 45 insertions(+), 8 deletions(-)
drivers/xen/events.c +1 -1
index da70f5c..a758bc1 100644
@@ -1021,7 +1021,7 @@ int bind_ipi_to_irqhandler(enum ipi_vector ipi,
 	if (irq < 0)
 		return irq;
 
-	irqflags |= IRQF_NO_SUSPEND | IRQF_FORCE_RESUME;
+	irqflags |= IRQF_NO_SUSPEND | IRQF_FORCE_RESUME | IRQF_EARLY_RESUME;
 	retval = request_irq(irq, handler, irqflags, devname, dev_id);
 	if (retval != 0) {
 		unbind_from_irq(irq);
include/linux/interrupt.h +3 -0
index 664544f..a64b00e 100644
@@ -59,6 +59,8 @@
  * IRQF_NO_SUSPEND - Do not disable this IRQ during suspend
  * IRQF_FORCE_RESUME - Force enable it on resume even if IRQF_NO_SUSPEND is set
  * IRQF_NO_THREAD - Interrupt cannot be threaded
+ * IRQF_EARLY_RESUME - Resume IRQ early during syscore instead of at device
+ *                resume time.
  */
 #define IRQF_DISABLED		0x00000020
 #define IRQF_SAMPLE_RANDOM	0x00000040
@@ -72,6 +74,7 @@
 #define IRQF_NO_SUSPEND		0x00004000
 #define IRQF_FORCE_RESUME	0x00008000
 #define IRQF_NO_THREAD		0x00010000
+#define IRQF_EARLY_RESUME	0x00020000
 
 #define IRQF_TIMER		(__IRQF_TIMER | IRQF_NO_SUSPEND | IRQF_NO_THREAD)
 
kernel/irq/pm.c +41 -7
index f76fc00..15e53b1 100644
@@ -9,6 +9,7 @@
 #include <linux/irq.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
+#include <linux/syscore_ops.h>
 
 #include "internals.h"
 
@@ -39,25 +40,58 @@ void suspend_device_irqs(void)
 }
 EXPORT_SYMBOL_GPL(suspend_device_irqs);
 
-/**
- * resume_device_irqs - enable interrupt lines disabled by suspend_device_irqs()
- *
- * Enable all interrupt lines previously disabled by suspend_device_irqs() that
- * have the IRQS_SUSPENDED flag set.
- */
-void resume_device_irqs(void)
+static void resume_irqs(bool want_early)
 {
 	struct irq_desc *desc;
 	int irq;
 
 	for_each_irq_desc(irq, desc) {
 		unsigned long flags;
+		bool is_early = desc->action &&
+			desc->action->flags & IRQF_EARLY_RESUME;
+
+		if (is_early != want_early)
+			continue;
 
 		raw_spin_lock_irqsave(&desc->lock, flags);
 		__enable_irq(desc, irq, true);
 		raw_spin_unlock_irqrestore(&desc->lock, flags);
 	}
 }
+
+/**
+ * irq_pm_syscore_ops - enable interrupt lines early
+ *
+ * Enable all interrupt lines with %IRQF_EARLY_RESUME set.
+ */
+static void irq_pm_syscore_resume(void)
+{
+	resume_irqs(true);
+}
+
+static struct syscore_ops irq_pm_syscore_ops = {
+	.resume		= irq_pm_syscore_resume,
+};
+
+static int __init irq_pm_init_ops(void)
+{
+	register_syscore_ops(&irq_pm_syscore_ops);
+	return 0;
+}
+
+device_initcall(irq_pm_init_ops);
+
+/**
+ * resume_device_irqs - enable interrupt lines disabled by suspend_device_irqs()
+ *
+ * Enable all non-%IRQF_EARLY_RESUME interrupt lines previously
+ * disabled by suspend_device_irqs() that have the IRQS_SUSPENDED flag
+ * set as well as those with %IRQF_FORCE_RESUME.
+ */
+void resume_device_irqs(void)
+{
+	resume_irqs(false);
+}
 EXPORT_SYMBOL_GPL(resume_device_irqs);
 
 /**
Signature · 1 line
1.7.3.4
#2 lore raw

Hi Greg,

Quoted 2 lines · Greg KH

If someone wants this in .32-stable, can they provide me a backported version, as this doesn't backport very easily (i.e. I tried and failed.)

Please see <[email protected]> which contains a backported version of the patch.

Stefan Bader reported that he was still having some issues even with this patch which I haven't had a chance to investigate fully, however I think the patch is correct in its own right.

Ian.

Quoted 149 lines

thanks,

greg k-h

Quoted 143 lines · Gregs git-bot

commit: 9bab0b7fbaceec47d32db51cd9e59c82fb071f5a
From: Ian Campbell <[email protected]>
Date: Mon, 3 Oct 2011 15:37:00 +0100
Subject: 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 676dc3cf5bc3 "xen: Use IRQF_FORCE_RESUME".

Cc Rafael J. Wysocki <[email protected]>
Cc Jeremy Fitzhardinge <[email protected]>
Cc xen-devel <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc [email protected] (at least to 2.6.32.y)
---
 drivers/xen/events.c      |    2 +-
 include/linux/interrupt.h |    3 ++
 kernel/irq/pm.c           |   48 ++++++++++++++++++++++++++++++++++++++------
 3 files changed, 45 insertions(+), 8 deletions(-)
drivers/xen/events.c +1 -1
index da70f5c..a758bc1 100644
@@ -1021,7 +1021,7 @@ int bind_ipi_to_irqhandler(enum ipi_vector ipi,
 	if (irq < 0)
 		return irq;
 
-	irqflags |= IRQF_NO_SUSPEND | IRQF_FORCE_RESUME;
+	irqflags |= IRQF_NO_SUSPEND | IRQF_FORCE_RESUME | IRQF_EARLY_RESUME;
 	retval = request_irq(irq, handler, irqflags, devname, dev_id);
 	if (retval != 0) {
 		unbind_from_irq(irq);
include/linux/interrupt.h +3 -0
index 664544f..a64b00e 100644
@@ -59,6 +59,8 @@
  * IRQF_NO_SUSPEND - Do not disable this IRQ during suspend
  * IRQF_FORCE_RESUME - Force enable it on resume even if IRQF_NO_SUSPEND is set
  * IRQF_NO_THREAD - Interrupt cannot be threaded
+ * IRQF_EARLY_RESUME - Resume IRQ early during syscore instead of at device
+ *                resume time.
  */
 #define IRQF_DISABLED		0x00000020
 #define IRQF_SAMPLE_RANDOM	0x00000040
@@ -72,6 +74,7 @@
 #define IRQF_NO_SUSPEND		0x00004000
 #define IRQF_FORCE_RESUME	0x00008000
 #define IRQF_NO_THREAD		0x00010000
+#define IRQF_EARLY_RESUME	0x00020000
 
 #define IRQF_TIMER		(__IRQF_TIMER | IRQF_NO_SUSPEND | IRQF_NO_THREAD)
 
kernel/irq/pm.c +41 -7
index f76fc00..15e53b1 100644
@@ -9,6 +9,7 @@
 #include <linux/irq.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
+#include <linux/syscore_ops.h>
 
 #include "internals.h"
 
@@ -39,25 +40,58 @@ void suspend_device_irqs(void)
 }
 EXPORT_SYMBOL_GPL(suspend_device_irqs);
 
-/**
- * resume_device_irqs - enable interrupt lines disabled by suspend_device_irqs()
- *
- * Enable all interrupt lines previously disabled by suspend_device_irqs() that
- * have the IRQS_SUSPENDED flag set.
- */
-void resume_device_irqs(void)
+static void resume_irqs(bool want_early)
 {
 	struct irq_desc *desc;
 	int irq;
 
 	for_each_irq_desc(irq, desc) {
 		unsigned long flags;
+		bool is_early = desc->action &&
+			desc->action->flags & IRQF_EARLY_RESUME;
+
+		if (is_early != want_early)
+			continue;
 
 		raw_spin_lock_irqsave(&desc->lock, flags);
 		__enable_irq(desc, irq, true);
 		raw_spin_unlock_irqrestore(&desc->lock, flags);
 	}
 }
+
+/**
+ * irq_pm_syscore_ops - enable interrupt lines early
+ *
+ * Enable all interrupt lines with %IRQF_EARLY_RESUME set.
+ */
+static void irq_pm_syscore_resume(void)
+{
+	resume_irqs(true);
+}
+
+static struct syscore_ops irq_pm_syscore_ops = {
+	.resume		= irq_pm_syscore_resume,
+};
+
+static int __init irq_pm_init_ops(void)
+{
+	register_syscore_ops(&irq_pm_syscore_ops);
+	return 0;
+}
+
+device_initcall(irq_pm_init_ops);
+
+/**
+ * resume_device_irqs - enable interrupt lines disabled by suspend_device_irqs()
+ *
+ * Enable all non-%IRQF_EARLY_RESUME interrupt lines previously
+ * disabled by suspend_device_irqs() that have the IRQS_SUSPENDED flag
+ * set as well as those with %IRQF_FORCE_RESUME.
+ */
+void resume_device_irqs(void)
+{
+	resume_irqs(false);
+}
 EXPORT_SYMBOL_GPL(resume_device_irqs);
 
 /**
Signature · 1 line
1.7.3.4
author
#3 lore raw
Quoted 8 lines · Ian Campbell

Hi Greg,

Quoted 2 lines · Greg KH

If someone wants this in .32-stable, can they provide me a backported version, as this doesn't backport very easily (i.e. I tried and failed.)

Please see <[email protected]> which contains a backported version of the patch.

Hm, any chance you could forward that to me? I don't see it in my archives and my google-foo doesn't seem to turn it up either :(

thanks,

greg k-h

#4 lore raw
Quoted 4 lines · Greg KH
Quoted 3 lines · Ian Campbell

Hi Greg,

On Tue, 2011-11-01 at 19:09 -0400, Greg KH wrote:

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

If someone wants this in .32-stable, can they provide me a backported version, as this doesn't backport very easily (i.e. I tried and failed.)

Please see <[email protected]> which contains a backported version of the patch.

Hm, any chance you could forward that to me? I don't see it in my archives and my google-foo doesn't seem to turn it up either :(

I seem to have sent it only to stable@ and not to you direct, sorry. I've just bounced you a copy.

Ian.

author
#5 lore raw
Quoted 8 lines · Ian Campbell
Quoted 7 lines · Greg KH
Quoted 6 lines · Ian Campbell

Hi Greg,

Quoted 2 lines · Greg KH

If someone wants this in .32-stable, can they provide me a backported version, as this doesn't backport very easily (i.e. I tried and failed.)

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Please see <[email protected]> which contains a backported version of the patch.

Hm, any chance you could forward that to me? I don't see it in my archives and my google-foo doesn't seem to turn it up either :(

I seem to have sent it only to stable@ and not to you direct, sorry. I've just bounced you a copy.

Wonderful, I now have it and will go queue it up.

greg k-h