From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932248AbbCWMrD (ORCPT ); Mon, 23 Mar 2015 08:47:03 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:36098 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752382AbbCWMpN (ORCPT ); Mon, 23 Mar 2015 08:45:13 -0400 From: Yijing Wang To: Bjorn Helgaas CC: Jiang Liu , , Yinghai Lu , , Marc Zyngier , , Russell King , , Thomas Gleixner , Benjamin Herrenschmidt , Rusty Russell , Tony Luck , , "David S. Miller" , "Guan Xuetao" , , , Liviu Dudau , "Arnd Bergmann" , Geert Uytterhoeven , "Yijing Wang" , Subject: [PATCH v7 19/31] powerpc/pci: Use pci_scan_host_bridge() for simplicity Date: Mon, 23 Mar 2015 20:40:45 +0800 Message-ID: <1427114457-16687-20-git-send-email-wangyijing@huawei.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1427114457-16687-1-git-send-email-wangyijing@huawei.com> References: <1427114457-16687-1-git-send-email-wangyijing@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.100.166] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020201.55100A98.0074,ss=1,re=0.001,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 1d3cf884abb94c9e6f6563a55d2b7b34 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now we could use pci_scan_host_bridge() to scan pci buses, provide powerpc specific pci_host_bridge_ops. Signed-off-by: Yijing Wang CC: Benjamin Herrenschmidt CC: linuxppc-dev@lists.ozlabs.org --- arch/powerpc/kernel/pci-common.c | 60 +++++++++++++++++++++++-------------- 1 files changed, 37 insertions(+), 23 deletions(-) diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 2c58200..e2b50a2 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -773,6 +773,29 @@ void pcibios_set_root_bus_speed(struct pci_host_bridge *bridge) return ppc_md.pcibios_set_root_bus_speed(bridge); } +static int pci_host_scan_bus(struct pci_host_bridge *host) +{ + int mode = PCI_PROBE_NORMAL; + struct pci_bus *bus = host->bus; + struct pci_controller *hose = dev_get_drvdata(&host->dev); + + /* Get probe mode and perform scan */ + if (hose->dn && ppc_md.pci_probe_mode) + mode = ppc_md.pci_probe_mode(bus); + + pr_debug(" probe mode: %d\n", mode); + if (mode == PCI_PROBE_DEVTREE) + of_scan_bus(hose->dn, bus); + + if (mode == PCI_PROBE_NORMAL) { + pci_bus_update_busn_res_end(bus, 255); + hose->last_busno = pci_scan_child_bus(bus); + pci_bus_update_busn_res_end(bus, hose->last_busno); + } + + return pci_bus_child_max_busnr(bus); +} + /* This header fixup will do the resource fixup for all devices as they are * probed, but not for bridge ranges */ @@ -1585,6 +1608,11 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus) return of_node_get(hose->dn); } +static struct pci_host_bridge_ops pci_host_ops = { + .set_root_bus_speed = pcibios_set_root_bus_speed, + .scan_bus = pci_host_scan_bus, +}; + /** * pci_scan_phb - Given a pci_controller, setup and scan the PCI bus * @hose: Pointer to the PCI host controller instance structure @@ -1592,9 +1620,8 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus) void pcibios_scan_phb(struct pci_controller *hose) { LIST_HEAD(resources); - struct pci_bus *bus; + struct pci_host_bridge *host; struct device_node *node = hose->dn; - int mode; pr_debug("PCI: Scanning PHB %s\n", of_node_full_name(node)); @@ -1609,31 +1636,18 @@ void pcibios_scan_phb(struct pci_controller *hose) hose->busn.flags = IORESOURCE_BUS; pci_add_resource(&resources, &hose->busn); + pci_host_ops.pci_ops = hose->ops; /* Create an empty bus for the toplevel */ - bus = pci_create_root_bus(hose->parent, hose->global_number, - hose->first_busno, hose->ops, hose, &resources); - if (bus == NULL) { - pr_err("Failed to create bus for PCI domain %04x\n", - hose->global_number); + host = pci_scan_host_bridge(hose->parent, hose->global_number, + hose->first_busno, hose, &resources, &pci_host_ops); + if (host == NULL) { + pr_err("Failed to create host bridge for pci%04x:%02x\n", + hose->global_number, hose->first_busno); pci_free_resource_list(&resources); return; } hose->bus = bus; - /* Get probe mode and perform scan */ - mode = PCI_PROBE_NORMAL; - if (node && ppc_md.pci_probe_mode) - mode = ppc_md.pci_probe_mode(bus); - pr_debug(" probe mode: %d\n", mode); - if (mode == PCI_PROBE_DEVTREE) - of_scan_bus(node, bus); - - if (mode == PCI_PROBE_NORMAL) { - pci_bus_update_busn_res_end(bus, 255); - hose->last_busno = pci_scan_child_bus(bus); - pci_bus_update_busn_res_end(bus, hose->last_busno); - } - /* Platform gets a chance to do some global fixups before * we proceed to resource allocation */ @@ -1641,9 +1655,9 @@ void pcibios_scan_phb(struct pci_controller *hose) ppc_md.pcibios_fixup_phb(hose); /* Configure PCI Express settings */ - if (bus && !pci_has_flag(PCI_PROBE_ONLY)) { + if (host->bus && !pci_has_flag(PCI_PROBE_ONLY)) { struct pci_bus *child; - list_for_each_entry(child, &bus->children, node) + list_for_each_entry(child, &host->bus->children, node) pcie_bus_configure_settings(child); } } -- 1.7.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from szxga03-in.huawei.com ([119.145.14.66]:36098 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752382AbbCWMpN (ORCPT ); Mon, 23 Mar 2015 08:45:13 -0400 From: Yijing Wang To: Bjorn Helgaas CC: Jiang Liu , , Yinghai Lu , , Marc Zyngier , , Russell King , , Thomas Gleixner , Benjamin Herrenschmidt , Rusty Russell , Tony Luck , , "David S. Miller" , "Guan Xuetao" , , , Liviu Dudau , "Arnd Bergmann" , Geert Uytterhoeven , "Yijing Wang" , Subject: [PATCH v7 19/31] powerpc/pci: Use pci_scan_host_bridge() for simplicity Date: Mon, 23 Mar 2015 20:40:45 +0800 Message-ID: <1427114457-16687-20-git-send-email-wangyijing@huawei.com> In-Reply-To: <1427114457-16687-1-git-send-email-wangyijing@huawei.com> References: <1427114457-16687-1-git-send-email-wangyijing@huawei.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-pci-owner@vger.kernel.org List-ID: Now we could use pci_scan_host_bridge() to scan pci buses, provide powerpc specific pci_host_bridge_ops. Signed-off-by: Yijing Wang CC: Benjamin Herrenschmidt CC: linuxppc-dev@lists.ozlabs.org --- arch/powerpc/kernel/pci-common.c | 60 +++++++++++++++++++++++-------------- 1 files changed, 37 insertions(+), 23 deletions(-) diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 2c58200..e2b50a2 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -773,6 +773,29 @@ void pcibios_set_root_bus_speed(struct pci_host_bridge *bridge) return ppc_md.pcibios_set_root_bus_speed(bridge); } +static int pci_host_scan_bus(struct pci_host_bridge *host) +{ + int mode = PCI_PROBE_NORMAL; + struct pci_bus *bus = host->bus; + struct pci_controller *hose = dev_get_drvdata(&host->dev); + + /* Get probe mode and perform scan */ + if (hose->dn && ppc_md.pci_probe_mode) + mode = ppc_md.pci_probe_mode(bus); + + pr_debug(" probe mode: %d\n", mode); + if (mode == PCI_PROBE_DEVTREE) + of_scan_bus(hose->dn, bus); + + if (mode == PCI_PROBE_NORMAL) { + pci_bus_update_busn_res_end(bus, 255); + hose->last_busno = pci_scan_child_bus(bus); + pci_bus_update_busn_res_end(bus, hose->last_busno); + } + + return pci_bus_child_max_busnr(bus); +} + /* This header fixup will do the resource fixup for all devices as they are * probed, but not for bridge ranges */ @@ -1585,6 +1608,11 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus) return of_node_get(hose->dn); } +static struct pci_host_bridge_ops pci_host_ops = { + .set_root_bus_speed = pcibios_set_root_bus_speed, + .scan_bus = pci_host_scan_bus, +}; + /** * pci_scan_phb - Given a pci_controller, setup and scan the PCI bus * @hose: Pointer to the PCI host controller instance structure @@ -1592,9 +1620,8 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus) void pcibios_scan_phb(struct pci_controller *hose) { LIST_HEAD(resources); - struct pci_bus *bus; + struct pci_host_bridge *host; struct device_node *node = hose->dn; - int mode; pr_debug("PCI: Scanning PHB %s\n", of_node_full_name(node)); @@ -1609,31 +1636,18 @@ void pcibios_scan_phb(struct pci_controller *hose) hose->busn.flags = IORESOURCE_BUS; pci_add_resource(&resources, &hose->busn); + pci_host_ops.pci_ops = hose->ops; /* Create an empty bus for the toplevel */ - bus = pci_create_root_bus(hose->parent, hose->global_number, - hose->first_busno, hose->ops, hose, &resources); - if (bus == NULL) { - pr_err("Failed to create bus for PCI domain %04x\n", - hose->global_number); + host = pci_scan_host_bridge(hose->parent, hose->global_number, + hose->first_busno, hose, &resources, &pci_host_ops); + if (host == NULL) { + pr_err("Failed to create host bridge for pci%04x:%02x\n", + hose->global_number, hose->first_busno); pci_free_resource_list(&resources); return; } hose->bus = bus; - /* Get probe mode and perform scan */ - mode = PCI_PROBE_NORMAL; - if (node && ppc_md.pci_probe_mode) - mode = ppc_md.pci_probe_mode(bus); - pr_debug(" probe mode: %d\n", mode); - if (mode == PCI_PROBE_DEVTREE) - of_scan_bus(node, bus); - - if (mode == PCI_PROBE_NORMAL) { - pci_bus_update_busn_res_end(bus, 255); - hose->last_busno = pci_scan_child_bus(bus); - pci_bus_update_busn_res_end(bus, hose->last_busno); - } - /* Platform gets a chance to do some global fixups before * we proceed to resource allocation */ @@ -1641,9 +1655,9 @@ void pcibios_scan_phb(struct pci_controller *hose) ppc_md.pcibios_fixup_phb(hose); /* Configure PCI Express settings */ - if (bus && !pci_has_flag(PCI_PROBE_ONLY)) { + if (host->bus && !pci_has_flag(PCI_PROBE_ONLY)) { struct pci_bus *child; - list_for_each_entry(child, &bus->children, node) + list_for_each_entry(child, &host->bus->children, node) pcie_bus_configure_settings(child); } } -- 1.7.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [119.145.14.66]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id F16351A2ABE for ; Mon, 23 Mar 2015 23:45:22 +1100 (AEDT) From: Yijing Wang To: Bjorn Helgaas Subject: [PATCH v7 19/31] powerpc/pci: Use pci_scan_host_bridge() for simplicity Date: Mon, 23 Mar 2015 20:40:45 +0800 Message-ID: <1427114457-16687-20-git-send-email-wangyijing@huawei.com> In-Reply-To: <1427114457-16687-1-git-send-email-wangyijing@huawei.com> References: <1427114457-16687-1-git-send-email-wangyijing@huawei.com> MIME-Version: 1.0 Content-Type: text/plain Cc: linux-ia64@vger.kernel.org, linux-pci@vger.kernel.org, Yijing Wang , Guan Xuetao , Russell King , x86@kernel.org, Geert Uytterhoeven , Arnd Bergmann , Marc Zyngier , Rusty Russell , linux-m68k@lists.linux-m68k.org, Thomas Gleixner , Yinghai Lu , linux-arm-kernel@lists.infradead.org, Liviu Dudau , Tony Luck , linux-kernel@vger.kernel.org, Jiang Liu , linux-alpha@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, "David S. Miller" List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Now we could use pci_scan_host_bridge() to scan pci buses, provide powerpc specific pci_host_bridge_ops. Signed-off-by: Yijing Wang CC: Benjamin Herrenschmidt CC: linuxppc-dev@lists.ozlabs.org --- arch/powerpc/kernel/pci-common.c | 60 +++++++++++++++++++++++-------------- 1 files changed, 37 insertions(+), 23 deletions(-) diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 2c58200..e2b50a2 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -773,6 +773,29 @@ void pcibios_set_root_bus_speed(struct pci_host_bridge *bridge) return ppc_md.pcibios_set_root_bus_speed(bridge); } +static int pci_host_scan_bus(struct pci_host_bridge *host) +{ + int mode = PCI_PROBE_NORMAL; + struct pci_bus *bus = host->bus; + struct pci_controller *hose = dev_get_drvdata(&host->dev); + + /* Get probe mode and perform scan */ + if (hose->dn && ppc_md.pci_probe_mode) + mode = ppc_md.pci_probe_mode(bus); + + pr_debug(" probe mode: %d\n", mode); + if (mode == PCI_PROBE_DEVTREE) + of_scan_bus(hose->dn, bus); + + if (mode == PCI_PROBE_NORMAL) { + pci_bus_update_busn_res_end(bus, 255); + hose->last_busno = pci_scan_child_bus(bus); + pci_bus_update_busn_res_end(bus, hose->last_busno); + } + + return pci_bus_child_max_busnr(bus); +} + /* This header fixup will do the resource fixup for all devices as they are * probed, but not for bridge ranges */ @@ -1585,6 +1608,11 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus) return of_node_get(hose->dn); } +static struct pci_host_bridge_ops pci_host_ops = { + .set_root_bus_speed = pcibios_set_root_bus_speed, + .scan_bus = pci_host_scan_bus, +}; + /** * pci_scan_phb - Given a pci_controller, setup and scan the PCI bus * @hose: Pointer to the PCI host controller instance structure @@ -1592,9 +1620,8 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus) void pcibios_scan_phb(struct pci_controller *hose) { LIST_HEAD(resources); - struct pci_bus *bus; + struct pci_host_bridge *host; struct device_node *node = hose->dn; - int mode; pr_debug("PCI: Scanning PHB %s\n", of_node_full_name(node)); @@ -1609,31 +1636,18 @@ void pcibios_scan_phb(struct pci_controller *hose) hose->busn.flags = IORESOURCE_BUS; pci_add_resource(&resources, &hose->busn); + pci_host_ops.pci_ops = hose->ops; /* Create an empty bus for the toplevel */ - bus = pci_create_root_bus(hose->parent, hose->global_number, - hose->first_busno, hose->ops, hose, &resources); - if (bus == NULL) { - pr_err("Failed to create bus for PCI domain %04x\n", - hose->global_number); + host = pci_scan_host_bridge(hose->parent, hose->global_number, + hose->first_busno, hose, &resources, &pci_host_ops); + if (host == NULL) { + pr_err("Failed to create host bridge for pci%04x:%02x\n", + hose->global_number, hose->first_busno); pci_free_resource_list(&resources); return; } hose->bus = bus; - /* Get probe mode and perform scan */ - mode = PCI_PROBE_NORMAL; - if (node && ppc_md.pci_probe_mode) - mode = ppc_md.pci_probe_mode(bus); - pr_debug(" probe mode: %d\n", mode); - if (mode == PCI_PROBE_DEVTREE) - of_scan_bus(node, bus); - - if (mode == PCI_PROBE_NORMAL) { - pci_bus_update_busn_res_end(bus, 255); - hose->last_busno = pci_scan_child_bus(bus); - pci_bus_update_busn_res_end(bus, hose->last_busno); - } - /* Platform gets a chance to do some global fixups before * we proceed to resource allocation */ @@ -1641,9 +1655,9 @@ void pcibios_scan_phb(struct pci_controller *hose) ppc_md.pcibios_fixup_phb(hose); /* Configure PCI Express settings */ - if (bus && !pci_has_flag(PCI_PROBE_ONLY)) { + if (host->bus && !pci_has_flag(PCI_PROBE_ONLY)) { struct pci_bus *child; - list_for_each_entry(child, &bus->children, node) + list_for_each_entry(child, &host->bus->children, node) pcie_bus_configure_settings(child); } } -- 1.7.1 From mboxrd@z Thu Jan 1 00:00:00 1970 From: wangyijing@huawei.com (Yijing Wang) Date: Mon, 23 Mar 2015 20:40:45 +0800 Subject: [PATCH v7 19/31] powerpc/pci: Use pci_scan_host_bridge() for simplicity In-Reply-To: <1427114457-16687-1-git-send-email-wangyijing@huawei.com> References: <1427114457-16687-1-git-send-email-wangyijing@huawei.com> Message-ID: <1427114457-16687-20-git-send-email-wangyijing@huawei.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Now we could use pci_scan_host_bridge() to scan pci buses, provide powerpc specific pci_host_bridge_ops. Signed-off-by: Yijing Wang CC: Benjamin Herrenschmidt CC: linuxppc-dev at lists.ozlabs.org --- arch/powerpc/kernel/pci-common.c | 60 +++++++++++++++++++++++-------------- 1 files changed, 37 insertions(+), 23 deletions(-) diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 2c58200..e2b50a2 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -773,6 +773,29 @@ void pcibios_set_root_bus_speed(struct pci_host_bridge *bridge) return ppc_md.pcibios_set_root_bus_speed(bridge); } +static int pci_host_scan_bus(struct pci_host_bridge *host) +{ + int mode = PCI_PROBE_NORMAL; + struct pci_bus *bus = host->bus; + struct pci_controller *hose = dev_get_drvdata(&host->dev); + + /* Get probe mode and perform scan */ + if (hose->dn && ppc_md.pci_probe_mode) + mode = ppc_md.pci_probe_mode(bus); + + pr_debug(" probe mode: %d\n", mode); + if (mode == PCI_PROBE_DEVTREE) + of_scan_bus(hose->dn, bus); + + if (mode == PCI_PROBE_NORMAL) { + pci_bus_update_busn_res_end(bus, 255); + hose->last_busno = pci_scan_child_bus(bus); + pci_bus_update_busn_res_end(bus, hose->last_busno); + } + + return pci_bus_child_max_busnr(bus); +} + /* This header fixup will do the resource fixup for all devices as they are * probed, but not for bridge ranges */ @@ -1585,6 +1608,11 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus) return of_node_get(hose->dn); } +static struct pci_host_bridge_ops pci_host_ops = { + .set_root_bus_speed = pcibios_set_root_bus_speed, + .scan_bus = pci_host_scan_bus, +}; + /** * pci_scan_phb - Given a pci_controller, setup and scan the PCI bus * @hose: Pointer to the PCI host controller instance structure @@ -1592,9 +1620,8 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus) void pcibios_scan_phb(struct pci_controller *hose) { LIST_HEAD(resources); - struct pci_bus *bus; + struct pci_host_bridge *host; struct device_node *node = hose->dn; - int mode; pr_debug("PCI: Scanning PHB %s\n", of_node_full_name(node)); @@ -1609,31 +1636,18 @@ void pcibios_scan_phb(struct pci_controller *hose) hose->busn.flags = IORESOURCE_BUS; pci_add_resource(&resources, &hose->busn); + pci_host_ops.pci_ops = hose->ops; /* Create an empty bus for the toplevel */ - bus = pci_create_root_bus(hose->parent, hose->global_number, - hose->first_busno, hose->ops, hose, &resources); - if (bus == NULL) { - pr_err("Failed to create bus for PCI domain %04x\n", - hose->global_number); + host = pci_scan_host_bridge(hose->parent, hose->global_number, + hose->first_busno, hose, &resources, &pci_host_ops); + if (host == NULL) { + pr_err("Failed to create host bridge for pci%04x:%02x\n", + hose->global_number, hose->first_busno); pci_free_resource_list(&resources); return; } hose->bus = bus; - /* Get probe mode and perform scan */ - mode = PCI_PROBE_NORMAL; - if (node && ppc_md.pci_probe_mode) - mode = ppc_md.pci_probe_mode(bus); - pr_debug(" probe mode: %d\n", mode); - if (mode == PCI_PROBE_DEVTREE) - of_scan_bus(node, bus); - - if (mode == PCI_PROBE_NORMAL) { - pci_bus_update_busn_res_end(bus, 255); - hose->last_busno = pci_scan_child_bus(bus); - pci_bus_update_busn_res_end(bus, hose->last_busno); - } - /* Platform gets a chance to do some global fixups before * we proceed to resource allocation */ @@ -1641,9 +1655,9 @@ void pcibios_scan_phb(struct pci_controller *hose) ppc_md.pcibios_fixup_phb(hose); /* Configure PCI Express settings */ - if (bus && !pci_has_flag(PCI_PROBE_ONLY)) { + if (host->bus && !pci_has_flag(PCI_PROBE_ONLY)) { struct pci_bus *child; - list_for_each_entry(child, &bus->children, node) + list_for_each_entry(child, &host->bus->children, node) pcie_bus_configure_settings(child); } } -- 1.7.1 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yijing Wang Date: Mon, 23 Mar 2015 12:40:45 +0000 Subject: [PATCH v7 19/31] powerpc/pci: Use pci_scan_host_bridge() for simplicity Message-Id: <1427114457-16687-20-git-send-email-wangyijing@huawei.com> List-Id: References: <1427114457-16687-1-git-send-email-wangyijing@huawei.com> In-Reply-To: <1427114457-16687-1-git-send-email-wangyijing@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Bjorn Helgaas Cc: Jiang Liu , linux-pci@vger.kernel.org, Yinghai Lu , linux-kernel@vger.kernel.org, Marc Zyngier , linux-arm-kernel@lists.infradead.org, Russell King , x86@kernel.org, Thomas Gleixner , Benjamin Herrenschmidt , Rusty Russell , Tony Luck , linux-ia64@vger.kernel.org, "David S. Miller" , Guan Xuetao , linux-alpha@vger.kernel.org, linux-m68k@vger.kernel.org, Liviu Dudau , Arnd Bergmann , Geert Uytterhoeven , Yijing Wang , linuxppc-dev@lists.ozlabs.org Now we could use pci_scan_host_bridge() to scan pci buses, provide powerpc specific pci_host_bridge_ops. Signed-off-by: Yijing Wang CC: Benjamin Herrenschmidt CC: linuxppc-dev@lists.ozlabs.org --- arch/powerpc/kernel/pci-common.c | 60 +++++++++++++++++++++++-------------- 1 files changed, 37 insertions(+), 23 deletions(-) diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 2c58200..e2b50a2 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -773,6 +773,29 @@ void pcibios_set_root_bus_speed(struct pci_host_bridge *bridge) return ppc_md.pcibios_set_root_bus_speed(bridge); } +static int pci_host_scan_bus(struct pci_host_bridge *host) +{ + int mode = PCI_PROBE_NORMAL; + struct pci_bus *bus = host->bus; + struct pci_controller *hose = dev_get_drvdata(&host->dev); + + /* Get probe mode and perform scan */ + if (hose->dn && ppc_md.pci_probe_mode) + mode = ppc_md.pci_probe_mode(bus); + + pr_debug(" probe mode: %d\n", mode); + if (mode = PCI_PROBE_DEVTREE) + of_scan_bus(hose->dn, bus); + + if (mode = PCI_PROBE_NORMAL) { + pci_bus_update_busn_res_end(bus, 255); + hose->last_busno = pci_scan_child_bus(bus); + pci_bus_update_busn_res_end(bus, hose->last_busno); + } + + return pci_bus_child_max_busnr(bus); +} + /* This header fixup will do the resource fixup for all devices as they are * probed, but not for bridge ranges */ @@ -1585,6 +1608,11 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus) return of_node_get(hose->dn); } +static struct pci_host_bridge_ops pci_host_ops = { + .set_root_bus_speed = pcibios_set_root_bus_speed, + .scan_bus = pci_host_scan_bus, +}; + /** * pci_scan_phb - Given a pci_controller, setup and scan the PCI bus * @hose: Pointer to the PCI host controller instance structure @@ -1592,9 +1620,8 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus) void pcibios_scan_phb(struct pci_controller *hose) { LIST_HEAD(resources); - struct pci_bus *bus; + struct pci_host_bridge *host; struct device_node *node = hose->dn; - int mode; pr_debug("PCI: Scanning PHB %s\n", of_node_full_name(node)); @@ -1609,31 +1636,18 @@ void pcibios_scan_phb(struct pci_controller *hose) hose->busn.flags = IORESOURCE_BUS; pci_add_resource(&resources, &hose->busn); + pci_host_ops.pci_ops = hose->ops; /* Create an empty bus for the toplevel */ - bus = pci_create_root_bus(hose->parent, hose->global_number, - hose->first_busno, hose->ops, hose, &resources); - if (bus = NULL) { - pr_err("Failed to create bus for PCI domain %04x\n", - hose->global_number); + host = pci_scan_host_bridge(hose->parent, hose->global_number, + hose->first_busno, hose, &resources, &pci_host_ops); + if (host = NULL) { + pr_err("Failed to create host bridge for pci%04x:%02x\n", + hose->global_number, hose->first_busno); pci_free_resource_list(&resources); return; } hose->bus = bus; - /* Get probe mode and perform scan */ - mode = PCI_PROBE_NORMAL; - if (node && ppc_md.pci_probe_mode) - mode = ppc_md.pci_probe_mode(bus); - pr_debug(" probe mode: %d\n", mode); - if (mode = PCI_PROBE_DEVTREE) - of_scan_bus(node, bus); - - if (mode = PCI_PROBE_NORMAL) { - pci_bus_update_busn_res_end(bus, 255); - hose->last_busno = pci_scan_child_bus(bus); - pci_bus_update_busn_res_end(bus, hose->last_busno); - } - /* Platform gets a chance to do some global fixups before * we proceed to resource allocation */ @@ -1641,9 +1655,9 @@ void pcibios_scan_phb(struct pci_controller *hose) ppc_md.pcibios_fixup_phb(hose); /* Configure PCI Express settings */ - if (bus && !pci_has_flag(PCI_PROBE_ONLY)) { + if (host->bus && !pci_has_flag(PCI_PROBE_ONLY)) { struct pci_bus *child; - list_for_each_entry(child, &bus->children, node) + list_for_each_entry(child, &host->bus->children, node) pcie_bus_configure_settings(child); } } -- 1.7.1 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yijing Wang Subject: [PATCH v7 19/31] powerpc/pci: Use pci_scan_host_bridge() for simplicity Date: Mon, 23 Mar 2015 20:40:45 +0800 Message-ID: <1427114457-16687-20-git-send-email-wangyijing@huawei.com> References: <1427114457-16687-1-git-send-email-wangyijing@huawei.com> Mime-Version: 1.0 Content-Transfer-Encoding: base64 Return-path: In-Reply-To: <1427114457-16687-1-git-send-email-wangyijing@huawei.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+glppe-linuxppc-embedded-2=m.gmane.org@lists.ozlabs.org Sender: "Linuxppc-dev" Content-Type: text/plain; charset="us-ascii" To: Bjorn Helgaas Cc: linux-ia64@vger.kernel.org, linux-pci@vger.kernel.org, Yijing Wang , Guan Xuetao , Russell King , x86@kernel.org, Geert Uytterhoeven , Arnd Bergmann , Marc Zyngier , Rusty Russell , linux-m68k@lists.linux-m68k.org, Thomas Gleixner , Yinghai Lu , linux-arm-kernel@lists.infradead.org, Liviu Dudau , Tony Luck , linux-kernel@vger.kernel.org, Jiang Liu , linux-alpha@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, "David S. Miller" Tm93IHdlIGNvdWxkIHVzZSBwY2lfc2Nhbl9ob3N0X2JyaWRnZSgpIHRvIHNjYW4KcGNpIGJ1c2Vz LCBwcm92aWRlIHBvd2VycGMgc3BlY2lmaWMgcGNpX2hvc3RfYnJpZGdlX29wcy4KClNpZ25lZC1v ZmYtYnk6IFlpamluZyBXYW5nIDx3YW5neWlqaW5nQGh1YXdlaS5jb20+CkNDOiBCZW5qYW1pbiBI ZXJyZW5zY2htaWR0IDxiZW5oQGtlcm5lbC5jcmFzaGluZy5vcmc+CkNDOiBs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