Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753897AbYBRRtn (ORCPT ); Mon, 18 Feb 2008 12:49:43 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751847AbYBRRtc (ORCPT ); Mon, 18 Feb 2008 12:49:32 -0500 Received: from www.tglx.de ([62.245.132.106]:59355 "EHLO www.tglx.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751340AbYBRRtb (ORCPT ); Mon, 18 Feb 2008 12:49:31 -0500 Date: Mon, 18 Feb 2008 18:49:14 +0100 (CET) From: Thomas Gleixner To: "Hennerich, Michael" cc: mingo@elte.hu, linux-kernel@vger.kernel.org Subject: Re: [BUG][RFC] [GENERIC IRQ] irq_chip_set_defaults shutdown / disable In-Reply-To: <600D5CB4DFD93545BF61FF01473D11AC125CC333@limkexm2.ad.analog.com> Message-ID: References: <600D5CB4DFD93545BF61FF01473D11AC125CC333@limkexm2.ad.analog.com> User-Agent: Alpine 1.00 (LFD 882 2007-12-20) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3817 Lines: 110 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 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 Signed-off-by: Thomas Gleixner 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) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/