From patchwork Fri Oct 23 05:03:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: matt@masarand.com X-Patchwork-Id: 7469861 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@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 62BDC9F36A for ; Fri, 23 Oct 2015 05:05:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7708220160 for ; Fri, 23 Oct 2015 05:05:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8D0D52021F for ; Fri, 23 Oct 2015 05:05:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751237AbbJWFFx (ORCPT ); Fri, 23 Oct 2015 01:05:53 -0400 Received: from foo.masarand.uk ([104.200.29.153]:36227 "EHLO foo.masarand.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751096AbbJWFFx (ORCPT ); Fri, 23 Oct 2015 01:05:53 -0400 Received: from localhost.localdomain (shredder.masarand.uk [81.187.126.108]) by foo.masarand.uk (Postfix) with ESMTPSA id 3E822AA55; Fri, 23 Oct 2015 06:05:52 +0100 (BST) From: Matthew Minter To: linux-pci@vger.kernel.org, bhelgaas@google.com, Liviu.Dudau@arm.com, ddaney@caviumnetworks.com, lorenzo.pieralisi@arm.com Cc: Matthew Minter Subject: [PATCH V4 11/29] powerpc/pci: Defer IRQ assignment to device enable time Date: Fri, 23 Oct 2015 06:03:44 +0100 Message-Id: <1445576642-29624-12-git-send-email-matt@masarand.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1445576642-29624-1-git-send-email-matt@masarand.com> References: <1445576642-29624-1-git-send-email-matt@masarand.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 The powerpc PCI init code is currently initialising PCI device IRQ during the boot time pcibios phase. This results in devices which are connected after boot time not being asigned IRQs which can cause various problems. This patch as part of its set fixes this be moving the IRQ initialisation into the PCI device enable code path so that it is run for boot time and hot-plugged devices alike. Signed-off-by: Matthew Minter --- arch/powerpc/kernel/pci-common.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 7587b2a..4189f50 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -231,7 +231,7 @@ struct pci_controller* pci_find_hose_for_OF_device(struct device_node* node) * If the interrupt is used, then gets the interrupt line from the * openfirmware and sets it in the pci_dev and pci_config line. */ -static int pci_read_irq_line(struct pci_dev *pci_dev) +static int pci_read_irq_line(struct pci_dev *pci_dev, u8 pin) { struct of_phandle_args oirq; unsigned int virq; @@ -243,7 +243,7 @@ static int pci_read_irq_line(struct pci_dev *pci_dev) #endif /* Try to get a mapping from the device-tree */ if (of_irq_parse_pci(pci_dev, &oirq)) { - u8 line, pin; + u8 line; /* If that fails, lets fallback to what is in the config * space and map that through the default controller. We @@ -252,10 +252,6 @@ static int pci_read_irq_line(struct pci_dev *pci_dev) * either provide a proper interrupt tree or don't use this * function. */ - if (pci_read_config_byte(pci_dev, PCI_INTERRUPT_PIN, &pin)) - return -1; - if (pin == 0) - return -1; if (pci_read_config_byte(pci_dev, PCI_INTERRUPT_LINE, &line) || line == 0xff || line == 0) { return -1; @@ -280,9 +276,16 @@ static int pci_read_irq_line(struct pci_dev *pci_dev) pr_debug(" Mapped to linux irq %d\n", virq); - pci_dev->irq = virq; + return virq; +} - return 0; +static int pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin) +{ + /* Read default IRQs and fixup if necessary */ + dev->irq = pci_read_irq_line(dev, pin); + if (ppc_md.pci_irq_fixup) + ppc_md.pci_irq_fixup(dev); + return dev->irq; } /* @@ -784,6 +787,7 @@ int pci_proc_domain(struct pci_bus *bus) int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) { + bridge->map_irq = pci_map_irq; if (ppc_md.pcibios_root_bridge_prepare) return ppc_md.pcibios_root_bridge_prepare(bridge); @@ -983,11 +987,6 @@ static void pcibios_setup_device(struct pci_dev *dev) phb = pci_bus_to_host(dev->bus); if (phb->controller_ops.dma_dev_setup) phb->controller_ops.dma_dev_setup(dev); - - /* Read default IRQs and fixup if necessary */ - pci_read_irq_line(dev); - if (ppc_md.pci_irq_fixup) - ppc_md.pci_irq_fixup(dev); } int pcibios_add_device(struct pci_dev *dev)