Skip to contentSkip to conversation

genirq: update irq_chip struct comment for irq_chip->disable hook

PATCH New Kevin Hilman 3 participants 16 messages May 7, 2009 – May 11, 2009 IRQ

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 genirq: update irq_chip struct comment for irq_chip->disable hook

The irq_chip disable hook no longer defaults to a irq_chip->unmask.

---
 include/linux/irq.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/linux/irq.h +1 -1
index b7cbeed..3674046 100644
@@ -88,7 +88,7 @@ struct msi_desc;
  * @startup:		start up the interrupt (defaults to ->enable if NULL)
  * @shutdown:		shut down the interrupt (defaults to ->disable if NULL)
  * @enable:		enable the interrupt (defaults to chip->unmask if NULL)
- * @disable:		disable the interrupt (defaults to chip->mask if NULL)
+ * @disable:		disable the interrupt
  * @ack:		start of a new interrupt
  * @mask:		mask an interrupt source
  * @mask_ack:		ack and mask an interrupt source
Signature · 1 line
1.6.2.2
#1 lore raw

PATCH 1/1 genirq: ensure IRQs are lazy disabled before suspend

In commit 76d2160147f43f982dfe881404cfde9fd0a9da21, the default behavior of disable_irq() was changed to delay the disable until it is next handled.

However, this leaves open the possibility that the system can go into suspend with an interrupt enabled. For example, if a driver calls disable_irq() in its suspend_hook (for example, to prevent that device IRQ from causing a system wakeup) there's now a possibility that the system is suspended before the lazy disable happens.

The result is an unwanted wakeup from suspend if the IRQ is capable of waking the system (common on embedded SoCs.)

This patch ensures that the lazy disable is done, and masked by the irq_chip before the system goes into suspend.

Note that even though __disable_irq() also calls irq_chip->disable, it is quite common for the irq_chip not to provide a disable hook in which case the IRQ is never masked/disabled in hardware before going into suspend.

---
 kernel/irq/manage.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
kernel/irq/manage.c +5 -0
index 2734eca..5d2cc1c 100644
@@ -190,6 +190,11 @@ void __disable_irq(struct irq_desc *desc, unsigned int irq, bool suspend)
 		if (!desc->action || (desc->action->flags & IRQF_TIMER))
 			return;
 		desc->status |= IRQ_SUSPENDED;
+
+		/* Lazy disable: handles case where lazy disable in
+		 * handler doesn't happen before suspend. */
+		if (desc->status & IRQ_DISABLED)
+			desc->chip->mask(irq);
 	}
 
 	if (!desc->depth++) {
Signature · 1 line
1.6.2.2
#2 lore raw

PATCH 1/1 genirq: ensure IRQs are lazy disabled before suspend

In reply to Kevin Hilman

In commit 76d2160147f43f982dfe881404cfde9fd0a9da21, the default behavior of disable_irq() was changed to delay the disable until it is next handled.

However, this leaves open the possibility that the system can go into suspend with an interrupt enabled. For example, if a driver calls disable_irq() in its suspend_hook (for example, to prevent that device IRQ from causing a system wakeup) there's now a possibility that the system is suspended before the lazy disable happens.

The result is an unwanted wakeup from suspend if the IRQ is capable of waking the system (common on embedded SoCs.)

This patch ensures that the lazy disable is done, and masked by the irq_chip before the system goes into suspend.

Note that even though __disable_irq() also calls irq_chip->disable, it is quite common for the irq_chip not to provide a disable hook in which case the IRQ is never masked/disabled in hardware before going into suspend.

---
 kernel/irq/manage.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
kernel/irq/manage.c +5 -0
index 2734eca..5d2cc1c 100644
@@ -190,6 +190,11 @@ void __disable_irq(struct irq_desc *desc, unsigned int irq, bool suspend)
 		if (!desc->action || (desc->action->flags & IRQF_TIMER))
 			return;
 		desc->status |= IRQ_SUSPENDED;
+
+		/* Lazy disable: handles case where lazy disable in
+		 * handler doesn't happen before suspend. */
+		if (desc->status & IRQ_DISABLED)
+			desc->chip->mask(irq);
 	}
 
 	if (!desc->depth++) {
Signature · 1 line
1.6.2.2
#3 lore raw

Re: [PATCH] genirq: ensure IRQs are lazy disabled before suspend

Quoted 31 lines · Kevin Hilman

In commit 76d2160147f43f982dfe881404cfde9fd0a9da21, the default behavior of disable_irq() was changed to delay the disable until it is next handled.

However, this leaves open the possibility that the system can go into suspend with an interrupt enabled. For example, if a driver calls disable_irq() in its suspend_hook (for example, to prevent that device IRQ from causing a system wakeup) there's now a possibility that the system is suspended before the lazy disable happens.

The result is an unwanted wakeup from suspend if the IRQ is capable of waking the system (common on embedded SoCs.)

This patch ensures that the lazy disable is done, and masked by the irq_chip before the system goes into suspend.

Note that even though __disable_irq() also calls irq_chip->disable, it is quite common for the irq_chip not to provide a disable hook in which case the IRQ is never masked/disabled in hardware before going into suspend.

---
 kernel/irq/manage.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
kernel/irq/manage.c +0 -0
index 2734eca..5d2cc1c 100644

kernel/irq/manage.c void __disable_irq(struct irq_desc *desc, unsigned int irq, bool suspend) · line 197

Quoted 8 lines
kernel/irq/manage.c +5 -0
@@ -190,6 +190,11 @@ void __disable_irq(struct irq_desc *desc, unsigned int irq, bool suspend)
 		if (!desc->action || (desc->action->flags & IRQF_TIMER))
 			return;
 		desc->status |= IRQ_SUSPENDED;
+
+		/* Lazy disable: handles case where lazy disable in
+		 * handler doesn't happen before suspend. */
+		if (desc->status & IRQ_DISABLED)
+			desc->chip->mask(irq);

Please look at the rest of the file and follow the multi-line comment style that is used in the 29 multi-line comment instances there. (which is also what Documentation/CodingStyle specifies)

Ingo

#4 lore raw

Re: [PATCH] genirq: ensure IRQs are lazy disabled before suspend

In reply to Kevin Hilman
Quoted 31 lines · Kevin Hilman

In commit 76d2160147f43f982dfe881404cfde9fd0a9da21, the default behavior of disable_irq() was changed to delay the disable until it is next handled.

However, this leaves open the possibility that the system can go into suspend with an interrupt enabled. For example, if a driver calls disable_irq() in its suspend_hook (for example, to prevent that device IRQ from causing a system wakeup) there's now a possibility that the system is suspended before the lazy disable happens.

The result is an unwanted wakeup from suspend if the IRQ is capable of waking the system (common on embedded SoCs.)

This patch ensures that the lazy disable is done, and masked by the irq_chip before the system goes into suspend.

Note that even though __disable_irq() also calls irq_chip->disable, it is quite common for the irq_chip not to provide a disable hook in which case the IRQ is never masked/disabled in hardware before going into suspend.

---
 kernel/irq/manage.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
kernel/irq/manage.c +0 -0
index 2734eca..5d2cc1c 100644

kernel/irq/manage.c void __disable_irq(struct irq_desc *desc, unsigned int irq, bool suspend) · line 197

Quoted 8 lines
kernel/irq/manage.c +5 -0
@@ -190,6 +190,11 @@ void __disable_irq(struct irq_desc *desc, unsigned int irq, bool suspend)
 		if (!desc->action || (desc->action->flags & IRQF_TIMER))
 			return;
 		desc->status |= IRQ_SUSPENDED;
+
+		/* Lazy disable: handles case where lazy disable in
+		 * handler doesn't happen before suspend. */
+		if (desc->status & IRQ_DISABLED)
+			desc->chip->mask(irq);

Please look at the rest of the file and follow the multi-line comment style that is used in the 29 multi-line comment instances there. (which is also what Documentation/CodingStyle specifies)

Ingo

#5 lore raw

Re: [PATCH] genirq: ensure IRQs are lazy disabled before suspend

Quoted 2 lines · Ingo Molnar

* Kevin Hilman <[email protected]> wrote:

[...]

Quoted 7 lines
Quoted 7 lines
kernel/irq/manage.c +1 -0
@@ -190,6 +190,11 @@ void __disable_irq(struct irq_desc *desc, unsigned int irq, bool suspend)
 		if (!desc->action || (desc->action->flags & IRQF_TIMER))
 			return;
 		desc->status |= IRQ_SUSPENDED;
+
Quoted 8 lines

kernel/irq/manage.c void __disable_irq(struct irq_desc *desc, unsigned int irq, bool suspend) · line 197

Quoted 4 lines
kernel/irq/manage.c +4 -0
+		/* Lazy disable: handles case where lazy disable in
+		 * handler doesn't happen before suspend. */
+		if (desc->status & IRQ_DISABLED)
+			desc->chip->mask(irq);

Please look at the rest of the file and follow the multi-line comment style that is used in the 29 multi-line comment instances there. (which is also what Documentation/CodingStyle specifies)

Doh, sorry. Updated patch below.

Kevin

Quoted 1 line

From a3f359c66bd0ae1bb2603e7cf120d9d4d68591b7 Mon Sep 17 00:00:00 2001

From: Kevin Hilman <[email protected]>
Date: Wed, 6 May 2009 16:00:07 -0700
Subject: [PATCH] genirq: ensure IRQs are lazy disabled before suspend

In commit 76d2160147f43f982dfe881404cfde9fd0a9da21, the default behavior of disable_irq() was changed to delay the disable until it is next handled.

However, this leaves open the possibility that the system can go into suspend with an interrupt enabled. For example, if a driver calls disable_irq() in its suspend_hook there's now a possibility that the system is suspended before the lazy disable happens.

The result is an unwanted wakeup from suspend if the IRQ is capable of waking the system (common on embedded SoCs.)

This patch ensures that the lazy disable is done, and masked by the irq_chip before the system goes into suspend.

Note that even though __disable_irq() also calls irq_chip->disable, it is quite common for the irq_chip not to provide a disable hook in which case the IRQ is never masked/disabled in hardware before going into suspend.

---
 kernel/irq/manage.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
kernel/irq/manage.c +7 -0
index 2734eca..c786820 100644
@@ -190,6 +190,13 @@ void __disable_irq(struct irq_desc *desc, unsigned int irq, bool suspend)
 		if (!desc->action || (desc->action->flags & IRQF_TIMER))
 			return;
 		desc->status |= IRQ_SUSPENDED;
+
+		/*
+		 * Lazy disable: handles case where lazy disable in
+		 * handler doesn't happen before suspend.
+		 */
+		if (desc->status & IRQ_DISABLED)
+			desc->chip->mask(irq);
 	}
 
 	if (!desc->depth++) {
Signature · 1 line
1.6.2.2
#6 lore raw

Re: [PATCH] genirq: ensure IRQs are lazy disabled before suspend

In reply to Ingo Molnar
Quoted 2 lines · Ingo Molnar

* Kevin Hilman <[email protected]> wrote:

[...]

Quoted 7 lines
Quoted 7 lines
kernel/irq/manage.c +1 -0
@@ -190,6 +190,11 @@ void __disable_irq(struct irq_desc *desc, unsigned int irq, bool suspend)
 		if (!desc->action || (desc->action->flags & IRQF_TIMER))
 			return;
 		desc->status |= IRQ_SUSPENDED;
+
Quoted 8 lines

kernel/irq/manage.c void __disable_irq(struct irq_desc *desc, unsigned int irq, bool suspend) · line 197

Quoted 4 lines
kernel/irq/manage.c +4 -0
+		/* Lazy disable: handles case where lazy disable in
+		 * handler doesn't happen before suspend. */
+		if (desc->status & IRQ_DISABLED)
+			desc->chip->mask(irq);

Please look at the rest of the file and follow the multi-line comment style that is used in the 29 multi-line comment instances there. (which is also what Documentation/CodingStyle specifies)

Doh, sorry. Updated patch below.

Kevin

Quoted 1 line

From a3f359c66bd0ae1bb2603e7cf120d9d4d68591b7 Mon Sep 17 00:00:00 2001

From: Kevin Hilman <[email protected]>
Date: Wed, 6 May 2009 16:00:07 -0700
Subject: [PATCH] genirq: ensure IRQs are lazy disabled before suspend

In commit 76d2160147f43f982dfe881404cfde9fd0a9da21, the default behavior of disable_irq() was changed to delay the disable until it is next handled.

However, this leaves open the possibility that the system can go into suspend with an interrupt enabled. For example, if a driver calls disable_irq() in its suspend_hook there's now a possibility that the system is suspended before the lazy disable happens.

The result is an unwanted wakeup from suspend if the IRQ is capable of waking the system (common on embedded SoCs.)

This patch ensures that the lazy disable is done, and masked by the irq_chip before the system goes into suspend.

Note that even though __disable_irq() also calls irq_chip->disable, it is quite common for the irq_chip not to provide a disable hook in which case the IRQ is never masked/disabled in hardware before going into suspend.

---
 kernel/irq/manage.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
kernel/irq/manage.c +7 -0
index 2734eca..c786820 100644
@@ -190,6 +190,13 @@ void __disable_irq(struct irq_desc *desc, unsigned int irq, bool suspend)
 		if (!desc->action || (desc->action->flags & IRQF_TIMER))
 			return;
 		desc->status |= IRQ_SUSPENDED;
+
+		/*
+		 * Lazy disable: handles case where lazy disable in
+		 * handler doesn't happen before suspend.
+		 */
+		if (desc->status & IRQ_DISABLED)
+			desc->chip->mask(irq);
 	}
 
 	if (!desc->depth++) {
Signature · 1 line
1.6.2.2
#7 lore raw

Re: [PATCH] genirq: ensure IRQs are lazy disabled before suspend

Quoted 9 lines · Kevin Hilman

From a3f359c66bd0ae1bb2603e7cf120d9d4d68591b7 Mon Sep 17 00:00:00 2001
From: Kevin Hilman <[email protected]>
Date: Wed, 6 May 2009 16:00:07 -0700
Subject: [PATCH] genirq: ensure IRQs are lazy disabled before suspend

In commit 76d2160147f43f982dfe881404cfde9fd0a9da21, the default behavior of disable_irq() was changed to delay the disable until it is next handled.

Quoted 7 lines

However, this leaves open the possibility that the system can go into suspend with an interrupt enabled.  For example, if a driver calls disable_irq() in its suspend_hook there's now a possibility that the system is suspended before the lazy disable happens.

The result is an unwanted wakeup from suspend if the IRQ is capable of waking the system (common on embedded SoCs.)

If the interrupt contoller uses the same enable register for wakeup and interrupts, I think it is the responsibility of the platform code, not individual drivers, to disable the interrupts that are not marked for wakeup before entering suspend.

Quoted 2 lines

This patch ensures that the lazy disable is done, and masked by the irq_chip before the system goes into suspend.

This will create a window where wakeup interrupts can be lost if the driver has masked the interrupt (by calling disable_irq). If the hardware does not allow edge detection on disabled interrupts (the msm platform has this limitation) then this change will turn off the edge detection. If suspend_ops->enter does not turn the interrupt (and edge detection) back on (without this change it may never need to turn on any interrupt) it will not wakeup at all.

Quoted 37 lines

Note that even though __disable_irq() also calls irq_chip->disable, it is quite common for the irq_chip not to provide a disable hook in which case the IRQ is never masked/disabled in hardware before going into suspend.

---
 kernel/irq/manage.c |    7 +++++++

 1 files changed, 7 insertions(+), 0 deletions(-)
kernel/irq/manage.c +7 -1
index 2734eca..c786820 100644
@@ -190,6 +190,13 @@ void __disable_irq(struct irq_desc *desc, unsigned int irq, bool suspend)
                if (!desc->action || (desc->action->flags & IRQF_TIMER))
                        return;
                desc->status |= IRQ_SUSPENDED;
+
+               /*
+                * Lazy disable: handles case where lazy disable in
+                * handler doesn't happen before suspend.
+                */
+               if (desc->status & IRQ_DISABLED)
+                       desc->chip->mask(irq);
        }
 
        if (!desc->depth++) {
--

1.6.2.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Signature · 1 line
Arve Hjønnevåg
#8 lore raw

Re: [PATCH] genirq: ensure IRQs are lazy disabled before suspend

In reply to Kevin Hilman
Quoted 9 lines · Kevin Hilman

From a3f359c66bd0ae1bb2603e7cf120d9d4d68591b7 Mon Sep 17 00:00:00 2001
From: Kevin Hilman <[email protected]>
Date: Wed, 6 May 2009 16:00:07 -0700
Subject: [PATCH] genirq: ensure IRQs are lazy disabled before suspend

In commit 76d2160147f43f982dfe881404cfde9fd0a9da21, the default behavior of disable_irq() was changed to delay the disable until it is next handled.

Quoted 7 lines

However, this leaves open the possibility that the system can go into suspend with an interrupt enabled.  For example, if a driver calls disable_irq() in its suspend_hook there's now a possibility that the system is suspended before the lazy disable happens.

The result is an unwanted wakeup from suspend if the IRQ is capable of waking the system (common on embedded SoCs.)

If the interrupt contoller uses the same enable register for wakeup and interrupts, I think it is the responsibility of the platform code, not individual drivers, to disable the interrupts that are not marked for wakeup before entering suspend.

Quoted 2 lines

This patch ensures that the lazy disable is done, and masked by the irq_chip before the system goes into suspend.

This will create a window where wakeup interrupts can be lost if the driver has masked the interrupt (by calling disable_irq). If the hardware does not allow edge detection on disabled interrupts (the msm platform has this limitation) then this change will turn off the edge detection. If suspend_ops->enter does not turn the interrupt (and edge detection) back on (without this change it may never need to turn on any interrupt) it will not wakeup at all.

Quoted 37 lines

Note that even though __disable_irq() also calls irq_chip->disable, it is quite common for the irq_chip not to provide a disable hook in which case the IRQ is never masked/disabled in hardware before going into suspend.

---
 kernel/irq/manage.c |    7 +++++++

 1 files changed, 7 insertions(+), 0 deletions(-)
kernel/irq/manage.c +7 -1
index 2734eca..c786820 100644
@@ -190,6 +190,13 @@ void __disable_irq(struct irq_desc *desc, unsigned int irq, bool suspend)
                if (!desc->action || (desc->action->flags & IRQF_TIMER))
                        return;
                desc->status |= IRQ_SUSPENDED;
+
+               /*
+                * Lazy disable: handles case where lazy disable in
+                * handler doesn't happen before suspend.
+                */
+               if (desc->status & IRQ_DISABLED)
+                       desc->chip->mask(irq);
        }
 
        if (!desc->depth++) {
--

1.6.2.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Signature · 1 line
Arve Hjønnevåg
#9 lore raw

Re: [PATCH] genirq: ensure IRQs are lazy disabled before suspend

Quoted 16 lines · Arve Hjønnevåg
Quoted 14 lines · Kevin Hilman

From a3f359c66bd0ae1bb2603e7cf120d9d4d68591b7 Mon Sep 17 00:00:00 2001
From: Kevin Hilman <[email protected]>
Date: Wed, 6 May 2009 16:00:07 -0700
Subject: [PATCH] genirq: ensure IRQs are lazy disabled before suspend

In commit 76d2160147f43f982dfe881404cfde9fd0a9da21, the default behavior of disable_irq() was changed to delay the disable until it is next handled.

However, this leaves open the possibility that the system can go into suspend with an interrupt enabled.  For example, if a driver calls disable_irq() in its suspend_hook there's now a possibility that the system is suspended before the lazy disable happens.

Quoted 7 lines
Quoted 2 lines

The result is an unwanted wakeup from suspend if the IRQ is capable of waking the system (common on embedded SoCs.)

If the interrupt contoller uses the same enable register for wakeup and interrupts, I think it is the responsibility of the platform code, not individual drivers, to disable the interrupts that are not marked for wakeup before entering suspend.

I agree, for wakeup interrupts, drivers should use [set|disable]_irq_wake() and the platform code should handle this.

I used wakeup interrupts in this description as an example which turned out to be a bad example. The 2nd version of this patch I posted, I removed the reference to wakeup interrupts in favor of just talking about the delayed disable piece.

But ignoring wakup interrupts, would you agree that the delayed disable of an interrupt should not wait until after resume?

Quoted 10 lines
Quoted 2 lines

This patch ensures that the lazy disable is done, and masked by the irq_chip before the system goes into suspend.

This will create a window where wakeup interrupts can be lost if the driver has masked the interrupt (by calling disable_irq). If the hardware does not allow edge detection on disabled interrupts (the msm platform has this limitation) then this change will turn off the edge detection. If suspend_ops->enter does not turn the interrupt (and edge detection) back on (without this change it may never need to turn on any interrupt) it will not wakeup at all.

Not sure I follow you here...

It seems like you're relying on the delayed disable to wait until after resume so that disabled interrupts can wake the system. How did this work before the delayed disable patch?

If the interrupt is being used as a wakeup, why would anyone be calling disable_irq()?

Kevin

#10 lore raw

Re: [PATCH] genirq: ensure IRQs are lazy disabled before suspend

In reply to Arve Hjønnevåg
Quoted 16 lines · Arve Hjønnevåg
Quoted 14 lines · Kevin Hilman

From a3f359c66bd0ae1bb2603e7cf120d9d4d68591b7 Mon Sep 17 00:00:00 2001
From: Kevin Hilman <[email protected]>
Date: Wed, 6 May 2009 16:00:07 -0700
Subject: [PATCH] genirq: ensure IRQs are lazy disabled before suspend

In commit 76d2160147f43f982dfe881404cfde9fd0a9da21, the default behavior of disable_irq() was changed to delay the disable until it is next handled.

However, this leaves open the possibility that the system can go into suspend with an interrupt enabled.  For example, if a driver calls disable_irq() in its suspend_hook there's now a possibility that the system is suspended before the lazy disable happens.

Quoted 7 lines
Quoted 2 lines

The result is an unwanted wakeup from suspend if the IRQ is capable of waking the system (common on embedded SoCs.)

If the interrupt contoller uses the same enable register for wakeup and interrupts, I think it is the responsibility of the platform code, not individual drivers, to disable the interrupts that are not marked for wakeup before entering suspend.

I agree, for wakeup interrupts, drivers should use [set|disable]_irq_wake() and the platform code should handle this.

I used wakeup interrupts in this description as an example which turned out to be a bad example. The 2nd version of this patch I posted, I removed the reference to wakeup interrupts in favor of just talking about the delayed disable piece.

But ignoring wakup interrupts, would you agree that the delayed disable of an interrupt should not wait until after resume?

Quoted 10 lines
Quoted 2 lines

This patch ensures that the lazy disable is done, and masked by the irq_chip before the system goes into suspend.

This will create a window where wakeup interrupts can be lost if the driver has masked the interrupt (by calling disable_irq). If the hardware does not allow edge detection on disabled interrupts (the msm platform has this limitation) then this change will turn off the edge detection. If suspend_ops->enter does not turn the interrupt (and edge detection) back on (without this change it may never need to turn on any interrupt) it will not wakeup at all.

Not sure I follow you here...

It seems like you're relying on the delayed disable to wait until after resume so that disabled interrupts can wake the system. How did this work before the delayed disable patch?

If the interrupt is being used as a wakeup, why would anyone be calling disable_irq()?

Kevin

#11 lore raw

Re: [PATCH] genirq: ensure IRQs are lazy disabled before suspend

2009/5/8 Kevin Hilman <[email protected]>:

Quoted 29 lines
Quoted 16 lines · Arve Hjønnevåg
Quoted 14 lines · Kevin Hilman

From a3f359c66bd0ae1bb2603e7cf120d9d4d68591b7 Mon Sep 17 00:00:00 2001
From: Kevin Hilman <[email protected]>
Date: Wed, 6 May 2009 16:00:07 -0700
Subject: [PATCH] genirq: ensure IRQs are lazy disabled before suspend

In commit 76d2160147f43f982dfe881404cfde9fd0a9da21, the default behavior of disable_irq() was changed to delay the disable until it is next handled.

However, this leaves open the possibility that the system can go into suspend with an interrupt enabled.  For example, if a driver calls disable_irq() in its suspend_hook there's now a possibility that the system is suspended before the lazy disable happens.

Quoted 7 lines
Quoted 2 lines

The result is an unwanted wakeup from suspend if the IRQ is capable of waking the system (common on embedded SoCs.)

If the interrupt contoller uses the same enable register for wakeup and interrupts, I think it is the responsibility of the platform code, not individual drivers, to disable the interrupts that are not marked for wakeup before entering suspend.

I agree, for wakeup interrupts, drivers should use [set|disable]_irq_wake() and the platform code should handle this.

Quoted 8 lines

I used wakeup interrupts in this description as an example which turned out to be a bad example.  The 2nd version of this patch I posted, I removed the reference to wakeup interrupts in favor of just talking about the delayed disable piece.

But ignoring wakup interrupts, would you agree that the delayed disable of an interrupt should not wait until after resume?

No. The platform code needs to turn off interrupts that are not wakeup interrupts anyway, so there is not much point in disabling some interrupts early. Also, if the interrupt in question is not a wakeup interrupt you leave it in a state where it does not detect an edge. A driver that enables its hardware in resume, then unmasks the interrupt would loose an interrupt that triggered between enabling the hardware and unmasking the interrupt.

Quoted 11 lines
Quoted 10 lines
Quoted 2 lines

This patch ensures that the lazy disable is done, and masked by the irq_chip before the system goes into suspend.

This will create a window where wakeup interrupts can be lost if the driver has masked the interrupt (by calling disable_irq). If the hardware does not allow edge detection on disabled interrupts (the msm platform has this limitation) then this change will turn off the edge detection. If suspend_ops->enter does not turn the interrupt (and edge detection) back on (without this change it may never need to turn on any interrupt) it will not wakeup at all.

Quoted 6 lines

Not sure I follow you here...

It seems like you're relying on the delayed disable to wait until after resume so that disabled interrupts can wake the system.  How did this work before the delayed disable patch?

It did not.

Quoted 3 lines

If the interrupt is being used as a wakeup, why would anyone be calling disable_irq()?

Drivers call disable_irq to make sure their interrupt handler does not get called. A driver may not be able take interrupts after its suspend hook has been called. If it calls disable_irq on a wakeup interrupt then this interrupt should abort suspend or wake up from suspend. The driver will then see the interrupt when it call enable_irq in its resume handler.

Signature · 1 line
Arve Hjønnevåg
#12 lore raw

Re: [PATCH] genirq: ensure IRQs are lazy disabled before suspend

Quoted 39 lines · Arve Hjønnevåg

2009/5/8 Kevin Hilman <[email protected]>:

Quoted 29 lines
Quoted 16 lines · Arve Hjønnevåg
Quoted 14 lines · Kevin Hilman

From a3f359c66bd0ae1bb2603e7cf120d9d4d68591b7 Mon Sep 17 00:00:00 2001
From: Kevin Hilman <[email protected]>
Date: Wed, 6 May 2009 16:00:07 -0700
Subject: [PATCH] genirq: ensure IRQs are lazy disabled before suspend

In commit 76d2160147f43f982dfe881404cfde9fd0a9da21, the default behavior of disable_irq() was changed to delay the disable until it is next handled.

However, this leaves open the possibility that the system can go into suspend with an interrupt enabled.  For example, if a driver calls disable_irq() in its suspend_hook there's now a possibility that the system is suspended before the lazy disable happens.

Quoted 7 lines
Quoted 2 lines

The result is an unwanted wakeup from suspend if the IRQ is capable of waking the system (common on embedded SoCs.)

If the interrupt contoller uses the same enable register for wakeup and interrupts, I think it is the responsibility of the platform code, not individual drivers, to disable the interrupts that are not marked for wakeup before entering suspend.

I agree, for wakeup interrupts, drivers should use [set|disable]_irq_wake() and the platform code should handle this.

Quoted 8 lines

I used wakeup interrupts in this description as an example which turned out to be a bad example.  The 2nd version of this patch I posted, I removed the reference to wakeup interrupts in favor of just talking about the delayed disable piece.

But ignoring wakup interrupts, would you agree that the delayed disable of an interrupt should not wait until after resume?

Quoted 7 lines

No. The platform code needs to turn off interrupts that are not wakeup interrupts anyway, so there is not much point in disabling some interrupts early. Also, if the interrupt in question is not a wakeup interrupt you leave it in a state where it does not detect an edge. A driver that enables its hardware in resume, then unmasks the interrupt would loose an interrupt that triggered between enabling the hardware and unmasking the interrupt.

Got it. Thanks for your (repeated) explanations. I understand now your reasons for allowing the interrupt to remain across suspend. I will modify my platform to rely on [enable|disable]_irq_wake() in addition to ensuring platform code is disabling non wakup IRQs.

Quoted 24 lines
Quoted 11 lines
Quoted 10 lines
Quoted 2 lines

This patch ensures that the lazy disable is done, and masked by the irq_chip before the system goes into suspend.

This will create a window where wakeup interrupts can be lost if the driver has masked the interrupt (by calling disable_irq). If the hardware does not allow edge detection on disabled interrupts (the msm platform has this limitation) then this change will turn off the edge detection. If suspend_ops->enter does not turn the interrupt (and edge detection) back on (without this change it may never need to turn on any interrupt) it will not wakeup at all.

Quoted 6 lines

Not sure I follow you here...

It seems like you're relying on the delayed disable to wait until after resume so that disabled interrupts can wake the system.  How did this work before the delayed disable patch?

It did not.

Quoted 3 lines

If the interrupt is being used as a wakeup, why would anyone be calling disable_irq()?

Quoted 6 lines

Drivers call disable_irq to make sure their interrupt handler does not get called. A driver may not be able take interrupts after its suspend hook has been called. If it calls disable_irq on a wakeup interrupt then this interrupt should abort suspend or wake up from suspend. The driver will then see the interrupt when it call enable_irq in its resume handler.

OK.

Kevin

#13 lore raw

Re: [PATCH] genirq: ensure IRQs are lazy disabled before suspend

In reply to Arve Hjønnevåg
Quoted 39 lines · Arve Hjønnevåg

2009/5/8 Kevin Hilman <[email protected]>:

Quoted 29 lines
Quoted 16 lines · Arve Hjønnevåg
Quoted 14 lines · Kevin Hilman

From a3f359c66bd0ae1bb2603e7cf120d9d4d68591b7 Mon Sep 17 00:00:00 2001
From: Kevin Hilman <[email protected]>
Date: Wed, 6 May 2009 16:00:07 -0700
Subject: [PATCH] genirq: ensure IRQs are lazy disabled before suspend

In commit 76d2160147f43f982dfe881404cfde9fd0a9da21, the default behavior of disable_irq() was changed to delay the disable until it is next handled.

However, this leaves open the possibility that the system can go into suspend with an interrupt enabled.  For example, if a driver calls disable_irq() in its suspend_hook there's now a possibility that the system is suspended before the lazy disable happens.

Quoted 7 lines
Quoted 2 lines

The result is an unwanted wakeup from suspend if the IRQ is capable of waking the system (common on embedded SoCs.)

If the interrupt contoller uses the same enable register for wakeup and interrupts, I think it is the responsibility of the platform code, not individual drivers, to disable the interrupts that are not marked for wakeup before entering suspend.

I agree, for wakeup interrupts, drivers should use [set|disable]_irq_wake() and the platform code should handle this.

Quoted 8 lines

I used wakeup interrupts in this description as an example which turned out to be a bad example.  The 2nd version of this patch I posted, I removed the reference to wakeup interrupts in favor of just talking about the delayed disable piece.

But ignoring wakup interrupts, would you agree that the delayed disable of an interrupt should not wait until after resume?

Quoted 7 lines

No. The platform code needs to turn off interrupts that are not wakeup interrupts anyway, so there is not much point in disabling some interrupts early. Also, if the interrupt in question is not a wakeup interrupt you leave it in a state where it does not detect an edge. A driver that enables its hardware in resume, then unmasks the interrupt would loose an interrupt that triggered between enabling the hardware and unmasking the interrupt.

Got it. Thanks for your (repeated) explanations. I understand now your reasons for allowing the interrupt to remain across suspend. I will modify my platform to rely on [enable|disable]_irq_wake() in addition to ensuring platform code is disabling non wakup IRQs.

Quoted 24 lines
Quoted 11 lines
Quoted 10 lines
Quoted 2 lines

This patch ensures that the lazy disable is done, and masked by the irq_chip before the system goes into suspend.

This will create a window where wakeup interrupts can be lost if the driver has masked the interrupt (by calling disable_irq). If the hardware does not allow edge detection on disabled interrupts (the msm platform has this limitation) then this change will turn off the edge detection. If suspend_ops->enter does not turn the interrupt (and edge detection) back on (without this change it may never need to turn on any interrupt) it will not wakeup at all.

Quoted 6 lines

Not sure I follow you here...

It seems like you're relying on the delayed disable to wait until after resume so that disabled interrupts can wake the system.  How did this work before the delayed disable patch?

It did not.

Quoted 3 lines

If the interrupt is being used as a wakeup, why would anyone be calling disable_irq()?

Quoted 6 lines

Drivers call disable_irq to make sure their interrupt handler does not get called. A driver may not be able take interrupts after its suspend hook has been called. If it calls disable_irq on a wakeup interrupt then this interrupt should abort suspend or wake up from suspend. The driver will then see the interrupt when it call enable_irq in its resume handler.

OK.

Kevin

#14 lore raw

Re: [PATCH] genirq: ensure IRQs are lazy disabled before suspend

In reply to Arve Hjønnevåg
Quoted 39 lines · Arve Hjønnevåg

2009/5/8 Kevin Hilman <[email protected]>:

Quoted 29 lines
Quoted 16 lines · Arve Hjønnevåg
Quoted 14 lines · Kevin Hilman

From a3f359c66bd0ae1bb2603e7cf120d9d4d68591b7 Mon Sep 17 00:00:00 2001
From: Kevin Hilman <[email protected]>
Date: Wed, 6 May 2009 16:00:07 -0700
Subject: [PATCH] genirq: ensure IRQs are lazy disabled before suspend

In commit 76d2160147f43f982dfe881404cfde9fd0a9da21, the default behavior of disable_irq() was changed to delay the disable until it is next handled.

However, this leaves open the possibility that the system can go into suspend with an interrupt enabled.  For example, if a driver calls disable_irq() in its suspend_hook there's now a possibility that the system is suspended before the lazy disable happens.

Quoted 7 lines
Quoted 2 lines

The result is an unwanted wakeup from suspend if the IRQ is capable of waking the system (common on embedded SoCs.)

If the interrupt contoller uses the same enable register for wakeup and interrupts, I think it is the responsibility of the platform code, not individual drivers, to disable the interrupts that are not marked for wakeup before entering suspend.

I agree, for wakeup interrupts, drivers should use [set|disable]_irq_wake() and the platform code should handle this.

Quoted 8 lines

I used wakeup interrupts in this description as an example which turned out to be a bad example.  The 2nd version of this patch I posted, I removed the reference to wakeup interrupts in favor of just talking about the delayed disable piece.

But ignoring wakup interrupts, would you agree that the delayed disable of an interrupt should not wait until after resume?

Quoted 7 lines

No. The platform code needs to turn off interrupts that are not wakeup interrupts anyway, so there is not much point in disabling some interrupts early. Also, if the interrupt in question is not a wakeup interrupt you leave it in a state where it does not detect an edge. A driver that enables its hardware in resume, then unmasks the interrupt would loose an interrupt that triggered between enabling the hardware and unmasking the interrupt.

Got it. Thanks for your (repeated) explanations. I understand now your reasons for allowing the interrupt to remain across suspend. I will modify my platform to rely on [enable|disable]_irq_wake() in addition to ensuring platform code is disabling non wakup IRQs.

Quoted 24 lines
Quoted 11 lines
Quoted 10 lines
Quoted 2 lines

This patch ensures that the lazy disable is done, and masked by the irq_chip before the system goes into suspend.

This will create a window where wakeup interrupts can be lost if the driver has masked the interrupt (by calling disable_irq). If the hardware does not allow edge detection on disabled interrupts (the msm platform has this limitation) then this change will turn off the edge detection. If suspend_ops->enter does not turn the interrupt (and edge detection) back on (without this change it may never need to turn on any interrupt) it will not wakeup at all.

Quoted 6 lines

Not sure I follow you here...

It seems like you're relying on the delayed disable to wait until after resume so that disabled interrupts can wake the system.  How did this work before the delayed disable patch?

It did not.

Quoted 3 lines

If the interrupt is being used as a wakeup, why would anyone be calling disable_irq()?

Quoted 6 lines

Drivers call disable_irq to make sure their interrupt handler does not get called. A driver may not be able take interrupts after its suspend hook has been called. If it calls disable_irq on a wakeup interrupt then this interrupt should abort suspend or wake up from suspend. The driver will then see the interrupt when it call enable_irq in its resume handler.

OK.

Kevin

#15 lore raw

Re: [PATCH] genirq: ensure IRQs are lazy disabled before suspend

In reply to Arve Hjønnevåg
Quoted 39 lines · Arve Hjønnevåg

2009/5/8 Kevin Hilman <[email protected]>:

Quoted 29 lines
Quoted 16 lines · Arve Hjønnevåg
Quoted 14 lines · Kevin Hilman

From a3f359c66bd0ae1bb2603e7cf120d9d4d68591b7 Mon Sep 17 00:00:00 2001
From: Kevin Hilman <[email protected]>
Date: Wed, 6 May 2009 16:00:07 -0700
Subject: [PATCH] genirq: ensure IRQs are lazy disabled before suspend

In commit 76d2160147f43f982dfe881404cfde9fd0a9da21, the default behavior of disable_irq() was changed to delay the disable until it is next handled.

However, this leaves open the possibility that the system can go into suspend with an interrupt enabled.  For example, if a driver calls disable_irq() in its suspend_hook there's now a possibility that the system is suspended before the lazy disable happens.

Quoted 7 lines
Quoted 2 lines

The result is an unwanted wakeup from suspend if the IRQ is capable of waking the system (common on embedded SoCs.)

If the interrupt contoller uses the same enable register for wakeup and interrupts, I think it is the responsibility of the platform code, not individual drivers, to disable the interrupts that are not marked for wakeup before entering suspend.

I agree, for wakeup interrupts, drivers should use [set|disable]_irq_wake() and the platform code should handle this.

Quoted 8 lines

I used wakeup interrupts in this description as an example which turned out to be a bad example.  The 2nd version of this patch I posted, I removed the reference to wakeup interrupts in favor of just talking about the delayed disable piece.

But ignoring wakup interrupts, would you agree that the delayed disable of an interrupt should not wait until after resume?

Quoted 7 lines

No. The platform code needs to turn off interrupts that are not wakeup interrupts anyway, so there is not much point in disabling some interrupts early. Also, if the interrupt in question is not a wakeup interrupt you leave it in a state where it does not detect an edge. A driver that enables its hardware in resume, then unmasks the interrupt would loose an interrupt that triggered between enabling the hardware and unmasking the interrupt.

Got it. Thanks for your (repeated) explanations. I understand now your reasons for allowing the interrupt to remain across suspend. I will modify my platform to rely on [enable|disable]_irq_wake() in addition to ensuring platform code is disabling non wakup IRQs.

Quoted 24 lines
Quoted 11 lines
Quoted 10 lines
Quoted 2 lines

This patch ensures that the lazy disable is done, and masked by the irq_chip before the system goes into suspend.

This will create a window where wakeup interrupts can be lost if the driver has masked the interrupt (by calling disable_irq). If the hardware does not allow edge detection on disabled interrupts (the msm platform has this limitation) then this change will turn off the edge detection. If suspend_ops->enter does not turn the interrupt (and edge detection) back on (without this change it may never need to turn on any interrupt) it will not wakeup at all.

Quoted 6 lines

Not sure I follow you here...

It seems like you're relying on the delayed disable to wait until after resume so that disabled interrupts can wake the system.  How did this work before the delayed disable patch?

It did not.

Quoted 3 lines

If the interrupt is being used as a wakeup, why would anyone be calling disable_irq()?

Quoted 6 lines

Drivers call disable_irq to make sure their interrupt handler does not get called. A driver may not be able take interrupts after its suspend hook has been called. If it calls disable_irq on a wakeup interrupt then this interrupt should abort suspend or wake up from suspend. The driver will then see the interrupt when it call enable_irq in its resume handler.

OK.

Kevin