From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yinghai Lu Subject: Re: [PATCH v5 02/33] genirq: Add irq_alloc_reserved_desc() Date: Mon, 24 Feb 2014 17:31:43 -0800 Message-ID: References: <1388707565-16535-1-git-send-email-yinghai@kernel.org> <1388707565-16535-3-git-send-email-yinghai@kernel.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Return-path: In-Reply-To: Sender: linux-pci-owner@vger.kernel.org To: Thomas Gleixner Cc: Ingo Molnar , "H. Peter Anvin" , Tony Luck , Bjorn Helgaas , "Rafael J. Wysocki" , "linux-pci@vger.kernel.org" , Linux Kernel Mailing List , ACPI Devel Maling List , Joerg Roedel , Konrad Rzeszutek Wilk , Sebastian Andrzej Siewior , Andrew Morton , Linus Torvalds List-Id: linux-acpi@vger.kernel.org On Sat, Feb 22, 2014 at 3:38 PM, Thomas Gleixner wrote: > > OMG, you really mean that: > > +++ b/arch/alpha/kernel/irq_i8259.c > @@ -92,6 +92,7 @@ init_i8259a_irqs(void) > outb(0xff, 0xA1); /* mask all of 8259A-2 */ > > for (i = 0; i < 16; i++) { > + irq_alloc_desc_at(i, 0); > irq_set_chip_and_handler(i, &i8259a_irq_type, handle_level_irq); > } > > You can't be serious about that. There are tons of ways to call into > the core and access an irq descriptor aside of irq_set_chip* before it > is potentially allocated. > > Are you going to analyze all of them and add an irq_alloc_desc_at() > before that call? > > HELL, NO! > > I'm really tired of that. > > Stay away from kernel/irq/* and wait for people who are competent > enough and willing to spend the extra thoughts to come up with > solutions which are not completely ass backwards. oh, no, sorry for annoying you again. In the irq_alloc_desc_at() path for !SPARSE_IRQ, it should not touch anything except setting that bit in allocated_irqs bitmap. Or could just replace irq_reserve_irq in irq_set_chip(), in that way will avoid touching arch codes. like diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index dc04c16..02d6ad0 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -28,8 +28,13 @@ int irq_set_chip(unsigned int irq, struct irq_chip *chip) { unsigned long flags; - struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0); + struct irq_desc *desc; + +#ifndef CONFIG_SPARSE_IRQ + irq_alloc_desc_at(irq, 0); +#endif + desc = irq_get_desc_lock(irq, &flags, 0); if (!desc) return -EINVAL; @@ -38,12 +43,7 @@ int irq_set_chip(unsigned int irq, struct irq_chip *chip) desc->irq_data.chip = chip; irq_put_desc_unlock(desc, flags); - /* - * For !CONFIG_SPARSE_IRQ make the irq show up in - * allocated_irqs. For the CONFIG_SPARSE_IRQ case, it is - * already marked, and this call is harmless. - */ - irq_reserve_irq(irq); + return 0; } EXPORT_SYMBOL(irq_set_chip);