linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Ok to call disable_irq before request_irq?
@ 2011-04-05  0:53 Timur Tabi
  2011-04-05  2:17 ` Lars-Peter Clausen
  0 siblings, 1 reply; 2+ messages in thread
From: Timur Tabi @ 2011-04-05  0:53 UTC (permalink / raw)
  To: linux-kernel

Is it okay to call disable_irq() before calling request_irq()?  My
device creates lots of spurious interrupts, and so I want the
interrupt enable only when I expect a real interrupt to occur.  It
seems to work, but I just want to make sure it's a proper technique.

-- 
Timur Tabi
Linux kernel developer at Freescale

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Ok to call disable_irq before request_irq?
  2011-04-05  0:53 Ok to call disable_irq before request_irq? Timur Tabi
@ 2011-04-05  2:17 ` Lars-Peter Clausen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars-Peter Clausen @ 2011-04-05  2:17 UTC (permalink / raw)
  To: Timur Tabi; +Cc: linux-kernel, Thomas Gleixner

[-- Attachment #1: Type: text/plain, Size: 794 bytes --]

On 04/05/2011 02:53 AM, Timur Tabi wrote:
> Is it okay to call disable_irq() before calling request_irq()?  My
> device creates lots of spurious interrupts, and so I want the
> interrupt enable only when I expect a real interrupt to occur.  It
> seems to work, but I just want to make sure it's a proper technique.
> 

It might work in your case, but in general that would certainly be really bad
practice.
If the irq was not requested before request_irq should enable the IRQ
regardless of whether irq_disable was called or not.

I have a patch which adds the IRQF_NOAUTOEN flag, which allows you to request a
IRQ without automatically enabling it. Unfortunately the current version of the
patch will fail if your irq_chip implements the irq_startup callback. I've
attached the patch.

- Lars

[-- Attachment #2: irqf_noautoen.patch --]
[-- Type: text/x-diff, Size: 1681 bytes --]

commit 0fefae8354e9045e720def1233bfe51592e2dc90
Author: Lars-Peter Clausen <lars@metafoo.de>
Date:   Thu Mar 31 19:47:41 2011 +0200

    IRQF_NOAUTOEN

diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 943c9b5..d596640 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -59,6 +59,7 @@
  * 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_NOAUTOEN - Do not enable the interrupt on request
  */
 #define IRQF_DISABLED		0x00000020
 #define IRQF_SAMPLE_RANDOM	0x00000040
@@ -72,6 +73,7 @@
 #define IRQF_NO_SUSPEND		0x00004000
 #define IRQF_FORCE_RESUME	0x00008000
 #define IRQF_NO_THREAD		0x00010000
+#define IRQF_NOAUTOEN		0x00020000
 
 #define IRQF_TIMER		(__IRQF_TIMER | IRQF_NO_SUSPEND | IRQF_NO_THREAD)
 
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 12a80fd..e5c538f 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -863,6 +863,10 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)
 	int ret, nested, shared = 0;
 	cpumask_var_t mask;
 
+	if (new->flags & (IRQF_NOAUTOEN | IRQF_SHARED) ==
+		(IRQF_NOAUTOEN | IRQF_SHARED))
+		return -EINVAL;
+
 	if (!desc)
 		return -EINVAL;
 
@@ -998,7 +1002,8 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)
 		if (new->flags & IRQF_ONESHOT)
 			desc->istate |= IRQS_ONESHOT;
 
-		if (irq_settings_can_autoenable(desc))
+		if (irq_settings_can_autoenable(desc) &&
+			!(new->flags & IRQF_NOAUTOEN))
 			irq_startup(desc);
 		else
 			/* Undo nested disables: */

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-04-05  2:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-05  0:53 Ok to call disable_irq before request_irq? Timur Tabi
2011-04-05  2:17 ` Lars-Peter Clausen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).