linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiang Liu <liuj97@gmail.com>
To: Bjorn Helgaas <bhelgaas@google.com>, Yinghai Lu <yinghai@kernel.org>
Cc: Jiang Liu <jiang.liu@huawei.com>,
	"Rafael J . Wysocki" <rjw@sisk.pl>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Gu Zheng <guz.fnst@cn.fujitsu.com>,
	Toshi Kani <toshi.kani@hp.com>,
	Myron Stowe <myron.stowe@redhat.com>,
	Yijing Wang <wangyijing@huawei.com>, Jiang Liu <liuj97@gmail.com>,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, Matthew Garrett <mjg@redhat.com>
Subject: [RFC PATCH v2, part 2 11/18] PCI, x86: use hotplug-safe iterators to walk PCI buses
Date: Wed, 15 May 2013 00:51:55 +0800	[thread overview]
Message-ID: <1368550322-1045-11-git-send-email-jiang.liu@huawei.com> (raw)
In-Reply-To: <1368550322-1045-1-git-send-email-jiang.liu@huawei.com>

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 <jiang.liu@huawei.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Cc: Myron Stowe <myron.stowe@redhat.com>
Cc: Yijing Wang <wangyijing@huawei.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Matthew Garrett <mjg@redhat.com>
Cc: Yinghai Lu <yinghai@kernel.org>
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);
-- 
1.8.1.2


  parent reply	other threads:[~2013-05-14 16:53 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-14 16:51 [RFC PATCH v2, part 2 01/18] PCI: introduce hotplug-safe PCI bus iterators Jiang Liu
2013-05-14 16:51 ` [RFC PATCH v2, part 2 02/18] PCI, core: use hotplug-safe iterators to walk PCI buses Jiang Liu
2013-05-14 18:55   ` Yinghai Lu
2013-05-14 16:51 ` [RFC PATCH v2, part 2 03/18] PCI, hotplug: " Jiang Liu
2013-05-14 18:57   ` Yinghai Lu
2013-05-14 16:51 ` [RFC PATCH v2, part 2 04/18] PCI, Alpha: " Jiang Liu
2013-05-14 16:51 ` [RFC PATCH v2, part 2 05/18] PCI, FRV: " Jiang Liu
2013-05-14 16:51 ` [RFC PATCH v2, part 2 06/18] PCI, IA64: " Jiang Liu
2013-05-14 16:51 ` [RFC PATCH v2, part 2 07/18] PCI, Microblaze: " Jiang Liu
2013-05-14 16:51 ` [RFC PATCH v2, part 2 08/18] PCI, mn10300: " Jiang Liu
2013-05-14 16:51 ` [RFC PATCH v2, part 2 09/18] PCI, PPC: " Jiang Liu
2013-05-14 23:30   ` Benjamin Herrenschmidt
2013-05-15 15:07     ` Liu Jiang
2013-05-15 15:17     ` Jiang Liu
2013-05-14 16:51 ` [RFC PATCH v2, part 2 10/18] PCI, SPARC: " Jiang Liu
2013-05-14 16:51 ` Jiang Liu [this message]
2013-05-14 18:59   ` [RFC PATCH v2, part 2 11/18] PCI, x86: " Yinghai Lu
2013-05-14 16:51 ` [RFC PATCH v2, part 2 12/18] PCI, ACPI: " Jiang Liu
2013-05-14 20:28   ` Rafael J. Wysocki
2013-05-14 16:51 ` [RFC PATCH v2, part 2 13/18] PCI, DRM: " Jiang Liu
2013-05-14 16:51 ` [RFC PATCH v2, part 2 14/18] PCI, EDAC: use hotplug-safe PCI bus " Jiang Liu
2013-05-22  4:12   ` Gu Zheng
2013-05-25 15:18     ` Liu Jiang
2013-05-14 16:51 ` [RFC PATCH v2, part 2 15/18] PCI, via-camera: use hotplug-safe " Jiang Liu
2013-05-14 16:52 ` [RFC PATCH v2, part 2 16/18] PCI, iommu: " Jiang Liu
2013-05-14 22:13   ` Don Dutile
2013-05-15 15:36     ` Liu Jiang
2013-05-14 16:52 ` [RFC PATCH v2, part 2 17/18] PCI, eeepc-laptop: " Jiang Liu
2013-05-14 16:52 ` [RFC PATCH v2, part 2 18/18] PCI, asus-wmi: " Jiang Liu
2013-05-14 17:05 ` [RFC PATCH v2, part 2 01/18] PCI: introduce hotplug-safe PCI bus iterators Greg Kroah-Hartman
2013-05-15 14:42   ` Liu Jiang
2013-05-15 14:51   ` Liu Jiang
2013-05-14 18:56 ` Yinghai Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1368550322-1045-11-git-send-email-jiang.liu@huawei.com \
    --to=liuj97@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=guz.fnst@cn.fujitsu.com \
    --cc=hpa@zytor.com \
    --cc=jiang.liu@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=mjg@redhat.com \
    --cc=myron.stowe@redhat.com \
    --cc=rjw@sisk.pl \
    --cc=tglx@linutronix.de \
    --cc=toshi.kani@hp.com \
    --cc=wangyijing@huawei.com \
    --cc=x86@kernel.org \
    --cc=yinghai@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).