From patchwork Fri Aug 17 10:26:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 144471 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp600527ljj; Fri, 17 Aug 2018 03:32:42 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxMaR05gop0FSh53R6QSvdqlP3GENBL9BzR+WlJUSy2r85mRLq3VNPVMx/nG2fbJoic+63X X-Received: by 2002:a17:902:7883:: with SMTP id q3-v6mr32418794pll.264.1534501962238; Fri, 17 Aug 2018 03:32:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534501962; cv=none; d=google.com; s=arc-20160816; b=C/vEdzlOkSmKcNKpO97kBTGTBvCMCXqdCsh4rpJIkAeB3poNgfTKH2/HeCYw8cCQM4 fbIq7okcsp3G1SMApltcHte6poyfos0PCCck3iavhB+uNkua74i5OEURHHFc1qbqBf0R xm5MSj/vCVlLs32Kct2sMxgXbYs+YHp+N4cBvadUeXIfGfq7R4iC/Gd06S9lKz46+5eZ u8RjET9amx6ko9UXbHOFv5Pjrf4n8drnET5FMHvAIsZd6hcChYLG8hmTZS/1KO2g3/9b VjrvfbaHr7CoOjDkyMogVVKBN0FpTdo9qQ1b03nV5drezJFPSUzKSbY1BUE/GfBLqy9n alXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=ufUodDYAFzgd7WNVdlY/Yr+NgGzGmsr7/1NlHE57JBY=; b=jAq4c4D/AdIh8G/DwzdMy0zwxJkCYlPSVk3Hv3/tH4nDqKlgJkUvkgnyDSp4xWAZv/ 1CzKsiaTbX2izqmVIFsh5naB2pvbj8jXTQdD4BEuOopYr2nDPDWy4ZJg+EzAP0DK01xJ QPstHdBZOIYnU7dzSQf93czvmTSgD1ffpW8QuVuTto0BDhJXL46aoWkzJSg4tSwQa+jb 6MVfi/oxflojRlC44w8DcOF/GWAubFAhRPhRMSBQqhgoobsE+cl62lVCH2lzI/GstCwN sd+KYzqnVc0EP9KjCyMtSRQ5XqVutz2L7MNoK/HoQFfWcPmiQBZH7dDwH4upc348yx40 Vv8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e1-v6si47820pgk.275.2018.08.17.03.32.42; Fri, 17 Aug 2018 03:32:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726860AbeHQNff (ORCPT + 9 others); Fri, 17 Aug 2018 09:35:35 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:42823 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725992AbeHQNfd (ORCPT ); Fri, 17 Aug 2018 09:35:33 -0400 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0M2Mj6-1g72xf2n4O-00s8O9; Fri, 17 Aug 2018 12:27:19 +0200 From: Arnd Bergmann To: linux-pci@vger.kernel.org, Bjorn Helgaas Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Lorenzo Pieralisi , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, Arnd Bergmann Subject: [RFC 11/15] PCI: hyperv: convert to pci_scan_root_bus_bridge Date: Fri, 17 Aug 2018 12:26:41 +0200 Message-Id: <20180817102645.3839621-12-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180817102645.3839621-1-arnd@arndb.de> References: <20180817102645.3839621-1-arnd@arndb.de> X-Provags-ID: V03:K1:GawKYPNeblKXqePXMTqVUwJzPp4kDv9XunHKMjoeqmVocUEEVjM lkYgN2PiNwSPbXjS7Dii+2JTCPx/c95lj3gECJvX5IBv4mvtne+6VUdTVunsCr0Y+mlTkfc DGbWBehQ648C/tekyqiyObV6jpd7FXp6y3vcEIFfvC8pa/mnrRfRoZ+Og0ehO+tP6FrDZE9 w8e4yawJshAPLppwwwJWw== X-UI-Out-Filterresults: notjunk:1; V01:K0:fxpVOh8CRvU=:q/r7CREw9q7Zjc/R/UTtzI t09tyN3hj1ulxsUAzwtiN6AP+Rrjag5zkIt+HBEPBbM2Qt/i/TWhW/n8MjB28kbWWFK/MfDk7 gYijMym2nAJA4EMb5oVzsbOB8TnLE9YGisDWuQtl09NvT0bvZWyCA7xZO3NUQVqQ0Gcl/o1sE YKJVPpgo+50TIG2bcPc9h5rl4Y1MLY/J866SsPVzk0buhtSh+ze5U0vDh23BIxCiXbln9ROdP XvD6AbRXd+Ab+OC6ueC6HDkxBTySOCIniSsVcKXivMdEmvxRdOAexM8J1kGzfL1niEItbNFF4 jPnQLewOBUcKHhhbt8ywxxetNSttd2yMQ6g5guRzWrrxs6XkNsjGKcOF102uqXH6L4b33rkWw T7eaXdgQSv9TS+l5E32pKSbHyjQ0bqMdvtJhtjFxBXeg3R2N9QHjzSbXgHUwy8+7/oRgu/ZN/ spJB24Qski3myqmjqhwQUg53lrz2irhiVphDyNLNPOavK116uauw6ZLjBH28xbYVU/3YUPFQl SLFzyR7Bb+XhM0L3GrmWQS9sx/AJgCwXWMUuE+Uv7/jNeORoJkSUNta25Ob6qPNSsHFV6ZsBu J/LvXO995FFGSi53/kmB9DbAj68BzSVuHU0E3BKj5GHm7w/cnTp1m2PGqGA6+/Z8WiiFTsg1N eZOkQdSTxgzBTJDY2e+UDyLrd8axaxN+A7+mMgqRIWYrx6PZtMOS4ps7zz5vqdsoA/VA= Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org create_root_hv_pci_bus() uses a rather generic method of probing the host bridge, which can be simplified by just calling pci_scan_root_bus_bridge() after setting up the pci_host_bridge structure. Since we can no longer assign hbus->pci_bus in the middle, I just remove that member completely and use the pci_host_bridge instead. Ideally we'd convert it to pci_host_probe() for simplicity, but that is a bit different and I could not easily test it. Using pci_scan_root_bus_bridge should not change the behavior at all. Signed-off-by: Arnd Bergmann --- drivers/pci/controller/pci-hyperv.c | 75 +++++++++++------------------ 1 file changed, 28 insertions(+), 47 deletions(-) -- 2.18.0 diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index df7cddea8e30..49586aefa38b 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -443,7 +443,7 @@ struct hv_pcibus_device { struct resource *high_mmio_res; struct completion *survey_event; struct completion remove_event; - struct pci_bus *pci_bus; + struct pci_host_bridge *bridge; spinlock_t config_lock; /* Avoid two threads writing index page */ spinlock_t device_list_lock; /* Protect lists below */ void __iomem *cfg_addr; @@ -1457,34 +1457,6 @@ static void prepopulate_bars(struct hv_pcibus_device *hbus) spin_unlock_irqrestore(&hbus->device_list_lock, flags); } -static struct pci_bus *pci_create_root_bus(struct device *parent, int bus, - struct pci_ops *ops, void *sysdata, struct list_head *resources) -{ - int error; - struct pci_host_bridge *bridge; - - bridge = pci_alloc_host_bridge(0); - if (!bridge) - return NULL; - - bridge->dev.parent = parent; - - list_splice_init(resources, &bridge->windows); - bridge->sysdata = sysdata; - bridge->busnr = bus; - bridge->ops = ops; - - error = pci_register_host_bridge(bridge); - if (error < 0) - goto err_out; - - return bridge->bus; - -err_out: - kfree(bridge); - return NULL; -} - /** * create_root_hv_pci_bus() - Expose a new root PCI bus * @hbus: Root PCI bus, as understood by this driver @@ -1493,25 +1465,34 @@ static struct pci_bus *pci_create_root_bus(struct device *parent, int bus, */ static int create_root_hv_pci_bus(struct hv_pcibus_device *hbus) { - /* Register the device */ - hbus->pci_bus = pci_create_root_bus(&hbus->hdev->device, - 0, /* bus number is always zero */ - &hv_pcifront_ops, - &hbus->sysdata, - &hbus->resources_for_children); - if (!hbus->pci_bus) - return -ENODEV; + struct pci_host_bridge *bridge; + int ret; + + bridge = pci_alloc_host_bridge(0); + if (!bridge) + return -ENOMEM; - hbus->pci_bus->msi = &hbus->msi_chip; - hbus->pci_bus->msi->dev = &hbus->hdev->device; + hbus->bridge = bridge; + bridge->dev.parent = &hbus->hdev->device; + list_splice_init(&hbus->resources_for_children, &bridge->windows); + bridge->sysdata = &hbus->sysdata; + bridge->ops = &hv_pcifront_ops; + bridge->msi = &hbus->msi_chip; + bridge->msi->dev = &hbus->hdev->device; pci_lock_rescan_remove(); - pci_scan_child_bus(hbus->pci_bus); - pci_bus_assign_resources(hbus->pci_bus); - pci_bus_add_devices(hbus->pci_bus); - pci_unlock_rescan_remove(); + /* ideally we should use pci_host_probe here */ + ret = pci_scan_root_bus_bridge(bridge); + if (ret < 0) { + pci_free_host_bridge(bridge); + goto error; + } + pci_bus_assign_resources(bridge->bus); + pci_bus_add_devices(bridge->bus); hbus->state = hv_pcibus_installed; - return 0; +error: + pci_unlock_rescan_remove(); + return ret; } struct q_res_req_compl { @@ -1769,7 +1750,7 @@ static void pci_devices_present_work(struct work_struct *work) * because there may have been changes. */ pci_lock_rescan_remove(); - pci_scan_child_bus(hbus->pci_bus); + pci_scan_child_bus(hbus->bridge->bus); pci_unlock_rescan_remove(); break; @@ -2669,8 +2650,8 @@ static int hv_pci_remove(struct hv_device *hdev) if (hbus->state == hv_pcibus_installed) { /* Remove the bus from PCI's point of view. */ pci_lock_rescan_remove(); - pci_stop_root_bus(hbus->pci_bus); - pci_remove_root_bus(hbus->pci_bus); + pci_stop_root_bus(hbus->bridge->bus); + pci_remove_root_bus(hbus->bridge->bus); pci_unlock_rescan_remove(); hbus->state = hv_pcibus_removed; }