From patchwork Thu Feb 26 01:29:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yijing Wang X-Patchwork-Id: 5886781 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CEF74BF6C3 for ; Thu, 26 Feb 2015 01:42:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0128620373 for ; Thu, 26 Feb 2015 01:42:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 16FD720375 for ; Thu, 26 Feb 2015 01:42:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753359AbbBZBcU (ORCPT ); Wed, 25 Feb 2015 20:32:20 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:45478 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753046AbbBZBcR (ORCPT ); Wed, 25 Feb 2015 20:32:17 -0500 Received: from 172.24.2.119 (EHLO szxeml430-hub.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BCI19465; Thu, 26 Feb 2015 09:32:12 +0800 (CST) Received: from localhost.localdomain (10.175.100.166) by szxeml430-hub.china.huawei.com (10.82.67.185) with Microsoft SMTP Server id 14.3.158.1; Thu, 26 Feb 2015 09:31:58 +0800 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 v3 14/30] PCI/x86: Refine pci_acpi_scan_root() with generic pci_host_bridge Date: Thu, 26 Feb 2015 09:29:31 +0800 Message-ID: <1424914187-21027-15-git-send-email-wangyijing@huawei.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1424914187-21027-1-git-send-email-wangyijing@huawei.com> References: <1424914187-21027-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.0A020203.54EE779C.0193, 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: c3a381120eea4eb3987b473268ef3e0d Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Signed-off-by: Yijing Wang CC: Thomas Gleixner CC: x86@kernel.org --- arch/x86/pci/acpi.c | 36 ++++++++++++++++++++---------------- 1 files changed, 20 insertions(+), 16 deletions(-) diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c index 5bfe983..3feb12c 100644 --- a/arch/x86/pci/acpi.c +++ b/arch/x86/pci/acpi.c @@ -349,6 +349,18 @@ static void probe_pci_root_info(struct pci_root_info *info, entry->res->name = info->name; } +static int pci_host_bridge_prepare(struct pci_host_bridge *bridge) +{ + struct pci_sysdata *sd = dev_get_drvdata(&bridge->dev); + + ACPI_COMPANION_SET(&bridge->dev, sd->companion); + return 0; +} + +static struct pci_host_bridge_ops phb_ops = { + .phb_prepare = pci_host_bridge_prepare, +}; + struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) { struct acpi_device *device = root->device; @@ -359,6 +371,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) LIST_HEAD(crs_res); LIST_HEAD(resources); struct pci_bus *bus; + struct pci_host_bridge *host = NULL; struct pci_sysdata *sd; int node; @@ -425,14 +438,13 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) if (!setup_mcfg_map(info, domain, (u8)root->secondary.start, (u8)root->secondary.end, root->mcfg_addr)) - bus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, busnum), - &pci_root_ops, sd, &resources); - - if (bus) { - pci_scan_child_bus(bus); - pci_set_host_bridge_release( - to_pci_host_bridge(bus->bridge), - release_pci_root_info, info); + host = pci_scan_root_bridge(NULL, PCI_DOMBUS(domain, busnum), + &pci_root_ops, sd, &resources, &phb_ops); + + if (host) { + bus = host->bus; + pci_set_host_bridge_release(host, release_pci_root_info, + info); } else { resource_list_free(&resources); teardown_mcfg_map(info); @@ -455,14 +467,6 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) return bus; } -int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) -{ - struct pci_sysdata *sd = bridge->bus->sysdata; - - ACPI_COMPANION_SET(&bridge->dev, sd->companion); - return 0; -} - int __init pci_acpi_init(void) { struct pci_dev *dev = NULL;