From patchwork Mon Mar 23 12:40:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yijing Wang X-Patchwork-Id: 6073111 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E1EAA9F2A9 for ; Mon, 23 Mar 2015 13:01:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DFCC920259 for ; Mon, 23 Mar 2015 13:01:08 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4BCF62024F for ; Mon, 23 Mar 2015 13:01:03 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ya1vz-0004ug-Gf; Mon, 23 Mar 2015 12:58:23 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ya1n2-000489-87 for linux-arm-kernel@bombadil.infradead.org; Mon, 23 Mar 2015 12:49:08 +0000 Received: from szxga03-in.huawei.com ([119.145.14.66]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ya1mv-0005jy-Tl for linux-arm-kernel@lists.infradead.org; Mon, 23 Mar 2015 12:49:06 +0000 Received: from 172.24.2.119 (EHLO szxeml434-hub.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BDN03946; Mon, 23 Mar 2015 20:44:08 +0800 (CST) Received: from localhost.localdomain (10.175.100.166) by szxeml434-hub.china.huawei.com (10.82.67.225) with Microsoft SMTP Server id 14.3.158.1; Mon, 23 Mar 2015 20:43:56 +0800 From: Yijing Wang To: Bjorn Helgaas Subject: [PATCH v7 16/31] PCI: Introduce pci_bus_child_max_busnr() Date: Mon, 23 Mar 2015 20:40:42 +0800 Message-ID: <1427114457-16687-17-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 X-Originating-IP: [10.175.100.166] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020205.55100A98.00E9, 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: eecb2f978dc9319a55b0331f3ca1a40e X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150323_084902_726582_9F7279AE X-CRM114-Status: GOOD ( 16.33 ) X-Spam-Score: -4.2 (----) Cc: linux-ia64@vger.kernel.org, linux-pci@vger.kernel.org, Yijing Wang , Guan Xuetao , Russell King , x86@kernel.org, Geert Uytterhoeven , Benjamin Herrenschmidt , 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, Fengguang Wu , "David S. Miller" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Sometimes, we want to know the highest reserved busnr for children bus. Because parent's bus->busn_res may have padding in it. For example, some host drivers don't know the bus end, so they supply the bus resource (root_bus, 255), they want to update the max bus number after pci scan complete. But pci scan functions won't return the actual max bus number. So we could use pci_bus_child_max_busnr() to find that. Signed-off-by: Fengguang Wu Signed-off-by: Yijing Wang --- drivers/pci/hotplug/acpiphp_glue.c | 29 +---------------------------- drivers/pci/pci.c | 27 +++++++++++++++++++++++++-- include/linux/pci.h | 2 +- 3 files changed, 27 insertions(+), 31 deletions(-) diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index bcb90e4..84f2584 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c @@ -397,33 +397,6 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge) acpi_unlock_hp_context(); } -/** - * acpiphp_max_busnr - return the highest reserved bus number under the given bus. - * @bus: bus to start search with - */ -static unsigned char acpiphp_max_busnr(struct pci_bus *bus) -{ - struct pci_bus *tmp; - unsigned char max, n; - - /* - * pci_bus_max_busnr will return the highest - * reserved busnr for all these children. - * that is equivalent to the bus->subordinate - * value. We don't want to use the parent's - * bus->subordinate value because it could have - * padding in it. - */ - max = bus->busn_res.start; - - list_for_each_entry(tmp, &bus->children, node) { - n = pci_bus_max_busnr(tmp); - if (n > max) - max = n; - } - return max; -} - static void acpiphp_set_acpi_region(struct acpiphp_slot *slot) { struct acpiphp_func *func; @@ -489,7 +462,7 @@ static void enable_slot(struct acpiphp_slot *slot) LIST_HEAD(add_list); acpiphp_rescan_slot(slot); - max = acpiphp_max_busnr(bus); + max = pci_bus_child_max_busnr(bus); for (pass = 0; pass < 2; pass++) { list_for_each_entry(dev, &bus->devices, bus_list) { if (PCI_SLOT(dev->devfn) != slot->device) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 6677fac..8a2f12c 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -108,7 +108,7 @@ static bool pcie_ari_disabled; * Given a PCI bus, returns the highest PCI bus number present in the set * including the given PCI bus and its list of child PCI buses. */ -unsigned char pci_bus_max_busnr(struct pci_bus *bus) +static unsigned char pci_bus_max_busnr(struct pci_bus *bus) { struct pci_bus *tmp; unsigned char max, n; @@ -121,7 +121,30 @@ unsigned char pci_bus_max_busnr(struct pci_bus *bus) } return max; } -EXPORT_SYMBOL_GPL(pci_bus_max_busnr); + +unsigned char pci_bus_child_max_busnr(struct pci_bus *bus) +{ + struct pci_bus *tmp; + unsigned char max, n; + + /* + * pci_bus_max_busnr will return the highest + * reserved busnr for all these children. + * that is equivalent to the bus->subordinate + * value. We don't want to use the parent's + * bus->subordinate value because it could have + * padding in it. + */ + max = bus->busn_res.start; + + list_for_each_entry(tmp, &bus->children, node) { + n = pci_bus_max_busnr(tmp); + if (n > max) + max = n; + } + return max; +} +EXPORT_SYMBOL_GPL(pci_bus_child_max_busnr); #ifdef CONFIG_HAS_IOMEM void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar) diff --git a/include/linux/pci.h b/include/linux/pci.h index 7f4f182..0b921d6 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1185,7 +1185,7 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, void pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *), void *userdata); int pci_cfg_space_size(struct pci_dev *dev); -unsigned char pci_bus_max_busnr(struct pci_bus *bus); +unsigned char pci_bus_child_max_busnr(struct pci_bus *bus); void pci_setup_bridge(struct pci_bus *bus); resource_size_t pcibios_window_alignment(struct pci_bus *bus, unsigned long type);