From patchwork Mon Nov 17 10:21:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wangyijing X-Patchwork-Id: 40894 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3356524035 for ; Mon, 17 Nov 2014 09:44:17 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id f15sf11367188lbj.7 for ; Mon, 17 Nov 2014 01:44:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:mime-version:cc:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=+s1vtDHE5hd/tfPxaP3or6z5pLIAeCrTO2Mtu9p+yDQ=; b=l1d9NelHydypszD/w72eVrpwV/tbyfToijBKSIoGrwdeoaR90ly9dv4Wp5T93Kz8L+ fivHYU/zV4ICawWbbcn9W6d8Q9Kz6xJxMiQYaljKG6MPXWAyKuw6WJI8tP9whPNR9GF9 1gFiHxkdjiiEqmfcRMRTOQBDv4vx4hwuuaXTOFcxalNj0Yq4f6VCA4owkBB3vFIrrk03 Dq8qknyfChAYuJdHaW5E1pwz6ixcL7+3GZaUJezURFoa5lV0hTp/0TAU25SRiTST6r85 0YpO+zkG3MwIOyOS9B3aeYLDPPunraw39sCe42qI2ptq9BVqoLejf8wEI9yZ9RDOgtWT GZMA== X-Gm-Message-State: ALoCoQl+vQ7uSLEEtJsmfxIyiZI40yvLaCzBT7xKDZoWsQUJAx3mk9vkWjV3SQu6NimAZzlNW9kx X-Received: by 10.152.88.98 with SMTP id bf2mr13743614lab.1.1416217456151; Mon, 17 Nov 2014 01:44:16 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.7 with SMTP id o7ls707174lao.55.gmail; Mon, 17 Nov 2014 01:44:15 -0800 (PST) X-Received: by 10.152.216.167 with SMTP id or7mr8556933lac.93.1416217455614; Mon, 17 Nov 2014 01:44:15 -0800 (PST) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id zm10si51008008lbb.125.2014.11.17.01.44.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 17 Nov 2014 01:44:15 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by mail-la0-f52.google.com with SMTP id q1so97185lam.11 for ; Mon, 17 Nov 2014 01:44:15 -0800 (PST) X-Received: by 10.152.116.102 with SMTP id jv6mr12458124lab.40.1416217455520; Mon, 17 Nov 2014 01:44:15 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp1127431lbc; Mon, 17 Nov 2014 01:44:14 -0800 (PST) X-Received: by 10.67.14.36 with SMTP id fd4mr28185726pad.79.1416217453820; Mon, 17 Nov 2014 01:44:13 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id ip2si34856414pac.14.2014.11.17.01.44.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Nov 2014 01:44:13 -0800 (PST) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; 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 1XqIpl-00087Z-72; Mon, 17 Nov 2014 09:42:57 +0000 Received: from szxga01-in.huawei.com ([119.145.14.64]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XqIp1-0007Ji-EO for linux-arm-kernel@lists.infradead.org; Mon, 17 Nov 2014 09:42:13 +0000 Received: from 172.24.2.119 (EHLO szxeml462-hub.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CEO10155; Mon, 17 Nov 2014 17:40:47 +0800 (CST) Received: from localhost.localdomain (10.175.100.166) by szxeml462-hub.china.huawei.com (10.82.67.205) with Microsoft SMTP Server id 14.3.158.1; Mon, 17 Nov 2014 17:40:36 +0800 From: Yijing Wang To: Bjorn Helgaas Subject: [RFC PATCH 11/16] x86/PCI: Use pci_scan_host_bridge() instead of pci_create_root_bus() Date: Mon, 17 Nov 2014 18:21:45 +0800 Message-ID: <1416219710-26088-12-git-send-email-wangyijing@huawei.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1416219710-26088-1-git-send-email-wangyijing@huawei.com> References: <1416219710-26088-1-git-send-email-wangyijing@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.100.166] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141117_014212_156461_729D4BC5 X-CRM114-Status: GOOD ( 13.96 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [119.145.14.64 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [119.145.14.64 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Liviu Dudau , Tony Luck , Russell King , linux-pci@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, Xinwei Hu , Thierry Reding , Suravee.Suthikulpanit@amd.com, Benjamin Herrenschmidt , Yijing Wang , linux-ia64@vger.kernel.org, Thomas Gleixner , Wuyun , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org 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+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: wangyijing@huawei.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Now we could use pci_scan_host_bridge() to refactor pci_acpi_scan_root(). Signed-off-by: Yijing Wang --- arch/x86/pci/acpi.c | 65 ++++++++++++++++++++++++++++++------------------- arch/x86/pci/common.c | 23 ++++++++++++----- 2 files changed, 56 insertions(+), 32 deletions(-) diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c index cfd1b13..528fca3 100644 --- a/arch/x86/pci/acpi.c +++ b/arch/x86/pci/acpi.c @@ -13,6 +13,7 @@ struct pci_root_info { unsigned int res_num; struct resource *res; resource_size_t *res_offset; + struct acpi_pci_root *root; struct pci_sysdata sd; #ifdef CONFIG_PCI_MMCONFIG bool mcfg_added; @@ -467,16 +468,40 @@ static void probe_pci_root_info(struct pci_root_info *info, info); } +static int pci_acpi_init_res(struct pci_host_bridge *host, + struct pci_host_info *arg) +{ + struct pci_sysdata *sd = arg->arg; + struct pci_root_info *info = container_of(sd, + struct pci_root_info, sd); + + /* insert busn res at first */ + pci_add_resource(&host->windows, &info->root->secondary); + /* + * _CRS with no apertures is normal, so only fall back to + * defaults or native bridge info if we're ignoring _CRS. + */ + if (pci_use_crs) + add_resources(info, &host->windows); + else { + free_pci_root_info_res(info); + x86_pci_root_bus_resources(host->busnum, &host->windows); + } + + return 0; +} + struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) { struct acpi_device *device = root->device; struct pci_root_info *info; int domain = root->segment; int busnum = root->secondary.start; - LIST_HEAD(resources); struct pci_bus *bus; struct pci_sysdata *sd; int node; + struct pci_host_info arg; + struct pci_host_bridge *host; if (pci_ignore_seg) domain = 0; @@ -506,10 +531,14 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) return NULL; } + info->root = root; sd = &info->sd; sd->domain = domain; sd->node = node; sd->companion = device; + init_pci_host_info(&arg); + arg.arg = sd; + arg.init_res = pci_acpi_init_res; bus = pci_find_bus(domain, busnum); if (bus) { @@ -522,33 +551,19 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) } else { probe_pci_root_info(info, device, busnum, domain); - /* insert busn res at first */ - pci_add_resource(&resources, &root->secondary); - /* - * _CRS with no apertures is normal, so only fall back to - * defaults or native bridge info if we're ignoring _CRS. - */ - if (pci_use_crs) - add_resources(info, &resources); - else { - free_pci_root_info_res(info); - x86_pci_root_bus_resources(busnum, &resources); + if (!setup_mcfg_map(info, domain, (u8)root->secondary.start, + (u8)root->secondary.end, root->mcfg_addr)) { + host = pci_scan_host_bridge(NULL, PCI_DOMBUS(domain, busnum), + &pci_root_ops, &arg); + bus = host->bus; } - if (!setup_mcfg_map(info, domain, (u8)root->secondary.start, - (u8)root->secondary.end, root->mcfg_addr)) - bus = pci_create_root_bus(NULL, busnum, &pci_root_ops, - sd, &resources); - - if (bus) { - pci_scan_child_bus(bus); - pci_set_host_bridge_release( - to_pci_host_bridge(bus->bridge), + if (bus) + pci_set_host_bridge_release(host, release_pci_root_info, info); - } else { - pci_free_resource_list(&resources); + else __release_pci_root_info(info); - } + } /* After the PCI-E bus has been walked and all devices discovered, @@ -568,7 +583,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) { - struct pci_sysdata *sd = bridge->bus->sysdata; + struct pci_sysdata *sd = bridge->sysdata; ACPI_COMPANION_SET(&bridge->dev, sd->companion); return 0; diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index b16632b..0032065 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c @@ -456,11 +456,18 @@ void __init dmi_check_pciprobe(void) dmi_check_system(pciprobe_dmi_table); } +static int pcibios_init_res(struct pci_host_bridge *host, + struct pci_host_info *info) +{ + x86_pci_root_bus_resources(host->busnum, &host->windows); + return 0; +} + void pcibios_scan_root(int busnum) { - struct pci_bus *bus; struct pci_sysdata *sd; - LIST_HEAD(resources); + struct pci_host_info info; + struct pci_host_bridge *host; sd = kzalloc(sizeof(*sd), GFP_KERNEL); if (!sd) { @@ -468,14 +475,16 @@ void pcibios_scan_root(int busnum) return; } sd->node = x86_pci_root_bus_node(busnum); - x86_pci_root_bus_resources(busnum, &resources); + init_pci_host_info(&info); + info.init_res = pcibios_init_res; + info.arg = sd; printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum); - bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources); - if (bus) { - pci_bus_add_devices(bus); + host = pci_scan_host_bridge(NULL, PCI_DOMBUS(0, busnum), + &pci_root_ops, &info); + if (host) { + pci_bus_add_devices(host->bus); return; } - pci_free_resource_list(&resources); kfree(sd); }