From patchwork Fri Aug 17 10:26:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 144472 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp600558ljj; Fri, 17 Aug 2018 03:32:43 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwEr6eool75ELLDS2fUttgKOwvzMauTbXcgUPwWAOay/bkFqW2Fzm3RXtPjlQRLqsAO9C9K X-Received: by 2002:a17:902:d24:: with SMTP id 33-v6mr32668614plu.211.1534501963829; Fri, 17 Aug 2018 03:32:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534501963; cv=none; d=google.com; s=arc-20160816; b=lVbPgAGqVCLpXs68p3jlplkj6ur0N95VNKXCVb6xsTVwLBAuA4IMufwxTRPhuUAIq9 TBzFqmoQpudDCtGXoEFaLdQqgqRA0NOQdjwWvV9KvhcmZ7NmvK7O93BNAfoyhi+/I4J1 3/fVKPBrxC2yGhxuQLP8l2wTX13BGam5eeyVviGHI9QPE64o2l3ADeSbpbigXSGtUm0R A1CpaNjtasDdyr72wDugTCRd8ibHdM4jerQ65NSjpu7zhCL2njLmMkw7bugd6S+JQgsa yEzZXCcctwGhFLb6CfQM3x9IjeJv4cbvZc8Mp/hlSzA73AkqN0KDcJx1rBIEp1U27F1t wRRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=4yc1jWbI+cgL0vsvsY+s/KwqfAMH8MRlQYakZIQhtSo=; b=ZfAplhRRst3gTxr+dl3/96HG8Cm5ePfklPAY9Hre1+GJzFBMI1FL6SXX7V/mfLQIQ4 KgWeEfnmXO1rvomajMVTFa+9Fj6RDOvope/J8M+3uwPXFlqdwTpUlExvi8fYxec1bfrF q1yZlWrTkFzvA/vX+cSY5Yzp4xyvMHngji14gBvyXe7DA08NeDxvJjUMBXxUUVPEfEsB 6aVU4I1HtgSSBh/CSgcd8IMpOrfV9dP7wFJw4FMfUQ4fMKLaBSR+yWELSHipLeXqMlvT qBnmmAqY1v+otoE018C013ZYyCieNdos6yy6hBg/tI4UHq91rAMCx8wei8l0F6iV2Y4m HkdA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i35-v6si1957947plg.460.2018.08.17.03.32.43; Fri, 17 Aug 2018 03:32:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727131AbeHQNfg (ORCPT + 9 others); Fri, 17 Aug 2018 09:35:36 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:41337 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726786AbeHQNfg (ORCPT ); Fri, 17 Aug 2018 09:35:36 -0400 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0Mf0OX-1fXBJl1wd7-00OXrw; Fri, 17 Aug 2018 12:27:16 +0200 From: Arnd Bergmann To: linux-pci@vger.kernel.org, Bjorn Helgaas Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Lorenzo Pieralisi , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, Arnd Bergmann Subject: [RFC 03/15] PCI: move pci_scan_root_bus into callers Date: Fri, 17 Aug 2018 12:26:33 +0200 Message-Id: <20180817102645.3839621-4-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180817102645.3839621-1-arnd@arndb.de> References: <20180817102645.3839621-1-arnd@arndb.de> X-Provags-ID: V03:K1:/BkngKF/6b10KWqzjF4LQs6B6MkQtkRFmL6SWbFHT/fR7ZScAD6 PxIPcoQ33neYAd2DVQLD4hSnISy5S+mjTGrPpMPdZPzOGGwcgsdWWFM+AuB+VXQ/Un5aGIY StxePL7nJko2UJ1UZ5SoqMJdCUyytat7rPOFwnoUXMwuQprWGUrja1NmIA1Y28QzLVqWGsL VZPgBGucfp/4ObNhRus3w== X-UI-Out-Filterresults: notjunk:1; V01:K0:yk/2WoKa2Tc=:UZx4Ov030SIXEGCgA89BLa Fo7ZjH7sD3AjG5Olyljg6m0KZNfNxTw4KN4WaBTbdciiJyzE9Nw2OqOnlrR63j7oiDJBVZaOd s9NmiGAJunm6OpoovumSicVPX53M/9bECWo1zLMuDvmT2l55e9ph+zWE3+iWaXg0XqbsA9SnI wQVT1yyBFacJosDoePfbuMw5g2w8UGIfoOJQ3ewVd5qJk9XhbgfK6oJf02f7AoFHoPFSWLZe6 t7vXC3p/uNgZlgxH2zg6f+gAvOfsiuGUU7c03yz7PE5qMswJpjkvnqWRPPXnqG6N02v3QJomV yiCAD2ZrXAnBidZ1nCpHyrI17n7/QvgK86I3h1psOQPsLieFhcawINXKNI1K+WXskW2lhZvrq 2x6KiGWINfBINz6Y9VA4gLZQz1yWKxGglBCKphglpE6HGwLHVIaoki/7fb683+vjKpJv2xRXp YHAxC7s+/XR8lQRoKRCL7FUB4wqjeQ1Gsie8TZriTyMtUdqvMsLU7WjxbiUcgyLsguIw+vXr5 97L4OarAAGrQcjvppO7sHk8eyu12XUuDYmjHgTKfPQBh3c+Af27LbvvIv6Z49ct5uYJUAeqn9 VF2lOMRy5cP4spbAiTVydTZVhP0xQesHqYOwasIPqxePgv5iErX0JTIdpZ+DeuW0jQ8Eyh8t1 Ta6LBxHDivrMsFXmCyrxPnINY+sjfjXqMtfSqpDRJRollpk7d7KE/NzL0a2BFiBtRkQ8= Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org There are only six remaining callers of the old pci_scan_root_bus() interface. Since we want to expose the pci_host_bridge structure everywhere and discourage users from calling the old interfaces, let's move the implementation into the respective callsites. While this duplicates the source code, it makes the object code smaller for almost all users by avoiding the global implementation, and it allows further cleanup of the callers. Signed-off-by: Arnd Bergmann --- arch/ia64/sn/kernel/io_init.c | 27 +++++++++++++++++++++++++++ arch/microblaze/pci/pci-common.c | 27 +++++++++++++++++++++++++++ arch/s390/pci/pci.c | 27 +++++++++++++++++++++++++++ arch/x86/pci/common.c | 27 +++++++++++++++++++++++++++ arch/xtensa/kernel/pci.c | 27 +++++++++++++++++++++++++++ drivers/pci/probe.c | 28 ---------------------------- drivers/pci/xen-pcifront.c | 27 +++++++++++++++++++++++++++ include/linux/pci.h | 3 --- 8 files changed, 162 insertions(+), 31 deletions(-) -- 2.18.0 diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c index d63809a6adfa..e768702a7b45 100644 --- a/arch/ia64/sn/kernel/io_init.c +++ b/arch/ia64/sn/kernel/io_init.c @@ -213,6 +213,33 @@ sn_io_slot_fixup(struct pci_dev *dev) } EXPORT_SYMBOL(sn_io_slot_fixup); +static struct pci_bus *pci_scan_root_bus(struct device *parent, int bus, + struct pci_ops *ops, void *sysdata, struct list_head *resources) +{ + struct pci_host_bridge *bridge; + int error; + + bridge = pci_alloc_host_bridge(0); + if (!bridge) + return NULL; + + list_splice_init(resources, &bridge->windows); + bridge->dev.parent = parent; + bridge->sysdata = sysdata; + bridge->busnr = bus; + bridge->ops = ops; + + error = pci_scan_root_bus_bridge(bridge); + if (error < 0) + goto err_out; + + return bridge->bus; + +err_out: + kfree(bridge); + return NULL; +} + /* * sn_pci_controller_fixup() - This routine sets up a bus's resources * consistent with the Linux PCI abstraction layer. diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c index f34346d56095..302071385e1b 100644 --- a/arch/microblaze/pci/pci-common.c +++ b/arch/microblaze/pci/pci-common.c @@ -977,6 +977,33 @@ static void pcibios_setup_phb_resources(struct pci_controller *hose, (unsigned long)hose->io_base_virt - _IO_BASE); } +static struct pci_bus *pci_scan_root_bus(struct device *parent, int bus, + struct pci_ops *ops, void *sysdata, struct list_head *resources) +{ + struct pci_host_bridge *bridge; + int error; + + bridge = pci_alloc_host_bridge(0); + if (!bridge) + return NULL; + + list_splice_init(resources, &bridge->windows); + bridge->dev.parent = parent; + bridge->sysdata = sysdata; + bridge->busnr = bus; + bridge->ops = ops; + + error = pci_scan_root_bus_bridge(bridge); + if (error < 0) + goto err_out; + + return bridge->bus; + +err_out: + kfree(bridge); + return NULL; +} + static void pcibios_scan_phb(struct pci_controller *hose) { LIST_HEAD(resources); diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c index 9f6f392a4461..b21205f131ce 100644 --- a/arch/s390/pci/pci.c +++ b/arch/s390/pci/pci.c @@ -786,6 +786,33 @@ void pcibios_remove_bus(struct pci_bus *bus) kfree(zdev); } +static struct pci_bus *pci_scan_root_bus(struct device *parent, int bus, + struct pci_ops *ops, void *sysdata, struct list_head *resources) +{ + struct pci_host_bridge *bridge; + int error; + + bridge = pci_alloc_host_bridge(0); + if (!bridge) + return NULL; + + list_splice_init(resources, &bridge->windows); + bridge->dev.parent = parent; + bridge->sysdata = sysdata; + bridge->busnr = bus; + bridge->ops = ops; + + error = pci_scan_root_bus_bridge(bridge); + if (error < 0) + goto err_out; + + return bridge->bus; + +err_out: + kfree(bridge); + return NULL; +} + static int zpci_scan_bus(struct zpci_dev *zdev) { LIST_HEAD(resources); diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index d4ec117c1142..e740d9aa4024 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c @@ -453,6 +453,33 @@ void __init dmi_check_pciprobe(void) dmi_check_system(pciprobe_dmi_table); } +static struct pci_bus *pci_scan_root_bus(struct device *parent, int bus, + struct pci_ops *ops, void *sysdata, struct list_head *resources) +{ + struct pci_host_bridge *bridge; + int error; + + bridge = pci_alloc_host_bridge(0); + if (!bridge) + return NULL; + + list_splice_init(resources, &bridge->windows); + bridge->dev.parent = parent; + bridge->sysdata = sysdata; + bridge->busnr = bus; + bridge->ops = ops; + + error = pci_scan_root_bus_bridge(bridge); + if (error < 0) + goto err_out; + + return bridge->bus; + +err_out: + kfree(bridge); + return NULL; +} + void pcibios_scan_root(int busnum) { struct pci_bus *bus; diff --git a/arch/xtensa/kernel/pci.c b/arch/xtensa/kernel/pci.c index 21f13e9aabe1..5a8fd67e6c5e 100644 --- a/arch/xtensa/kernel/pci.c +++ b/arch/xtensa/kernel/pci.c @@ -116,6 +116,33 @@ static void __init pci_controller_apertures(struct pci_controller *pci_ctrl, } } +static struct pci_bus *pci_scan_root_bus(struct device *parent, int bus, + struct pci_ops *ops, void *sysdata, struct list_head *resources) +{ + struct pci_host_bridge *bridge; + int error; + + bridge = pci_alloc_host_bridge(0); + if (!bridge) + return NULL; + + list_splice_init(resources, &bridge->windows); + bridge->dev.parent = parent; + bridge->sysdata = sysdata; + bridge->busnr = bus; + bridge->ops = ops; + + error = pci_scan_root_bus_bridge(bridge); + if (error < 0) + goto err_out; + + return bridge->bus; + +err_out: + kfree(bridge); + return NULL; +} + static int __init pcibios_init(void) { struct pci_controller *pci_ctrl; diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 12c3aa63c34d..cf169742c03e 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -3050,34 +3050,6 @@ int pci_scan_root_bus_bridge(struct pci_host_bridge *bridge) } EXPORT_SYMBOL(pci_scan_root_bus_bridge); -struct pci_bus *pci_scan_root_bus(struct device *parent, int bus, - struct pci_ops *ops, void *sysdata, struct list_head *resources) -{ - struct pci_host_bridge *bridge; - int error; - - bridge = pci_alloc_host_bridge(0); - if (!bridge) - return NULL; - - list_splice_init(resources, &bridge->windows); - bridge->dev.parent = parent; - bridge->sysdata = sysdata; - bridge->busnr = bus; - bridge->ops = ops; - - error = pci_scan_root_bus_bridge(bridge); - if (error < 0) - goto err_out; - - return bridge->bus; - -err_out: - kfree(bridge); - return NULL; -} -EXPORT_SYMBOL(pci_scan_root_bus); - /** * pci_rescan_bus_bridge_resize - Scan a PCI bus for devices * @bridge: PCI bridge for the bus to scan diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c index eba6e33147a2..24070e1c5f22 100644 --- a/drivers/pci/xen-pcifront.c +++ b/drivers/pci/xen-pcifront.c @@ -443,6 +443,33 @@ static int pcifront_scan_bus(struct pcifront_device *pdev, return 0; } +static struct pci_bus *pci_scan_root_bus(struct device *parent, int bus, + struct pci_ops *ops, void *sysdata, struct list_head *resources) +{ + struct pci_host_bridge *bridge; + int error; + + bridge = pci_alloc_host_bridge(0); + if (!bridge) + return NULL; + + list_splice_init(resources, &bridge->windows); + bridge->dev.parent = parent; + bridge->sysdata = sysdata; + bridge->busnr = bus; + bridge->ops = ops; + + error = pci_scan_root_bus_bridge(bridge); + if (error < 0) + goto err_out; + + return bridge->bus; + +err_out: + kfree(bridge); + return NULL; +} + static int pcifront_scan_root(struct pcifront_device *pdev, unsigned int domain, unsigned int bus) { diff --git a/include/linux/pci.h b/include/linux/pci.h index d77ce35a2b33..d226e06fb5e5 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -912,9 +912,6 @@ int pci_host_probe(struct pci_host_bridge *bridge); int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax); int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax); void pci_bus_release_busn_res(struct pci_bus *b); -struct pci_bus *pci_scan_root_bus(struct device *parent, int bus, - struct pci_ops *ops, void *sysdata, - struct list_head *resources); int pci_scan_root_bus_bridge(struct pci_host_bridge *bridge); struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, int busnr); From patchwork Fri Aug 17 10:26:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 144468 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp597358ljj; Fri, 17 Aug 2018 03:29:40 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxZ9Z/cHT4VXQc+ks2ZaGvjQxYXjdhIWIpxe+RDBogjwfxod+gIfS2NWHpKRHOue7XbtXPv X-Received: by 2002:a17:902:ac1:: with SMTP id 59-v6mr32956454plp.18.1534501779931; Fri, 17 Aug 2018 03:29:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534501779; cv=none; d=google.com; s=arc-20160816; b=NxLranAWCDnCY3Pz81EpnOOIpWPszz9EF/XE3thVDXYzKk5N0ZwrA0s1MWynWhMUS/ iN1MupDYwaz1t459tgP/eCOsvUh2yvFOb8YqiQZIe1fEKAKEO8GyYt025f2b7++UndaF /ZKQxy6YtUfH7RYgeTNheTijXAbZD2uBipCgvHZ9omU1/8BBhjbDx+Tr+Ux9HIfCNU1G mU5+5aSshe+aMyGOe24ROJ/ncNNV3uVTntlcTcO7MQhkIg/ivEzk4w160fiO0+/DSVkU rDZ5r9aQ03KLwrggsMbK+gCV9k+gt99dZZRdUhaL5RDqPaslsqR2myixa/Mr9ZBdqpOu Pt6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=F5Zwxifn8V/tBAPGrXJsGnV6xhPcHkFiCoID5zO02J4=; b=aX6qPc14dURhTFAlCfV4ubrQjZnDl/PICgZHSvIRnG6lBPHZvVG1x4u0pIsYWopWga B81/Nv5LvLDjYXKMoLwSPuyHwiCFwGw9NNtfVut3rH+rfpV6Ft827QN7Hr+2WPQZNops rIg6VXHd2+YN+ZalgCUY2iWlZmn6B73mJRrmEMEAOj9bqSFnnksjtkNV76y32FI6YJC9 4pTufir7x3U5a7a7fZQPb/T+vNkrwKLRUNiAq4j/7080pf0eQDWdI4Aa61tjz3XNdgMI M2XRZ49/wYOu25yvkTxYjBaeh5ZrAb+8CTMKbjea+ANplLvpQN6b/YaJNDQyPqsZZYwc OFoA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 7-v6si1826272pgw.207.2018.08.17.03.29.39; Fri, 17 Aug 2018 03:29:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726339AbeHQNcd (ORCPT + 9 others); Fri, 17 Aug 2018 09:32:33 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:55085 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726226AbeHQNcc (ORCPT ); Fri, 17 Aug 2018 09:32:32 -0400 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0LvSJX-1fz1xG2f1H-010giE; Fri, 17 Aug 2018 12:27:17 +0200 From: Arnd Bergmann To: linux-pci@vger.kernel.org, Bjorn Helgaas Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Lorenzo Pieralisi , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, Arnd Bergmann Subject: [RFC 06/15] powerpc/pci: fold pci_create_root_bus into pcibios_scan_phb Date: Fri, 17 Aug 2018 12:26:36 +0200 Message-Id: <20180817102645.3839621-7-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180817102645.3839621-1-arnd@arndb.de> References: <20180817102645.3839621-1-arnd@arndb.de> X-Provags-ID: V03:K1:GixNoySXnYxESLRg71MMIUbdbc//wFh3XcXU1/rjlBZzggqeBtp KPW4mj1HSwQZQBdmqQg5+/P2JSkT5CbRoRegXb4oiClTKfDQh+QKkW5IWPmMGJO014pWS9j rUlg1LOuTJCptgf5uWmttL2Kdz0uSl83sfIu0nv6TbSYcbgDSSGxso8c+NkJc0Hlzvd+op6 I+pz8368UQ08r7uDZiDbw== X-UI-Out-Filterresults: notjunk:1; V01:K0:C2dcC/uIStM=:3Ei2a6aC1/jz/fC6EZFUqw QSvyA2LDGlBHcM8akYCfcsVYAUX9Sn93QVKdDUwUaIjZellX6+Jp08+YoKJ42rZueKfDM8cI2 tdSn7be0cCWBSvAzSDIf3xptp63SGM3UnqcA+eKUfGB14qShFIioNxoGmxuSIa8COAZ+EQb5i E0rHSOoF4RwGk3rOK7VIrz+CtN/TkS13drpbZ1SPK3/aA8JsxLxpaoOp0k6AyTyvDl4KSvKco niiqoWZgL+tQGo9msu0Bwn5FsvgShgOHtZgCgZyKHS3xxzgdEaHZ12WfSziBXQtL2Rvagu1nt 1uzeG9KTgRTMXRjGVHUz3qb6a1PFAxzpUa+dXsUge04dss81ZGpKdNlgzQtoU9Y9/7x24RhsF gDHCBftvOgWxzt/CB0XfsYa/1T2XXoMrEPo60+ctxFFsuzj9Kxkwm1hHaxB9RDjoxvM/qI5hN H702qoml66LVdN8BwvZ2Xxadpq1kfgX3Ek61O9sXCtG8+566F+6hSBca3MOYK4AFD2/1Udli3 JiSNWzt9W0B+4GJ0LnWMxL8u0Rcs9V7BfNODINGNavNtMCB88UzaVBtXx4ccTs0Ne9KlHGixU E3uNjsM9wfOEAiSRYnoGgBGhomF68lw7y7k2g6H7owOaYcPkCS45r5zKAyFPFzGo03HW4zd0K VhnsBhPwJwpyt920c4dup7565tuAwVDIGRIuKedk+ndktXMirehAC/jTBYLdiIGEcXRI= Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org This slightly simplifies the pcibios_scan_phb() implementation, and gives us an easier point to add further fields in the pci_host_bridge structure. I tried removing fields that are duplicated between pci_host_bridge and pci_controller (which really serve the same purpose), but ran into the problem that we can't call pci_alloc_host_bridge() as early as pcibios_alloc_controller(). Some more refactoring is needed for that, but it could noticably clean the powerpc code up more. Signed-off-by: Arnd Bergmann --- arch/powerpc/include/asm/pci-bridge.h | 3 ++ arch/powerpc/kernel/pci-common.c | 72 ++++++++++----------------- 2 files changed, 30 insertions(+), 45 deletions(-) -- 2.18.0 diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h index 94d449031b18..42ae567084d9 100644 --- a/arch/powerpc/include/asm/pci-bridge.h +++ b/arch/powerpc/include/asm/pci-bridge.h @@ -51,8 +51,11 @@ struct pci_controller_ops { /* * Structure of a PCI controller (host bridge) + * Some members here are duplicated in struct pci_host_bridge + * and should be moved there. */ struct pci_controller { + struct pci_host_bridge *bridge; struct pci_bus *bus; char is_dynamic; #ifdef CONFIG_PPC64 diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 57ca621a32f4..096011ec8670 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -1587,81 +1587,63 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus) return of_node_get(hose->dn); } -static struct pci_bus *pci_create_root_bus(struct device *parent, int bus, - struct pci_ops *ops, void *sysdata, struct list_head *resources) -{ - int error; - struct pci_host_bridge *bridge; - - bridge = pci_alloc_host_bridge(0); - if (!bridge) - return NULL; - - bridge->dev.parent = parent; - - list_splice_init(resources, &bridge->windows); - bridge->sysdata = sysdata; - bridge->busnr = bus; - bridge->ops = ops; - - error = pci_register_host_bridge(bridge); - if (error < 0) - goto err_out; - - return bridge->bus; - -err_out: - kfree(bridge); - return NULL; -} - /** * pci_scan_phb - Given a pci_controller, setup and scan the PCI bus * @hose: Pointer to the PCI host controller instance structure */ void pcibios_scan_phb(struct pci_controller *hose) { - LIST_HEAD(resources); - struct pci_bus *bus; struct device_node *node = hose->dn; int mode; + struct pci_host_bridge *bridge; + int error; pr_debug("PCI: Scanning PHB %pOF\n", node); + /* The allocation should ideally be done in pcibios_alloc_controller(), + * but pci_alloc_host_bridge() requires slab to work first */ + bridge = pci_alloc_host_bridge(0); + if (!bridge) + return; + /* Get some IO space for the new PHB */ pcibios_setup_phb_io_space(hose); /* Wire up PHB bus resources */ - pcibios_setup_phb_resources(hose, &resources); + pcibios_setup_phb_resources(hose, &bridge->windows); hose->busn.start = hose->first_busno; hose->busn.end = hose->last_busno; hose->busn.flags = IORESOURCE_BUS; - pci_add_resource(&resources, &hose->busn); + pci_add_resource(&bridge->windows, &hose->busn); + + bridge->dev.parent = hose->parent; + bridge->sysdata = hose; + bridge->busnr = hose->first_busno; + bridge->ops = hose->ops; - /* Create an empty bus for the toplevel */ - bus = pci_create_root_bus(hose->parent, hose->first_busno, - hose->ops, hose, &resources); - if (bus == NULL) { + error = pci_register_host_bridge(bridge); + if (error < 0) { pr_err("Failed to create bus for PCI domain %04x\n", hose->global_number); - pci_free_resource_list(&resources); + pci_free_host_bridge(bridge); return; } - hose->bus = bus; + hose->bridge = bridge; + hose->bus = bridge->bus; /* Get probe mode and perform scan */ mode = PCI_PROBE_NORMAL; if (node && hose->controller_ops.probe_mode) - mode = hose->controller_ops.probe_mode(bus); + mode = hose->controller_ops.probe_mode(bridge->bus); pr_debug(" probe mode: %d\n", mode); if (mode == PCI_PROBE_DEVTREE) - of_scan_bus(node, bus); + of_scan_bus(node, bridge->bus); if (mode == PCI_PROBE_NORMAL) { - pci_bus_update_busn_res_end(bus, 255); - hose->last_busno = pci_scan_child_bus(bus); - pci_bus_update_busn_res_end(bus, hose->last_busno); + pci_bus_update_busn_res_end(bridge->bus, 255); + hose->last_busno = pci_scan_child_bus(bridge->bus); + pci_bus_update_busn_res_end(bridge->bus, hose->last_busno); } /* Platform gets a chance to do some global fixups before @@ -1671,9 +1653,9 @@ void pcibios_scan_phb(struct pci_controller *hose) ppc_md.pcibios_fixup_phb(hose); /* Configure PCI Express settings */ - if (bus && !pci_has_flag(PCI_PROBE_ONLY)) { + if (bridge->bus && !pci_has_flag(PCI_PROBE_ONLY)) { struct pci_bus *child; - list_for_each_entry(child, &bus->children, node) + list_for_each_entry(child, &bridge->bus->children, node) pcie_bus_configure_settings(child); } } From patchwork Fri Aug 17 10:26:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 144469 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp600459ljj; Fri, 17 Aug 2018 03:32:37 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzuiI8sCABw9O1iNhs/OubB3KbiD0mwMw8wSXrEkUa9QLZ9s17A+bB/I4Cn0OLSpex3zPk7 X-Received: by 2002:a63:3d41:: with SMTP id k62-v6mr32430643pga.254.1534501957837; Fri, 17 Aug 2018 03:32:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534501957; cv=none; d=google.com; s=arc-20160816; b=ezJxZfHlGuuBCUcVnEvBKHApg02NCQekJ0LjSCxnddiSeT/jkVuv5Tqqrb6UeqT0Pi Lnhm2c3lhNou+jeNod8m0v0hQHfXsClgbt0gnm0pMz7iVeCbTFRsbRYTZnbwVQR6u9kP ihLP+7Bw0YPZrrXAAH4wKfBacKp0jhTBcTwXhv1vzPiiOx6USPbTVv/0e+ffoRdPuajF nPvd2e7G3l5BCCtJ9fv5T2yorKYhz6aTPUqhESzQ6rhZ4H8jr5evzmctCJEfHsgN22Jo g+8iRsX7cEZP3T4c9cl8fdQWwijM3AlsbDjuGq2auivibhGQiToi6oZwqAb9XEH9v9+Z n1Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=itK3PnYOQ97entVnURmWte0Mcw/NI960fHv7WmwGUdU=; b=SnPtiT2OLzGNapKxaBJF+UeaM542K7sXyQlfp8tutw269wa5WtOyQAB70sUEU1YPQC i42H4QfmhW/TPxOZRFVbxpE8G02/e825KSuLFfcRXvvlhCMQPY5EftqZcWRI7pAO7I3L xF8XchDZ65d67tK9rYYSYuobxSOegVVfAwU1brDhPaf/XAItCc1fHXKaiW3yiqCHlYMq aYUdChGYrjNi+h5KmxprwP6nReoWq8RMWhbpLE1cuDqIHDxyCLIwm4WQ9uIKLuelPU6E fYCMDx+juZsko4fvvHzj2BO4msdQMqb2gz6CqeZdrWdsl6LeOoNDrnF/QxbYvG9+X4Ug EElA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l5-v6si1673154pff.304.2018.08.17.03.32.37; Fri, 17 Aug 2018 03:32:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726213AbeHQNfb (ORCPT + 9 others); Fri, 17 Aug 2018 09:35:31 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:52961 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725845AbeHQNfb (ORCPT ); Fri, 17 Aug 2018 09:35:31 -0400 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0LgHVU-1gBMPa1mGS-00ngPB; Fri, 17 Aug 2018 12:27:18 +0200 From: Arnd Bergmann To: linux-pci@vger.kernel.org, Bjorn Helgaas Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Lorenzo Pieralisi , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, Arnd Bergmann Subject: [RFC 08/15] x86: PCI: clean up pcibios_scan_root() Date: Fri, 17 Aug 2018 12:26:38 +0200 Message-Id: <20180817102645.3839621-9-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180817102645.3839621-1-arnd@arndb.de> References: <20180817102645.3839621-1-arnd@arndb.de> X-Provags-ID: V03:K1:tlcedIIbu3wiz3zsxlYn2+G+v0etxI3PP6TAmZreLsijFeYR04M h/VODDtc+5SUwz1uyxw71Eq8VwF/rrPeX4Mi73yyRzW86zhOmQypatEJjTmy5UJ8/VTs3si Or6SucrdTdcrzJKrTR3QI43wWqbF1ZN69gr+AUCaoNRbF51vgqmBAbIdS99XUNw57/qq4KP 6/LoQH+SxPzNn6+AMM4rg== X-UI-Out-Filterresults: notjunk:1; V01:K0:weQ6RTKTUsY=:XbEL7s+SkjRfvaO/OBnUBt ht0iALf7RLwZ+Pg4PqsRtLWIZH4P1cYoeJV2Ihh0UQD1qouQ1J3OdYGV47+3L395N4n9voRlw IH4kXgIGHDHCQojbrS3ViJndFx6PJGDA8jk0NkZUSTLdBLzcbHAXrOjmUbSx6xv3rPr1Y86YB OJXCDPtboW5sf4qcQm0weWm/5Knr32PPYh5RgJrZ96UyNL/oNUnxMttcHcBswPlYdETa8AAXh jikLLMG11oGfgI10VBT2eShT/ILBVvB+eQSbge2txFONEJ66ESQjUnT38uBXBC4XvkO3kd+zl k+bscHpGd3QyNeWxs8XZyzPmhNKsXNjOdqUU+7yfMAp0UgSwH7Fn/a9JkbkN21WNBAOLUx6lE u+g4OrVQFBzvcwkmwHY4WKdpYQv3pKzYkKDCNmHQptwy7ynQkXmd2n5dq9hyDTsnkE63eTbWG zCHFSRlEIpUfEdU/YuNCSJJIFcyGYt08H+qwfW9+OxsHZo5qCQSOEqq47OtnyIJANhMhiD+pP YeLmH89ATYf2Ug1E9TPiz3qcV3UGNuP3s3iW7iJjJChA5hN+Hg52TgED0fTWiH/i+nPQ8oUde eSO38j3Y3kkOt93/38VBYsVKkPRXM0J5QLiplQndvAB9Xr3l9hshp9Dopw2tthNxH4X3CDbPP jXxyPaG7Fw9HHSQZMuplcmXPAS09LGPqYRYwgkvq7V313AabwV/yRxpFa3DBpIdTwt+U= Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org pcibios_scan_root() is now just a wrapper around pci_scan_root_bus(), and merging the two into one makes it shorter and more readable. We can also take advantage of pci_alloc_host_bridge() doing the allocation of the sysdata for us, which helps if we ever want to allow hot-unplugging the host bridge itself. We might be able to simplify it further using pci_host_probe(), but I wasn't sure about the resource registration there. Signed-off-by: Arnd Bergmann --- arch/x86/pci/common.c | 53 ++++++++++++++----------------------------- 1 file changed, 17 insertions(+), 36 deletions(-) -- 2.18.0 diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index e740d9aa4024..920d0885434c 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c @@ -453,54 +453,35 @@ void __init dmi_check_pciprobe(void) dmi_check_system(pciprobe_dmi_table); } -static struct pci_bus *pci_scan_root_bus(struct device *parent, int bus, - struct pci_ops *ops, void *sysdata, struct list_head *resources) +void pcibios_scan_root(int busnum) { + struct pci_sysdata *sd; struct pci_host_bridge *bridge; int error; - bridge = pci_alloc_host_bridge(0); - if (!bridge) - return NULL; + bridge = pci_alloc_host_bridge(sizeof(sd)); + if (!bridge) { + printk(KERN_ERR "PCI: OOM, skipping PCI bus %02x\n", busnum); + return; + } + sd = pci_host_bridge_priv(bridge); - list_splice_init(resources, &bridge->windows); - bridge->dev.parent = parent; - bridge->sysdata = sysdata; - bridge->busnr = bus; - bridge->ops = ops; + sd->node = x86_pci_root_bus_node(busnum); + x86_pci_root_bus_resources(busnum, &bridge->windows); + bridge->sysdata = sd; + bridge->busnr = busnum; + bridge->ops = &pci_root_ops; + printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum); error = pci_scan_root_bus_bridge(bridge); if (error < 0) goto err_out; - return bridge->bus; + pci_bus_add_devices(bridge->bus); + return; err_out: - kfree(bridge); - return NULL; -} - -void pcibios_scan_root(int busnum) -{ - struct pci_bus *bus; - struct pci_sysdata *sd; - LIST_HEAD(resources); - - sd = kzalloc(sizeof(*sd), GFP_KERNEL); - if (!sd) { - printk(KERN_ERR "PCI: OOM, skipping PCI bus %02x\n", busnum); - return; - } - sd->node = x86_pci_root_bus_node(busnum); - x86_pci_root_bus_resources(busnum, &resources); - printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum); - bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources); - if (!bus) { - pci_free_resource_list(&resources); - kfree(sd); - return; - } - pci_bus_add_devices(bus); + pci_free_host_bridge(bridge); } void __init pcibios_set_cache_line_size(void) From patchwork Fri Aug 17 10:26:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 144460 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp595571ljj; Fri, 17 Aug 2018 03:27:37 -0700 (PDT) X-Google-Smtp-Source: AA+uWPy4+h8GI4RSXiKhl1dXr5Jsj3GctK2l9wYfCqJNxznCrcUI7KgNiya7sMaGlEaIRxnI9YmX X-Received: by 2002:a63:6485:: with SMTP id y127-v6mr1776160pgb.393.1534501656906; Fri, 17 Aug 2018 03:27:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534501656; cv=none; d=google.com; s=arc-20160816; b=C9DbVEIUIp+1jAHgzgojgFXzah8arLMZIuojhyIqoenTeoSeGsUSPJzeiGiZUeIODc +3EH2ouKCM+FRpa8gHV++7ygK9Sw2U6xoighUROUi6WGIA2bMbjbDZuBwQO1ww1F42Vh GFBJ75dso2vkW9Lt8adzBN6GkxUGDQvXNA7jSdiwhG5etviXU278Ej2RwvQV6sTX54Zm 8rlEScP/eFC6YGPgnpNw7ynqYLHNTI30A2Dw6t0yJ9uN74BsirFevs9SlT/N0CUdHKBl czUtooEDC818F2D+TtetI+OYgQWbydZJKph593vs8OxJ9QZtLjeDE8FNmrYycTg0kpOZ q7nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=4glr0kvgtSk5U4Z0QAVyubzO4ZZgzOjt7IHSG/rJRz0=; b=RgaaTrTGgjCVIfnXjlx4QhTocamJVrbQsar3r7qIMAP3gAteY9W+YC/XYF9QybJ0ZS NmLECqoj5vWbfX6Zjl7NxBGm6Xl5kxQHvQBRavBou7jdVnw7E65awniN92M+eMu9yj0y R3YVsBe9ZuCi3tSibAin/TJzCnq1YhGLVp9TN8tSI4IuxgIffIeIsro1gojiu7BCnaEl +suYcZbhIPBBkmK48F4hVfGCVzjFMUQ4BpjlJI/Bu/ABjoIjxVv0hjXi0rslGwhsR9Kw Zcqml5/lUu/CNjoP3MNf1MidrM7fcHvn6iiwrmTp97Hk8mcx2wshzZMwWNkGCJ24EAuV AT2Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i8-v6si1631175pgj.33.2018.08.17.03.27.36; Fri, 17 Aug 2018 03:27:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726376AbeHQNa3 (ORCPT + 9 others); Fri, 17 Aug 2018 09:30:29 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:54093 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725845AbeHQNa3 (ORCPT ); Fri, 17 Aug 2018 09:30:29 -0400 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0MF3Yx-1ffKFY0w9b-00GG86; Fri, 17 Aug 2018 12:27:19 +0200 From: Arnd Bergmann To: linux-pci@vger.kernel.org, Bjorn Helgaas Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Lorenzo Pieralisi , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, Arnd Bergmann Subject: [RFC 10/15] sparc/PCI: simplify pci_scan_one_pbm Date: Fri, 17 Aug 2018 12:26:40 +0200 Message-Id: <20180817102645.3839621-11-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180817102645.3839621-1-arnd@arndb.de> References: <20180817102645.3839621-1-arnd@arndb.de> X-Provags-ID: V03:K1:tqfqrJow5W4imcQdki9mGzYbBLDxofa09sQuKVVmcKPe9NKicQu 8BCFKR5x8HHGblInvnpgfM0Om9m61dXNuEzCIJ49sP//cfH3KTR8BqOqORdz4p1h7JROjqJ CiXbMgNkdpblfAYzq1OUFR9CqgorJFNPchgd2Qp4LZRLY2gq8SB2mQD0V3AQBL6R9BKkfBV T5dOLAgJhkzmztez96I5g== X-UI-Out-Filterresults: notjunk:1; V01:K0:HIAfquh0tdI=:0dA2U75J9e6Y7bRAeRLDpU fiYaLHOH0AVd2s9rov8WWEfjDdY97CTXbyas7dLBOmGUy3alOcAjpKpHC23tgOnaVQ+KqEI6h SY9mf4k7l5qaPraBVNvUcijJ5fmnEtBnPKgZ61VULSXOUZB5C/Ae7EZvleU8GoWQOaYqho0Wd uv/8+l54vLvdm+i5rPtjRntUa0wDwIEyviUXWwEMjn2CXS3RUp6te6SkpZAk/YRuhDiuAPAyn qS3vZeDS+n5QC9CSNsDkv/SZ+RjR/eqV5DgKB1PKXzj2nUybL8qQv/RkGazoc04kHmvd+GF6R pTM19Xq8siVJoyeODtmjIkZ0Ttt6uew7BA7y+E4RdhS0D4pgV2L9y4U9V4VxKgU2HjujjxexW Uw6KKZh3BTyN0rov5fERh2p1R5nunp9qffBcEle8v5LH2pInZmdZOMSZzDYRHk29LkoYJ7qFU Ba0xUQlY2OcL9tOKbHMps8HhKxVob6TtX+/MCqIRHQ07673JUS92Fnbu7MYYBBp8JHzjJTE96 xlfE87rK553fEbwQ3WXiwNpYx+zmtNhznqU/mX/rLks1rS4WTfc5rEPfPn1fPOH4+xrf9FvkG OxcDpE4M86hDsuMcxq9q/dlgAfu34AMyTyIXeh0xv2ZFXedd8Z5m7vqzzTxVmz8oOCGMN9HVo /oqizZtfSKo7q+qqQIjvQG9mW/eRsqNid04WKSzays1sWwEwevVrC6W8SHm7Wl9Edo3I= Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org We no longer need a separate pci_create_root_bus() function, and merging it into pci_scan_one_pbm() makes the implementation easier to understand. A possible future cleanup would move the allocation of the pci_host_bridge structure into the callers of pci_scan_one_pbm, and avoid duplication between pci_host_bridge and pci_pbm_info fields. Signed-off-by: Arnd Bergmann --- arch/sparc/kernel/pci.c | 62 ++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 41 deletions(-) -- 2.18.0 diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c index afbce59d9231..0d34fb2ac55b 100644 --- a/arch/sparc/kernel/pci.c +++ b/arch/sparc/kernel/pci.c @@ -691,70 +691,50 @@ static void pci_claim_bus_resources(struct pci_bus *bus) pci_claim_bus_resources(child_bus); } -static struct pci_bus *pci_create_root_bus(struct device *parent, int bus, - struct pci_ops *ops, void *sysdata, struct list_head *resources) +struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm, + struct device *parent) { - int error; + struct device_node *node = pbm->op->dev.of_node; struct pci_host_bridge *bridge; + int ret; bridge = pci_alloc_host_bridge(0); if (!bridge) return NULL; bridge->dev.parent = parent; + bridge->sysdata = pbm; + bridge->busnr = pbm->pci_first_busno; + bridge->ops = pbm->pci_ops; - list_splice_init(resources, &bridge->windows); - bridge->sysdata = sysdata; - bridge->busnr = bus; - bridge->ops = ops; - - error = pci_register_host_bridge(bridge); - if (error < 0) - goto err_out; - - return bridge->bus; - -err_out: - kfree(bridge); - return NULL; -} - -struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm, - struct device *parent) -{ - LIST_HEAD(resources); - struct device_node *node = pbm->op->dev.of_node; - struct pci_bus *bus; - - printk("PCI: Scanning PBM %s\n", node->full_name); - - pci_add_resource_offset(&resources, &pbm->io_space, + pci_add_resource_offset(&bridge->windows, &pbm->io_space, pbm->io_offset); - pci_add_resource_offset(&resources, &pbm->mem_space, + pci_add_resource_offset(&bridge->windows, &pbm->mem_space, pbm->mem_offset); if (pbm->mem64_space.flags) - pci_add_resource_offset(&resources, &pbm->mem64_space, + pci_add_resource_offset(&bridge->windows, &pbm->mem64_space, pbm->mem64_offset); pbm->busn.start = pbm->pci_first_busno; pbm->busn.end = pbm->pci_last_busno; pbm->busn.flags = IORESOURCE_BUS; - pci_add_resource(&resources, &pbm->busn); - bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops, - pbm, &resources); - if (!bus) { + pci_add_resource(&bridge->windows, &pbm->busn); + + printk("PCI: Scanning PBM %s\n", node->full_name); + ret = pci_register_host_bridge(bridge); + if (!ret) { printk(KERN_ERR "Failed to create bus for %s\n", node->full_name); - pci_free_resource_list(&resources); + pci_free_host_bridge(bridge); return NULL; } - pci_of_scan_bus(pbm, node, bus); - pci_bus_register_of_sysfs(bus); + pci_of_scan_bus(pbm, node, bridge->bus); + pci_bus_register_of_sysfs(bridge->bus); - pci_claim_bus_resources(bus); + pci_claim_bus_resources(bridge->bus); - pci_bus_add_devices(bus); - return bus; + pci_bus_add_devices(bridge->bus); + return bridge->bus; } int pcibios_enable_device(struct pci_dev *dev, int mask) From patchwork Fri Aug 17 10:26:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 144471 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp600527ljj; Fri, 17 Aug 2018 03:32:42 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxMaR05gop0FSh53R6QSvdqlP3GENBL9BzR+WlJUSy2r85mRLq3VNPVMx/nG2fbJoic+63X X-Received: by 2002:a17:902:7883:: with SMTP id q3-v6mr32418794pll.264.1534501962238; Fri, 17 Aug 2018 03:32:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534501962; cv=none; d=google.com; s=arc-20160816; b=C/vEdzlOkSmKcNKpO97kBTGTBvCMCXqdCsh4rpJIkAeB3poNgfTKH2/HeCYw8cCQM4 fbIq7okcsp3G1SMApltcHte6poyfos0PCCck3iavhB+uNkua74i5OEURHHFc1qbqBf0R xm5MSj/vCVlLs32Kct2sMxgXbYs+YHp+N4cBvadUeXIfGfq7R4iC/Gd06S9lKz46+5eZ u8RjET9amx6ko9UXbHOFv5Pjrf4n8drnET5FMHvAIsZd6hcChYLG8hmTZS/1KO2g3/9b VjrvfbaHr7CoOjDkyMogVVKBN0FpTdo9qQ1b03nV5drezJFPSUzKSbY1BUE/GfBLqy9n alXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=ufUodDYAFzgd7WNVdlY/Yr+NgGzGmsr7/1NlHE57JBY=; b=jAq4c4D/AdIh8G/DwzdMy0zwxJkCYlPSVk3Hv3/tH4nDqKlgJkUvkgnyDSp4xWAZv/ 1CzKsiaTbX2izqmVIFsh5naB2pvbj8jXTQdD4BEuOopYr2nDPDWy4ZJg+EzAP0DK01xJ QPstHdBZOIYnU7dzSQf93czvmTSgD1ffpW8QuVuTto0BDhJXL46aoWkzJSg4tSwQa+jb 6MVfi/oxflojRlC44w8DcOF/GWAubFAhRPhRMSBQqhgoobsE+cl62lVCH2lzI/GstCwN sd+KYzqnVc0EP9KjCyMtSRQ5XqVutz2L7MNoK/HoQFfWcPmiQBZH7dDwH4upc348yx40 Vv8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e1-v6si47820pgk.275.2018.08.17.03.32.42; Fri, 17 Aug 2018 03:32:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726860AbeHQNff (ORCPT + 9 others); Fri, 17 Aug 2018 09:35:35 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:42823 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725992AbeHQNfd (ORCPT ); Fri, 17 Aug 2018 09:35:33 -0400 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0M2Mj6-1g72xf2n4O-00s8O9; Fri, 17 Aug 2018 12:27:19 +0200 From: Arnd Bergmann To: linux-pci@vger.kernel.org, Bjorn Helgaas Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Lorenzo Pieralisi , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, Arnd Bergmann Subject: [RFC 11/15] PCI: hyperv: convert to pci_scan_root_bus_bridge Date: Fri, 17 Aug 2018 12:26:41 +0200 Message-Id: <20180817102645.3839621-12-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180817102645.3839621-1-arnd@arndb.de> References: <20180817102645.3839621-1-arnd@arndb.de> X-Provags-ID: V03:K1:GawKYPNeblKXqePXMTqVUwJzPp4kDv9XunHKMjoeqmVocUEEVjM lkYgN2PiNwSPbXjS7Dii+2JTCPx/c95lj3gECJvX5IBv4mvtne+6VUdTVunsCr0Y+mlTkfc DGbWBehQ648C/tekyqiyObV6jpd7FXp6y3vcEIFfvC8pa/mnrRfRoZ+Og0ehO+tP6FrDZE9 w8e4yawJshAPLppwwwJWw== X-UI-Out-Filterresults: notjunk:1; V01:K0:fxpVOh8CRvU=:q/r7CREw9q7Zjc/R/UTtzI t09tyN3hj1ulxsUAzwtiN6AP+Rrjag5zkIt+HBEPBbM2Qt/i/TWhW/n8MjB28kbWWFK/MfDk7 gYijMym2nAJA4EMb5oVzsbOB8TnLE9YGisDWuQtl09NvT0bvZWyCA7xZO3NUQVqQ0Gcl/o1sE YKJVPpgo+50TIG2bcPc9h5rl4Y1MLY/J866SsPVzk0buhtSh+ze5U0vDh23BIxCiXbln9ROdP XvD6AbRXd+Ab+OC6ueC6HDkxBTySOCIniSsVcKXivMdEmvxRdOAexM8J1kGzfL1niEItbNFF4 jPnQLewOBUcKHhhbt8ywxxetNSttd2yMQ6g5guRzWrrxs6XkNsjGKcOF102uqXH6L4b33rkWw T7eaXdgQSv9TS+l5E32pKSbHyjQ0bqMdvtJhtjFxBXeg3R2N9QHjzSbXgHUwy8+7/oRgu/ZN/ spJB24Qski3myqmjqhwQUg53lrz2irhiVphDyNLNPOavK116uauw6ZLjBH28xbYVU/3YUPFQl SLFzyR7Bb+XhM0L3GrmWQS9sx/AJgCwXWMUuE+Uv7/jNeORoJkSUNta25Ob6qPNSsHFV6ZsBu J/LvXO995FFGSi53/kmB9DbAj68BzSVuHU0E3BKj5GHm7w/cnTp1m2PGqGA6+/Z8WiiFTsg1N eZOkQdSTxgzBTJDY2e+UDyLrd8axaxN+A7+mMgqRIWYrx6PZtMOS4ps7zz5vqdsoA/VA= Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org create_root_hv_pci_bus() uses a rather generic method of probing the host bridge, which can be simplified by just calling pci_scan_root_bus_bridge() after setting up the pci_host_bridge structure. Since we can no longer assign hbus->pci_bus in the middle, I just remove that member completely and use the pci_host_bridge instead. Ideally we'd convert it to pci_host_probe() for simplicity, but that is a bit different and I could not easily test it. Using pci_scan_root_bus_bridge should not change the behavior at all. Signed-off-by: Arnd Bergmann --- drivers/pci/controller/pci-hyperv.c | 75 +++++++++++------------------ 1 file changed, 28 insertions(+), 47 deletions(-) -- 2.18.0 diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index df7cddea8e30..49586aefa38b 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -443,7 +443,7 @@ struct hv_pcibus_device { struct resource *high_mmio_res; struct completion *survey_event; struct completion remove_event; - struct pci_bus *pci_bus; + struct pci_host_bridge *bridge; spinlock_t config_lock; /* Avoid two threads writing index page */ spinlock_t device_list_lock; /* Protect lists below */ void __iomem *cfg_addr; @@ -1457,34 +1457,6 @@ static void prepopulate_bars(struct hv_pcibus_device *hbus) spin_unlock_irqrestore(&hbus->device_list_lock, flags); } -static struct pci_bus *pci_create_root_bus(struct device *parent, int bus, - struct pci_ops *ops, void *sysdata, struct list_head *resources) -{ - int error; - struct pci_host_bridge *bridge; - - bridge = pci_alloc_host_bridge(0); - if (!bridge) - return NULL; - - bridge->dev.parent = parent; - - list_splice_init(resources, &bridge->windows); - bridge->sysdata = sysdata; - bridge->busnr = bus; - bridge->ops = ops; - - error = pci_register_host_bridge(bridge); - if (error < 0) - goto err_out; - - return bridge->bus; - -err_out: - kfree(bridge); - return NULL; -} - /** * create_root_hv_pci_bus() - Expose a new root PCI bus * @hbus: Root PCI bus, as understood by this driver @@ -1493,25 +1465,34 @@ static struct pci_bus *pci_create_root_bus(struct device *parent, int bus, */ static int create_root_hv_pci_bus(struct hv_pcibus_device *hbus) { - /* Register the device */ - hbus->pci_bus = pci_create_root_bus(&hbus->hdev->device, - 0, /* bus number is always zero */ - &hv_pcifront_ops, - &hbus->sysdata, - &hbus->resources_for_children); - if (!hbus->pci_bus) - return -ENODEV; + struct pci_host_bridge *bridge; + int ret; + + bridge = pci_alloc_host_bridge(0); + if (!bridge) + return -ENOMEM; - hbus->pci_bus->msi = &hbus->msi_chip; - hbus->pci_bus->msi->dev = &hbus->hdev->device; + hbus->bridge = bridge; + bridge->dev.parent = &hbus->hdev->device; + list_splice_init(&hbus->resources_for_children, &bridge->windows); + bridge->sysdata = &hbus->sysdata; + bridge->ops = &hv_pcifront_ops; + bridge->msi = &hbus->msi_chip; + bridge->msi->dev = &hbus->hdev->device; pci_lock_rescan_remove(); - pci_scan_child_bus(hbus->pci_bus); - pci_bus_assign_resources(hbus->pci_bus); - pci_bus_add_devices(hbus->pci_bus); - pci_unlock_rescan_remove(); + /* ideally we should use pci_host_probe here */ + ret = pci_scan_root_bus_bridge(bridge); + if (ret < 0) { + pci_free_host_bridge(bridge); + goto error; + } + pci_bus_assign_resources(bridge->bus); + pci_bus_add_devices(bridge->bus); hbus->state = hv_pcibus_installed; - return 0; +error: + pci_unlock_rescan_remove(); + return ret; } struct q_res_req_compl { @@ -1769,7 +1750,7 @@ static void pci_devices_present_work(struct work_struct *work) * because there may have been changes. */ pci_lock_rescan_remove(); - pci_scan_child_bus(hbus->pci_bus); + pci_scan_child_bus(hbus->bridge->bus); pci_unlock_rescan_remove(); break; @@ -2669,8 +2650,8 @@ static int hv_pci_remove(struct hv_device *hdev) if (hbus->state == hv_pcibus_installed) { /* Remove the bus from PCI's point of view. */ pci_lock_rescan_remove(); - pci_stop_root_bus(hbus->pci_bus); - pci_remove_root_bus(hbus->pci_bus); + pci_stop_root_bus(hbus->bridge->bus); + pci_remove_root_bus(hbus->bridge->bus); pci_unlock_rescan_remove(); hbus->state = hv_pcibus_removed; } From patchwork Fri Aug 17 10:26:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 144474 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp600933ljj; Fri, 17 Aug 2018 03:33:05 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxP9djtqrYfuWQ24Hr+2GN1n3AqwEhtcCj+bqp4ja+7elCI4BSARxo96hR56PS5nP4YQsjo X-Received: by 2002:a63:4386:: with SMTP id q128-v6mr32498766pga.353.1534501985587; Fri, 17 Aug 2018 03:33:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534501985; cv=none; d=google.com; s=arc-20160816; b=DevS1Rojmp85NN9TrEmyH5m3kLyw10qGRI+2xZx3qQ6uNmu59QCfeUgshNwLqDXs8x CTCgKwipDX5qew0SvYqNKuq4ZKoap4JA6h58TQK6h4hdPUlvZHAnG55BV0pUa98Y8KiE Gp4F2EStdHFhg9vx92RY0ZNmInzLnCdCXdiQIPB/X0dMYF+bw0ML5XKQ1nfp1BheVBRk yQh+8s8qnVq2DFstQtERShfHlScupLWhbFhjWzUteuqFcUVouFbiSyD5O9s1OHenehdd la4ZjQfY3XPoMLqF0PhHs9AmgLpXcdBKxtbI764cTXwyMz6/v1psuXFH6anmKvTW1X3Q BLCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=g7wxfw76aZWI35Ws4WNA2KhvYos3vv5ZQBFZqyKGqYs=; b=TdFM73V2RPcHMHWjKHnHnFneU8LT4dM4qfQr+OJmuhIZKgWZlkJoRuscDpJq6dbqVD kDILU8uQAo4/axEcRl0FqG70DFR5NYB5Eci/3e9Y3zaFYHX/Z3m6q7b9pOQm7ZbZcIFs lRBuzm6fisTvpv/c74f7nUv/vavJRVIrTFzp4mTRIO/B1WRCSFaELcB0K4jHUy5JCOm2 suK5tw/41rVXGy/4koav6/hjygmmNRbfIgZpQhs2G7em4HMKn/MWE1SWfPBtAD8L6ihE 8O5zqPZQ3eQjQwUTj4CZ083HkxuqznvvK7ZxIxkh+viNQ3ddb+Cd6LMR790KoJWJsEZk RdCA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e7-v6si1843308plt.325.2018.08.17.03.33.05; Fri, 17 Aug 2018 03:33:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725992AbeHQNf7 (ORCPT + 9 others); Fri, 17 Aug 2018 09:35:59 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:53879 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726795AbeHQNfe (ORCPT ); Fri, 17 Aug 2018 09:35:34 -0400 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0LopY3-1gNDhj20RX-00glB0; Fri, 17 Aug 2018 12:27:20 +0200 From: Arnd Bergmann To: linux-pci@vger.kernel.org, Bjorn Helgaas Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Lorenzo Pieralisi , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, Arnd Bergmann Subject: [RFC 13/15] PCI: turn pcibios_alloc_irq into a callback Date: Fri, 17 Aug 2018 12:26:43 +0200 Message-Id: <20180817102645.3839621-14-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180817102645.3839621-1-arnd@arndb.de> References: <20180817102645.3839621-1-arnd@arndb.de> X-Provags-ID: V03:K1:vGOxD5cso1fRX7vOFpg6264LHD7qp984mQlv5MPT6s07XrS4K2q Ixzfk8bDO/hDFJUEyLUy4cqBFvWycxqJfqu8myqpu+DeGzm1WHg70Dm0VhCWS3UfXdQMZUh vCVDLDNLy0TIi89lHJhy6GxOzRcS4zgTlQr8KfLRoWv/eaypGIooBRH9J0jTanPDmePlu2G yp3nrpbGuNd8g0mqp4zsg== X-UI-Out-Filterresults: notjunk:1; V01:K0:qiT72hH/I1Q=:9Hqj/v305t7b/4GjgDoN/e Ue8HbedIQ953rUOU4QCIrxtJEmq42LgC1lNOW2wV05FwAP1teCMpuw5EXUnwyVPR5Pst0E2oT yFIfuTQMC0KVvRUuZiHkl2xc8AV844sORxrAHRk2FYS6HDx3zKe98/ZfITQolb0YeyfUWSegv 5kgbJb+UtFGVEoCzgiHqOV1URMwqykKggoFu98N5hGdy4ACiAHfwLtrfjAy3XgMtIp34q95eJ OLTSZTGpJWJCzzZGDuH78sPadMJmvRrWhgD/FQsYl9AZcG5gutbR7vaZK5V7TeNW/hfk/xuuG RoKaH+M4ewI+f7cG9bReKVqfGInD2+FlK4EPmJ8ItQmjzgCNAzALHkB8vlXsXRUVgH2lQ+3dI 03VNLSmbzlhW+aTOur1hTEge9XLP6vHyWg+upyxLGH2zy3BedElcJxWQ1BDWFvux20M1regty +mz5A2Rn/dSr6r2aK2KPpTSr1P8DnlMFYoVGvnDwPULJd89k7o8WU2pnHdzi5deZxVHK//YDJ T7ctzSbG72zxqlW3vMSAAnCsQTbSNWnTU+EfZfiJGEBzfynJhquv+1ZugGcBASOSjn11dcq4C Ih6zebi1/g82y4cGXSIckDdAAjN+79Mv4TOkMu+LqPZnFxUnO4dxJgZtZOe1zrPAncRjTJh8F q3AJPPohH8aOM0jIpA5GNzi4LVgq7xnfVj7gjqc08fgObkjbZr8ajiTOFeLT+ajfY5tE= Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Weak functions are a bit confusing, and we can better deal with this using a callback function. pcibios_free_irq() is actually completely unused, but it seems better to treat it the same way as the allocation, unless we want to remove it completely. Signed-off-by: Arnd Bergmann --- arch/arm64/kernel/pci.c | 16 +++------------- drivers/pci/pci-driver.c | 13 +++++++++++-- include/linux/pci.h | 2 ++ 3 files changed, 16 insertions(+), 15 deletions(-) -- 2.18.0 diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index 0e2ea1c78542..3d196c68e362 100644 --- a/arch/arm64/kernel/pci.c +++ b/arch/arm64/kernel/pci.c @@ -22,19 +22,6 @@ #include #include -#ifdef CONFIG_ACPI -/* - * Try to assign the IRQ number when probing a new device - */ -int pcibios_alloc_irq(struct pci_dev *dev) -{ - if (!acpi_disabled) - acpi_pci_irq_enable(dev); - - return 0; -} -#endif - /* * raw_pci_read/write - Platform-specific PCI config space access. */ @@ -93,6 +80,9 @@ int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) ACPI_COMPANION_SET(&bridge->dev, adev); set_dev_node(bus_dev, acpi_get_node(acpi_device_handle(adev))); + + /* Try to assign the IRQ number when probing a new device */ + bridge->alloc_irq = acpi_pci_irq_enable; } return 0; diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index bef17c3fca67..c96bc7bd56da 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -387,13 +387,22 @@ static int __pci_device_probe(struct pci_driver *drv, struct pci_dev *pci_dev) return error; } -int __weak pcibios_alloc_irq(struct pci_dev *dev) +int pcibios_alloc_irq(struct pci_dev *dev) { + struct pci_host_bridge *bridge = pci_find_host_bridge(dev->bus); + + if (bridge->alloc_irq) + return bridge->alloc_irq(dev); + return 0; } -void __weak pcibios_free_irq(struct pci_dev *dev) +void pcibios_free_irq(struct pci_dev *dev) { + struct pci_host_bridge *bridge = pci_find_host_bridge(dev->bus); + + if (bridge->free_irq) + bridge->free_irq(dev); } #ifdef CONFIG_PCI_IOV diff --git a/include/linux/pci.h b/include/linux/pci.h index d1072690cb4f..1296d9fcc5da 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -476,6 +476,8 @@ struct pci_host_bridge { int (*map_irq)(const struct pci_dev *, u8, u8); void (*release_fn)(struct pci_host_bridge *); void (*bus_add_device)(struct pci_dev *pdev); + int (*alloc_irq)(struct pci_dev *); + int (*free_irq)(struct pci_dev *); void *release_data; struct msi_controller *msi; unsigned int ignore_reset_delay:1; /* For entire hierarchy */