Skip to contentSkip to conversation

Add SA_PERCPU_IRQ flag support

PATCH In review Dimitri Sivanich 4 participants 5 messages Mar 21, 2006 – Mar 22, 2006 IRQ

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add SA_PERCPU_IRQ flag support

The generic request_irq/setup_irq code should support the SA_PERCPU_IRQ flag.

This patch was posted previously, but this one should build on all arch's.

kernel/irq/manage.c +4 -0
Index: linux-2.6.15/kernel/irq/manage.c
===================================================================
@@ -206,6 +206,10 @@ int setup_irq(unsigned int irq, struct i
 	 * The following block of code has to be executed atomically
 	 */
 	spin_lock_irqsave(&desc->lock,flags);
+#if defined(ARCH_HAS_IRQ_PER_CPU) && defined(SA_PERCPU_IRQ)
+	if (new->flags & SA_PERCPU_IRQ)
+		desc->status |= IRQ_PER_CPU;
+#endif
 	p = &desc->action;
 	if ((old = *p) != NULL) {
 		/* Can't share interrupts unless both agree to */
#1 lore raw
Quoted 12 lines · Dimitri Sivanich

The generic request_irq/setup_irq code should support the SA_PERCPU_IRQ flag.

This patch was posted previously, but this one should build on all arch's.

Index: linux-2.6.15/kernel/irq/manage.c
===================================================================

kernel/irq/manage.c int setup_irq(unsigned int irq, struct i · line 215

Quoted 10 lines
kernel/irq/manage.c +4 -0
@@ -206,6 +206,10 @@ int setup_irq(unsigned int irq, struct i
 	 * The following block of code has to be executed atomically
 	 */
 	spin_lock_irqsave(&desc->lock,flags);
+#if defined(ARCH_HAS_IRQ_PER_CPU) && defined(SA_PERCPU_IRQ)
+	if (new->flags & SA_PERCPU_IRQ)
+		desc->status |= IRQ_PER_CPU;
+#endif
 	p = &desc->action;
 	if ((old = *p) != NULL) {
 		/* Can't share interrupts unless both agree to */

hm. Last time around I pointed out that we should be checking that all handlers for this IRQ agree about the percpuness. What happened to that?

#2 lore raw
Quoted 3 lines · Andrew Morton

hm. Last time around I pointed out that we should be checking that all handlers for this IRQ agree about the percpuness. What happened to that?

Maybe simply add this patch on top?

kernel/irq/manage.c +2 -0
Index: linux-2.6.16-rc6-mm2/kernel/irq/manage.c
===================================================================
@@ -204,6 +204,8 @@ int setup_irq(unsigned int irq, struct i
 #if defined(ARCH_HAS_IRQ_PER_CPU) && defined(SA_PERCPU_IRQ)
 	if (new->flags & SA_PERCPU_IRQ)
 		desc->status |= IRQ_PER_CPU;
+	else
+		BUG_ON(desc->status & IRQ_PER_CPU);
 #endif
 	p = &desc->action;
 	if ((old = *p) != NULL) {
#3 lore raw

kernel/irq/manage.c int setup_irq(unsigned int irq, struct i · line 208

Quoted 3 lines
kernel/irq/manage.c +2 -0
+	else
+		BUG_ON(desc->status & IRQ_PER_CPU);

I see that you are a member of the school of brutalism ! :)

Ben.

#4 lore raw
In reply to Andrew Morton
Quoted 3 lines · Andrew Morton

hm. Last time around I pointed out that we should be checking that all handlers for this IRQ agree about the percpuness. What happened to that?

I believe this version has what you are looking for.

kernel/irq/manage.c +18 -5
Index: linux-2.6.15/kernel/irq/manage.c
===================================================================
@@ -209,10 +209,14 @@ int setup_irq(unsigned int irq, struct i
 	p = &desc->action;
 	if ((old = *p) != NULL) {
 		/* Can't share interrupts unless both agree to */
-		if (!(old->flags & new->flags & SA_SHIRQ)) {
-			spin_unlock_irqrestore(&desc->lock,flags);
-			return -EBUSY;
-		}
+		if (!(old->flags & new->flags & SA_SHIRQ))
+			goto mismatch;
+
+#if defined(ARCH_HAS_IRQ_PER_CPU) && defined(SA_PERCPU_IRQ)
+		/* All handlers must agree on per-cpuness */
+		if ((old->flags & IRQ_PER_CPU) != (new->flags & IRQ_PER_CPU))
+			goto mismatch;
+#endif
 
 		/* add new interrupt at end of irq queue */
 		do {
@@ -223,7 +227,10 @@ int setup_irq(unsigned int irq, struct i
 	}
 
 	*p = new;
-
+#if defined(ARCH_HAS_IRQ_PER_CPU) && defined(SA_PERCPU_IRQ)
+	if (new->flags & SA_PERCPU_IRQ)
+		desc->status |= IRQ_PER_CPU;
+#endif
 	if (!shared) {
 		desc->depth = 0;
 		desc->status &= ~(IRQ_DISABLED | IRQ_AUTODETECT |
@@ -241,6 +248,12 @@ int setup_irq(unsigned int irq, struct i
 	register_handler_proc(irq, new);
 
 	return 0;
+
+mismatch:
+	spin_unlock_irqrestore(&desc->lock, flags);
+	printk(KERN_ERR "%s: irq handler mismatch\n", __FUNCTION__);
+	dump_stack();
+	return -EBUSY;
 }
 
 /*