mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Ingo Molnar <mingo@elte.hu>,
	Peter Zijlstra <peterz@infradead.org>,
	Arjan van de Veen <arjan@infradead.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Jon Masters <jonathan@jonmasters.org>
Subject: [patch 3/4] genirq: add a quick check handler
Date: Thu, 26 Feb 2009 13:28:18 -0000	[thread overview]
Message-ID: <20090226131719.640887792@linutronix.de> (raw)
In-Reply-To: <20090226131336.423054348@linutronix.de>

[-- Attachment #1: genirq-add-quickcheckhandler.patch --]
[-- Type: text/plain, Size: 4864 bytes --]

Preparatory patch for threaded interrupt handlers.

Adds a quick check handler which is called before the real handler.
The quick check handler can decide whether the interrupt was originated
from the device or not. It can also declare the interrupt as handled
and subsequently avoid that the real handler is called.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Peter Zijlstra <peterz@infradead.org>

---
 include/linux/interrupt.h |   16 ++++++++++++++--
 include/linux/irqreturn.h |    2 ++
 kernel/irq/handle.c       |   18 +++++++++++++++---
 kernel/irq/manage.c       |   17 ++++++++++++-----
 4 files changed, 43 insertions(+), 10 deletions(-)

Index: linux-2.6-tip/include/linux/interrupt.h
===================================================================
--- linux-2.6-tip.orig/include/linux/interrupt.h
+++ linux-2.6-tip/include/linux/interrupt.h
@@ -62,6 +62,7 @@
 typedef irqreturn_t (*irq_handler_t)(int, void *);
 
 struct irqaction {
+	irq_handler_t quick_check_handler;
 	irq_handler_t handler;
 	unsigned long flags;
 	cpumask_t mask;
@@ -73,8 +74,19 @@ struct irqaction {
 };
 
 extern irqreturn_t no_action(int cpl, void *dev_id);
-extern int __must_check request_irq(unsigned int, irq_handler_t handler,
-		       unsigned long, const char *, void *);
+
+extern int __must_check
+request_irq_quickcheck(unsigned int irq, irq_handler_t handler,
+		       irq_handler_t quick_check_handler,
+		       unsigned long flags, const char *name, void *dev);
+
+static inline int __must_check
+request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags,
+	    const char *name, void *dev)
+{
+	return request_irq_quickcheck(irq, handler, NULL, flags, name, dev);
+}
+
 extern void free_irq(unsigned int, void *);
 
 struct device;
Index: linux-2.6-tip/include/linux/irqreturn.h
===================================================================
--- linux-2.6-tip.orig/include/linux/irqreturn.h
+++ linux-2.6-tip/include/linux/irqreturn.h
@@ -5,10 +5,12 @@
  * enum irqreturn
  * @IRQ_NONE		interrupt was not from this device
  * @IRQ_HANDLED		interrupt was handled by this device
+ * @IRQ_NEEDS_HANDLING	quick check handler requests to run real handler
  */
 enum irqreturn {
 	IRQ_NONE,
 	IRQ_HANDLED,
+	IRQ_NEEDS_HANDLING,
 };
 
 typedef enum irqreturn irqreturn_t;
Index: linux-2.6-tip/kernel/irq/handle.c
===================================================================
--- linux-2.6-tip.orig/kernel/irq/handle.c
+++ linux-2.6-tip/kernel/irq/handle.c
@@ -354,9 +354,21 @@ irqreturn_t handle_IRQ_event(unsigned in
 		local_irq_enable_in_hardirq();
 
 	do {
-		ret = action->handler(irq, action->dev_id);
-		if (ret == IRQ_HANDLED)
-			status |= action->flags;
+		if (action->quick_check_handler)
+			ret = action->quick_check_handler(irq, action->dev_id);
+		else
+			ret = IRQ_NEEDS_HANDLING;
+
+		switch (ret) {
+		default:
+			break;
+
+		case IRQ_NEEDS_HANDLING:
+			ret = action->handler(irq, action->dev_id);
+			if (ret == IRQ_HANDLED)
+				status |= action->flags;
+			break;
+		}
 		retval |= ret;
 		action = action->next;
 	} while (action);
Index: linux-2.6-tip/kernel/irq/manage.c
===================================================================
--- linux-2.6-tip.orig/kernel/irq/manage.c
+++ linux-2.6-tip/kernel/irq/manage.c
@@ -641,9 +641,13 @@ void free_irq(unsigned int irq, void *de
 EXPORT_SYMBOL(free_irq);
 
 /**
- *	request_irq - allocate an interrupt line
+ *	request_irq_quickcheck - allocate an interrupt line
  *	@irq: Interrupt line to allocate
- *	@handler: Function to be called when the IRQ occurs
+ *	@handler: Function to be called when the IRQ occurs.
+ *		  Primary handler for threaded interrupts
+ *      @quick_check_handler: Function called before the real interrupt
+ *			handler. It checks if the interrupt originated
+ *			from the device. This can be NULL.
  *	@irqflags: Interrupt type flags
  *	@devname: An ascii name for the claiming device
  *	@dev_id: A cookie passed back to the handler function
@@ -670,8 +674,10 @@ EXPORT_SYMBOL(free_irq);
  *	IRQF_TRIGGER_*		Specify active edge(s) or level
  *
  */
-int request_irq(unsigned int irq, irq_handler_t handler,
-		unsigned long irqflags, const char *devname, void *dev_id)
+int request_irq_quickcheck(unsigned int irq, irq_handler_t handler,
+			   irq_handler_t quick_check_handler,
+			   unsigned long irqflags, const char *devname,
+			   void *dev_id)
 {
 	struct irqaction *action;
 	struct irq_desc *desc;
@@ -718,6 +724,7 @@ int request_irq(unsigned int irq, irq_ha
 	if (!action)
 		return -ENOMEM;
 
+	action->quick_check_handler = quick_check_handler;
 	action->handler = handler;
 	action->flags = irqflags;
 	action->name = devname;
@@ -748,4 +755,4 @@ int request_irq(unsigned int irq, irq_ha
 #endif
 	return retval;
 }
-EXPORT_SYMBOL(request_irq);
+EXPORT_SYMBOL(request_irq_quickcheck);



  parent reply	other threads:[~2009-02-26 13:29 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-26 13:28 [patch 0/4] genirq: add infrastructure for threaded interrupt handlers V2 Thomas Gleixner
2009-02-26 13:28 ` [patch 1/4] genirq: make irqreturn_t an enum Thomas Gleixner
2009-03-25 19:51   ` Geert Uytterhoeven
2009-02-26 13:28 ` [patch 2/4] genirq: use kzalloc instead of explicit zero initialization Thomas Gleixner
2009-02-26 13:28 ` Thomas Gleixner [this message]
2009-02-26 23:03   ` [patch 3/4] genirq: add a quick check handler Andrew Morton
2009-02-26 23:11     ` Thomas Gleixner
2009-02-28 22:24   ` Christoph Hellwig
2009-03-01  9:44     ` Thomas Gleixner
2009-03-05 19:59     ` Sven-Thorsten Dietrich
2009-03-17  7:54       ` Christoph Hellwig
2009-03-17 15:29         ` Steven Rostedt
2009-02-26 13:28 ` [patch 4/4] genirq: add support for threaded interrupt handlers Thomas Gleixner
2009-02-26 23:32   ` Andrew Morton
2009-02-27  5:27     ` Arjan van de Ven
2009-02-27  5:45       ` Andrew Morton
2009-02-27  7:18         ` Peter Zijlstra
2009-02-27  7:48           ` Andrew Morton
2009-02-27  8:05             ` Peter Zijlstra
2009-02-27  8:15               ` Andrew Morton
2009-02-27 15:06               ` Arjan van de Ven
2009-02-27 15:30                 ` Steven Rostedt
2009-02-28 13:46                   ` Stefan Richter
2009-03-02 13:21                     ` Peter Zijlstra
2009-02-28 17:13             ` Andi Kleen
2009-02-27 16:43     ` Thomas Gleixner
2009-02-26 15:26 ` [patch 0/4] genirq: add infrastructure for threaded interrupt handlers V2 Jon Masters
2009-03-05 20:03   ` Sven-Thorsten Dietrich
2009-02-28 22:10 ` Christoph Hellwig
2009-03-01  9:43   ` Thomas Gleixner
2009-03-05  8:40 ` [ANNOUNCE] USB genirq " Sven-Thorsten Dietrich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090226131719.640887792@linutronix.de \
    --to=tglx@linutronix.de \
    --cc=akpm@linux-foundation.org \
    --cc=arjan@infradead.org \
    --cc=jonathan@jonmasters.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®