From patchwork Mon Nov 17 10:21:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wangyijing X-Patchwork-Id: 40897 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 402A524035 for ; Mon, 17 Nov 2014 09:45:48 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id r20sf687960wiv.1 for ; Mon, 17 Nov 2014 01:45:47 -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:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=GfYVdFFPEuh4AC/0m8ZJKYAIDJBpIAZ2gSw/Qram6/A=; b=UzYVdnsm9c5OijfERrGGd9C27zTzwHwbb4AwJnbv4Ten5ZzYTj2BqGK0Ecxw5HmcdN eXZq5AruGKj+jny8ADOuuQeCEkke0R6XMMfONaeTGHegiIbbl0dFvCRllx3eXEOvLi3/ tph1eiHhAB42658Zwb5ftj2bgt0wKj326GK1W+qs0DCyUqcZnRpg+xHle+RoKhUYWvny DNh0LrmOBh89XkoUGFUdmvpJmrQX41BR2EE2r3ZwcC4X3ZNOyv7KYcCTGDXtrI9zbM75 eshrdnuNixtcXOLudZWMqukawD7KH0xkPEcEKJdgj6NoBaj5S99HrXd+2zPCwcJl+wy8 W0gA== X-Gm-Message-State: ALoCoQlOsUvuuvk46wEYoKgDEjWUP/AmTN5RLgiSyPstDV2SWIkudhI61MnlTeWuLsyjYKIQy4bF X-Received: by 10.112.125.6 with SMTP id mm6mr220654lbb.8.1416217547473; Mon, 17 Nov 2014 01:45:47 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.4.33 with SMTP id cb1ls1261281lad.89.gmail; Mon, 17 Nov 2014 01:45:47 -0800 (PST) X-Received: by 10.152.205.11 with SMTP id lc11mr23660439lac.34.1416217547205; Mon, 17 Nov 2014 01:45:47 -0800 (PST) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id b6si50969492lae.131.2014.11.17.01.45.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 17 Nov 2014 01:45:47 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by mail-lb0-f177.google.com with SMTP id z12so8711783lbi.22 for ; Mon, 17 Nov 2014 01:45:47 -0800 (PST) X-Received: by 10.112.62.166 with SMTP id z6mr8766906lbr.74.1416217547010; Mon, 17 Nov 2014 01:45:47 -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 ew9csp1127577lbc; Mon, 17 Nov 2014 01:45:45 -0800 (PST) X-Received: by 10.70.47.130 with SMTP id d2mr10306968pdn.111.1416217545161; Mon, 17 Nov 2014 01:45:45 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o3si1931076pdn.39.2014.11.17.01.45.44 for ; Mon, 17 Nov 2014 01:45:45 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752444AbaKQJnj (ORCPT + 26 others); Mon, 17 Nov 2014 04:43:39 -0500 Received: from szxga01-in.huawei.com ([119.145.14.64]:43138 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751653AbaKQJkw (ORCPT ); Mon, 17 Nov 2014 04:40:52 -0500 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 CEO10125; Mon, 17 Nov 2014 17:40:42 +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:30 +0800 From: Yijing Wang To: Bjorn Helgaas CC: , , Xinwei Hu , Wuyun , , Russell King , , Thomas Gleixner , Benjamin Herrenschmidt , , Tony Luck , , Thierry Reding , Liviu Dudau , , Yijing Wang Subject: [RFC PATCH 04/16] PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus() Date: Mon, 17 Nov 2014 18:21:38 +0800 Message-ID: <1416219710-26088-5-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 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.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.217.177 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 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Rip out pci_bus_add_devices() from pci_scan_root_bus() for following reasons. 1. pci_scan_root_bus() means we only do the scan, we should not add pci busses. 2. A lots of drviers which use pci_scan_root_bus() call pci_bus_size_bridges(), pci_bus_assign_resources() after pci_scan_root_bus(). But strictly speaking pci_bus_add_devices() should be called after the resources assignment. Signed-off-by: Yijing Wang --- arch/alpha/kernel/pci.c | 1 + arch/alpha/kernel/sys_nautilus.c | 1 + arch/frv/mb93090-mb00/pci-vdk.c | 8 +++++--- arch/ia64/sn/kernel/io_init.c | 2 ++ arch/m68k/coldfire/pci.c | 1 + arch/microblaze/pci/pci-common.c | 2 +- arch/mips/pci/pci.c | 1 + arch/mn10300/unit-asb2305/pci.c | 7 +++++-- arch/s390/pci/pci.c | 2 +- arch/sh/drivers/pci/pci.c | 1 + arch/sparc/kernel/leon_pci.c | 1 + arch/sparc/kernel/pcic.c | 2 ++ arch/tile/kernel/pci.c | 3 ++- arch/tile/kernel/pci_gx.c | 3 ++- arch/unicore32/kernel/pci.c | 2 +- arch/x86/pci/common.c | 10 ++++++---- arch/xtensa/kernel/pci.c | 1 + drivers/pci/host/pci-xgene.c | 2 +- drivers/pci/hotplug/ibmphp_core.c | 6 ++++-- drivers/pci/probe.c | 1 - 20 files changed, 39 insertions(+), 18 deletions(-) diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c index 076c35c..81251a5 100644 --- a/arch/alpha/kernel/pci.c +++ b/arch/alpha/kernel/pci.c @@ -349,6 +349,7 @@ common_init_pci(void) pci_assign_unassigned_resources(); pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq); + pci_bus_add_devices(bus); } diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c index 1047ab3..60fbd77 100644 --- a/arch/alpha/kernel/sys_nautilus.c +++ b/arch/alpha/kernel/sys_nautilus.c @@ -253,6 +253,7 @@ nautilus_init_pci(void) for the root bus, so just clear it. */ bus->self = NULL; pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq); + pci_bus_add_devices(bus); } /* diff --git a/arch/frv/mb93090-mb00/pci-vdk.c b/arch/frv/mb93090-mb00/pci-vdk.c index efa5d65..85f87dc 100644 --- a/arch/frv/mb93090-mb00/pci-vdk.c +++ b/arch/frv/mb93090-mb00/pci-vdk.c @@ -316,6 +316,7 @@ void pcibios_fixup_bus(struct pci_bus *bus) int __init pcibios_init(void) { + struct pci_bus *bus = NULL; struct pci_ops *dir = NULL; LIST_HEAD(resources); @@ -383,12 +384,13 @@ int __init pcibios_init(void) printk("PCI: Probing PCI hardware\n"); pci_add_resource(&resources, &pci_ioport_resource); pci_add_resource(&resources, &pci_iomem_resource); - pci_scan_root_bus(NULL, 0, pci_root_ops, NULL, &resources); - + bus = pci_scan_root_bus(NULL, 0, pci_root_ops, NULL, &resources); + if (!bus) + return -ENXIO; pcibios_irq_init(); pcibios_fixup_irqs(); pcibios_resource_survey(); - + pci_bus_add_devices(bus); return 0; } diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c index 0b5ce82..1be65eb 100644 --- a/arch/ia64/sn/kernel/io_init.c +++ b/arch/ia64/sn/kernel/io_init.c @@ -271,7 +271,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus) if (bus == NULL) { kfree(res); kfree(controller); + return; } + pci_bus_add_devices(bus); } /* diff --git a/arch/m68k/coldfire/pci.c b/arch/m68k/coldfire/pci.c index 4d242fb..840a431 100644 --- a/arch/m68k/coldfire/pci.c +++ b/arch/m68k/coldfire/pci.c @@ -319,6 +319,7 @@ static int __init mcf_pci_init(void) pci_fixup_irqs(pci_common_swizzle, mcf_pci_map_irq); pci_bus_size_bridges(rootbus); pci_bus_assign_resources(rootbus); + pci_bus_add_devices(rootbus); return 0; } diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c index 9037914..9ca7e3f 100644 --- a/arch/microblaze/pci/pci-common.c +++ b/arch/microblaze/pci/pci-common.c @@ -1344,8 +1344,8 @@ static void pcibios_scan_phb(struct pci_controller *hose) } bus->busn_res.start = hose->first_busno; hose->bus = bus; - hose->last_busno = bus->busn_res.end; + pci_bus_add_devices(bus); } static int __init pcibios_init(void) diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c index 1bf60b1..f083688 100644 --- a/arch/mips/pci/pci.c +++ b/arch/mips/pci/pci.c @@ -113,6 +113,7 @@ static void pcibios_scanbus(struct pci_controller *hose) if (!pci_has_flag(PCI_PROBE_ONLY)) { pci_bus_size_bridges(bus); pci_bus_assign_resources(bus); + pci_bus_add_devices(bus); } } } diff --git a/arch/mn10300/unit-asb2305/pci.c b/arch/mn10300/unit-asb2305/pci.c index 6b4339f..011af54 100644 --- a/arch/mn10300/unit-asb2305/pci.c +++ b/arch/mn10300/unit-asb2305/pci.c @@ -345,6 +345,7 @@ void pcibios_fixup_bus(struct pci_bus *bus) */ static int __init pcibios_init(void) { + struct pci_bus *bus; resource_size_t io_offset, mem_offset; LIST_HEAD(resources); @@ -376,11 +377,13 @@ static int __init pcibios_init(void) pci_add_resource_offset(&resources, &pci_ioport_resource, io_offset); pci_add_resource_offset(&resources, &pci_iomem_resource, mem_offset); - pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL, &resources); - + bus = pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL, &resources); + if (!bus) + return 0; pcibios_irq_init(); pcibios_fixup_irqs(); pcibios_resource_survey(); + pci_bus_add_devices(bus); return 0; } diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c index 2fa7b14..016ea48 100644 --- a/arch/s390/pci/pci.c +++ b/arch/s390/pci/pci.c @@ -755,7 +755,7 @@ static int zpci_scan_bus(struct zpci_dev *zdev) zpci_cleanup_bus_resources(zdev); return -EIO; } - + pci_bus_add_devices(zdev->bus); zdev->bus->max_bus_speed = zdev->max_bus_speed; return 0; } diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c index 1bc09ee..efc1051 100644 --- a/arch/sh/drivers/pci/pci.c +++ b/arch/sh/drivers/pci/pci.c @@ -69,6 +69,7 @@ static void pcibios_scanbus(struct pci_channel *hose) pci_bus_size_bridges(bus); pci_bus_assign_resources(bus); + pci_bus_add_devices(bus); } else { pci_free_resource_list(&resources); } diff --git a/arch/sparc/kernel/leon_pci.c b/arch/sparc/kernel/leon_pci.c index 899b720..2971076 100644 --- a/arch/sparc/kernel/leon_pci.c +++ b/arch/sparc/kernel/leon_pci.c @@ -40,6 +40,7 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info) /* Assign devices with resources */ pci_assign_unassigned_resources(); + pci_bus_add_devices(root_bus); } else { pci_free_resource_list(&resources); } diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c index 64aafac..5457814 100644 --- a/arch/sparc/kernel/pcic.c +++ b/arch/sparc/kernel/pcic.c @@ -392,6 +392,8 @@ static void __init pcic_pbm_scan_bus(struct linux_pcic *pcic) pbm->pci_bus = pci_scan_root_bus(NULL, pbm->pci_first_busno, &pcic_ops, pbm, NULL); + if (pbm->pci_bus) + pci_bus_add_devices(pbm->pci_bus); #if 0 /* deadwood transplanted from sparc64 */ pci_fill_in_pbm_cookies(pbm->pci_bus, pbm, pbm->prom_node); pci_record_assignments(pbm, pbm->pci_bus); diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c index 1f80a88..268423e 100644 --- a/arch/tile/kernel/pci.c +++ b/arch/tile/kernel/pci.c @@ -326,7 +326,8 @@ int __init pcibios_init(void) /* Configure the max_read_size and max_payload_size values. */ fixup_read_and_payload_sizes(); - + if (bus) + pci_bus_add_devices(bus); /* Record the I/O resources in the PCI controller structure. */ for (i = 0; i < TILE_NUM_PCIE; i++) { /* diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c index e39f9c5..5f05a9a 100644 --- a/arch/tile/kernel/pci_gx.c +++ b/arch/tile/kernel/pci_gx.c @@ -903,7 +903,8 @@ int __init pcibios_init(void) * associated with the devices read in above. */ pci_assign_unassigned_resources(); - + if (bus) + pci_bus_add_devices(bus); /* Record the I/O resources in the PCI controller structure. */ for (i = 0; i < num_rc_controllers; i++) { struct pci_controller *controller = &pci_controllers[i]; diff --git a/arch/unicore32/kernel/pci.c b/arch/unicore32/kernel/pci.c index be0f261..0d4c563 100644 --- a/arch/unicore32/kernel/pci.c +++ b/arch/unicore32/kernel/pci.c @@ -270,11 +270,11 @@ static int __init pci_common_init(void) * Size the bridge windows. */ pci_bus_size_bridges(puv3_bus); - /* * Assign resources. */ pci_bus_assign_resources(puv3_bus); + pci_bus_add_devices(puv3_bus); } return 0; diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index 7b20bcc..b16632b 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c @@ -471,10 +471,12 @@ void pcibios_scan_root(int busnum) x86_pci_root_bus_resources(busnum, &resources); 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_free_resource_list(&resources); - kfree(sd); - } + if (bus) { + pci_bus_add_devices(bus); + return; + } + pci_free_resource_list(&resources); + kfree(sd); } void __init pcibios_set_cache_line_size(void) diff --git a/arch/xtensa/kernel/pci.c b/arch/xtensa/kernel/pci.c index 5b34033..c4b5b5d 100644 --- a/arch/xtensa/kernel/pci.c +++ b/arch/xtensa/kernel/pci.c @@ -185,6 +185,7 @@ static int __init pcibios_init(void) pci_controller_apertures(pci_ctrl, &resources); bus = pci_scan_root_bus(NULL, pci_ctrl->first_busno, pci_ctrl->ops, pci_ctrl, &resources); + pci_bus_add_devices(bus); pci_ctrl->bus = bus; pci_ctrl->last_busno = bus->busn_res.end; if (next_busno <= pci_ctrl->last_busno) diff --git a/drivers/pci/host/pci-xgene.c b/drivers/pci/host/pci-xgene.c index 9ecabfa..e7a4f66 100644 --- a/drivers/pci/host/pci-xgene.c +++ b/drivers/pci/host/pci-xgene.c @@ -634,7 +634,7 @@ static int xgene_pcie_probe_bridge(struct platform_device *pdev) bus = pci_scan_root_bus(&pdev->dev, 0, &xgene_pcie_ops, port, &res); if (!bus) return -ENOMEM; - + pci_bus_add_devices(bus); platform_set_drvdata(pdev, port); return 0; } diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c index b486432..76ce157 100644 --- a/drivers/pci/hotplug/ibmphp_core.c +++ b/drivers/pci/hotplug/ibmphp_core.c @@ -740,7 +740,7 @@ static void ibm_unconfigure_device(struct pci_func *func) */ static u8 bus_structure_fixup(u8 busno) { - struct pci_bus *bus; + struct pci_bus *bus, *b; struct pci_dev *dev; u16 l; @@ -767,7 +767,9 @@ static u8 bus_structure_fixup(u8 busno) (l != 0x0000) && (l != 0xffff)) { debug("%s - Inside bus_structure_fixup()\n", __func__); - pci_scan_root_bus(NULL, busno, ibmphp_pci_bus->ops, NULL, NULL); + b = pci_scan_root_bus(NULL, busno, ibmphp_pci_bus->ops, NULL, NULL); + if (b) + pci_bus_add_devices(b); break; } } diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 0a02fc2..97711f3 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2101,7 +2101,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus, if (!found) pci_bus_update_busn_res_end(b, max); - pci_bus_add_devices(b); return b; } EXPORT_SYMBOL(pci_scan_root_bus);