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: 144462 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp595656ljj; Fri, 17 Aug 2018 03:27:43 -0700 (PDT) X-Google-Smtp-Source: AA+uWPz/qdU6JOsEp7QMwBjjaFaR71sGG00N7ojlb6IVqt19Dq5tDE+qYBPcWKUfxqCPr0noJYsg X-Received: by 2002:a17:902:48c8:: with SMTP id u8-v6mr33157326plh.152.1534501662981; Fri, 17 Aug 2018 03:27:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534501662; cv=none; d=google.com; s=arc-20160816; b=CpBiePocdqT3ywSHD8LoKlI7Qz0w9HTPKLAeWaz8w+SobidExE3VZvukIQux76oYyp VMPX6eq9ZZ+24ACkuLZYBa+MrwZIQxwg50d3awaJe12ItVN0e0KtLdY4Vnx0yIxXgWHY 1pfbNLUABYCFKyMwPeXdk5ZYBVYk0BJ6KfDQ6w3xrUCkx0mIZ+gPQQ/iqw1y3flFPNWU reEbYBAJ0Df9ybt1sh16ayJYZPor3AxbSsDJITpPPhb7hgQ6NZXMOfOO6+r2TLqzZh3v h0u/L6PzIwAsIf70yfvQj0lClLwB3JcIKr8zpqJ1OG1SJRLK5mn7ur27iW9F+iIFilas AnfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=WY/BzzXOVhHdn8tUGz9NNnmNsgm1zDkmOPBX3FrXEyY=; b=nGcLw7TEnmihLlgrZflq87H+Pz1waRffH0lL2KO/X6/65qoW+6glgINR0Gj72scC+F aQqVdqS7EtH8/GjL9pMJ0O5yJe3d+K4BmTGl45YhSd8xXM7Pgsk4kyS6MUUV3dN0KUqY dV9aFp21+HPNOKqSaad5a3PAsPp/jvmSjRTDGh6dYAReUA+ONQ8vHdy5TjAKWqLYzxr4 kvINSBq8ZH1lefkmIQZgorbUZainy6JvmCOAu/AWKYDKdFng5sdyVpf6MD66oqVHKumA 7uxIQ6WQ7SmAPT42x6kFWP+3PxDsG0/H+tdHaJYY2ubfZKcbWhS2L87Oc5KjpdbVmWf/ KnXw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m11-v6si1953668pgk.468.2018.08.17.03.27.42; Fri, 17 Aug 2018 03:27:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727273AbeHQNad (ORCPT + 32 others); Fri, 17 Aug 2018 09:30:33 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:49229 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726218AbeHQNab (ORCPT ); Fri, 17 Aug 2018 09:30:31 -0400 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 Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Lorenzo Pieralisi , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, Arnd Bergmann Subject: [RFC 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:jfQRhFGulKg=:XukBP/UhVY4BRzkO84yddY qQprVATs/qCyceQTQaz+NSylj38T+4mtihVDs3Lu2LdCa1KYaNdq3gRlgvmqPRcs8HvdHy6Oi 9gEnQJaQJTT28Na47z6gb3ssYaSqkriElVDkOJ6POo3RjjkpCPEf+02/pTfuqK3E4fvzcxwD0 BsvGfrcRv1rBlbcLybB4/WrFXvSLSgbapLU9ENLSsVJRMKh9bgR5IJtNotnR14UkHxxJl3X5k 9pIUmf11wUVON5jlM9WT8wJBOFmcmsKfAxcQ5/dhB8fnzqtofDUYi8ghIisUjtYpusFeyI+lP XCOQ5IRbxIL1Mv+LBQ/O/jqMQ0hJwza3VFRwmrsFihyPai9gybRhVVear1GmMLGvHu1rpMjXP PkfaKh/Nche6GRkGXkltaZsVuMqrlDwFxTWN/qVCg92pRQk1VMSUQLvbWZYhelAs3GKgcKBRm uXLFTlGeXM3t3x6/3HyDjg4GBGEfs7MxcbUlJfhSkI1niAgMYb5TTB6fkbBex2PXKOah0tDE3 NLbO9MPHnbrM88zKxCyN4CziOFndAmJTEH42nME+FcgVqAJc2gJkOGzJL9DwcC+zDTSule+RG lvvEzhnosFOE+1Phg9bv8wgPAmbyGBaoDqUia7FHDe0LutTZgvUruaDaa25nfzFZGGqRV8d4S GnUtdvrrcKhF2BVCA+dU2Gnpmp0a6aap6Q0M8QFyLPMA3HDxd2vt8msowj/dDlKIVlzE= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.18.0 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: 144470 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp600507ljj; Fri, 17 Aug 2018 03:32:40 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzCszazrbxoDoX/iR5n9PyINs5rJ4X/6I7xoXkdvnYRFfyqrwBmHfc/xc4nk9hGZp2qo9wN X-Received: by 2002:a62:5047:: with SMTP id e68-v6mr36450734pfb.157.1534501960758; Fri, 17 Aug 2018 03:32:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534501960; cv=none; d=google.com; s=arc-20160816; b=AMI1a6CEMOnrEPnaQuxjq8gtAZVgaMat0awuDmcyz38/fF3lpqwjKISql6ZNf+v8cL pVA9y1zgaPGw45PNAiF/4qVVc/G07DlbXxNUpvZr27xsxXGzalQ7MhlMo/5QzJQGnoog 4pYrPbvuz4HKlGpNlOfTnZu0c40lnUaDYt5uiqhrI/nWDUCmOY+y/wDAa4IB9GRVranc HAHiigdqOisTh7Hvjo+EZc/s+qQrjxWE9JdjJMr07qjBJKhPCoeq3Q9AnglnGkujV42I ko5nLTSJR4qyYXwsmS3LF1bGRjsf6oDmkcsZkbDSLR3BJDSArpEfuXJzfWyzvBKGY0z3 gCEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=p8w09xVM9zhkVdyu4XW0cEIdqqulf4D5os1h1zs1Iv8=; b=Jnr1NIgd+UJqg7jDhGEgEy/iSQZ8R6eKl7F1tE/dz4/H4CZ0eeVSE4htWdUMTAY3GK ioW4aKIg2ebAqbQztsASFanOojjHi8VTrt9kwUbPrldnBpRcR+dE86rS+DQ+ykemy4eS cMqC/tq/AkIPDDT0eNQAL7VZauu1yM6jO/mWcr2FgiIGHyuXZrXnFdomggsuZTnnzybh E3yE0J4uiSHJvRATFwPMYb0ixxEPdTQyF2tB1kGZL6QTwoAJfl1HST+5RqUnmhaommjB +FdWeiJhNl/CXb43imYuW2ruX7VklKQF0VVVNU0jq5nsUD7HbzLPcJS9NqlKhU7i0Jf/ /Jdw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e1-v6si47820pgk.275.2018.08.17.03.32.40; Fri, 17 Aug 2018 03:32:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726768AbeHQNfc (ORCPT + 32 others); Fri, 17 Aug 2018 09:35:32 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:56531 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725992AbeHQNfb (ORCPT ); Fri, 17 Aug 2018 09:35:31 -0400 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0M9oN6-1fjzDA0HrE-00B3KP; Fri, 17 Aug 2018 12:27:16 +0200 From: Arnd Bergmann To: linux-pci@vger.kernel.org, Bjorn Helgaas Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Lorenzo Pieralisi , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, Arnd Bergmann Subject: [RFC 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= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.18.0 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: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: 144467 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp596192ljj; Fri, 17 Aug 2018 03:28:19 -0700 (PDT) X-Google-Smtp-Source: AA+uWPx6NtEadozR3J4GdDb4zqX/luKQAOQp/KqN+ZRDTHNYshP1vM/xVQx6MmAAK+nbbNqy5zpo X-Received: by 2002:a62:fc5:: with SMTP id 66-v6mr36436401pfp.237.1534501699102; Fri, 17 Aug 2018 03:28:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534501699; cv=none; d=google.com; s=arc-20160816; b=BFAwzvT7hScU9MUvUzsLAktLz+yOF3FNr9jRnNyauULvHbWZ0F2oFYBnXScWWh6PWy Itd/5nQP9N/tfStpRAeNPEIxR7SlNJTUqG3ttJaclSzq3rn16IG1aJPayh5SKZBNq3AF +rOwJZ1MMzpIBlxn43NzDki/rLw4GNo/Ed2EhUWwOgReWGBWAqE5PtpY01+YWgtcqgZB KRLF0AZ8tvkg4mMJri6lV36le5O/Jeo77YiXv74GdBOjjdISPzdWvMM78A+BlsmFA3cE CDPnXSHVzvleQG+dXQunKDYPT45cZTuCfIwj+p3tPXckwZusIhKrjWusfWtLGMlDnqLm WSUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=E6E8D4iCwO5eyh2oGtKaG0vyFm/WWnHElO1PiOsU+lU=; b=ipRzvfN1TDJfGKszx3mDgc3dwV+GFYERaOZXzSewdKzCTDK2zFdP2aXfccyA/VSBuy 4B7acsEdUFJv/pjVVGjfbKuPzlL88n+JOQ6hryBdPytcHYWf8O+qWmBs1JPuc49P84Ah hmgIHIyMVwFB/FvGeSXCAfRikbrRBL0jRdwNEz6MXGjt1zmLay5NKZNYOZeDJkVte3Cx wV7jQcc8ICkXn5WrQxj/GEmVi52ZbfhIogim7M16IOzzXJgC2FnrmolX6Egp4kmNAcpF F4bjQQAho1zXK2XaAAmRHh+344Sg86DM4AYJEPj1FKA1WVYCfAnxQVFSYEBMwgpqBrR+ 9Qww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n34-v6si1865788pld.99.2018.08.17.03.28.18; Fri, 17 Aug 2018 03:28:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727461AbeHQNbK (ORCPT + 32 others); Fri, 17 Aug 2018 09:31:10 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:59335 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727032AbeHQNab (ORCPT ); Fri, 17 Aug 2018 09:30:31 -0400 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 Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Lorenzo Pieralisi , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, Arnd Bergmann Subject: [RFC 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:6viyPx4Qb74=:ccCWwxVG4h9e67s1aeOEA5 DSD5frqpk3rf+CElY2taeu1iNYf0RDqjWPk1AQkQlRZIT8V6ygBWKhYW8+niK8SPrhzEefQoN MTAzJhGQjUG5mJz4neuPJrfWfvoRyWWno3raPfFD4IBjJzeE+wQ5wSD5PVhe19BsXlubY02g8 5MO+LdODz2tWxlOkI+FGaNMHD3AUyYbfeZFVfCVihpH50sWaTbfhg9dfHCMQlN3Ux8fH+iDcz CzK2NJmTJLXfvDYvkbuBwOQsXeMCOMgWI0S787/Hu3SxiX6sgA0WyOQsvPnufZss/8nagJgzF pmhXqG5ei/dM3MxDDeER5wKJlSfFLLZV9YBysTjF+RyUu0srfhAgAK/0VoLg/xLf8+W+ss8S6 cT6Eop6PKWq7TliAkzqtHUgUqQKfTg63eGJ+bxelz36NgAJhtrdwfjUrvcK8GvIo9n6ofst7f M+ZpnwtofMJalysbiNMd0/U5C+LZvQIDyhBnjN+ztTMX161kKMmQQRMGt9bU5zlGebSHJML9t uxwQ3exwP8EM1g/36YZc/Juqs5Obu3SVHVwOM1GmpgDg6RViN0CBJ9wm0T9fA1B4qvj9y5YX3 okKhgiwMMZCJUT1fjABTxHH38aHmgTpoprIuHZ9tZSVc1oJT/y7nNxmLlGE+AtLIOIUiyAUVu 8M9riaC7jjFCIl60jk8C9N1eE/iRsPX3qGaPVVog7/SbWPtLeyy25TBnk4ZFk760HgD0= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.18.0 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: 144466 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp596009ljj; Fri, 17 Aug 2018 03:28:07 -0700 (PDT) X-Google-Smtp-Source: AA+uWPy+V4XQbRwmqO+aEoGLgxCbCisYCE0o+Z5YpKYRp/13EfzfM+qCnilHE6nzniMvU7xsysmi X-Received: by 2002:a63:10c:: with SMTP id 12-v6mr178247pgb.62.1534501687342; Fri, 17 Aug 2018 03:28:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534501687; cv=none; d=google.com; s=arc-20160816; b=tXZm8OtC987f12t/Jj+/m2d11lDvsPcwCyRVPoZr2EhJNO3aAgTX814zebqrZD/x7V Kl7AlT5lVy/Gnhf3Y+zkPAR0CtLF6U0b7FIwHuaVKS3UpeGNDEp/CPNGDf7DUVueY0ek KcRbWfkgl87S4O7iJANRwJjg7vnufZHMWssaI5pE0ULCiMD9+/CW1XrLbhqVU8c3RMcr eMnpzdZuAjLv+SIZ1EbF1HC8y2Y6+TT39KkTOnz28p/bAAJVs6B1evjb5FGGCXtg2A46 rmggnnqeNxQ60fK9zD+PdzzzBlbsWgzk38WTwHoQ4/A0IB73pHCPnIY7o9rn5153zoZl v7Bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=gOgTj87nR1dqiKIxt6n8tNAYzeLSESarhKMAi0XBbhM=; b=k4N6pOW1ZMlXhWlP2K10nVlDIfPeWHzCwUDNN6ev8o1yFz/3nadY7YqggEgll5piwI aoZz3bI/FIOcO/vWh5QXIBsvant8fdyfDopSVfPoavn4Nxu1zu+q3jgn55IX04TT/NbP ZyoZdBijdwgNLs4PGYIELQiq+Gx71m2M0zF4ir9oTTv0Ed8wtUdB3NiU0dymBzcIUNE8 v37C1iym9LEbpc/qeVQoOqXEtFxD+5AOhI3Q30wxhp8C36TFlOUrJKIwvhNCBCEBqGnU 0736gj6vUDhNdNvoiN2Y+hA+NDVLoL8LWUXvBiHD5xNm/PRZsiImPDzQND6xze07bu14 /dGA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l127-v6si1934751pfc.135.2018.08.17.03.28.07; Fri, 17 Aug 2018 03:28:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727407AbeHQNax (ORCPT + 32 others); Fri, 17 Aug 2018 09:30:53 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:48209 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727058AbeHQNac (ORCPT ); Fri, 17 Aug 2018 09:30:32 -0400 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 Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Lorenzo Pieralisi , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, Arnd Bergmann Subject: [RFC 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:XHSfvXBRCKU=:r58iToc42PeA5q2a7Kt6oq 6VlaRcPJclx97z1Jv6s1RQc7jr29NLhEHSyFjQLdKbtVuTjqprA7cNjLMZoDdmcoTtQ4Jd3/p X2UGiWXAOL8bjI9Aw4JbLcTGFToUMDS6NZ2Fw5+xkVWVAGa7HtXLe48DCTi37wWrTviu8xsIF Won9k1ZcAlTV+3P/X7fdqbWSZYaFVOGVYk3qqZBwMLDHBwggFqHdNJlY8bcBK16BFyHsrxGtk FTw0zLa2JxW7wPKoWg6r2pWPMf+QVeo0TgoYchxwH+2/HEJonT/y81adZr4o29pAQaTTfZlIj TMNzdytb5wtfI8/0wp0GuDNgF6uw8oBDX6O4a3W9s7myMxk8e/xENDdRZ4r+/n+WsTjFo25wg oqltuqbiP5+Y6pWZMVuZ59/FSxAhZSF3gu5GBCtKRFCmduyhdFx6WI88coxOIgxZFLBJCFVfE SWKQOTUBZ8chFX2lO9l862T3zvMwuMno94GC5LJ4d++t+IeIvQmVDy4wWdWv1lbFqJBb6WCzn 0I8O0euMhPFqywJVhFDz3opUkBO9ZE4x2r4sQFp+i2Ywku/1L2PSk5tpnAEUyR5h01v6Zg/P9 hG0vfNQyOfjDgXZiku0to7vkxWcVUSpP/IPE30CLegGuaVIiwKw72RCBmHqvYe4CAXjM5qY9B GKxebiB7ng9TNi2dRfLqd2I0Io9btA2NgJBHrk4eccGwnwzm5ukK5KTUCXkpkHX90ybY= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.18.0 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: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: 144475 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp601042ljj; Fri, 17 Aug 2018 03:33:12 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzWs7y8ho6DmqbEVPdhh8pXSQCONbh7+NeGro/4eW8OBVp0GnhSexwtF/4aZxeuWnpnXXSt X-Received: by 2002:a17:902:6114:: with SMTP id t20-v6mr3499787plj.92.1534501991888; Fri, 17 Aug 2018 03:33:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534501991; cv=none; d=google.com; s=arc-20160816; b=MznseFFaUrfftP6iOdGT7R9A3a0BRJRxWwfSPhGfmmHEwHJn7WUwX2L3RLdwD59uuz 3P5fNjbHKC56QmttIreCFegJ0QSGeY8nt9G72ff8iskh6Onh5I3qqSvZg0pf/XZFmoOy Qv1dklcNseaNDyIomfLOQkFADLwtiiRrb0MyqEWktjSod97ZqV/nDJBqF3nfV0CNecC8 AsU7ERojqDCMPz6RtVi75O49ssJDZHxZHF8+o7uwrN1PEC1ezEN4cF4bQ+NIyd+lgt4T Ycg3URCGWLcuSJ8OP/oJbZumktZTEDTAmCIQBaDufYAaU/g6qq/mjuD/ZYuF/xeySMPD yz8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=MLEl6GCzzc7+zTFjxPoVNQWlIJ0OhYzOWIF8wLl8BvE=; b=Xzjyycj3LSdKAJPSkfN/aqTz+TKIFNRtz3bI0hW8dcIow0mNhT4LY30v4zJaXYyvJc SjWgY69ITjAl7h7dHPdRkOnBm6lbUARUnBvfPIUVo3FtBBRk6BN8j+HfgbSPnZ06u+xN dEgFb3oHzdWFR1hYBgYcMFUJYbBgP9LvgVbFMrBXeApI8/gFzQxCGtPaDxP5rk6A+++W 4PGef4zZOe6zUgZ3EHEdaFxHsABEJp8boTpthYAEVr/35Ye/x3lMcgTng1zzw8CRoh26 dan+yVKwq045YwTqTcuDVtuyWDMOJg6hhpBHpPqX+tjxsHpfclkEQin6kOttKLOSSlvN 5fsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x3-v6si616940pgb.329.2018.08.17.03.33.11; Fri, 17 Aug 2018 03:33:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726854AbeHQNfe (ORCPT + 32 others); Fri, 17 Aug 2018 09:35:34 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:32981 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726760AbeHQNfd (ORCPT ); Fri, 17 Aug 2018 09:35:33 -0400 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0M7Knm-1g271607FO-00x44h; Fri, 17 Aug 2018 12:27:18 +0200 From: Arnd Bergmann To: linux-pci@vger.kernel.org, Bjorn Helgaas Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Lorenzo Pieralisi , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, Arnd Bergmann Subject: [RFC 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= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.18.0 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: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: 144465 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp595945ljj; Fri, 17 Aug 2018 03:28:02 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwksEGtZFHJU92gARxk4uCENZfFnwZ9ULtArqhK3MQcB94cE4Bmgeq91isnphA3KbYL5+RT X-Received: by 2002:a62:c218:: with SMTP id l24-v6mr36257903pfg.185.1534501682770; Fri, 17 Aug 2018 03:28:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534501682; cv=none; d=google.com; s=arc-20160816; b=W/Yiy1C3t7ZPNtuiIIvwhdHiRcsmTSz2OWPmhhcrH556MPOqdQugIckljSghn1wZ0H By1cjxHZDoe3uPYvHyDNEyxhEtlSoMe5RV3lAimNNM9dlA45YQEnp/YjhLX/cm8aBpVL oSc2q7rzjoKjM8YiCljrjluwhJuGSASjFNKE3ioW50OnIOLY2RI5LphrvtcHbk8Oxr9I ASPYOJDDuXMhGZc2B4iW6HHcGF9vm30tbQv1i0TdIj8k96LwixSrxoESjGW6NRvpCFek ZtE+J1XB9f1DHpVK6eVxmdIwYluZqw1Re3YsNdddpZIzf//9cP61g8B5aePEdcM680/o IcYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=E9K6caDRCOFAqXYs/Z/taCaKv/lmALqzWiE05IITlbE=; b=KhbEMkOzTZTDsRzCXMWDb5t4iqm84RAP2iuioGQt5Gz2SEywGnh10n0248kIsfrNn9 /e2TLT9nJ6GSCSLbSYKFcYVinbFOp/wp0UvQBay/oflix15HOU8F3q9s+yC03W6tW5tf TRxGNmh1uoHOP5UjyMBlNWd6C18eLJe4hpJs6uU+7N4ZFLALbjvJidAqkLoTJccC0fM+ NQr7fbuHn34+FTxnEEURLpDSxdR49McjUgcyE6TSIIyNWDLWrsnIbF2sEVf8mGYx8YB8 eO9QzdbP+c3gCgtVOj2879nf+Yqr195cputHdBmDxoVMr2Yp+pM32xDol4G2ztmCqjwS RcXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l127-v6si1934751pfc.135.2018.08.17.03.28.02; Fri, 17 Aug 2018 03:28:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727442AbeHQNax (ORCPT + 32 others); Fri, 17 Aug 2018 09:30:53 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:44097 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727119AbeHQNac (ORCPT ); Fri, 17 Aug 2018 09:30:32 -0400 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 Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Lorenzo Pieralisi , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, Arnd Bergmann Subject: [RFC 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:FL2ZqB/032s=:1A5r01tQmTrILHRXQDy23a KFl3ApCPT8sFp2nlafvObwMRHbliIqVL2rMDndnA07kCYvYEizbMGt3o0wJZAFdpNz3kS7ln6 doQt8lxk5AjbiyNPeSPVypLaLKBL+9ecrGYPefgriCFVt9Ddh617MIlRnTb/RM4FjvZzpdzk2 aW8MbQIuJtfC+B2Q15BroI+/75njcF7WXHu6vf9kZu1mYXNPAoq4nS/qN+BBq1q10kF/qZiSB 4ElYO57rst6Jvl7XlbRKy1D9O+uqCHLl1NiZZeWHGuAh7LvkLCBB6sQL1mgERYY1HPInoadrM NaNGhb6gpNJAaJ+aOhqBqZTwSEz905wppbKg8my0ZgosbExtpjhGJBpDrImOpXkrw9Sb85cZT PhYnGbAjh+HxCXfyWW8G3raZzukxI7xGnFVlaaxLXgYduuV7CMu/Qll6tQQCQIGokEipROWKF Zk9BsAVXb5wdT7saIcAAplUs0nccZd6gYsyLcEnHSur1Z6OIsevthXjOvaReUUF1XggWq4Ze/ Q4LljBdzAVS14y6HHjFLmP7+dsqXO6uLSPiicMrc/2jS+mzp4QV3fFuzubU2V1pV+mVeG8DxR iPsP7lfV+geEoBhHreBzfk9KOHzn00fI60UbvvvOEj6R0j3U5WLp2DZV58EHejQqaTxd40NGA nLme5S/oqqT7vNaz8ku8EyO+SZ1KgTzYgkvH3VlEQQaBAxuKnuzI9PXk/u92Ay6Ic9vw= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.18.0 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: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: 144464 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp595767ljj; Fri, 17 Aug 2018 03:27:51 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwM2eeX/eIl2Z80E5t+vcomUScZRfXG6rIvBS1uCQULXW650BT+C4CcPRbDBM+dapc+Fggd X-Received: by 2002:a63:5c52:: with SMTP id n18-v6mr31919511pgm.360.1534501671343; Fri, 17 Aug 2018 03:27:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534501671; cv=none; d=google.com; s=arc-20160816; b=fXCfsZ5snQFH1uJNfOtj2f09gMKz1y/ITc463Vr6gyXHwMxw8bB5EYcy9sgOkL6IKe cNpkWcU0n+CdEdhN/S/jLE6JCtT9oJJ/2Gob82iw8g38iQpdChhbcg9ZxfG8p4UXbsMj 8egGvV2s5xBVKkFV+aeAkn0ll1jffBlfQbPXiGXvGHDKCJI8JVX+sbK3lfBhwWsQUZnS fv/3kywRuGSHhjGxzzdWrAimRuE/WDeJkw7gJ6ZqTz2eVW2Gv/OLYOlN/9xpSXOfznDR 51+b7aOqbmBR89FnFmoeOTNm6WN//Hjvlzi/eIOUrMYfK77pCAYf1yof8Z00W/WaG8yl HuYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=2gnWvanEOLA+2uGkhBlJDr9nFhcCebgIXniWEMkSzcw=; b=OXKa9fZJ4NdCy/1niYkHzJ/SfW7EszPyDTBj0aOlZPKMwqIr9j1nNNx96klC6LeZSf A7/D0SbEhYCLb/wwaz8mdOBo64FunWee2bM0phNIEwkknP9meLnuOjOWR564K73yLDBI GL8UozcMcI4URFlTDIVjX2nTR1I/JndzlTKfL2g+Qc5ebeRmHv79ONxa9sJRUSN7DcAz HEaHrwavaFr7UzW2C7bopRbDuLu4CtfnPjBmFPIhTqljXgsVk9NZasO+MYNx0usR1pfo 8pE2CtqqJ9QPiBXTZPBLs6Fugmy3Zj+q3gw6waSaa1V+5sL0v2nT5HKLDFXmPPAQNYRI AjbA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z77-v6si1998739pff.100.2018.08.17.03.27.50; Fri, 17 Aug 2018 03:27:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727363AbeHQNam (ORCPT + 32 others); Fri, 17 Aug 2018 09:30:42 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:58943 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726623AbeHQNaf (ORCPT ); Fri, 17 Aug 2018 09:30:35 -0400 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 Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Lorenzo Pieralisi , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, Arnd Bergmann Subject: [RFC 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:+d5rM4wws+U=:XOOzHLEIzDhldl610OMod6 Zap/qlXbAkH836yGeY/ib2fecXn6x4Y+6uThsJIVQJyn1cS1tX2TZ4owbnjdpC4UEm9ToZpZt QLMMZq8rhF/NIBw7YW1Gprxc5Hng3xGnBj9P/BV/mJoznZWMtHwuSpaGZB/Izug6RIcyqqRvd wUf/G+k24qNuyRjJopb5WPzsOluIBzDSiO5d2e57HCuJBS8iAtlRKCdHhRtghBuztlo8P7ktL fyvt0pz6K/sFh+VMz77tGl9B42B1WlrFRXUZYMSi8U6zq20RGyTFSfjeClcdkGW08EcwR85Q3 GccZApVCV2R3XGaUbH9SfyZ9ip2eyb+Q7DTP7COv8HAyFVquOZsid+9KhPnsBGu7k04/8a1Rv rtVTUu+qgS7Mq/XVDsHemBgXHs0bMKPFYvDwxSLr7TVeUDIkah1OYgh0CqHSEfWTpzrp91vxs g05h5QYibqxZ/EMLEuPJQnSEFQ64U2MljnkMnk1tMqvzNVkOocrGSXWsOgztBl8aN+tm9r1uN B1xw3o2sf/jUMlEHE4njh3nfstIXMdtG2ehg/F4tZU11is8jqyrZGSB5gVmCRzeIyItMc1dlT vkpYm6hS+SoavmhiL98V9H/X0+vW72Llfqsmb5M5AzlIGeJ37cFqN5tRz6j0pTb1QXr1RzIP6 EGr0f7BPgHqn64IaeBC3USy0HuUGf2QxRfTCJE77+kiUQMT+auy//1ddRGoRrYgQP6So= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.18.0 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: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: 144473 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp600565ljj; Fri, 17 Aug 2018 03:32:44 -0700 (PDT) X-Google-Smtp-Source: AA+uWPygmDKfP0j2LBunObHLSjB2P4NcuEM1evot7VU7uvD9c0Eo/sI5R4eLNIUGS4xvbA7SiAVu X-Received: by 2002:a17:902:9a47:: with SMTP id x7-v6mr20401790plv.37.1534501964157; Fri, 17 Aug 2018 03:32:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534501964; cv=none; d=google.com; s=arc-20160816; b=gEAOdjlbzgQzhejGGG82IxIkJhNlrTCf8/QxHlWU2VH3e6MJVoD0pxjtJ6fhkvqNTG +I53gaM5TNOAAa08uXyGzlsyelWEuw72p/+ttbmIVU1LrhoLvX+8KgxHCMrbX6Fc2aG1 STj+8b3Qc2iG7x1EwiiJlq7bjOriYIVb50WPjib20IZGlqiwy+0cREKgJ7SdwFs8ZiyA PMErNBH1/f4Hu6uIoW4ptV5DTGK8Rs4gWlwkw5qqItoA58OU3Oox7U+oHNnNpLsdHoUk kRQYBBrXDwRa45XIHOnDdOKC9At6ip5F/oFfBTbUgr2z1WTw2v2znVJl6Apm6U53o67m hLnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=uFGd+S/1wlSSMGit1ckPaGj52c/uQDEc4euzXnfcC28=; b=w4gUEdBGBc85vq00P34Qh1UV+GGVuUGZPSu2LcTJ+74dagYHHVvdlAC4n3H/NcSby/ NZwCgn3GgDJotAxtct9I6s4NU3KhvCZpvjwlzCwLNcRgSYGyEmmLVdTzRBVeDjEThKAN 7XuswYoxTVeT5piLD+1AFxKzjnVa8HJrTT3oTi1QleIO7p+Mf6bZU1mRgkpluJJ8m929 AXUIR547ABDemUdz4ZgwP8s8qjPRfd+JTmH8HGLl6RrJ//AyTc28/dX6Wnxv00Vyvn6O JVxmKDPbH7CSar5ZudteUGTyniWHbzmHs6gJcpFdcFtDyW3X4ldfAiHM5JNKthfxndH6 XApg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i35-v6si1957947plg.460.2018.08.17.03.32.43; Fri, 17 Aug 2018 03:32:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727251AbeHQNfh (ORCPT + 32 others); Fri, 17 Aug 2018 09:35:37 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:57301 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725992AbeHQNfg (ORCPT ); Fri, 17 Aug 2018 09:35:36 -0400 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0MIe3k-1fsotc3lQO-002Dcj; Fri, 17 Aug 2018 12:27:21 +0200 From: Arnd Bergmann To: linux-pci@vger.kernel.org, Bjorn Helgaas Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Lorenzo Pieralisi , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, Arnd Bergmann Subject: [RFC 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= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.18.0 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: 144463 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp595695ljj; Fri, 17 Aug 2018 03:27:46 -0700 (PDT) X-Google-Smtp-Source: AA+uWPymiY2+4t+MFeO30fJEHIzHQ/sbr0vzYiWKx/p2b/VpngEQQPsiY4csc+oRBmt7PswkHrWd X-Received: by 2002:a63:81c3:: with SMTP id t186-v6mr33050853pgd.413.1534501665902; Fri, 17 Aug 2018 03:27:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534501665; cv=none; d=google.com; s=arc-20160816; b=DbOFjAfnoiv2XaN+C1BJE2XTP8DsPl+Ouf8OgmWWWwF5wyN650OaaYiTJSsbUqzAO5 WkQUy/+wQ8cVwh8LCuUjLWKZ6roxKfM3hCvpaDb0aW12YmaYVHR2RTu8mYjoOG1GzSDN +A9XScldbFCRe/bImtqOSc8wJu8H2oTypdX7yI5tdwFpM5kRUb2aAzUvnPdX6/ULWmIO A3oANbboe0zUUXZIxa46PESpxACPtHfRn/v0hMuWLR8NqinURWDflh8xGQB4/IcPV4Xq gOimHZfO5Ohnl7M5PiY30h2AHMjXKX0WyT2Z/C7lYqdY/0mQE+xpXdrmZ3JV4P/n425i 8sPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=Y9CQbTeAKbG535slRqUY+wj+BWJX8MRE+fUcpjVOYCc=; b=V30ZjmS0+IkpRFZNq7dGyEiGvNVcynGkb71Yy+kWDbMLIDE/+o+//19JecNg3HitiX +RCWthQaYghoObc2++4QlvwsdPa0B64e/zVsBNr2x7OX9FRT256hFIXoZjAjFN086+Ui yk0UlwT2fctK4wCop23cF+3ZGa/C9ri4tevzxeHConCm39+jq5BqOqZQp6qHK6iAKCo2 4L13pBauOsxzTDC3aapjWK7fJk+LNUj2tgMgYGWSyfi3ddSFO7TRzaNtQt/c0Mquj7gt kAwwNdAa/oOeyNnaLOOVelvQ1ybV+HHMRpDlBVf41AUYLo0dopozbuVUyohEumPkAFNa eadQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v84-v6si1867227pfd.71.2018.08.17.03.27.45; Fri, 17 Aug 2018 03:27:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727342AbeHQNag (ORCPT + 32 others); Fri, 17 Aug 2018 09:30:36 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:39429 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726218AbeHQNae (ORCPT ); Fri, 17 Aug 2018 09:30:34 -0400 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 Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Lorenzo Pieralisi , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, Arnd Bergmann Subject: [RFC 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:YniJy3MqZc4=:nm3kiV+WQhPrhRGL9FUae4 i9umo/rybRlnAwRBDrn0Sy3HDXlVnfDLSzZOxABcc41K/uvEt/E68HLmwCmngDQ6OcM+2GNfd 8nnlmOFxxtqtwHEzgVUkPB1fIDgojYiFYkK5qN4pJ6IayqWWxNen8/weDzNMc+qNOYKEBhrfq soau4uR6N3N+Xb1x6JECyrI9/ISINZ9G8yIgpAwed+3qbjZknFJVWrZ7V60urdilBY21F3Qt9 pAr9l0vTc0+QkNtXxB+M/iVR9UgZ2yBhlZkkt5HQnB8NwazdTnh0qN2t5LQtqpL2L9hHypKpA +t/m5IyTJ9YzdRa+uMSX5qW5lv3m9F4ZVeI9fEvlmSRIt2+QzAJdoI99j6UnwvfgE8eSs1eyM ZTao4rMwDbxh2LQ4EpQqOwPxMPlTi+0IRKoGHG6O4AKxrLqiSnnvZseksx43Kn61k9BVDx1Ma ET7i6/K4sTPxQ1AXOAoM7ICrkL8j+hJuCPYMAgaAWZUeDi8fL+fpc25XRHVb/ysqeD2Q9A8mW 8bcQvko0r7dsZGkIPuwyk9EEFPJu+I10wbaZa6GUEdw8HT0zpBa+zUc2ndEZTwlysp6t4h1Fv gshhS1OCrYReZLvwuaXZb11++WnFla0gulPGVHpXg6K4nlAbrbQIAkmTatn3WZC5VP+OL7Wm4 xcoO4RnkSDCOS68WDbU/eGt0VezXnwrW1XiPIAvcYkjf7ZhcwV5SWPWDfCKOHJR3jiO0= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.18.0 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 */