mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bjorn Helgaas <bhelgaas@google.com>
To: linux-pci@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 04/12] x86/PCI: supply root bus resources to pci_create_bus()
Date: Mon, 10 Oct 2011 21:18:46 -0600	[thread overview]
Message-ID: <20111011031846.5149.27532.stgit@bhelgaas.mtv.corp.google.com> (raw)
In-Reply-To: <20111011030726.5149.23793.stgit@bhelgaas.mtv.corp.google.com>

Parse ACPI host bridge _CRS resources first, so we can build a list of
resources available on the root bus and pass it to pci_create_bus().

Note that as before, we parse the ACPI _CRS even if we aren't paying
attention to it so we can print it for debugging purposes.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/x86/pci/acpi.c |   41 ++++++++++++++++++++++++++---------------
 1 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 9bf7aaa..6269545 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -12,7 +12,7 @@ struct pci_root_info {
 	char *name;
 	unsigned int res_num;
 	struct resource *res;
-	struct pci_bus *bus;
+	struct list_head *resources;
 	int busnum;
 };
 
@@ -250,27 +250,27 @@ static void add_resources(struct pci_root_info *info)
 				 "ignoring host bridge window %pR (conflicts with %s %pR)\n",
 				 res, conflict->name, conflict);
 		else
-			pci_bus_add_resource(info->bus, res, 0);
+			pci_add_resource(info->resources, res);
 	}
 }
 
-static void
-get_current_resources(struct acpi_device *device, int busnum,
-			int domain, struct pci_bus *bus)
+static struct list_head *
+get_current_resources(struct acpi_device *device, int busnum, int domain)
 {
 	struct pci_root_info info;
 	size_t size;
 
-	if (pci_use_crs)
-		pci_bus_remove_resources(bus);
-
 	info.bridge = device;
-	info.bus = bus;
 	info.res_num = 0;
+	info.resources = kmalloc(sizeof(struct list_head), GFP_KERNEL);
+	if (!info.resources)
+		return NULL;
+
+	INIT_LIST_HEAD(info.resources);
 	acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_resource,
 				&info);
 	if (!info.res_num)
-		return;
+		goto res_alloc_fail;
 
 	size = sizeof(*info.res) * info.res_num;
 	info.res = kmalloc(size, GFP_KERNEL);
@@ -286,12 +286,12 @@ get_current_resources(struct acpi_device *device, int busnum,
 				&info);
 
 	add_resources(&info);
-	return;
+	return info.resources;
 
 name_alloc_fail:
 	kfree(info.res);
 res_alloc_fail:
-	return;
+	return info.resources;
 }
 
 struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
@@ -299,6 +299,7 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
 	struct acpi_device *device = root->device;
 	int domain = root->segment;
 	int busnum = root->secondary.start;
+	struct list_head *resources;
 	struct pci_bus *bus;
 	struct pci_sysdata *sd;
 	int node;
@@ -353,11 +354,21 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
 		memcpy(bus->sysdata, sd, sizeof(*sd));
 		kfree(sd);
 	} else {
-		bus = pci_create_bus(NULL, busnum, &pci_root_ops, sd, NULL);
-		if (bus) {
-			get_current_resources(device, busnum, domain, bus);
+		resources = get_current_resources(device, busnum, domain);
+		if (!pci_use_crs) {
+			pci_free_resource_list(resources);
+			resources = NULL;
+		}
+
+		bus = pci_create_bus(NULL, busnum, &pci_root_ops, sd,
+				     resources);
+		if (bus)
 			bus->subordinate = pci_scan_child_bus(bus);
+		else {
+			if (resources)
+				pci_free_resource_list(resources);
 		}
+		kfree(resources);
 	}
 
 	/* After the PCI-E bus has been walked and all devices discovered,


  parent reply	other threads:[~2011-10-11  3:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-11  3:18 [RFC PATCH 00/12] Create PCI root buses with correct resources Bjorn Helgaas
2011-10-11  3:18 ` [PATCH 01/12] PCI: add helpers for building PCI bus resource lists Bjorn Helgaas
2011-10-11  3:18 ` [PATCH 02/12] PCI: pass available resources into pci_create_bus() Bjorn Helgaas
2011-10-11  3:18 ` [PATCH 03/12] MIPS: PCI: supply root bus resources to pci_create_bus() Bjorn Helgaas
2011-10-11  3:18 ` Bjorn Helgaas [this message]
2011-10-11  3:18 ` [PATCH 05/12] powerpc/pci: make pcibios_setup_phb_resources() static Bjorn Helgaas
2011-10-11  3:18 ` [PATCH 06/12] powerpc/pci: split PHB part out of pcibios_map_io_space() Bjorn Helgaas
2011-10-11  3:19 ` [PATCH 07/12] powerpc/pci: supply root bus resources to pci_create_bus() Bjorn Helgaas
2011-10-11  3:19 ` [PATCH 08/12] microblaze/pci: make pcibios_setup_phb_resources() static Bjorn Helgaas
2011-10-11  3:19 ` [PATCH 09/12] microblaze/pci: supply root bus resources to pci_create_bus() Bjorn Helgaas
2011-10-11  3:19 ` [PATCH 10/12] sparc/pci: " Bjorn Helgaas
2011-10-11  3:33   ` David Miller
2011-10-11  3:19 ` [PATCH 11/12] sparc/pci: use pci_create_bus() instead of pci_scan_bus_parented() Bjorn Helgaas
2011-10-11  3:19 ` [PATCH 12/12] sparc/pci: supply root bus resources to pci_create_bus() Bjorn Helgaas
2011-10-11  3:33   ` David Miller

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=20111011031846.5149.27532.stgit@bhelgaas.mtv.corp.google.com \
    --to=bhelgaas@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.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

all inboxes | Powered by JetHome®