{"id":958753,"url":"http://patchwork.ozlabs.org/api/patches/958753/?format=json","web_url":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20180817102645.3839621-12-arnd@arndb.de/","project":{"id":2,"url":"http://patchwork.ozlabs.org/api/projects/2/?format=json","name":"Linux PPC development","link_name":"linuxppc-dev","list_id":"linuxppc-dev.lists.ozlabs.org","list_email":"linuxppc-dev@lists.ozlabs.org","web_url":"https://github.com/linuxppc/wiki/wiki","scm_url":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git","webscm_url":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/","list_archive_url":"https://lore.kernel.org/linuxppc-dev/","list_archive_url_format":"https://lore.kernel.org/linuxppc-dev/{}/","commit_url_format":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id={}"},"msgid":"<20180817102645.3839621-12-arnd@arndb.de>","list_archive_url":"https://lore.kernel.org/linuxppc-dev/20180817102645.3839621-12-arnd@arndb.de/","date":"2018-08-17T10:26:41","name":"[RFC,11/15] PCI: hyperv: convert to pci_scan_root_bus_bridge","commit_ref":null,"pull_url":null,"state":"not-applicable","archived":false,"hash":"41e5640ee022e2e0ba8f76e8fa23d408c260a523","submitter":{"id":30,"url":"http://patchwork.ozlabs.org/api/people/30/?format=json","name":"Arnd Bergmann","email":"arnd@arndb.de"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20180817102645.3839621-12-arnd@arndb.de/mbox/","series":[{"id":61229,"url":"http://patchwork.ozlabs.org/api/series/61229/?format=json","web_url":"http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=61229","date":"2018-08-17T10:26:32","name":"PCI: turn some __weak functions into callbacks","version":1,"mbox":"http://patchwork.ozlabs.org/series/61229/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/958753/comments/","check":"success","checks":"http://patchwork.ozlabs.org/api/patches/958753/checks/","tags":{},"related":[],"headers":{"Return-Path":"<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>","X-Original-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Delivered-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Received":["from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 41sKTH3nD1z9s3Z\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri, 17 Aug 2018 20:39:47 +1000 (AEST)","from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 41sKTH2LCBzF0gv\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri, 17 Aug 2018 20:39:47 +1000 (AEST)","from mout.kundenserver.de (mout.kundenserver.de [212.227.17.13])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128\n\tbits)) (No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 41sKK61ljZzDqm6\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tFri, 17 Aug 2018 20:32:41 +1000 (AEST)","from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de\n\t(mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id\n\t0M2Mj6-1g72xf2n4O-00s8O9; Fri, 17 Aug 2018 12:27:19 +0200"],"Authentication-Results":["ozlabs.org;\n\tdmarc=none (p=none dis=none) header.from=arndb.de","lists.ozlabs.org;\n\tdmarc=none (p=none dis=none) header.from=arndb.de","lists.ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=arndb.de\n\t(client-ip=212.227.17.13; helo=mout.kundenserver.de;\n\tenvelope-from=arnd@arndb.de; receiver=<UNKNOWN>)","lists.ozlabs.org;\n\tdmarc=none (p=none dis=none) header.from=arndb.de"],"From":"Arnd Bergmann <arnd@arndb.de>","To":"linux-pci@vger.kernel.org,\n\tBjorn Helgaas <bhelgaas@google.com>","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\n\tlkYgN2PiNwSPbXjS7Dii+2JTCPx/c95lj3gECJvX5IBv4mvtne+6VUdTVunsCr0Y+mlTkfc\n\tDGbWBehQ648C/tekyqiyObV6jpd7FXp6y3vcEIFfvC8pa/mnrRfRoZ+Og0ehO+tP6FrDZE9\n\tw8e4yawJshAPLppwwwJWw==","X-UI-Out-Filterresults":"notjunk:1; V01:K0:fxpVOh8CRvU=:q/r7CREw9q7Zjc/R/UTtzI\n\tt09tyN3hj1ulxsUAzwtiN6AP+Rrjag5zkIt+HBEPBbM2Qt/i/TWhW/n8MjB28kbWWFK/MfDk7\n\tgYijMym2nAJA4EMb5oVzsbOB8TnLE9YGisDWuQtl09NvT0bvZWyCA7xZO3NUQVqQ0Gcl/o1sE\n\tYKJVPpgo+50TIG2bcPc9h5rl4Y1MLY/J866SsPVzk0buhtSh+ze5U0vDh23BIxCiXbln9ROdP\n\tXvD6AbRXd+Ab+OC6ueC6HDkxBTySOCIniSsVcKXivMdEmvxRdOAexM8J1kGzfL1niEItbNFF4\n\tjPnQLewOBUcKHhhbt8ywxxetNSttd2yMQ6g5guRzWrrxs6XkNsjGKcOF102uqXH6L4b33rkWw\n\tT7eaXdgQSv9TS+l5E32pKSbHyjQ0bqMdvtJhtjFxBXeg3R2N9QHjzSbXgHUwy8+7/oRgu/ZN/\n\tspJB24Qski3myqmjqhwQUg53lrz2irhiVphDyNLNPOavK116uauw6ZLjBH28xbYVU/3YUPFQl\n\tSLFzyR7Bb+XhM0L3GrmWQS9sx/AJgCwXWMUuE+Uv7/jNeORoJkSUNta25Ob6qPNSsHFV6ZsBu\n\tJ/LvXO995FFGSi53/kmB9DbAj68BzSVuHU0E3BKj5GHm7w/cnTp1m2PGqGA6+/Z8WiiFTsg1N\n\teZOkQdSTxgzBTJDY2e+UDyLrd8axaxN+A7+mMgqRIWYrx6PZtMOS4ps7zz5vqdsoA/VA=","X-BeenThere":"linuxppc-dev@lists.ozlabs.org","X-Mailman-Version":"2.1.27","Precedence":"list","List-Id":"Linux on PowerPC Developers Mail List\n\t<linuxppc-dev.lists.ozlabs.org>","List-Unsubscribe":"<https://lists.ozlabs.org/options/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=unsubscribe>","List-Archive":"<http://lists.ozlabs.org/pipermail/linuxppc-dev/>","List-Post":"<mailto:linuxppc-dev@lists.ozlabs.org>","List-Help":"<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=help>","List-Subscribe":"<https://lists.ozlabs.org/listinfo/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=subscribe>","Cc":"Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,\n\tArnd Bergmann <arnd@arndb.de>, linux-kernel@vger.kernel.org,\n\tChristoph Hellwig <hch@infradead.org>, linux-acpi@vger.kernel.org,\n\tlinuxppc-dev@lists.ozlabs.org","Errors-To":"linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org","Sender":"\"Linuxppc-dev\"\n\t<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>"},"content":"create_root_hv_pci_bus() uses a rather generic method of probing the host\nbridge, which can be simplified by just calling pci_scan_root_bus_bridge()\nafter setting up the pci_host_bridge structure.\n\nSince we can no longer assign hbus->pci_bus in the middle, I just remove\nthat member completely and use the pci_host_bridge instead.\n\nIdeally we'd convert it to pci_host_probe() for simplicity, but\nthat is a bit different and I could not easily test it. Using\npci_scan_root_bus_bridge should not change the behavior at all.\n\nSigned-off-by: Arnd Bergmann <arnd@arndb.de>\n---\n drivers/pci/controller/pci-hyperv.c | 75 +++++++++++------------------\n 1 file changed, 28 insertions(+), 47 deletions(-)","diff":"diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c\nindex df7cddea8e30..49586aefa38b 100644\n--- a/drivers/pci/controller/pci-hyperv.c\n+++ b/drivers/pci/controller/pci-hyperv.c\n@@ -443,7 +443,7 @@ struct hv_pcibus_device {\n \tstruct resource *high_mmio_res;\n \tstruct completion *survey_event;\n \tstruct completion remove_event;\n-\tstruct pci_bus *pci_bus;\n+\tstruct pci_host_bridge *bridge;\n \tspinlock_t config_lock;\t/* Avoid two threads writing index page */\n \tspinlock_t device_list_lock;\t/* Protect lists below */\n \tvoid __iomem *cfg_addr;\n@@ -1457,34 +1457,6 @@ static void prepopulate_bars(struct hv_pcibus_device *hbus)\n \tspin_unlock_irqrestore(&hbus->device_list_lock, flags);\n }\n \n-static struct pci_bus *pci_create_root_bus(struct device *parent, int bus,\n-\t\tstruct pci_ops *ops, void *sysdata, struct list_head *resources)\n-{\n-\tint error;\n-\tstruct pci_host_bridge *bridge;\n-\n-\tbridge = pci_alloc_host_bridge(0);\n-\tif (!bridge)\n-\t\treturn NULL;\n-\n-\tbridge->dev.parent = parent;\n-\n-\tlist_splice_init(resources, &bridge->windows);\n-\tbridge->sysdata = sysdata;\n-\tbridge->busnr = bus;\n-\tbridge->ops = ops;\n-\n-\terror = pci_register_host_bridge(bridge);\n-\tif (error < 0)\n-\t\tgoto err_out;\n-\n-\treturn bridge->bus;\n-\n-err_out:\n-\tkfree(bridge);\n-\treturn NULL;\n-}\n-\n /**\n  * create_root_hv_pci_bus() - Expose a new root PCI bus\n  * @hbus:\tRoot PCI bus, as understood by this driver\n@@ -1493,25 +1465,34 @@ static struct pci_bus *pci_create_root_bus(struct device *parent, int bus,\n  */\n static int create_root_hv_pci_bus(struct hv_pcibus_device *hbus)\n {\n-\t/* Register the device */\n-\thbus->pci_bus = pci_create_root_bus(&hbus->hdev->device,\n-\t\t\t\t\t    0, /* bus number is always zero */\n-\t\t\t\t\t    &hv_pcifront_ops,\n-\t\t\t\t\t    &hbus->sysdata,\n-\t\t\t\t\t    &hbus->resources_for_children);\n-\tif (!hbus->pci_bus)\n-\t\treturn -ENODEV;\n+\tstruct pci_host_bridge *bridge;\n+\tint ret;\n+\n+\tbridge = pci_alloc_host_bridge(0);\n+\tif (!bridge)\n+\t\treturn -ENOMEM;\n \n-\thbus->pci_bus->msi = &hbus->msi_chip;\n-\thbus->pci_bus->msi->dev = &hbus->hdev->device;\n+\thbus->bridge = bridge;\n+\tbridge->dev.parent = &hbus->hdev->device;\n+\tlist_splice_init(&hbus->resources_for_children, &bridge->windows);\n+\tbridge->sysdata = &hbus->sysdata;\n+\tbridge->ops = &hv_pcifront_ops;\n+\tbridge->msi = &hbus->msi_chip;\n+\tbridge->msi->dev = &hbus->hdev->device;\n \n \tpci_lock_rescan_remove();\n-\tpci_scan_child_bus(hbus->pci_bus);\n-\tpci_bus_assign_resources(hbus->pci_bus);\n-\tpci_bus_add_devices(hbus->pci_bus);\n-\tpci_unlock_rescan_remove();\n+\t/* ideally we should use pci_host_probe here */\n+\tret = pci_scan_root_bus_bridge(bridge);\n+\tif (ret < 0) {\n+\t\tpci_free_host_bridge(bridge);\n+\t\tgoto error;\n+\t}\n+\tpci_bus_assign_resources(bridge->bus);\n+\tpci_bus_add_devices(bridge->bus);\n \thbus->state = hv_pcibus_installed;\n-\treturn 0;\n+error:\n+\tpci_unlock_rescan_remove();\n+\treturn ret;\n }\n \n struct q_res_req_compl {\n@@ -1769,7 +1750,7 @@ static void pci_devices_present_work(struct work_struct *work)\n \t\t * because there may have been changes.\n \t\t */\n \t\tpci_lock_rescan_remove();\n-\t\tpci_scan_child_bus(hbus->pci_bus);\n+\t\tpci_scan_child_bus(hbus->bridge->bus);\n \t\tpci_unlock_rescan_remove();\n \t\tbreak;\n \n@@ -2669,8 +2650,8 @@ static int hv_pci_remove(struct hv_device *hdev)\n \tif (hbus->state == hv_pcibus_installed) {\n \t\t/* Remove the bus from PCI's point of view. */\n \t\tpci_lock_rescan_remove();\n-\t\tpci_stop_root_bus(hbus->pci_bus);\n-\t\tpci_remove_root_bus(hbus->pci_bus);\n+\t\tpci_stop_root_bus(hbus->bridge->bus);\n+\t\tpci_remove_root_bus(hbus->bridge->bus);\n \t\tpci_unlock_rescan_remove();\n \t\thbus->state = hv_pcibus_removed;\n \t}\n","prefixes":["RFC","11/15"]}