From patchwork Sun Jan 27 19:23:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 2052221 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 2E8593FD49 for ; Sun, 27 Jan 2013 19:24:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755365Ab3A0TYW (ORCPT ); Sun, 27 Jan 2013 14:24:22 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:32312 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755388Ab3A0TYW (ORCPT ); Sun, 27 Jan 2013 14:24:22 -0500 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r0RJOBXA009086 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 27 Jan 2013 19:24:12 GMT Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r0RJOAjP000053 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 27 Jan 2013 19:24:11 GMT Received: from abhmt120.oracle.com (abhmt120.oracle.com [141.146.116.72]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id r0RJOAuC018586; Sun, 27 Jan 2013 13:24:10 -0600 Received: from linux-siqj.site (/75.36.243.194) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 27 Jan 2013 11:24:10 -0800 From: Yinghai Lu To: Bjorn Helgaas , Jiang Liu , "Rafael J. Wysocki" , Taku Izumi , Toshi Kani Cc: "Greg Kroah-Hartman" , linux-pci@vger.kernel.org, Yinghai Lu Subject: [PATCH v3 12/22] PCI: Kill pci_root_buses in setup-bus Date: Sun, 27 Jan 2013 11:23:39 -0800 Message-Id: <1359314629-18651-13-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1359314629-18651-1-git-send-email-yinghai@kernel.org> References: <1359314629-18651-1-git-send-email-yinghai@kernel.org> X-Source-IP: ucsinet21.oracle.com [156.151.31.93] Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Replace that with hotplug-safe version iteration. Signed-off-by: Yinghai Lu --- drivers/pci/setup-bus.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 7e8739e..8c0870b 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -1318,12 +1318,12 @@ static int __init pci_bus_get_depth(struct pci_bus *bus) static int __init pci_get_max_depth(void) { int depth = 0; - struct pci_bus *bus; + struct pci_host_bridge *host_bridge = NULL; - list_for_each_entry(bus, &pci_root_buses, node) { + for_each_pci_host_bridge(host_bridge) { int ret; - ret = pci_bus_get_depth(bus); + ret = pci_bus_get_depth(host_bridge->bus); if (ret > depth) depth = ret; } @@ -1393,6 +1393,7 @@ void __init pci_assign_unassigned_resources(void) { struct pci_bus *bus; + struct pci_host_bridge *host_bridge = NULL; LIST_HEAD(realloc_head); /* list of resources that want additional resources */ struct list_head *add_list = NULL; @@ -1423,12 +1424,13 @@ again: add_list = &realloc_head; /* Depth first, calculate sizes and alignments of all subordinate buses. */ - list_for_each_entry(bus, &pci_root_buses, node) - __pci_bus_size_bridges(bus, add_list); + for_each_pci_host_bridge(host_bridge) + __pci_bus_size_bridges(host_bridge->bus, add_list); /* Depth last, allocate resources and update the hardware. */ - list_for_each_entry(bus, &pci_root_buses, node) - __pci_bus_assign_resources(bus, add_list, &fail_head); + for_each_pci_host_bridge(host_bridge) + __pci_bus_assign_resources(host_bridge->bus, add_list, + &fail_head); if (add_list) BUG_ON(!list_empty(add_list)); tried_times++; @@ -1480,12 +1482,12 @@ again: enable_and_dump: /* Depth last, update the hardware. */ - list_for_each_entry(bus, &pci_root_buses, node) - pci_enable_bridges(bus); + for_each_pci_host_bridge(host_bridge) + pci_enable_bridges(host_bridge->bus); /* dump the resource on buses */ - list_for_each_entry(bus, &pci_root_buses, node) - pci_bus_dump_resources(bus); + for_each_pci_host_bridge(host_bridge) + pci_bus_dump_resources(host_bridge->bus); } void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge)