Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751274AbbKBTKM (ORCPT ); Mon, 2 Nov 2015 14:10:12 -0500 Received: from www.linutronix.de ([62.245.132.108]:40724 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750843AbbKBTKL (ORCPT ); Mon, 2 Nov 2015 14:10:11 -0500 Date: Mon, 2 Nov 2015 20:09:20 +0100 (CET) From: Thomas Gleixner To: Vitaly Kuznetsov cc: x86@kernel.org, Ingo Molnar , "H. Peter Anvin" , Jiang Liu , "K. Y. Srinivasan" , linux-kernel@vger.kernel.org Subject: Re: [PATCH] x86/irq: Probe for PIC presence before allocating descs for legacy IRQs In-Reply-To: <1446470676-1877-1-git-send-email-vkuznets@redhat.com> Message-ID: References: <1446470676-1877-1-git-send-email-vkuznets@redhat.com> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2624 Lines: 67 Vitaly! On Mon, 2 Nov 2015, Vitaly Kuznetsov wrote: > Commit d32932d02e18 ("x86/irq: Convert IOAPIC to use hierarchical irqdomain > interfaces") brought a regression for Hyper-V Gen2 instances. These > instances don't have i8259 legacy PIC but they use legacy IRQs for serial > port, rtc, and acpi. With this commit included we end up with these IRQs > not initialized. Earlier, there was a special workaround for legacy IRQs > in mp_map_pin_to_irq() doing mp_irqdomain_map() without looking at > nr_legacy_irqs() and now we fail in __irq_domain_alloc_irqs() when > irq_domain_alloc_descs() returns -EEXIST. > > The essence of the issue seems to be that early_irq_init() calls > arch_probe_nr_irqs() to figure out the number of legacy IRQs before > we probe for i8259 and gets 16. Later when init_8259A() is called we switch > to NULL legacy PIC and nr_legacy_irqs() starts to return 0 but we already > have 16 descs allocated. > > Solve the issue by separating i8259 probe from init and calling it in > arch_probe_nr_irqs() before we actually use nr_legacy_irqs() information. Nice catch! > Fixes: d32932d02e18 ("x86/irq: Convert IOAPIC to use hierarchical irqdomain interfaces") > Signed-off-by: Vitaly Kuznetsov > --- > arch/x86/include/asm/i8259.h | 1 + > arch/x86/kernel/apic/vector.c | 3 +++ > arch/x86/kernel/i8259.c | 24 ++++++++++++++++-------- > 3 files changed, 20 insertions(+), 8 deletions(-) > > diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h > index ccffa53..bd55a77 100644 > --- a/arch/x86/include/asm/i8259.h > +++ b/arch/x86/include/asm/i8259.h > @@ -60,6 +60,7 @@ struct legacy_pic { > void (*mask_all)(void); > void (*restore_mask)(void); > void (*init)(int auto_eoi); > + void (*probe)(void); > int (*irq_pending)(unsigned int irq); > void (*make_irq)(unsigned int irq); > }; > diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c > index 836d11b..aadd7ae 100644 > --- a/arch/x86/kernel/apic/vector.c > +++ b/arch/x86/kernel/apic/vector.c > @@ -361,6 +361,9 @@ int __init arch_probe_nr_irqs(void) > if (nr < nr_irqs) > nr_irqs = nr; > > + /* nr_legecy_irqs() depends on the PIC presence */ > + legacy_pic->probe(); > + > return nr_legacy_irqs(); We can simplify this by letting probe() return the number of legacy interrupts, hmm? Thanks, tglx -- 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/