From patchwork Fri Aug 17 10:26:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 958759 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41sKjw6n0Rz9s3Z for ; Fri, 17 Aug 2018 20:50:44 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41sKjw5SkQzF15Z for ; Fri, 17 Aug 2018 20:50:44 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=arndb.de (client-ip=212.227.17.13; helo=mout.kundenserver.de; envelope-from=arnd@arndb.de; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41sKKV74xtzDrb6 for ; Fri, 17 Aug 2018 20:33:02 +1000 (AEST) Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0LbrfA-1gFk7r2rG0-00jIgT; Fri, 17 Aug 2018 12:27:15 +0200 From: Arnd Bergmann To: linux-pci@vger.kernel.org, Bjorn Helgaas Subject: [RFC 01/15] PCI: clean up legacy host bridge scan functions Date: Fri, 17 Aug 2018 12:26:31 +0200 Message-Id: <20180817102645.3839621-2-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:qDqhbuzSX8z08T2QJlMsg/+ruOlcqG1c6ro78J/5MxdL56nnRad yO5HhKo3efL2siEaAAY7qOiJJ3tKLIqKd6DJd1500VXoRHZnzIU11B5eNkG3bBfbRbiMaOC 7sIxy4pZO0kdRg2lK5a97hD/1JtCLT9+XU9Bhcz8Phl5VVvzt8s/T5OnHN6eXScNldLezo9 2xaQ1mtfde4n2i8BI3gDQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:3BVTzKig7xo=:PLgrU7L7PtC8+B3pvfIMPk qJZkq430xbSgQwNh2d5sekkbnSpC+T//3qhmBwjZBvxEwLiSsm34Y26J6Fe0Bxg2BPEydcocc NVe6m6I+xPvtqFB1CFXAH/kF6zwuuewlYNBb5f/DLgujFia2xYzFjfs5YH39G5bNERQASdrVG ChwUErAJpTpHMqJEvQZa2hXaTCelXwEfRVOGj6FSLNQ65MGRYvau8q7dYDZ9QQK+7KtDXEjOe PKlF78LvMdp8OPPUItU3MlcWJOFI03b/X9O3CY90iFle808yxjwoB7Onht9MvwHkiHvf15PPD q2dyz7YaThSqMNIHYhqSI6nF76fcYYKFcWo1zXyBZwjOUOhJmufYjlCgzJdqctbghySTFpzpr 4KUdAXK8ZC3XSfGaf9go+bMwOzuRqy0HB1rf7/fScw34+NQ6ss8IaXn1dn7/9nCQa61DzV46e i/mBhjC0J6O/ZdrDCpzOKzCBJTZTzlf67Av/bthglhVNUkh70gxyvUyFJC63+KC+g01cVZVcK kLbVDGSL+L9n8oRHgY9gnCU5b4C8WroVzGkCT+Ewn7lWTLuU/IiJ0IMmY66T2xxz10QAkWaCe 45ZyXobbwW3Oe5QF4oVQlO9Z8MAIjHRxStnSesQs3nogvblrsMRaiVDkJiOgMHS/ehyzaoyil FIV2wFNwGepJKW5tZq2DX8DUMHRPQsPvAICCND/zCOKpTInGF4RDQ46YBTKrEU6nKMUU= X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Pieralisi , Arnd Bergmann , linux-kernel@vger.kernel.org, Christoph Hellwig , linux-acpi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Aside from the modern pci_host_bridge based interfaces, we have a couple of interfaces from old times that are still used in a couple of platforms: pci_create_root_bus(), pci_scan_bus() and pci_scan_root_bus(). As a first step towards getting everybody to use the new interfaces, this simplifies the latter two to call the pci_alloc_host_bridge() and pci_register_host_bridge()/pci_scan_root_bus_bridge() interfaces directly. The behavior should be entirely unchanged here, but we can then push down the functions into the individual host implementations. Signed-off-by: Arnd Bergmann --- drivers/pci/probe.c | 86 ++++++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 41 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index ec784009a36b..b0f666271245 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -23,13 +23,6 @@ #define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */ #define CARDBUS_RESERVE_BUSNR 3 -static struct resource busn_resource = { - .name = "PCI busn", - .start = 0, - .end = 255, - .flags = IORESOURCE_BUS, -}; - /* Ugh. Need to stop exporting this to modules. */ LIST_HEAD(pci_root_buses); EXPORT_SYMBOL(pci_root_buses); @@ -3060,53 +3053,64 @@ 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 resource_entry *window; - bool found = false; - struct pci_bus *b; - int max; - - resource_list_for_each_entry(window, resources) - if (window->res->flags & IORESOURCE_BUS) { - found = true; - break; - } + struct pci_host_bridge *bridge; + int error; - b = pci_create_root_bus(parent, bus, ops, sysdata, resources); - if (!b) + bridge = pci_alloc_host_bridge(0); + if (!bridge) return NULL; - if (!found) { - dev_info(&b->dev, - "No busn resource found for root bus, will use [bus %02x-ff]\n", - bus); - pci_bus_insert_busn_res(b, bus, 255); - } + list_splice_init(resources, &bridge->windows); + bridge->dev.parent = parent; + bridge->sysdata = sysdata; + bridge->busnr = bus; + bridge->ops = ops; - max = pci_scan_child_bus(b); + error = pci_scan_root_bus_bridge(bridge); + if (error < 0) + goto err_out; - if (!found) - pci_bus_update_busn_res_end(b, max); + return bridge->bus; - return b; +err_out: + kfree(bridge); + return NULL; } EXPORT_SYMBOL(pci_scan_root_bus); +static struct resource busn_resource = { + .name = "PCI busn", + .start = 0, + .end = 255, + .flags = IORESOURCE_BUS, +}; + struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata) { - LIST_HEAD(resources); - struct pci_bus *b; + struct pci_host_bridge *bridge; + int error; - pci_add_resource(&resources, &ioport_resource); - pci_add_resource(&resources, &iomem_resource); - pci_add_resource(&resources, &busn_resource); - b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources); - if (b) { - pci_scan_child_bus(b); - } else { - pci_free_resource_list(&resources); - } - return b; + bridge = pci_alloc_host_bridge(0); + if (!bridge) + goto err; + + pci_add_resource(&bridge->windows, &ioport_resource); + pci_add_resource(&bridge->windows, &iomem_resource); + pci_add_resource(&bridge->windows, &busn_resource); + bridge->sysdata = sysdata; + bridge->busnr = bus; + bridge->ops = ops; + + error = pci_scan_root_bus_bridge(bridge); + if (error < 0) + goto err; + + return bridge->bus; + +err: + pci_free_host_bridge(bridge); + return NULL; } EXPORT_SYMBOL(pci_scan_bus); From patchwork Fri Aug 17 10:26:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 958750 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41sKM15trDz9s3Z for ; Fri, 17 Aug 2018 20:34:21 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41sKM14Z7VzF0yB for ; Fri, 17 Aug 2018 20:34:21 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=arndb.de (client-ip=212.227.17.24; helo=mout.kundenserver.de; envelope-from=arnd@arndb.de; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41sKK45cX4zDr5p for ; Fri, 17 Aug 2018 20:32:40 +1000 (AEST) Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0M9oN6-1fjzDA0HrE-00B3KP; Fri, 17 Aug 2018 12:27:16 +0200 From: Arnd Bergmann To: linux-pci@vger.kernel.org, Bjorn Helgaas Subject: [RFC 02/15] PCI: move pci_scan_bus into callers Date: Fri, 17 Aug 2018 12:26:32 +0200 Message-Id: <20180817102645.3839621-3-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:LWXnCU+7Z6xUjdeuzFbZ45bQvgVeaaHfbEf3zC3L26Zzk+q2P/M eBqWnJgU7gwLWWrQHzKtQNFZcb0iVWb27FKaSLk3FaYqvRDAS8Fc4O+kVUSdbViQeydnUMw h7NpiAMFG72dNFXfPHSVlJ0LvhHR19fn798oy2WXLztnZxxmtfjsh5iUmx/CcbOiGkUFKfA 9U53X0yWkPqyToR2KeuMw== X-UI-Out-Filterresults: notjunk:1; V01:K0:i52elxbByfA=:zby/nqAY9+e5yB3sPpAwYv XLGsWsbrJP8EnEyYsf7aWdz+YQwQ06Ay+C2xJ5V8q/Z5WbutiLIkDZsmtklPkwbb7VCHQtmNc htBAhFuY5icvQ7ZSlxEM+0cGgKZ6I3KOhTvVIAI1hTJZCc+BkIF9BYnyKn0Yp+PCGgxGDQc9M z2qGTvyaoqU2FTh0gNlCN4py088cSrcuWuOyS7lrUNN+yexf76tAyIai6J/Qpo1nTPKfX4UaC a/AVBf3VrEDHfcR6l+BV8i7N5LVgln2sjTmuo8Yg0ZW5xLMpvJQQ7LDbTff8GLoJHdL/v9vSL l9M5feuoSNoq08gOtnzB7oh0V9yrObBfHyHyzIj2cw4sWC9u++uFOAaRAtFMZN94PM8BJ3wos j9q5FETIOSk9yTticaNzrsQkjVgxSCp0V7yo94oM1lVcK9JZiJ//fG1W8/rU5B2Re2dDyMPqj z8OF1cfeU1Uk4B22sF2AA9+660U331pPJxrV17EIAM6i/2TpX8dlrUBkXabg7pquF9KiJOSFI iLwaWs2BlcB74LMmqnjgmIPZ9LpA2kF2IE9kVlqdkJ3iltoUzxWxMatjJZJTVH4aB0puA0L8Z 3E4j6jwjkz1DogegisuGl2kt9gbdDITkq6aqv9vgGww9e/6hPek/b5d4mHT/kyli11fgFtW4G 2bcIKPNIenX30apnEBsXNGgTE7pq3vgJD97ENKj+H4O9bz1RK2rxVEgLDfx8bQnPwmJE= X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Pieralisi , Arnd Bergmann , linux-kernel@vger.kernel.org, Christoph Hellwig , linux-acpi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" There are only two remaining callers of the old pci_scan_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 all users by avoiding the global implementation, and it allows further cleanup of the two callers. Signed-off-by: Arnd Bergmann --- arch/sparc/kernel/pcic.c | 35 ++++++++++++++++++++++++++++++ drivers/pci/hotplug/ibmphp_core.c | 35 ++++++++++++++++++++++++++++++ drivers/pci/probe.c | 36 ------------------------------- include/linux/pci.h | 1 - 4 files changed, 70 insertions(+), 37 deletions(-) diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c index ee4c9a9a171c..0197b80fe590 100644 --- a/arch/sparc/kernel/pcic.c +++ b/arch/sparc/kernel/pcic.c @@ -387,6 +387,41 @@ int __init pcic_probe(void) return 0; } +static struct resource busn_resource = { + .name = "PCI busn", + .start = 0, + .end = 255, + .flags = IORESOURCE_BUS, +}; + +static struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, + void *sysdata) +{ + struct pci_host_bridge *bridge; + int error; + + bridge = pci_alloc_host_bridge(0); + if (!bridge) + return NULL; + + pci_add_resource(&bridge->windows, &ioport_resource); + pci_add_resource(&bridge->windows, &iomem_resource); + pci_add_resource(&bridge->windows, &busn_resource); + bridge->sysdata = sysdata; + bridge->busnr = bus; + bridge->ops = ops; + + error = pci_scan_root_bus_bridge(bridge); + if (error < 0) + goto err; + + return bridge->bus; + +err_res: + pci_free_host_bridge(bridge); + return NULL; +} + static void __init pcic_pbm_scan_bus(struct linux_pcic *pcic) { struct linux_pbm_info *pbm = &pcic->pbm; diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c index 4ea57e9019f1..d35463ee96ba 100644 --- a/drivers/pci/hotplug/ibmphp_core.c +++ b/drivers/pci/hotplug/ibmphp_core.c @@ -717,6 +717,41 @@ static void ibm_unconfigure_device(struct pci_func *func) pci_unlock_rescan_remove(); } +static struct resource busn_resource = { + .name = "pci busn", + .start = 0, + .end = 255, + .flags = IORESOURCE_BUS, +}; + +static struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, + void *sysdata) +{ + struct pci_host_bridge *bridge; + int error; + + bridge = pci_alloc_host_bridge(0); + if (!bridge) + return NULL; + + pci_add_resource(&bridge->windows, &ioport_resource); + pci_add_resource(&bridge->windows, &iomem_resource); + pci_add_resource(&bridge->windows, &busn_resource); + bridge->sysdata = sysdata; + bridge->busnr = bus; + bridge->ops = ops; + + error = pci_scan_root_bus_bridge(bridge); + if (error < 0) + goto err; + + return bridge->bus; + +err: + pci_free_host_bridge(bridge); + return NULL; +} + /* * The following function is to fix kernel bug regarding * getting bus entries, here we manually add those primary diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index b0f666271245..12c3aa63c34d 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -3078,42 +3078,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus, } EXPORT_SYMBOL(pci_scan_root_bus); -static struct resource busn_resource = { - .name = "PCI busn", - .start = 0, - .end = 255, - .flags = IORESOURCE_BUS, -}; - -struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, - void *sysdata) -{ - struct pci_host_bridge *bridge; - int error; - - bridge = pci_alloc_host_bridge(0); - if (!bridge) - goto err; - - pci_add_resource(&bridge->windows, &ioport_resource); - pci_add_resource(&bridge->windows, &iomem_resource); - pci_add_resource(&bridge->windows, &busn_resource); - bridge->sysdata = sysdata; - bridge->busnr = bus; - bridge->ops = ops; - - error = pci_scan_root_bus_bridge(bridge); - if (error < 0) - goto err; - - return bridge->bus; - -err: - pci_free_host_bridge(bridge); - return NULL; -} -EXPORT_SYMBOL(pci_scan_bus); - /** * pci_rescan_bus_bridge_resize - Scan a PCI bus for devices * @bridge: PCI bridge for the bus to scan diff --git a/include/linux/pci.h b/include/linux/pci.h index e72ca8dd6241..d77ce35a2b33 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -905,7 +905,6 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res, void pcibios_scan_specific_bus(int busn); struct pci_bus *pci_find_bus(int domain, int busnr); void pci_bus_add_devices(const struct pci_bus *bus); -struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata); struct pci_bus *pci_create_root_bus(struct device *parent, int bus, struct pci_ops *ops, void *sysdata, struct list_head *resources); 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: 958755 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41sKYC2yS2z9s3Z for ; Fri, 17 Aug 2018 20:43:11 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41sKYC1crWzF0vb for ; Fri, 17 Aug 2018 20:43:11 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=arndb.de (client-ip=217.72.192.73; helo=mout.kundenserver.de; envelope-from=arnd@arndb.de; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from mout.kundenserver.de (mout.kundenserver.de [217.72.192.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41sKKB6CqkzDrWY for ; Fri, 17 Aug 2018 20:32:45 +1000 (AEST) 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 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= X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Pieralisi , Arnd Bergmann , linux-kernel@vger.kernel.org, Christoph Hellwig , linux-acpi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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(-) 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:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 958758 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41sKgT5pPkz9s3Z for ; Fri, 17 Aug 2018 20:48:37 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41sKgT4VVhzDr5t for ; Fri, 17 Aug 2018 20:48:37 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=arndb.de (client-ip=212.227.17.13; helo=mout.kundenserver.de; envelope-from=arnd@arndb.de; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41sKKS34kSzDrWY for ; Fri, 17 Aug 2018 20:32:59 +1000 (AEST) Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0MAdid-1fjhxn3cuR-00BsPO; Fri, 17 Aug 2018 12:27:16 +0200 From: Arnd Bergmann To: linux-pci@vger.kernel.org, Bjorn Helgaas Subject: [RFC 04/15] PCI: export pci_register_host_bridge Date: Fri, 17 Aug 2018 12:26:34 +0200 Message-Id: <20180817102645.3839621-5-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:qV+QiFpoLBNDT+pnsfxk7Q12Wr+Zfztf79RikKLfT1kBpbTwKUM iZEEf/AFkASGLvQTzHO6lI+OsNf423ev36D4uMlANybis7iSjomPpFGobYlMVXCwQdTCqSd ugZbMhW+33xetnzQSUdMeicQ786GrhuoT6iTK6eAwaMormNmf16uMK5AaJlveZ1uMEi0UOl d7rj/WjNLBnDisKLuP0zg== X-UI-Out-Filterresults: notjunk:1; V01:K0:mqjwwQrypPA=:CArrxfvE0eZuS2Tt7c+ARj PB1UM7pT4Qxw19VZKHb8nMpyI/uAcjOdGl34colob8MlcOZ1Z23JNuFcJSk2CzI4vCkC4cmgK dsQG4Ypj/8Lb29zrXwHeTlWSa9Bpr9/Q7BWS0apZ9d6NxClv2GezO+icIFTa2aYX7ZbwNkstN S+5ERKIYLetoH6vIc150sHb/yJFabyR018w7ymbajQtCjeDRb5+KXyLUIYmRxtgyB4yBegOmU VkwZ774duD+vcTFI1z4PHvynaII4pHEtUZc/+JQsthKuORJA1gCZeDISxYlevtzvSt4G1uGDD IJyVkxGukDGtllR4qU9ejNh7MZRassBp9Iaj433hp8VOUu0SGlX/OBlO9mzD29KBXGFX5gyaI pnP/0AhrwtxHaByaaz76/xDqi9AMAxLjZ1YvbuYscV6mZbSipvVGv77Il724iD4gHNifsd6wz BP74DYRS6UEV0SkhTNIGtI3jAhHHPKFwNJ9YMvxV3Ms5Q/eACiEYIM72R/q6HAh0aplklkMvH v1eVEe7v/KEMSMq5FJ2w9OoME/qOgVchx3kmRRQlo2DmPO6y2WYLTTyiv6o2HWQ+BJPedZQzz rEL4UAP+St13A6SE6p4hxxmX/3KAcUxY6gWVZHNOmrLLmtkEhCDYdgV8vkTwXV52mVEi0j4wW Rc4X7Qs9C/GTE8qhH3LEVMUTtvlB6Pj0ttYAxAaTZBKky2s4IhucciZzjdiDxc2KdVXQ= X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Pieralisi , Arnd Bergmann , linux-kernel@vger.kernel.org, Christoph Hellwig , linux-acpi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" There are a couple of users of the old pci_create_root_bus() interface, which calls pci_register_host_bridge() without actually scanning the bus. In order to get those callers a little closer to the current method of separating the allocation and probing of the host bridge, this exports the internal interface to modules. If all the callers can get moved over to pci_host_probe() or pci_scan_root_bus_bridge() later, the export can be removed again. Signed-off-by: Arnd Bergmann --- drivers/pci/probe.c | 25 ++++++++++++++++++++++++- include/linux/pci.h | 1 + 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index cf169742c03e..5ca7d5941ad0 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -762,7 +762,29 @@ static void pci_set_bus_msi_domain(struct pci_bus *bus) dev_set_msi_domain(&bus->dev, d); } -static int pci_register_host_bridge(struct pci_host_bridge *bridge) +/* + * pci_register_host_bridge() - Register a host bridge without scanning + * + * @bridge: a newly allocated host bridge structure + * + * This is the core part of bringing up a new PCI host bridge, + * before we scan for attached devices and register them as + * pci_dev. + * + * For the most part, this is an implementation detail of the + * pci_host_probe() interface, which brings up the entire bus, + * bus some older platforms still call it directly and manually + * scan for devices. + * + * If your driver uses this, try to convert it to using + * pci_host_probe() instead. + * + * Return: zero on suggess, or a negative error code. + * Note: after pci_register_host_bridge() successfully returns, + * the pci_host_bridge device is alive in driver core, and must + * not be freed directly. + */ +int pci_register_host_bridge(struct pci_host_bridge *bridge) { struct device *parent = bridge->dev.parent; struct resource_entry *window, *n; @@ -877,6 +899,7 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge) kfree(bus); return err; } +EXPORT_SYMBOL_GPL(pci_register_host_bridge); static bool pci_bridge_child_ext_cfg_accessible(struct pci_dev *bridge) { diff --git a/include/linux/pci.h b/include/linux/pci.h index d226e06fb5e5..e1337148cf9f 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -909,6 +909,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus, struct pci_ops *ops, void *sysdata, struct list_head *resources); int pci_host_probe(struct pci_host_bridge *bridge); +int pci_register_host_bridge(struct pci_host_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); From patchwork Fri Aug 17 10:26:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 958760 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41sKlw0SYBz9ryn for ; Fri, 17 Aug 2018 20:52:28 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41sKlv6KSczF0ph for ; Fri, 17 Aug 2018 20:52:27 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=arndb.de (client-ip=212.227.17.10; helo=mout.kundenserver.de; envelope-from=arnd@arndb.de; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41sKKW4LFrzF0kx for ; Fri, 17 Aug 2018 20:33:03 +1000 (AEST) Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0M40t0-1g7af110mg-00rZtP; Fri, 17 Aug 2018 12:27:17 +0200 From: Arnd Bergmann To: linux-pci@vger.kernel.org, Bjorn Helgaas Subject: [RFC 05/15] PCI: move pci_create_root_bus into callers Date: Fri, 17 Aug 2018 12:26:35 +0200 Message-Id: <20180817102645.3839621-6-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:vNkQe7G80rrJcSh/6xIdR1XKwwCej6w5is+lloFStD924Tqfn0L yGVewaIh1+4Vgki1oP1wIOx6XkkD8GqaEGxmZE/7FaVmqAKP6giye+TP/hkfc6OKPffr61n BKj4FMOs1JjhhEoTVwABpSAUn4IGk9rSZ4N6mT4NrMHQ6maNd+haxnEQ2CqoGVIgcApxPg0 JhwKxIDMDp3jSLLSD7sug== X-UI-Out-Filterresults: notjunk:1; V01:K0:/zf2tNgXlnM=:vYWFeFSOmdZ5gdseNRCLWT i/38cE+419ghJALH+b4shgekXlfB3l/lyYqFzkBYpk9XmpRYDe1SAcyB2/7sX4E6THtoX5YGg 3UL2hOoC7NYoo60j3LQQXdbXv2wOnxAzROhUls4qj3CamvDJLJDbwRdeSn0QH9SsiqTpGgelH Gzy0IYO3oqpPNs1KC2O9zeH583JjyJm6Z0ty6Yjyjk0TFXjkX5iftelTc3WMtZWHJfTVFRvJd aMIC2skS2wiq7IzuXWn95COMEOnvs/s3lUuB/2O26VNdgsAuH7fVjsb2hkEGVPH+h6hXYOXvV oJA7VXdm4fK4PZu38fFVIYGK+VI5UcCFRmlNCApoxCO4oEHAEixGBc+udgJXrGMvxp7gQ7u2/ Xw0/gK4GBpUe2hJo+op2zDRyOi9vUAN3oGlLkrbnXhttYNYsWCAXy0ssTEJoIazkGhTi/IoHi 2Ss32My9qNM1qQy2O1YkTpsdUBgHcKZttrFGlE4+OHUMIMWw7UTSXnwQOff+Lb5ZqTx8hMwsB jBZEUmEAAzOBoocfjwBvnL2JLcn4UVMyLgRVHrAHNedrLJQQiojNE1+rIbZ7AN5v8l6P/6Md8 yTynijlr/KnWIsRfMdAdDGyPQE2rh/Oe0Ta5tY6pbpDDWWwPgZzXsJXvYlwgvtciince2wQNV FWM52JZHr+YPhiilnVR5soZXKmyzh3inYH5QPrrs192qwdRjI+ZppcwBE56Wk5DhGooQ= X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Pieralisi , Arnd Bergmann , linux-kernel@vger.kernel.org, Christoph Hellwig , linux-acpi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" There are only seven 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/powerpc/kernel/pci-common.c | 28 +++++++++++++++++++++++++++ arch/sparc/kernel/pci.c | 28 +++++++++++++++++++++++++++ drivers/acpi/pci_root.c | 30 ++++++++++++++++++++++++++++- drivers/parisc/dino.c | 28 +++++++++++++++++++++++++++ drivers/parisc/lba_pci.c | 28 +++++++++++++++++++++++++++ drivers/pci/controller/pci-hyperv.c | 28 +++++++++++++++++++++++++++ drivers/pci/controller/vmd.c | 30 ++++++++++++++++++++++++++++- drivers/pci/probe.c | 29 ---------------------------- include/linux/pci.h | 3 --- 9 files changed, 198 insertions(+), 34 deletions(-) diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 88e4f69a09e5..57ca621a32f4 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -1587,6 +1587,34 @@ 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 diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c index 17ea16a1337c..afbce59d9231 100644 --- a/arch/sparc/kernel/pci.c +++ b/arch/sparc/kernel/pci.c @@ -691,6 +691,34 @@ 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) +{ + 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; +} + struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm, struct device *parent) { diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 7433035ded95..85dbcf47015b 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -873,6 +873,34 @@ static void acpi_pci_root_release_info(struct pci_host_bridge *bridge) __acpi_pci_root_release_info(bridge->release_data); } +static struct pci_bus *acpi_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; +} + struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root, struct acpi_pci_root_ops *ops, struct acpi_pci_root_info *info, @@ -902,7 +930,7 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root, pci_acpi_root_add_resources(info); pci_add_resource(&info->resources, &root->secondary); - bus = pci_create_root_bus(NULL, busnum, ops->pci_ops, + bus = acpi_pci_create_root_bus(NULL, busnum, ops->pci_ops, sysdata, &info->resources); if (!bus) goto out_release_info; diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c index 7390fb8ca9d1..91c837de7616 100644 --- a/drivers/parisc/dino.c +++ b/drivers/parisc/dino.c @@ -882,6 +882,34 @@ static const char *cujo_vers[] = { void ccio_cujo20_fixup(struct parisc_device *dev, u32 iovp); +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; +} + /* ** Determine if dino should claim this chip (return 0) or not (return 1). ** If so, initialize the chip appropriately (card-mode vs bridge mode). diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c index 69bd98421eb1..901b7f07fe91 100644 --- a/drivers/parisc/lba_pci.c +++ b/drivers/parisc/lba_pci.c @@ -1464,6 +1464,34 @@ lba_hw_init(struct lba_device *d) */ static unsigned int lba_next_bus = 0; +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; +} + /* * Determine if lba should claim this chip (return 0) or not (return 1). * If so, initialize the chip and tell other partners in crime they diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index c00f82cc54aa..df7cddea8e30 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -1457,6 +1457,34 @@ 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 diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c index fd2dbd7eed7b..311c9f6761ae 100644 --- a/drivers/pci/controller/vmd.c +++ b/drivers/pci/controller/vmd.c @@ -579,6 +579,34 @@ static int vmd_find_free_domain(void) return domain + 1; } +static struct pci_bus *vmd_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; +} + static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features) { struct pci_sysdata *sd = &vmd->sysdata; @@ -705,7 +733,7 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features) pci_add_resource_offset(&resources, &vmd->resources[1], offset[0]); pci_add_resource_offset(&resources, &vmd->resources[2], offset[1]); - vmd->bus = pci_create_root_bus(&vmd->dev->dev, busn_start, &vmd_ops, + vmd->bus = vmd_create_root_bus(&vmd->dev->dev, busn_start, &vmd_ops, sd, &resources); if (!vmd->bus) { pci_free_resource_list(&resources); diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 5ca7d5941ad0..eaedb4fe143a 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2909,35 +2909,6 @@ void __weak pcibios_remove_bus(struct pci_bus *bus) { } -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; -} -EXPORT_SYMBOL_GPL(pci_create_root_bus); - int pci_host_probe(struct pci_host_bridge *bridge) { struct pci_bus *bus, *child; diff --git a/include/linux/pci.h b/include/linux/pci.h index e1337148cf9f..1dd8a3ecf753 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -905,9 +905,6 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res, void pcibios_scan_specific_bus(int busn); struct pci_bus *pci_find_bus(int domain, int busnr); void pci_bus_add_devices(const struct pci_bus *bus); -struct pci_bus *pci_create_root_bus(struct device *parent, int bus, - struct pci_ops *ops, void *sysdata, - struct list_head *resources); int pci_host_probe(struct pci_host_bridge *bridge); int pci_register_host_bridge(struct pci_host_bridge *); int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax); 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: 958765 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41sKwP5FpKz9s4Z for ; Fri, 17 Aug 2018 20:59:49 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41sKwP42tTzF1fG for ; Fri, 17 Aug 2018 20:59:49 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=arndb.de (client-ip=212.227.17.10; helo=mout.kundenserver.de; envelope-from=arnd@arndb.de; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41sKNw33gNzDrHP for ; Fri, 17 Aug 2018 20:36:00 +1000 (AEST) 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 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:qvgOFMZ0I7A=:Gx0aW1QYwSmyFRDDO1zijf NctExfKrHqHaFwHYiKMrwgplqXZJhv786mqls0MMaloSXPr/w49UVp7tJ8M9S1ltt7BqG1O3G FQlGtszMTxeFd2z8kSeY5L2KP/sVQXPzbRH0jQ+oiyTpvWCAWVxKg3JS48xTNRatlUUEqlLcl +DuD+/Qptf7Kckj7LgUzpB/zqzv4C8navDWm2SAYUO5LV2zw8CO9NKDa5qGuN2bdlmGabH3b6 /0iLKHYz2rP6armKkRp9ZJkdRgqq4ZxCjTz6dlfC6BMf0i+xd5LCG4rpch0Ub7KI9jzQC/LzC /LsWrtXWarm+5NbLf7xlo1ekc2uz+Obp5jJLuSQkLAs1dTl2WtcPpx2cyXYghVzEGKOLO9Xhb sT4E4LfFWY74ojFbkuv/8oo2GAsO3v9dPUlUUJmJBMjZ/P4ao8HyglOJ8RojuT5TZFlBIf5jd 5ZiG/eViOUKhh74YrR0WU4yDBOTskMw5dNI4yjTFR5EnPBJaFwGiFc6oxz3wGvBLkaA5sf35z ONRrc0Hccy8jXMPhgNXpGedrWSSO2nlNtSl5eu6FiSRM3Pea70h692f+++1VFOGCLJD4y3ZxS VuND2psbeV1wMGHYL1/AMGjISCdPzE/Gr/rL7BuArXiy6EMF/Jkh0sSvEmMqzhWRhiGrpSYj7 GvjRvceQC3wf7DhEIDYtPJx/bIdzA7IATXd7Ei7i63uDNxagE27QJuSaFZv0TtpewAF8= X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Pieralisi , Arnd Bergmann , linux-kernel@vger.kernel.org, Christoph Hellwig , linux-acpi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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(-) 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:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 958752 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41sKRG0frzz9s3Z for ; Fri, 17 Aug 2018 20:38:02 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41sKRF6Z2TzF0vb for ; Fri, 17 Aug 2018 20:38:01 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=arndb.de (client-ip=212.227.17.10; helo=mout.kundenserver.de; envelope-from=arnd@arndb.de; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41sKK63ZXZzDr5p for ; Fri, 17 Aug 2018 20:32:41 +1000 (AEST) Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0M7Knm-1g271607FO-00x44h; Fri, 17 Aug 2018 12:27:18 +0200 From: Arnd Bergmann To: linux-pci@vger.kernel.org, Bjorn Helgaas Subject: [RFC 07/15] PCI/ACPI: clean up acpi_pci_root_create() Date: Fri, 17 Aug 2018 12:26:37 +0200 Message-Id: <20180817102645.3839621-8-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:d27yj6uZ03Y8vFzVtfOG4i3FXwc0amjneq2jCzS3uuPksZ77MJw z4AgJqMZ+dms4uVm3++DD8efqm6WoDdC/G6wfOryIsOV1RJ2ZY4ekevcPFE7ZTFqkpdKzEv v8GV2slLum4Zw9yyUZDD4tFjdvfudOKVLZwMAK0sYh5leF4mXZD6qcPYHNKEZHtlwNRN1V2 bRQa6vslOKqjMiXp7VGJw== X-UI-Out-Filterresults: notjunk:1; V01:K0:dQxK7tItEl4=:M58Fmg5hzmIJtGAnJoWRiX lolFQgFa9Bv2Jzomd8ZcKQFhSRZvChrCKG6kMN4eONirFrjiQvLDtv1Xquv0p8/2VpgFiYgcE vCu0/uhbhORMSrGBxJBz9GEKFGYSXOMJHltVdDKPNhxY/pu0C1LrOxCbpRECgS930TbBXtL3g ZO6yChgg5Oj7V4bNhSRjm6LPDmhje4+qCpygbu1ZUEfXWdmc/g5kxL7LCFKZYvr4PJ9Tl6ary FVjhbbXqR3+3VP8ljQ3GY/od8tVN3WyDLhrEU1OPf6mgcaKFbd8oKlTUxlCC8TBCyptLH6Qdm BdOqGgMxGLALN3gKh5ptAWLsfsKYDQsEb75eovdwMEarGTjHUzi94I4LG5tK/b9sexHFELK50 vhN7zaEakHOQlz1Q60WzTb8GplZ+TCR3FflwWKesT2kQ/RInMyyYAHcxQfUUnEAqth6SNIQCb v2Bm0ntVXggdTjsRQ0yMwMuZh287Is44XfttsP7ELxU92jaLQEzRvJgGG45O4xlS1PIpAnsZg 95t2v0gEe2eV60wSpm/mNwHz6hOzcxtNNz2ZGWUo0oOtOioq11nuxSeMHPiVaY1F80O0nHt/t 781UwKEK/tkhs7/WF94ZbLmsgRr346WW+W+KuloOyzmNrgg8GiiWHdNrJyF9nXNGFLfglJV78 eG562zDwpU6+HVPCDRIUAwzjUeH2gxhKMehascMDaXSFSPjKao20exZi9lZwJqyb4tiM= X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Pieralisi , Arnd Bergmann , linux-kernel@vger.kernel.org, Christoph Hellwig , linux-acpi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" The acpi_pci_create_root_bus() can be fully integrated into acpi_pci_root_create(), improving a few things: * We can call pci_scan_root_bus_bridge(), which registers and scans the bridge in one step. * After a failure in pci_register_host_bridge(), we correctly clean up the resources. * The bridge settings (release function, flags, operations etc) can get set up before registering the bridge. * Further cleanup would be possible, removing duplication between pci_host_bridge and some ACPI structures. Signed-off-by: Arnd Bergmann --- drivers/acpi/pci_root.c | 68 +++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 44 deletions(-) diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 85dbcf47015b..5f73de3b67c8 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -873,34 +873,6 @@ static void acpi_pci_root_release_info(struct pci_host_bridge *bridge) __acpi_pci_root_release_info(bridge->release_data); } -static struct pci_bus *acpi_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; -} - struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root, struct acpi_pci_root_ops *ops, struct acpi_pci_root_info *info, @@ -909,8 +881,7 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root, int ret, busnum = root->secondary.start; struct acpi_device *device = root->device; int node = acpi_get_node(device->handle); - struct pci_bus *bus; - struct pci_host_bridge *host_bridge; + struct pci_host_bridge *bridge; info->root = root; info->bridge = device; @@ -930,30 +901,39 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root, pci_acpi_root_add_resources(info); pci_add_resource(&info->resources, &root->secondary); - bus = acpi_pci_create_root_bus(NULL, busnum, ops->pci_ops, - sysdata, &info->resources); - if (!bus) + + bridge = pci_alloc_host_bridge(0); + if (!bridge) goto out_release_info; - host_bridge = to_pci_host_bridge(bus->bridge); + list_splice_init(&info->resources, &bridge->windows); + bridge->sysdata = sysdata; + bridge->busnr = busnum; + bridge->ops = ops->pci_ops; + pci_set_host_bridge_release(bridge, acpi_pci_root_release_info, + info); + if (!(root->osc_control_set & OSC_PCI_EXPRESS_NATIVE_HP_CONTROL)) - host_bridge->native_pcie_hotplug = 0; + bridge->native_pcie_hotplug = 0; if (!(root->osc_control_set & OSC_PCI_SHPC_NATIVE_HP_CONTROL)) - host_bridge->native_shpc_hotplug = 0; + bridge->native_shpc_hotplug = 0; if (!(root->osc_control_set & OSC_PCI_EXPRESS_AER_CONTROL)) - host_bridge->native_aer = 0; + bridge->native_aer = 0; if (!(root->osc_control_set & OSC_PCI_EXPRESS_PME_CONTROL)) - host_bridge->native_pme = 0; + bridge->native_pme = 0; if (!(root->osc_control_set & OSC_PCI_EXPRESS_LTR_CONTROL)) - host_bridge->native_ltr = 0; + bridge->native_ltr = 0; + + ret = pci_scan_root_bus_bridge(bridge); + if (ret < 0) + goto out_release_bridge; - pci_scan_child_bus(bus); - pci_set_host_bridge_release(host_bridge, acpi_pci_root_release_info, - info); if (node != NUMA_NO_NODE) - dev_printk(KERN_DEBUG, &bus->dev, "on NUMA node %d\n", node); - return bus; + dev_printk(KERN_DEBUG, &bridge->bus->dev, "on NUMA node %d\n", node); + return bridge->bus; +out_release_bridge: + pci_free_host_bridge(bridge); out_release_info: __acpi_pci_root_release_info(info); return NULL; 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: 958751 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41sKPB16Zyz9s3x for ; Fri, 17 Aug 2018 20:36:14 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41sKP96P3vzF0pD for ; Fri, 17 Aug 2018 20:36:13 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=arndb.de (client-ip=212.227.17.24; helo=mout.kundenserver.de; envelope-from=arnd@arndb.de; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de X-Greylist: delayed 300 seconds by postgrey-1.36 at bilbo; Fri, 17 Aug 2018 20:32:40 AEST Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41sKK45V5rzDqm6 for ; Fri, 17 Aug 2018 20:32:40 +1000 (AEST) 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 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= X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Pieralisi , Arnd Bergmann , linux-kernel@vger.kernel.org, Christoph Hellwig , linux-acpi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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(-) 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:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 958762 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41sKnw063fz9ryn for ; Fri, 17 Aug 2018 20:54:12 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41sKnv5yfTzDr5p for ; Fri, 17 Aug 2018 20:54:11 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=arndb.de (client-ip=217.72.192.74; helo=mout.kundenserver.de; envelope-from=arnd@arndb.de; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from mout.kundenserver.de (mout.kundenserver.de [217.72.192.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41sKKW3zZCzDrHP for ; Fri, 17 Aug 2018 20:33:03 +1000 (AEST) Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0LfAVs-1gEfGg3Ql6-00olnh; Fri, 17 Aug 2018 12:27:18 +0200 From: Arnd Bergmann To: linux-pci@vger.kernel.org, Bjorn Helgaas Subject: [RFC 09/15] PCI: xenfront: clean up pcifront_scan_root() Date: Fri, 17 Aug 2018 12:26:39 +0200 Message-Id: <20180817102645.3839621-10-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:imp36udsrO2nyS8JPjqHA5Ds3hFhxVLPHpRGVSWPBGXVbL9/rNV imiE1c81Sfttwp+bT8f8tuK+epvIVP0/tH2n09iCfqvqjLRLlFBwdbr6U+nTVjL+eKbRy82 /29LhtzYPzABNffKaggHUp+zeicohWvtT/S8mD+XO+rHW/DejrjMQq9cGaJyd1HBBEumpqw plfhY45irAx+gsxE+znig== X-UI-Out-Filterresults: notjunk:1; V01:K0:66KgbqXwaoY=:P/v24nJmghk+b9u5YGEuSj L9rIV7n62Bc7vJoWNZz6hTXEI984RM8vhiKtFjIcTKl//gHowye519aIoLUsS4E8WUktVzk89 8o+Va+yWc7a3CuQeKkM2u6glYf+oAJeeoDimT1cWN3HGoD0oJG6yLJC6Mp1AOpbb3KZuzGIYa SyP6TRSa1fiCOqFBfWOr/19B/YBuO9ywza6acDO9Tg3WJOxFMMa7Sx7hkBkWhzs28P8LHDvD8 yQCSrHJUtQJAaO2xa2uL9eQM7xVkc78zWW5Bnfzhb/PwubQsm+Otf3msOPffihr1O0UqXiATf wc8kYjigbpOMUl7dpQUNu83t/pITBUAinMKt0RKrUSECKb7K+FFTWX7lW/zHMzr4ruJaW67CA xPVbvXDP0hWzBapqVIBXSir2LSRwoCX2iDqN7fTfW7gIfFAin4bWR9fLvBrd1RNpJ1HBOwJST Xnr4N2SDUHy8TT+8fAxKT4OB8isAVhJUwPpcINuDGjGwCYqD8CZvuD5QHzx/Cta7k6LMNGGal xLwqx06jxdFzUoeUmWl5Qjzag0pHlblexrRLJsWxMKC9iXtCCkgKwDrIq+qA3vCj7JruLkwba 7jHMQFElxZRF01Ne7Ln6+tF8qf1IHPPIZBkLkA5bcIaaPIduvqojP10mfeGKnVOi9wbm9FPUU twunQwIXPau8+zTW30IISEeFLPurGUboLnh6vOgC3rvckEmnfui82Jfa/1KGf/dPqXi8= X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Pieralisi , Arnd Bergmann , linux-kernel@vger.kernel.org, Christoph Hellwig , linux-acpi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Merging pci_scan_root_bus() into pcifront_scan_root() simplifies the implementation and makes it more readable. We can allocate the pcifront_sd structure along with the bridge structure, which helps manage its lifetime rules so we don't free it before the device has been released. There are two small issues that I noticed that could be improved: - It seems we unregister the 'bus' device that is a child of the 'pci_host_bridge' device after we unregister its parent in pcifront_free_roots(), which seems odd. - We probably don't need an extra pci_bus_entry list at all, but could instead walk the children of the pcifront_device, which are all pci_host_bridge devices. Signed-off-by: Arnd Bergmann --- drivers/pci/xen-pcifront.c | 67 ++++++++++++-------------------------- 1 file changed, 21 insertions(+), 46 deletions(-) diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c index 24070e1c5f22..a5eb6cb02bec 100644 --- a/drivers/pci/xen-pcifront.c +++ b/drivers/pci/xen-pcifront.c @@ -443,40 +443,12 @@ 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) { - struct pci_bus *b; - LIST_HEAD(resources); struct pcifront_sd *sd = NULL; struct pci_bus_entry *bus_entry = NULL; + struct pci_host_bridge *bridge; int err = 0; static struct resource busn_res = { .start = 0, @@ -498,50 +470,55 @@ static int pcifront_scan_root(struct pcifront_device *pdev, dev_info(&pdev->xdev->dev, "Creating PCI Frontend Bus %04x:%02x\n", domain, bus); + bridge = pci_alloc_host_bridge(sizeof(*sd)); + if (!bridge) + return -ENOMEM; + bus_entry = kzalloc(sizeof(*bus_entry), GFP_KERNEL); - sd = kzalloc(sizeof(*sd), GFP_KERNEL); - if (!bus_entry || !sd) { + sd = pci_host_bridge_priv(bridge); + if (!bus_entry) { err = -ENOMEM; goto err_out; } - pci_add_resource(&resources, &ioport_resource); - pci_add_resource(&resources, &iomem_resource); - pci_add_resource(&resources, &busn_res); + pci_add_resource(&bridge->windows, &ioport_resource); + pci_add_resource(&bridge->windows, &iomem_resource); + pci_add_resource(&bridge->windows, &busn_res); pcifront_init_sd(sd, domain, bus, pdev); + bridge->dev.parent = &pdev->xdev->dev; + bridge->sysdata = sd; + bridge->busnr = bus; + bridge->ops = &pcifront_bus_ops; pci_lock_rescan_remove(); - b = pci_scan_root_bus(&pdev->xdev->dev, bus, - &pcifront_bus_ops, sd, &resources); - if (!b) { + err = pci_scan_root_bus_bridge(bridge); + if (err < 0) { dev_err(&pdev->xdev->dev, "Error creating PCI Frontend Bus!\n"); - err = -ENOMEM; pci_unlock_rescan_remove(); - pci_free_resource_list(&resources); goto err_out; } - bus_entry->bus = b; + bus_entry->bus = bridge->bus; list_add(&bus_entry->list, &pdev->root_buses); /* pci_scan_root_bus skips devices which do not have a * devfn==0. The pcifront_scan_bus enumerates all devfn. */ - err = pcifront_scan_bus(pdev, domain, bus, b); + err = pcifront_scan_bus(pdev, domain, bus, bridge->bus); /* Claim resources before going "live" with our devices */ - pci_walk_bus(b, pcifront_claim_resource, pdev); + pci_walk_bus(bridge->bus, pcifront_claim_resource, pdev); /* Create SysFS and notify udev of the devices. Aka: "going live" */ - pci_bus_add_devices(b); + pci_bus_add_devices(bridge->bus); pci_unlock_rescan_remove(); return err; err_out: + pci_free_host_bridge(bridge); kfree(bus_entry); - kfree(sd); return err; } @@ -605,8 +582,6 @@ static void pcifront_free_roots(struct pcifront_device *pdev) free_root_bus_devs(bus_entry->bus); - kfree(bus_entry->bus->sysdata); - device_unregister(bus_entry->bus->bridge); pci_remove_bus(bus_entry->bus); 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: 958756 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41sKbS34KXz9s3Z for ; Fri, 17 Aug 2018 20:45:08 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41sKbS1vKbzF12F for ; Fri, 17 Aug 2018 20:45:08 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=arndb.de (client-ip=212.227.17.10; helo=mout.kundenserver.de; envelope-from=arnd@arndb.de; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41sKKP0XfRzF0gL for ; Fri, 17 Aug 2018 20:32:56 +1000 (AEST) 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 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:NwRKKMzv3E8=:QlBuV1sRCJGQm0iC5/TM6k rUiyobUJCUMFNLefA+dKv9cSraIqTCXZATc6YpSdv5MeIiDiXqZrOrbPJLrU0ovVGvoXXGiju kb2wBbSDra92INnlUuVJjgDGdhFE2KajDetqBPU7hO/klwLL0jcbhAomkZaEY1YyaEfP9ayru EnXRTxogVL6/XcomoGxt28wyQzgXsopuQMlW4E/0olqJmIuuxAeOWvkYZFxXtdyWSPhg4wdRt M19d2fUaHKoDOvS9QTsorAKv/1ka30Io+Fm9oi5lupfC7sbB6W0FfGJ61ebw5GeeSUhnHLCsu aNUy9H3s4BYmaLLVMYE2ikiEn7AZoQYuUO32Y8NBr4GMJUKi8tHhRSRRSqfxFpbfjJdxuU3LI E7ZAVvdh0b6P2kdtTbmCeJC7RWSslaHQV19nUWu02F09EC3lmCt94PRk0ER1cUGinpzc16rv7 YL/BD4XUfyDtUZ32LltOTBsnS4VWU7qg+PFdWnOEEuqH/y1S3Up0Q1J1Rvnt2lOttzFI84qid UNZMUqV0wGXX7OTTyyrWmSycxkkwGI6D1/Zmm2QIehXpFOz7E9Ze9nDX5HeoXd2WZf8pGpSyg ZHWD1cXUS0theeaux/a2f3lBcc0EdQMmX3YArT7vuICi9Id/Q7M3zj9R9HRzUm7Pv0oNHcDTy luhOgxKA2KKU7O2tLYOQRjdTUn5M7GacTjCgnaJ3qgb0ltuYKvn6VblZSuNyWc/JctBQ= X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Pieralisi , Arnd Bergmann , linux-kernel@vger.kernel.org, Christoph Hellwig , linux-acpi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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(-) 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: 958753 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41sKTH3nD1z9s3Z for ; Fri, 17 Aug 2018 20:39:47 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41sKTH2LCBzF0gv for ; Fri, 17 Aug 2018 20:39:47 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=arndb.de (client-ip=212.227.17.13; helo=mout.kundenserver.de; envelope-from=arnd@arndb.de; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41sKK61ljZzDqm6 for ; Fri, 17 Aug 2018 20:32:41 +1000 (AEST) 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 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= X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Pieralisi , Arnd Bergmann , linux-kernel@vger.kernel.org, Christoph Hellwig , linux-acpi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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(-) 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:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 958764 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41sKsy5v4hz9s5b for ; Fri, 17 Aug 2018 20:57:42 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41sKsy47nYzDrcW for ; Fri, 17 Aug 2018 20:57:42 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=arndb.de (client-ip=212.227.17.24; helo=mout.kundenserver.de; envelope-from=arnd@arndb.de; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41sKKY2mfpzF0gv for ; Fri, 17 Aug 2018 20:33:05 +1000 (AEST) Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0MC1IG-1fhmHo0FzU-008rTJ; Fri, 17 Aug 2018 12:27:20 +0200 From: Arnd Bergmann To: linux-pci@vger.kernel.org, Bjorn Helgaas Subject: [RFC 12/15] PCI: make pcibios_bus_add_device() a callback function Date: Fri, 17 Aug 2018 12:26:42 +0200 Message-Id: <20180817102645.3839621-13-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:R1utoXtX1xNh6nDBCTDKYtshx4x5Ad5wYNBJAgXrFk787hWLNDF 5obZ97/w/5En0hskq/pxyK7SOPl4UhPJ2PTwKnGPNKAKwSSdQ44BRgnjAIpA6XYIYn0Er06 Pc2dX6A+UrbraMGwdzGaTIO5CmmDZNbHiidjXfSMXOaA8lWZRiNZ9X5Rk7imkL9cOwKt3Sk D03IBJSMeL9atj01F6mqA== X-UI-Out-Filterresults: notjunk:1; V01:K0:JT18v2PmRjM=:BdxvTLBWgjFTWFz/lix40r 9z4L3bxqOuksALVAYcFPcGpBAZuHvxmXREciCWT0V4/KjIXU7sz10GNs3qu0muAS692Y4EBws y+uS8NypHKJkVoSyknYHDj1g11Iu4pvyZqQYI6ncINrrbegVAxG9Z+B3fpehQ7XQOKhdqeYkn jn3FweKwwFL+VeWCuHooBR7iSTg86FYe7UYVuNIw5MzmMWP3fX9BHR2ImBsD+mQfCvMjNg5lF gGbPHgrRtwSX+GTsRnmZVzCHwjuW5FgQtJ8OJ0QOtzQ93iopjmt78mviBj+iy0/Y0c9zY01PE jIkdyyGlOlaAhDElnwPn/yIojydgF/B8h/nAR6j+GbGIzTCmqSoIU64UfKheX8l45C/L0s+kK tCfFlZnlqOEWD/N36yRWCRohnxPcXEz1piMQO5lTC9i0wZbK/w8I/gFKm4egVgjhOzRfGYfPb xya+oG5EXfKiYxkCNUzEV5IsLsyW1Rb9owa3hrXKHagKNI+G0FyPcgX7Up6LGKBPx7T0loImS fGoU7kHZoFm/i7EI1ePh4pUDtxXzxvXaNn7DnHhXsF/qaRs5lobIrV9LxKk7gBUXjKjucaa/m iUnGqaHijQc0KiZ88rSKl8sMm9gwqe/QqHLWHtQpay9Mm8L4VOy1CNddVxFlNINETjzZChzIB 0z50LSuBb/sqfq6Q+iqBd0aXbZIliRA0Y5RL3HF0K3GjQGCz70DsvRVRuiObKuhVfw2g= X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Pieralisi , Arnd Bergmann , linux-kernel@vger.kernel.org, Christoph Hellwig , linux-acpi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Weak functions are confusion, and we can now add callback pointers to pci host bridges for any controller, so let's make this one a callback rather than a __weak global function. Signed-off-by: Arnd Bergmann --- arch/powerpc/kernel/pci-common.c | 7 +------ arch/sh/drivers/pci/pci.c | 1 + arch/sh/drivers/pci/pcie-sh7786.c | 3 ++- arch/sh/include/asm/pci.h | 2 ++ drivers/pci/bus.c | 8 +++++++- include/linux/pci.h | 2 +- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 096011ec8670..afc9598e4349 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -270,12 +270,6 @@ int pcibios_sriov_disable(struct pci_dev *pdev) #endif /* CONFIG_PCI_IOV */ -void pcibios_bus_add_device(struct pci_dev *pdev) -{ - if (ppc_md.pcibios_bus_add_device) - ppc_md.pcibios_bus_add_device(pdev); -} - static resource_size_t pcibios_io_size(const struct pci_controller *hose) { #ifdef CONFIG_PPC64 @@ -1617,6 +1611,7 @@ void pcibios_scan_phb(struct pci_controller *hose) hose->busn.flags = IORESOURCE_BUS; pci_add_resource(&bridge->windows, &hose->busn); + bridge->bus_add_device = ppc_md->pcibios_bus_add_device; bridge->dev.parent = hose->parent; bridge->sysdata = hose; bridge->busnr = hose->first_busno; diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c index 8256626bc53c..d5c01a86cde1 100644 --- a/arch/sh/drivers/pci/pci.c +++ b/arch/sh/drivers/pci/pci.c @@ -65,6 +65,7 @@ static void pcibios_scanbus(struct pci_channel *hose) bridge->ops = hose->pci_ops; bridge->swizzle_irq = pci_common_swizzle; bridge->map_irq = pcibios_map_platform_irq; + bridge->bus_add_device = hose->bus_add_device; ret = pci_scan_root_bus_bridge(bridge); if (ret) { diff --git a/arch/sh/drivers/pci/pcie-sh7786.c b/arch/sh/drivers/pci/pcie-sh7786.c index 3d81a8b80942..ab78356681a0 100644 --- a/arch/sh/drivers/pci/pcie-sh7786.c +++ b/arch/sh/drivers/pci/pcie-sh7786.c @@ -122,6 +122,7 @@ extern struct pci_ops sh7786_pci_ops; .reg_base = start, \ .mem_offset = 0, \ .io_offset = 0, \ + .bus_add_device = sh7786_pci_bus_add_device, \ } static struct pci_channel sh7786_pci_channels[] = { @@ -488,7 +489,7 @@ int pcibios_map_platform_irq(const struct pci_dev *pdev, u8 slot, u8 pin) return evt2irq(0xae0); } -void pcibios_bus_add_device(struct pci_dev *pdev) +static void sh7786_pci_bus_add_device(struct pci_dev *pdev) { pdev->dev.dma_pfn_offset = dma_pfn_offset; } diff --git a/arch/sh/include/asm/pci.h b/arch/sh/include/asm/pci.h index 10a36b1cf2ea..e605141cbcbe 100644 --- a/arch/sh/include/asm/pci.h +++ b/arch/sh/include/asm/pci.h @@ -35,6 +35,8 @@ struct pci_channel { /* Optional error handling */ struct timer_list err_timer, serr_timer; unsigned int err_irq, serr_irq; + + void (*bus_add_device)(struct pci_dev *pdev); }; /* arch/sh/drivers/pci/pci.c */ diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index 5cb40b2518f9..45873ac1a49c 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -299,7 +299,13 @@ bool pci_bus_clip_resource(struct pci_dev *dev, int idx) void __weak pcibios_resource_survey_bus(struct pci_bus *bus) { } -void __weak pcibios_bus_add_device(struct pci_dev *pdev) { } +static void pcibios_bus_add_device(struct pci_dev *pdev) +{ + struct pci_host_bridge *bridge = pci_find_host_bridge(pdev->bus); + + if (bridge->bus_add_device) + bridge->bus_add_device(pdev); +} /** * pci_bus_add_device - start driver for a single device diff --git a/include/linux/pci.h b/include/linux/pci.h index 1dd8a3ecf753..d1072690cb4f 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -475,6 +475,7 @@ struct pci_host_bridge { u8 (*swizzle_irq)(struct pci_dev *, u8 *); /* Platform IRQ swizzler */ int (*map_irq)(const struct pci_dev *, u8, u8); void (*release_fn)(struct pci_host_bridge *); + void (*bus_add_device)(struct pci_dev *pdev); void *release_data; struct msi_controller *msi; unsigned int ignore_reset_delay:1; /* For entire hierarchy */ @@ -880,7 +881,6 @@ extern struct list_head pci_root_buses; /* List of all known PCI buses */ int no_pci_devices(void); void pcibios_resource_survey_bus(struct pci_bus *bus); -void pcibios_bus_add_device(struct pci_dev *pdev); void pcibios_add_bus(struct pci_bus *bus); void pcibios_remove_bus(struct pci_bus *bus); void pcibios_fixup_bus(struct pci_bus *); 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: 958766 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41sKyQ4q9vz9s4c for ; Fri, 17 Aug 2018 21:01:34 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41sKyQ3f0TzF12M for ; Fri, 17 Aug 2018 21:01:34 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=arndb.de (client-ip=212.227.17.24; helo=mout.kundenserver.de; envelope-from=arnd@arndb.de; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41sKV71DYvzF0h9 for ; Fri, 17 Aug 2018 20:40:30 +1000 (AEST) 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 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:49iudi3bBaI=:kBMubrQJiekBrRn4GS1zwv 9uv03XXdyQQioh/MXWDqx8qGJsDX2a+D4BydEYisG6pnTnsQmDY5p2EfpEw4IPJc+uBN+xwLx 8rDvoRbkuxpbLImx05ZCMs0KPqjTctrI9J2w14ZQKIjP1AqqHyNoXaOguv0yZtPP6QJqroPbE vVjJYpoC2R/xuRH7MEUeJtx2+vJ1CP0rgW29LOhPM1IdR7vsi1twBKnZH8rvVbaC1TAohySwk 4qf9gXSUfsnkEE+Grp0I+IeBPIPK826Fzuo0XIt4t5Os9n8eNax31SJKuMf8iK3EXVILHv8Un +mhrxxcJYNVznlDFWvkE54CU/1PeGPc0R4iZBGFTTd3hC/JwcqJ7ojW40bivDYYXFl9fovxHN 0BaXRXZNVzQaZtW+AlVodcddIga1p3m2lqD9f25ZwjBbP/23jdG4mQwNO/9jg2T1hyO2TCw+8 NElUJR0/DVVpatF6O9eUnqoV3wWo0T1wzA5jr4itg8u9n6ATUkPiyAdPrqQ+lTeGwpGbzucr8 xNc+8Ldx/cHO4dyjgeIq9x2+MsD0JWPIvhIhlRdySF+e5AFeoUn65lT41D59f3T2NB00BE4IQ 1fxrfP1ihDdZRgK+lR1K6+IofWJIJt4e1iXBOx3H2Yd6M+UOSstw0OqfGJCzB3tLqM2LosSzm mQCRV83X5IW1iNFyijhsw14do98ph1ULftDKxeHDfwj0/uTu5J31lrUL58YNjH7EQ9v4= X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Pieralisi , Arnd Bergmann , linux-kernel@vger.kernel.org, Christoph Hellwig , linux-acpi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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(-) 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 */ From patchwork Fri Aug 17 10:26:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 958754 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41sKWH0zdYz9s3Z for ; Fri, 17 Aug 2018 20:41:31 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41sKWG6YhhzF0vb for ; Fri, 17 Aug 2018 20:41:30 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=arndb.de (client-ip=217.72.192.75; helo=mout.kundenserver.de; envelope-from=arnd@arndb.de; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de X-Greylist: delayed 301 seconds by postgrey-1.36 at bilbo; Fri, 17 Aug 2018 20:32:46 AEST Received: from mout.kundenserver.de (mout.kundenserver.de [217.72.192.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41sKKB4GR2zDrRN for ; Fri, 17 Aug 2018 20:32:45 +1000 (AEST) Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0MIe3k-1fsotc3lQO-002Dcj; Fri, 17 Aug 2018 12:27:21 +0200 From: Arnd Bergmann To: linux-pci@vger.kernel.org, Bjorn Helgaas Subject: [RFC 14/15] PCI: make pcibios_root_bridge_prepare a callback Date: Fri, 17 Aug 2018 12:26:44 +0200 Message-Id: <20180817102645.3839621-15-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:vZ1tUwmaDYGgBzDuu0lrWWtkxQnlkXj5dtYX8zCbAbjMLPhmXwP t9LwpfD9mkpXEZveH7+fB8uk6X4OjdFYNyOnA1ey8wm+8CsZSfl/mDsjXOrb7MOd2PtYpje OlpTlmfI8HEz2MmVEtEV3Ua7aljIba3990heu2dTAIP1yUOKAYEcf+hRy1ZnQhsCmKw51jI +C4qufrNzYmzj/M0BHZrg== X-UI-Out-Filterresults: notjunk:1; V01:K0:dxliqE4bdUU=:3wNTq0x8GVJJDBiQ3AXqXs G1qv2M9EJ/R9gkV1bKMYZCs8sWmMSWUClGEIkfFaJ2W2G0STrO3wSkWADrlKtkCc9PfdTAoup 3zxFFpGjrFC3KfzxAbZML6rOtKnoEb5e3CksJj+aa1fm6aeQMQTvedb371xxPgfGWKva598XF PUSLvS6C3LcfmUQxzp0qZhcq8yppA5YYztqdY4TGZalE1Y8SY+nXhfKO6wlKvVk8gBAw8bicO EVd+BdFeloh0voA6J06gKNEZYjc6N7/m2U+JDcnX3Ypj9EGMwtWwQMC/6iRinDdnA0fgkwqW4 veqzwD45anZ44l+bkcdHI139spogAFCokqTAoS3lNwGdDFgnCrnv5wpnz92x18JhrHZFSK46h 1ooUzAs76v4ReXOyxEaBYCIkZfLExQcmeFHG/69ANMAnxIAA7Yx8NyY+vmE5/VThcDYmgZXGe 1jKXIZH/4ZFYKwPKIieTXdvXbmbnn+iTnmgndrm+wqozHbn1r61w/IAcy+XYfVEqj5uzXRSMJ 1QxFviL9Dt34LjlL5KMfIJTwrsc9uYg7id2Spp2jrfngo0HnfwR71KrBA6ZNY7a0IAEr+OX4X 030RsyIZnKMH2VTlrWfZhEjRisjQ8d9DdbWD9684DeNYA34N2KYNUgsazhi7hJGNV8xjU9sY+ IW1+wFwF4nHlkdCh9SPWlrphoEsYEnEVQAW5fgWeSJm3dqoevlxFhDJCnasD5iu58MTk= X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Pieralisi , Arnd Bergmann , linux-kernel@vger.kernel.org, Christoph Hellwig , linux-acpi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" pcibios_root_bridge_prepare() is always used as a per host bridge function, not per architecture. Making it a callback in the pci_host_bridge instead lets the host bridge implementation easily override it, and avoids the checks in the architecture for which host bridge implementation is being used. Alternatively, we could probably just call the pcibios_root_bridge_prepare after alloc_pci_host_bridge() here and get rid of it as a generic interface altogether, but doing that has a slightly higher chance of breaking something subtle. Signed-off-by: Arnd Bergmann --- arch/arm64/kernel/pci.c | 18 ++++++++---------- arch/ia64/pci/pci.c | 15 ++++----------- arch/powerpc/kernel/pci-common.c | 9 +-------- arch/x86/pci/acpi.c | 15 ++++----------- drivers/acpi/pci_root.c | 1 + drivers/pci/probe.c | 28 ++++++++++++++++------------ include/linux/acpi.h | 2 ++ include/linux/pci.h | 3 +-- 8 files changed, 37 insertions(+), 54 deletions(-) diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index 3d196c68e362..8958a7c32a9f 100644 --- a/arch/arm64/kernel/pci.c +++ b/arch/arm64/kernel/pci.c @@ -71,19 +71,17 @@ int acpi_pci_bus_find_domain_nr(struct pci_bus *bus) return root->segment; } -int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) +int acpi_pci_root_bridge_prepare(struct pci_host_bridge *bridge) { - if (!acpi_disabled) { - struct pci_config_window *cfg = bridge->bus->sysdata; - struct acpi_device *adev = to_acpi_device(cfg->parent); - struct device *bus_dev = &bridge->bus->dev; + struct pci_config_window *cfg = bridge->bus->sysdata; + struct acpi_device *adev = to_acpi_device(cfg->parent); + struct device *bus_dev = &bridge->bus->dev; - ACPI_COMPANION_SET(&bridge->dev, adev); - set_dev_node(bus_dev, acpi_get_node(acpi_device_handle(adev))); + 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; - } + /* Try to assign the IRQ number when probing a new device */ + bridge->alloc_irq = acpi_pci_irq_enable; return 0; } diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c index 7ccc64d5fe3e..511b8a058d80 100644 --- a/arch/ia64/pci/pci.c +++ b/arch/ia64/pci/pci.c @@ -308,18 +308,11 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) &info->common, &info->controller); } -int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) +int acpi_pci_root_bridge_prepare(struct pci_host_bridge *bridge) { - /* - * We pass NULL as parent to pci_create_root_bus(), so if it is not NULL - * here, pci_create_root_bus() has been called by someone else and - * sysdata is likely to be different from what we expect. Let it go in - * that case. - */ - if (!bridge->dev.parent) { - struct pci_controller *controller = bridge->bus->sysdata; - ACPI_COMPANION_SET(&bridge->dev, controller->companion); - } + struct pci_controller *controller = bridge->bus->sysdata; + ACPI_COMPANION_SET(&bridge->dev, controller->companion); + return 0; } diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index afc9598e4349..5e5c6dd7ebe8 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -771,14 +771,6 @@ int pci_proc_domain(struct pci_bus *bus) return 1; } -int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) -{ - if (ppc_md.pcibios_root_bridge_prepare) - return ppc_md.pcibios_root_bridge_prepare(bridge); - - return 0; -} - /* This header fixup will do the resource fixup for all devices as they are * probed, but not for bridge ranges */ @@ -1612,6 +1604,7 @@ void pcibios_scan_phb(struct pci_controller *hose) pci_add_resource(&bridge->windows, &hose->busn); bridge->bus_add_device = ppc_md->pcibios_bus_add_device; + bridge->prepare = ppc_md->pcibios_root_bridge_prepare; bridge->dev.parent = hose->parent; bridge->sysdata = hose; bridge->busnr = hose->first_busno; diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c index 5559dcaddd5e..041b2003707c 100644 --- a/arch/x86/pci/acpi.c +++ b/arch/x86/pci/acpi.c @@ -382,18 +382,11 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) return bus; } -int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) +int acpi_pci_root_bridge_prepare(struct pci_host_bridge *bridge) { - /* - * We pass NULL as parent to pci_create_root_bus(), so if it is not NULL - * here, pci_create_root_bus() has been called by someone else and - * sysdata is likely to be different from what we expect. Let it go in - * that case. - */ - if (!bridge->dev.parent) { - struct pci_sysdata *sd = bridge->bus->sysdata; - ACPI_COMPANION_SET(&bridge->dev, sd->companion); - } + struct pci_sysdata *sd = bridge->bus->sysdata; + ACPI_COMPANION_SET(&bridge->dev, sd->companion); + return 0; } diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 5f73de3b67c8..5da0f70c4e65 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -910,6 +910,7 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root, bridge->sysdata = sysdata; bridge->busnr = busnum; bridge->ops = ops->pci_ops; + bridge->prepare = acpi_pci_root_bridge_prepare; pci_set_host_bridge_release(bridge, acpi_pci_root_release_info, info); diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index eaedb4fe143a..f493d7e299e6 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -762,6 +762,22 @@ static void pci_set_bus_msi_domain(struct pci_bus *bus) dev_set_msi_domain(&bus->dev, d); } +/** + * pcibios_root_bridge_prepare - Platform-specific host bridge setup + * @bridge: Host bridge to set up + * + * Host bridge drivers can do some last minute fixups on the bridge + * here. Usually this should be done before calling pci_register_host_bridge + * though, so this hook can be removed. + */ +static int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) +{ + if (bridge->prepare) + return bridge->prepare(bridge); + + return 0; +} + /* * pci_register_host_bridge() - Register a host bridge without scanning * @@ -2889,18 +2905,6 @@ unsigned int pci_scan_child_bus(struct pci_bus *bus) } EXPORT_SYMBOL_GPL(pci_scan_child_bus); -/** - * pcibios_root_bridge_prepare - Platform-specific host bridge setup - * @bridge: Host bridge to set up - * - * Default empty implementation. Replace with an architecture-specific setup - * routine, if necessary. - */ -int __weak pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) -{ - return 0; -} - void __weak pcibios_add_bus(struct pci_bus *bus) { } diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 9967ba2e0b31..62c0278a7614 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -336,12 +336,14 @@ extern int acpi_get_override_irq(u32 gsi, int *trigger, int *polarity); void acpi_unregister_gsi (u32 gsi); struct pci_dev; +struct pci_host_bridge; int acpi_pci_irq_enable (struct pci_dev *dev); void acpi_penalize_isa_irq(int irq, int active); bool acpi_isa_irq_available(int irq); void acpi_penalize_sci_irq(int irq, int trigger, int polarity); void acpi_pci_irq_disable (struct pci_dev *dev); +int acpi_pci_root_bridge_prepare(struct pci_host_bridge *bridge); extern int ec_read(u8 addr, u8 *val); extern int ec_write(u8 addr, u8 val); diff --git a/include/linux/pci.h b/include/linux/pci.h index 1296d9fcc5da..24216daef6f8 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -472,6 +472,7 @@ struct pci_host_bridge { void *sysdata; int busnr; struct list_head windows; /* resource_entry */ + int (*prepare)(struct pci_host_bridge *bridge); u8 (*swizzle_irq)(struct pci_dev *, u8 *); /* Platform IRQ swizzler */ int (*map_irq)(const struct pci_dev *, u8, u8); void (*release_fn)(struct pci_host_bridge *); @@ -518,8 +519,6 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge, void (*release_fn)(struct pci_host_bridge *), void *release_data); -int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge); - /* * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond * to P2P or CardBus bridge windows) go in a table. Additional ones (for From patchwork Fri Aug 17 10:26:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 958763 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41sKqx5MTpz9ryn for ; Fri, 17 Aug 2018 20:55:57 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41sKqx3x4JzF0ph for ; Fri, 17 Aug 2018 20:55:57 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=arndb.de (client-ip=217.72.192.75; helo=mout.kundenserver.de; envelope-from=arnd@arndb.de; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from mout.kundenserver.de (mout.kundenserver.de [217.72.192.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41sKKW6MDgzF0vb for ; Fri, 17 Aug 2018 20:33:03 +1000 (AEST) Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0LnjcV-1gM7mA1Qsh-00hrda; Fri, 17 Aug 2018 12:27:21 +0200 From: Arnd Bergmann To: linux-pci@vger.kernel.org, Bjorn Helgaas Subject: [RFC 15/15] PCI: make pcibios_add_bus/remove_bus callbacks Date: Fri, 17 Aug 2018 12:26:45 +0200 Message-Id: <20180817102645.3839621-16-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:rGoCCDOtdTx0VIyssezT4pFtEqNhxuve6iKaXwJBHf+4WU+8faw Dpu9wq8RQiguXqn4V5akgwPWXgaOy5cgDTJiHcHLT3xv/oOaMtG54uC8vvLQSdW///4q0nw I5RKZeCd07/18v074X+Gqwju9Ri5zhyU1Epl7WlCft+LD22RQMCW/zNHZIYUSLUK+qnJWcB s4jqjjsW1kamBVSX4DlSQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:dvnAj65ZFk0=:VDZz8f5vebrAq/ejMgOjie 8GyIQqycNcIjvjvExiOocGOAUqnYGIWU/GPr3VlveyEov22HhpNdGxGf/bsY002217lItjy6h VoxKTupeKpH67W+bXJkWRoqklPmUmpb1fNxUAfmkRbM1r9io4i21ka6OTjAYe9RG9kXC2zokv Ehbteks6J3NYY0o6b4UDg4zMihthl+jRPCDPFG8/6oMHMHQw1+TvpeWuOOXOoF7yTprRj9HcS YpyClDchECbHOW7LYaf4s/laoMpumYks4bT0bT+y4zGgIoY5Ucm3hA/+4dgRuJOQ6b+pwWdLA mtE2Jdbhg7ZuTwHM4JlpKb5gCg6vA003Qr+XxFzDv8z8d4PlxsPqgsP9UDiXg0jHaOjZROh1h CGbOHnX14PWKO/OfpGznpCJs8iQiMfJp+oQZKL0GZAxI7b5VexFCawSq4cF3j/U/eCoF+cpKk Nn4MlOjtFvrSWnh/H1GQk9NMh/Bxr6e5CXiZIfm0qXqzkJGI5gNQV8Lb76AUxAork3vZuETPA 3Hsnaonx4c43qnu982RWXcxqfzToGmZ79byd5UFTROEe8FtyyMuIiMl1b5YVzNvrhXJNpmzG8 eJOTazidq4DgvQhXN+PZpkkVZjFQOQQj+4b9UAdXo4zMUM71Uc5rvlNLYFv03ZsI9FRi1Et0I K8wkUQd2CtRY7r9IXecV6AttFf/QbE7LJhT0+5b1krOYE3NR21BYg/iubv7KQt442+C8= X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Pieralisi , Arnd Bergmann , linux-kernel@vger.kernel.org, Christoph Hellwig , linux-acpi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" These are mostly not architecture specific but are meant for particular PCI host bridge implementations, in particular for the ACPI version. Turn them both into callback functions that are implemented by the APCI PCI implementation as well as the one architecture that overrides pcibios_remove_bus. Signed-off-by: Arnd Bergmann --- arch/arm64/kernel/pci.c | 10 ---------- arch/ia64/pci/pci.c | 10 ---------- arch/s390/pci/pci.c | 3 ++- arch/x86/pci/common.c | 10 ---------- drivers/acpi/pci_root.c | 2 ++ drivers/pci/probe.c | 12 ++++++++++-- include/linux/pci.h | 2 ++ 7 files changed, 16 insertions(+), 33 deletions(-) diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index 8958a7c32a9f..99fac25efe88 100644 --- a/arch/arm64/kernel/pci.c +++ b/arch/arm64/kernel/pci.c @@ -191,14 +191,4 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) return bus; } -void pcibios_add_bus(struct pci_bus *bus) -{ - acpi_pci_add_bus(bus); -} - -void pcibios_remove_bus(struct pci_bus *bus) -{ - acpi_pci_remove_bus(bus); -} - #endif diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c index 511b8a058d80..f47e0920d308 100644 --- a/arch/ia64/pci/pci.c +++ b/arch/ia64/pci/pci.c @@ -367,16 +367,6 @@ void pcibios_fixup_bus(struct pci_bus *b) platform_pci_fixup_bus(b); } -void pcibios_add_bus(struct pci_bus *bus) -{ - acpi_pci_add_bus(bus); -} - -void pcibios_remove_bus(struct pci_bus *bus) -{ - acpi_pci_remove_bus(bus); -} - void pcibios_set_master (struct pci_dev *dev) { /* No special bus mastering setup handling */ diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c index b21205f131ce..120beb83b6a5 100644 --- a/arch/s390/pci/pci.c +++ b/arch/s390/pci/pci.c @@ -769,7 +769,7 @@ static void zpci_free_domain(struct zpci_dev *zdev) spin_unlock(&zpci_domain_lock); } -void pcibios_remove_bus(struct pci_bus *bus) +static void zpci_remove_bus(struct pci_bus *bus) { struct zpci_dev *zdev = get_zdev_by_bus(bus); @@ -801,6 +801,7 @@ static struct pci_bus *pci_scan_root_bus(struct device *parent, int bus, bridge->sysdata = sysdata; bridge->busnr = bus; bridge->ops = ops; + bridge->remove_bus = zpci_remove_bus; error = pci_scan_root_bus_bridge(bridge); if (error < 0) diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index 920d0885434c..987e6fefd5d3 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c @@ -168,16 +168,6 @@ void pcibios_fixup_bus(struct pci_bus *b) pcibios_fixup_device_resources(dev); } -void pcibios_add_bus(struct pci_bus *bus) -{ - acpi_pci_add_bus(bus); -} - -void pcibios_remove_bus(struct pci_bus *bus) -{ - acpi_pci_remove_bus(bus); -} - /* * Only use DMI information to set this if nothing was passed * on the kernel command line (which was parsed earlier). diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 5da0f70c4e65..cf7a9a7bf1e7 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -911,6 +911,8 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root, bridge->busnr = busnum; bridge->ops = ops->pci_ops; bridge->prepare = acpi_pci_root_bridge_prepare; + bridge->add_bus = acpi_pci_add_bus; + bridge->remove_bus = acpi_pci_remove_bus; pci_set_host_bridge_release(bridge, acpi_pci_root_release_info, info); diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index f493d7e299e6..86a678fa8c13 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2905,12 +2905,20 @@ unsigned int pci_scan_child_bus(struct pci_bus *bus) } EXPORT_SYMBOL_GPL(pci_scan_child_bus); -void __weak pcibios_add_bus(struct pci_bus *bus) +void pcibios_add_bus(struct pci_bus *bus) { + struct pci_host_bridge *bridge = pci_find_host_bridge(bus); + + if (bridge->add_bus) + bridge->add_bus(bus); } -void __weak pcibios_remove_bus(struct pci_bus *bus) +void pcibios_remove_bus(struct pci_bus *bus) { + struct pci_host_bridge *bridge = pci_find_host_bridge(bus); + + if (bridge->remove_bus) + bridge->remove_bus(bus); } int pci_host_probe(struct pci_host_bridge *bridge) diff --git a/include/linux/pci.h b/include/linux/pci.h index 24216daef6f8..bc9635313747 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -479,6 +479,8 @@ 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 (*add_bus)(struct pci_bus *); + void (*remove_bus)(struct pci_bus *); void *release_data; struct msi_controller *msi; unsigned int ignore_reset_delay:1; /* For entire hierarchy */