From patchwork Sat Apr 20 13:55:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 2467971 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id 6FD15DF2A1 for ; Sat, 20 Apr 2013 13:56:44 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UTYGz-00068f-SP; Sat, 20 Apr 2013 13:56:14 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UTYGk-0006RE-VR; Sat, 20 Apr 2013 13:55:58 +0000 Received: from mail-la0-x22e.google.com ([2a00:1450:4010:c03::22e]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UTYGb-0006Px-0G for linux-arm-kernel@lists.infradead.org; Sat, 20 Apr 2013 13:55:51 +0000 Received: by mail-la0-f46.google.com with SMTP id ep20so452398lab.5 for ; Sat, 20 Apr 2013 06:55:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=EWOjL2LWe/JQ2TOPgzDrVduZF9kjcHpz+RNXhFsxBuE=; b=biCPzw7RKnEkbpv/PNXIC2UZ63i7DrZ3pC68sqq0XkWJnFVjtGICHhNu+ITeSt8+W7 5I8t3fy8INWT2rfkYWIaIykhGbpP266ndohuxBGiMgxd4YNz3xdIwigVct2Aw+nxR3r/ EmjXxBmzcS149vG3i91/hX+k9EmEwajiinSxYbGpail4RT9ppv27G4+N3gqJGroBox8l k87HGFjaRgLrP5hhoIxbr1ceP5z1WqLLIsFEeF3UYjMLGw7vhvKiShecijxBSbEbT6Ou pVLMLc4UMpnWdGABTr+YWCX6wEU8VaE7q84D/az3zy+Xy4dAV5iGs2t4fgew4xiUJRDq X1dA== X-Received: by 10.112.156.2 with SMTP id wa2mr9921627lbb.17.1366466144988; Sat, 20 Apr 2013 06:55:44 -0700 (PDT) Received: from localhost.localdomain (c83-249-208-67.bredband.comhem.se. [83.249.208.67]) by mx.google.com with ESMTPS id v10sm7723602lae.9.2013.04.20.06.55.43 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 20 Apr 2013 06:55:44 -0700 (PDT) From: Linus Walleij To: linux-arm-kernel@lists.infradead.org Subject: [RESEND PATCH 02/12 v4] ARM: pci: create pci_common_init_dev() Date: Sat, 20 Apr 2013 15:55:41 +0200 Message-Id: <1366466141-15405-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.8.1.4 X-Gm-Message-State: ALoCoQn8sSkDT+Z5KguuSODR7PWhEvKAKGkmJrZR1nsBj3AOJkNsNbdU/09XmBzLxI9FZ7/1wuGd X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130420_095549_293192_4FC68696 X-CRM114-Status: GOOD ( 15.76 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Arnd Bergmann , Benjamin Herrenschmitt , Linus Walleij , Mike Rapoport , Ralf Baechle , Andrew Murray , Russell King X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org When working with device tree support for PCI on ARM you run into a problem when mapping IRQs from the device tree irqmaps: doing this the code in drivers/of/of_pci_irq.c will try to find the OF node on the root bridge and this fails, because bus->dev.of_node is NULL, and that in turn boils down to the fact that pci_set_bus_of_node() has called pcibios_get_phb_of_node() from drivers/pci/of.c to obtain the OF node of the bridge or its parent and none is set and thus NULL is returned. Fix this by adding an additional parent argument API for registering PCI bridges on the ARM architecture called pci_common_init_dev(), and pass along this parent to pci_scan_root_bus() called from pcibios_init_hw() in bios32.c and voila: the IRQ mappings start working: the OF node can be retrieved from the parent. Create the old pci_common_init() as a wrapper around the new call. Cc: Mike Rapoport Cc: Russell King Cc: Ralf Baechle Cc: Andrew Murray Cc: Arnd Bergmann Cc: Benjamin Herrenschmitt Reviewed-by: Thierry Reding Signed-off-by: Linus Walleij --- ChangeLog v3->v4: - Put opening bracket on its own line. - Use the proper rmk+kernel address for Russells CC. --- arch/arm/include/asm/mach/pci.h | 12 +++++++++++- arch/arm/kernel/bios32.c | 9 +++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/arch/arm/include/asm/mach/pci.h b/arch/arm/include/asm/mach/pci.h index 5cf2e97..28ac12f 100644 --- a/arch/arm/include/asm/mach/pci.h +++ b/arch/arm/include/asm/mach/pci.h @@ -16,6 +16,7 @@ struct pci_sys_data; struct pci_ops; struct pci_bus; +struct device; struct hw_pci { #ifdef CONFIG_PCI_DOMAINS @@ -57,7 +58,16 @@ struct pci_sys_data { /* * Call this with your hw_pci struct to initialise the PCI system. */ -void pci_common_init(struct hw_pci *); +void pci_common_init_dev(struct device *, struct hw_pci *); + +/* + * Compatibility wrapper for older platforms that do not care about + * passing the parent device. + */ +static inline void pci_common_init(struct hw_pci *hw) +{ + pci_common_init_dev(NULL, hw); +} /* * Setup early fixed I/O mapping. diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c index a1f73b5..a99bde1 100644 --- a/arch/arm/kernel/bios32.c +++ b/arch/arm/kernel/bios32.c @@ -445,7 +445,8 @@ static int pcibios_init_resources(int busnr, struct pci_sys_data *sys) return 0; } -static void pcibios_init_hw(struct hw_pci *hw, struct list_head *head) +static void pcibios_init_hw(struct device *parent, struct hw_pci *hw, + struct list_head *head) { struct pci_sys_data *sys = NULL; int ret; @@ -479,7 +480,7 @@ static void pcibios_init_hw(struct hw_pci *hw, struct list_head *head) if (hw->scan) sys->bus = hw->scan(nr, sys); else - sys->bus = pci_scan_root_bus(NULL, sys->busnr, + sys->bus = pci_scan_root_bus(parent, sys->busnr, hw->ops, sys, &sys->resources); if (!sys->bus) @@ -496,7 +497,7 @@ static void pcibios_init_hw(struct hw_pci *hw, struct list_head *head) } } -void pci_common_init(struct hw_pci *hw) +void pci_common_init_dev(struct device *parent, struct hw_pci *hw) { struct pci_sys_data *sys; LIST_HEAD(head); @@ -504,7 +505,7 @@ void pci_common_init(struct hw_pci *hw) pci_add_flags(PCI_REASSIGN_ALL_RSRC); if (hw->preinit) hw->preinit(); - pcibios_init_hw(hw, &head); + pcibios_init_hw(parent, hw, &head); if (hw->postinit) hw->postinit();