From patchwork Thu Feb 11 17:17:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 8283051 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 32CFE9F3CD for ; Thu, 11 Feb 2016 17:17:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 50780202EC for ; Thu, 11 Feb 2016 17:17:23 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 66205202EB for ; Thu, 11 Feb 2016 17:17:22 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aTuqW-0003LH-AS; Thu, 11 Feb 2016 17:16:00 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aTupw-0001hP-RY for linux-arm-kernel@lists.infradead.org; Thu, 11 Feb 2016 17:15:36 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1C7DD49; Thu, 11 Feb 2016 09:14:14 -0800 (PST) Received: from red-moon (red-moon.cambridge.arm.com [10.1.203.137]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1CF793F238; Thu, 11 Feb 2016 09:14:57 -0800 (PST) Date: Thu, 11 Feb 2016 17:17:00 +0000 From: Lorenzo Pieralisi To: Tomasz Nowicki Subject: Re: [PATCH V4 22/23] arm64, pci, acpi: Assign legacy IRQs once device is enable. Message-ID: <20160211171700.GB25235@red-moon> References: <1454606941-9523-1-git-send-email-tn@semihalf.com> <1454606941-9523-23-git-send-email-tn@semihalf.com> <20160211115843.GA24136@red-moon> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160211115843.GA24136@red-moon> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160211_091525_165161_CBED12F7 X-CRM114-Status: GOOD ( 20.58 ) X-Spam-Score: -7.1 (-------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linaro-acpi@lists.linaro.org, linux-pci@vger.kernel.org, will.deacon@arm.com, okaya@codeaurora.org, wangyijing@huawei.com, ddaney@caviumnetworks.com, linux-acpi@vger.kernel.org, robert.richter@caviumnetworks.com, catalin.marinas@arm.com, jcm@redhat.com, arnd@arndb.de, Stefano.Stabellini@eu.citrix.com, Liviu.Dudau@arm.com, msalter@redhat.com, bhelgaas@google.com, mw@semihalf.com, linux-arm-kernel@lists.infradead.org, jchandra@broadcom.com, rjw@rjwysocki.net, linux-kernel@vger.kernel.org, hanjun.guo@linaro.org, Suravee.Suthikulpanit@amd.com, jiang.liu@linux.intel.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, Feb 11, 2016 at 11:58:53AM +0000, Lorenzo Pieralisi wrote: > On Thu, Feb 04, 2016 at 06:29:00PM +0100, Tomasz Nowicki wrote: > > This is the last step before enabling generic ACPI PCI host controller > > for ARM64. We need to take care of legacy IRQ mapping for non-MSI(X) > > PCI devices. pcibios_enable_device() boot order is not sensitive to > > ACPI device enumeration, so it is the best place to assign device's IRQs. > > I guess you are referring to: > > https://lists.linaro.org/pipermail/linaro-acpi/2015-October/005944.html > > It is weird that the dependency can't be enforced, I will have a look > into this, it would be nice to have DT and ACPI legacy IRQs mapping > confined in pcibios_add_device() so that we can remove them in one go > when Matthew's series is merged. One option, that is not ideal but has the merit of setting the stage for pcibios_enable_device() AND pcibios_add_device() removal, is to add IRQ mapping (by adding the call) in a pcibios_alloc_irq() callback (if Bjorn does not remove it from core code before we manage to add it, I think he is only reverting the x86 version). https://lkml.org/lkml/2016/2/9/648 That's called at device probe time, it should not change DT probing path (unless we use the irq number before the device is probed, which I doubt) and should allow the ACPI scan handlers to be installed so that the ACPI IRQ mapping can be effectively carried out. pcibios_alloc_irq() replaces pcibios_add_device(). When Matthew's patchset lands in mainline, pcibios_alloc_irq() will be removed too (at least we have a place where all legacy IRQ mappings are carried out and I can obliterate it easily). Other option is to change ACPI core code, I see no other way. Tested on KVM PCI host generic (that uses pci_fixup_irqs() so it does not really count for DT). Here (on top of your series), ready for flak. Lorenzo -- >8 -- diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index 0b53262..26ee291 100644 --- a/arch/arm64/kernel/pci.c +++ b/arch/arm64/kernel/pci.c @@ -45,28 +45,23 @@ resource_size_t pcibios_align_resource(void *data, const struct resource *res, */ int pcibios_enable_device(struct pci_dev *dev, int mask) { - int ret; - if (pci_has_flag(PCI_PROBE_ONLY)) return 0; - ret = pci_enable_resources(dev, mask); - if (ret < 0) - return ret; - -#ifdef CONFIG_ACPI - if (!pci_dev_msi_enabled(dev)) - return acpi_pci_irq_enable(dev); -#endif - return 0; + return pci_enable_resources(dev, mask); } /* - * Try to assign the IRQ number from DT when adding a new device + * Try to assign the IRQ number when probing a new device */ -int pcibios_add_device(struct pci_dev *dev) +int pcibios_alloc_irq(struct pci_dev *dev) { - dev->irq = of_irq_parse_and_map_pci(dev, 0, 0); + if (acpi_disabled) + dev->irq = of_irq_parse_and_map_pci(dev, 0, 0); +#ifdef CONFIG_ACPI + else + return acpi_pci_irq_enable(dev); +#endif return 0; }