From patchwork Sun May 26 15:53:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 2616381 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 9418AE01D7 for ; Sun, 26 May 2013 15:59:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754501Ab3EZP6e (ORCPT ); Sun, 26 May 2013 11:58:34 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:60744 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754454Ab3EZP6c (ORCPT ); Sun, 26 May 2013 11:58:32 -0400 Received: by mail-pa0-f45.google.com with SMTP id tj12so1047817pac.32 for ; Sun, 26 May 2013 08:58:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=sCtK0CsWqu+IqVoLUnBRIiRpZ6L+L0HVBROMBiwtVXY=; b=hkophpx200/yfoJ0aHVaVlzc5lBKTzBv+mRT7UrIe57PiYcwQmTvzBLp29WQFeZiht +wGeEocEgPSDsj5CN3wqDKXVqBUr/YO9brAE3tbnB7eEUtFLobZvHvNYMPRFS06J8PEk iH6/+/paVrmcCCPzk87/Vi+NhlTOPdbgdBdo/y1tVFvh374Jc+0ATNrS2hkXktoH4c9r e+ZCb5+aRQsw5OWi1rsttIfvI8Wh7B6KaHuXs+X3bVzDrTfGh5UUHZGGk6gneoInCEHu JNPJy0AMm3wx/Vyc9jiECXbj3QhoaOW5X+8X7vpy22xZ9p+FvkBp83yUAMK6F8Bqry++ 4Qiw== X-Received: by 10.68.204.98 with SMTP id kx2mr25880054pbc.26.1369583911685; Sun, 26 May 2013 08:58:31 -0700 (PDT) Received: from localhost.localdomain ([111.196.197.202]) by mx.google.com with ESMTPSA id ze11sm26603189pab.22.2013.05.26.08.58.18 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 26 May 2013 08:58:30 -0700 (PDT) From: Jiang Liu To: Bjorn Helgaas , Yinghai Lu Cc: Jiang Liu , "Rafael J . Wysocki" , Greg Kroah-Hartman , Gu Zheng , Toshi Kani , Myron Stowe , Yijing Wang , Jiang Liu , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Matthew Garrett Subject: [PATCH v3, part2 12/20] PCI, x86: use hotplug-safe iterators to walk PCI buses Date: Sun, 26 May 2013 23:53:09 +0800 Message-Id: <1369583597-3801-13-git-send-email-jiang.liu@huawei.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1369583597-3801-1-git-send-email-jiang.liu@huawei.com> References: <1369583597-3801-1-git-send-email-jiang.liu@huawei.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Enhance x86 architecture specific code to use hotplug-safe iterators to walk PCI buses. In other words, replace pci_find_bus(), pci_find_next_bus() and pci_root_buses with pci_bus_exists(), pci_get_bus(), pci_get_next_bus() and pci_get_next_root_bus() etc. Signed-off-by: Jiang Liu Acked-by: Yinghai Lu Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x86@kernel.org Cc: Myron Stowe Cc: Yijing Wang Cc: Greg Kroah-Hartman Cc: Matthew Garrett Cc: linux-kernel@vger.kernel.org --- arch/x86/pci/acpi.c | 3 ++- arch/x86/pci/common.c | 3 ++- arch/x86/pci/i386.c | 9 ++++----- arch/x86/pci/irq.c | 2 +- arch/x86/pci/legacy.c | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c index 3e72425..b972f04 100644 --- a/arch/x86/pci/acpi.c +++ b/arch/x86/pci/acpi.c @@ -526,7 +526,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) * Maybe the desired pci bus has been already scanned. In such case * it is unnecessary to scan the pci bus with the given domain,busnum. */ - bus = pci_find_bus(domain, busnum); + bus = pci_get_bus(domain, busnum); if (bus) { /* * If the desired bus exits, the content of bus->sysdata will @@ -534,6 +534,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) */ memcpy(bus->sysdata, sd, sizeof(*sd)); kfree(info); + pci_bus_put(bus); } else { probe_pci_root_info(info, device, busnum, domain); diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index 305c68b..51cc1be 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c @@ -460,8 +460,9 @@ struct pci_bus *pcibios_scan_root(int busnum) { struct pci_bus *bus = NULL; - while ((bus = pci_find_next_bus(bus)) != NULL) { + for_each_pci_root_bus(bus) { if (bus->number == busnum) { + pci_bus_put(bus); /* Already scanned */ return bus; } diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c index 94919e3..6481d25 100644 --- a/arch/x86/pci/i386.c +++ b/arch/x86/pci/i386.c @@ -343,7 +343,7 @@ static int __init pcibios_assign_resources(void) struct pci_bus *bus; if (!(pci_probe & PCI_ASSIGN_ROMS)) - list_for_each_entry(bus, &pci_root_buses, node) + for_each_pci_root_bus(bus) pcibios_allocate_rom_resources(bus); pci_assign_unassigned_resources(); @@ -371,12 +371,11 @@ void __init pcibios_resource_survey(void) DBG("PCI: Allocating resources\n"); - list_for_each_entry(bus, &pci_root_buses, node) + for_each_pci_root_bus(bus) pcibios_allocate_bus_resources(bus); - - list_for_each_entry(bus, &pci_root_buses, node) + for_each_pci_root_bus(bus) pcibios_allocate_resources(bus, 0); - list_for_each_entry(bus, &pci_root_buses, node) + for_each_pci_root_bus(bus) pcibios_allocate_resources(bus, 1); e820_reserve_resources_late(); diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c index 372e9b8..65898f6 100644 --- a/arch/x86/pci/irq.c +++ b/arch/x86/pci/irq.c @@ -137,7 +137,7 @@ static void __init pirq_peer_trick(void) } for (i = 1; i < 256; i++) { int node; - if (!busmap[i] || pci_find_bus(0, i)) + if (!busmap[i] || pci_bus_exists(0, i)) continue; node = get_mp_bus_to_node(i); if (pci_scan_bus_on_node(i, &pci_root_ops, node)) diff --git a/arch/x86/pci/legacy.c b/arch/x86/pci/legacy.c index 4db96fb..1fb7922 100644 --- a/arch/x86/pci/legacy.c +++ b/arch/x86/pci/legacy.c @@ -40,7 +40,7 @@ void pcibios_scan_specific_bus(int busn) long node; u32 l; - if (pci_find_bus(0, busn)) + if (pci_bus_exists(0, busn)) return; node = get_mp_bus_to_node(busn);