mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: akpm@osdl.org
Cc: arjan@infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH] Debug shared irqs.
Date: Thu, 22 Dec 2005 11:42:46 +0000	[thread overview]
Message-ID: <1135251766.3557.13.camel@pmac.infradead.org> (raw)

Drivers registering IRQ handlers with SA_SHIRQ really ought to be able
to handle an interrupt happening before request_irq() returns. They also
ought to be able to handle an interrupt happening during the start of
their call to free_irq(). Let's test that hypothesis....

Signed-off-by: David Woodhouse <dwmw2@infradead.org>

I'm not wonderfully happy with the faked pt_regs, but I think it ought
to be OK like that.

--- linux-2.6.14/lib//Kconfig.debug~	2005-12-19 00:57:18.000000000 +0000
+++ linux-2.6.14/lib//Kconfig.debug	2005-12-22 11:37:27.000000000 +0000
@@ -176,6 +176,15 @@ config DEBUG_VM
 
 	  If unsure, say N.
 
+config SHARE_ME_HARDER
+       bool "Debug shared IRQ handlers"
+       depends on GENERIC_HARDIRQS
+       help
+         Enable this to generate a spurious interrupt as soon as a shared interrupt
+	 handler is registered, and just before one is deregistered. Drivers ought
+	 to be able to handle interrupts coming in at those some; some don't and
+	 need to be caught.
+
 config FRAME_POINTER
 	bool "Compile the kernel with frame pointers"
 	depends on DEBUG_KERNEL && (X86 || CRIS || M68K || M68KNOMMU || FRV || UML)
--- linux-2.6.14/kernel/irq/manage.c~	2005-12-19 00:57:18.000000000 +0000
+++ linux-2.6.14/kernel/irq/manage.c	2005-12-22 11:24:40.000000000 +0000
@@ -238,6 +238,10 @@ int setup_irq(unsigned int irq, struct i
 	return 0;
 }
 
+#ifdef CONFIG_SHARE_ME_HARDER
+static struct pt_regs shirq_fakeregs;
+#endif
+
 /**
  *	free_irq - free an interrupt
  *	@irq: Interrupt line to free
@@ -257,6 +261,7 @@ void free_irq(unsigned int irq, void *de
 	struct irq_desc *desc;
 	struct irqaction **p;
 	unsigned long flags;
+	irqreturn_t (*handler)(int, void *, struct pt_regs *) = NULL;
 
 	if (irq >= NR_IRQS)
 		return;
@@ -295,6 +300,8 @@ void free_irq(unsigned int irq, void *de
 
 			/* Make sure it's not being used on another CPU */
 			synchronize_irq(irq);
+			if (action->flags & SA_SHIRQ)
+				handler = action->handler;
 			kfree(action);
 			return;
 		}
@@ -302,6 +309,15 @@ void free_irq(unsigned int irq, void *de
 		spin_unlock_irqrestore(&desc->lock,flags);
 		return;
 	}
+#ifdef CONFIG_SHARE_ME_HARDER
+	if (handler) {
+		/* It's a shared IRQ -- the driver ought to be prepared for it to happen
+		   even now it's being freed, so let's make sure.... 
+		   We do this after actually deregistering it, to make sure that a 'real'
+		   IRQ doesn't run in parallel with our fake. */
+		handler(irq, dev_id, &shirq_fakeregs);
+	}
+#endif
 }
 
 EXPORT_SYMBOL(free_irq);
@@ -366,6 +382,16 @@ int request_irq(unsigned int irq,
 	action->next = NULL;
 	action->dev_id = dev_id;
 
+#ifdef CONFIG_SHARE_ME_HARDER
+	if (irqflags & SA_SHIRQ) {
+		/* It's a shared IRQ -- the driver ought to be prepared for it to happen
+		   immediately, so let's make sure.... 
+		   We do this before actually registering it, to make sure that a 'real'
+		   IRQ doesn't run in parallel with our fake. */
+		handler(irq, dev_id, &shirq_fakeregs);
+	}
+#endif
+
 	retval = setup_irq(irq, action);
 	if (retval)
 		kfree(action);


-- 
dwmw2


             reply	other threads:[~2005-12-22 11:43 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-22 11:42 David Woodhouse [this message]
2006-01-05 10:19 ` Andrew Morton
2006-01-05 10:39   ` David Woodhouse
2006-01-05 11:08     ` Andrew Morton
2006-01-05 10:48   ` Arjan van de Ven
2006-01-05 13:49   ` [PATCH] reduce sizeof(percpu_data) and removes dependance against NR_CPUS Eric Dumazet
2006-01-05 14:00     ` Andrew Morton
2006-01-05 14:33       ` Eric Dumazet
2006-01-06  7:18     ` Jan Engelhardt
2006-01-06  7:27       ` Andrew Morton
2006-01-06  7:29       ` Eric Dumazet

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=1135251766.3557.13.camel@pmac.infradead.org \
    --to=dwmw2@infradead.org \
    --cc=akpm@osdl.org \
    --cc=arjan@infradead.org \
    --cc=linux-kernel@vger.kernel.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®