Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932444AbcDNOqZ (ORCPT ); Thu, 14 Apr 2016 10:46:25 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:37153 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754266AbcDNOqY (ORCPT ); Thu, 14 Apr 2016 10:46:24 -0400 Subject: Re: Xen regression, Was: [PATCH] x86/irq: Probe for PIC presence before allocating descs for legacy IRQs To: David Vrabel , Stefano Stabellini References: <1446470676-1877-1-git-send-email-vkuznets@redhat.com> <570CF69A.1020701@oracle.com> <570F9EF2.1030604@citrix.com> Cc: Vitaly Kuznetsov , x86@kernel.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Jiang Liu , "K. Y. Srinivasan" , linux-kernel@vger.kernel.org, konrad.wilk@oracle.com, jgross@suse.com From: Boris Ostrovsky Message-ID: <570FAD30.5060708@oracle.com> Date: Thu, 14 Apr 2016 10:46:08 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <570F9EF2.1030604@citrix.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3075 Lines: 87 On 04/14/2016 09:45 AM, David Vrabel wrote: > On 12/04/16 19:06, Stefano Stabellini wrote: >> On Tue, 12 Apr 2016, Boris Ostrovsky wrote: >>> On 04/11/2016 10:08 PM, Stefano Stabellini wrote: >>>> Hi all, >>>> >>>> Unfortunately this patch (now commit >>>> 8c058b0b9c34d8c8d7912880956543769323e2d8) causes a regression on Xen >>>> when running on top of QEMU: the number of PIT irqs get set to 0 by >>>> probe_8259A but actually there are 16. >>>> >>>> Any suggestions on how to fix this? >>>> >>>> 1) we could revert 8c058b0b9c34d8c8d7912880956543769323e2d8 >>>> 2) we could introduce an 'if (!xen_domain())' in probe_8259A >>>> 3) suggestions welcome >>> Stefano, do you have b4ff8389ed14b849354b59ce9b360bdefcdbf99c ? >>> >>> It was supposed to fix this problem for Xen. However, I just noticed that >>> arch/arm64/include/asm/irq.h makes nr_legacy_irqs() return 0 (unlike >>> arch/arm/include/asm/irq.h). Could that be the problem? >> I have b4ff8389ed14b849354b59ce9b360bdefcdbf99c but it doesn't fix the >> issue for me. >> >> Is the idea of your patch that xen_allocate_irq_gsi will allocate the >> descriptor dynamically instead? If so, it doesn't work because it >> doesn't get called for irq 14: >> >> piix_init_one -> ata_pci_sff_activate_host -> devm_request_irq -> >> devm_request_threaded_irq-> request_threaded_irq -> irq_to_desc(14) -> >> -EVAIL >> >> If you look at pci_xen_initial_domain, the loop: >> >> for (irq = 0; irq < nr_legacy_irqs(); irq++) { >> >> won't work anymore because by the time is called, nr_legacy_irqs() >> already returns 0, because it has been changed by probe_8259A(). >> >> We also need the following patch: >> >> --- >> >> xen/x86: actually allocate legacy interrupts on PV guests >> >> b4ff8389ed14 is incomplete: relies on nr_legacy_irqs() to get the number >> of legacy interrupts when actually nr_legacy_irqs() returns 0 after >> probe_8259A(). Use NR_IRQS_LEGACY instead. >> >> Signed-off-by: Stefano Stabellini >> >> diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c >> index beac4df..6db0060 100644 >> --- a/arch/x86/pci/xen.c >> +++ b/arch/x86/pci/xen.c >> @@ -492,7 +492,7 @@ int __init pci_xen_initial_domain(void) >> __acpi_register_gsi = acpi_register_gsi_xen; >> __acpi_unregister_gsi = NULL; >> /* Pre-allocate legacy irqs */ >> - for (irq = 0; irq < nr_legacy_irqs(); irq++) { >> + for (irq = 0; irq < NR_IRQS_LEGACY; irq++) { >> int trigger, polarity; >> >> if (acpi_get_override_irq(irq, &trigger, &polarity) == -1) > I think I prefer this fix because PV guests don't have a legacy PIC and > don't need any legacy irqs allocated so fiddling with nr_legacy_irqs() > seems wrong. > > But we do need a comment here saying something like: > > /* > * Pre-allocate the legacy IRQs. Use NR_LEGACY_IRQS here > * because we don't have a PCI and thus nr_legacy_irqs() is zero. s/PCI/PIC > */ > > Does this make sense? > > David OK. (I first thought that we also don't have RTC and yet we claim that dom0 has it. But then I realized that we do emulate it) -boris