LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: "Hennerich, Michael" <Michael.Hennerich@analog.com>
Cc: mingo@elte.hu, linux-kernel@vger.kernel.org
Subject: Re: [BUG][RFC] [GENERIC IRQ] irq_chip_set_defaults shutdown / disable
Date: Mon, 18 Feb 2008 18:49:14 +0100 (CET)	[thread overview]
Message-ID: <alpine.LFD.1.00.0802181814550.7583@apollo.tec.linutronix.de> (raw)
In-Reply-To: <600D5CB4DFD93545BF61FF01473D11AC125CC333@limkexm2.ad.analog.com>

On Mon, 18 Feb 2008, Hennerich, Michael wrote:
> RESENT: Add Maintainers 
> 
> free_irq() does not disable/mask the irq, in case disable or shutdown in struct irq_chip is left uninitilazied.
> 
> /**
>  * struct irq_chip - hardware interrupt chip descriptor
>  *
>  * @name:	name for /proc/interrupts
>  * @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)
> 
> 
> According to linux/irq.h struct irq_chip information,
> chip->disable should default to chip->mask if NULL.
> However irq_chip_set_defaults(struct irq_chip *chip) will set it to default_disable an empty function.
> 
> In earlier kernel versions such as 2.6.19 default_disable called chip->mask.
> In 2.6.22 and 2.6.24 default_disable is an empty function.
> 
> Looking through various architectures, it's still pretty common that disable and shutdown is NULL.

Yeah, you are right. This was broken by commit
76d2160147f43f982dfe881404cfde9fd0a9da21

> Do I miss something here?

Just a small detail. The commit optimized the irq_disable/enable logic
by defaulting to delayed disable. So we want to keep that logic intact
in case that we still have a device which is handling this
interrupt. For the free_irq() case your patch is correct.

The patch below fixes the shutdown case and keeps the delayed disable
logic intact.

How did you notice ? I guess you got spurious interrupts after calling
free_irq(), right ?

Thanks for analyzing and reporting,

	tglx

------------->
Subject: genirq: do not leave interupts enabled on free_irq
From: Thomas Gleixner <tglx@linutronix.de>
Date: Mon, 18 Feb 2008 18:25:17 +0100

The default_disable() function was changed in commit:

 76d2160147f43f982dfe881404cfde9fd0a9da21
 genirq: do not mask interrupts by default

It removed the mask function in favour of the default delayed
interrupt disable handling. Unfortunately this also broke the shutdown
in free_irq() when the last handler is removed from the interrupt for
those architectures which rely on the default implementations. Now we
can end up with a enabled interrupt line after the last handler was
removed.

Fix this by adding a default_shutdown function, which is only
installed, when the irqchip implementation does provide neither a
shutdown nor a disable function.

Pointed-out-by: Michael Hennerich <Michael.Hennerich@analog.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
CC: stable@kernel.org

---
 kernel/irq/chip.c |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

Index: linux-2.6/kernel/irq/chip.c
===================================================================
--- linux-2.6.orig/kernel/irq/chip.c
+++ linux-2.6/kernel/irq/chip.c
@@ -246,6 +246,17 @@ static unsigned int default_startup(unsi
 }
 
 /*
+ * default shutdown function
+ */
+static void default_shutdown(unsigned int irq)
+{
+	struct irq_desc *desc = irq_desc + irq;
+
+	desc->chip->mask(irq);
+	desc->status &= ~IRQ_MASKED;
+}
+
+/*
  * Fixup enable/disable function pointers
  */
 void irq_chip_set_defaults(struct irq_chip *chip)
@@ -257,7 +268,8 @@ void irq_chip_set_defaults(struct irq_ch
 	if (!chip->startup)
 		chip->startup = default_startup;
 	if (!chip->shutdown)
-		chip->shutdown = chip->disable;
+		chip->shutdown = chip->disable != default_disable ?
+			chip_disable : default_shutdown;
 	if (!chip->name)
 		chip->name = chip->typename;
 	if (!chip->end)

  reply	other threads:[~2008-02-18 17:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-18 16:58 Hennerich, Michael
2008-02-18 17:49 ` Thomas Gleixner [this message]
2008-02-18 18:04   ` Hennerich, Michael
2008-02-18 20:37     ` Thomas Gleixner
2008-02-19  8:58       ` Hennerich, Michael
2008-02-19  9:12         ` Thomas Gleixner
2008-02-18 20:47     ` Thomas Gleixner
2008-02-19 10:25       ` [BUG][RFC][GENERIC IRQ] linux-2.6.24 (delayed) disable IRQ feature not functional for handle_simple_irq Hennerich, Michael
2008-02-19 10:49         ` Thomas Gleixner
2008-02-19 11:51           ` Hennerich, Michael

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=alpine.LFD.1.00.0802181814550.7583@apollo.tec.linutronix.de \
    --to=tglx@linutronix.de \
    --cc=Michael.Hennerich@analog.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --subject='Re: [BUG][RFC] [GENERIC IRQ] irq_chip_set_defaults shutdown / disable' \
    /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

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).