public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Rajesh Shah <rajesh.shah@intel.com>
To: gregkh@suse.de, tony.luck@intel.com, matthew@wil.cx, len.brown@intel.com
Cc: linux-pci@atrey.karlin.mff.cuni.cz, linux-kernel@vger.kernel.org,
	pcihpd-discuss@lists.sourceforge.net, linux-ia64@vger.kernel.org,
	parisc-linux@parisc-linux.org
Subject: [Patch 1/12] ACPI based root bridge hot-add
Date: Fri, 18 Mar 2005 13:48:35 -0800	[thread overview]
Message-ID: <20050318134834.A1145@unix-os.sc.intel.com> (raw)
In-Reply-To: <20050318133856.A878@unix-os.sc.intel.com>; from rajesh.shah@intel.com on Fri, Mar 18, 2005 at 01:38:57PM -0800

When you hot-plug a (root) bridge hierarchy, it may have p2p
bridges and devices attached to it that have not been configured
by firmware. In this case, we need to configure the devices 
before starting them. This patch separates device start from
device scan so that we can introduce the configuration step in
the middle. 

I kept the existing semantics for pci_scan_bus() since there
are a huge number of callers to that function.

Also, I have no way of testing the changes I made to the parisc
files, so this needs review by those folks. Sorry for the massive
cross-post, this touches files in many different places.

Signed-off-by: Rajesh Shah <rajesh.shah@intel.com>
---

 linux-2.6.11-mm4-iohp-rshah1/arch/i386/pci/common.c   |    2 -
 linux-2.6.11-mm4-iohp-rshah1/arch/i386/pci/legacy.c   |    2 +
 linux-2.6.11-mm4-iohp-rshah1/arch/i386/pci/numa.c     |    2 +
 linux-2.6.11-mm4-iohp-rshah1/arch/ia64/pci/pci.c      |    2 -
 linux-2.6.11-mm4-iohp-rshah1/drivers/acpi/pci_bind.c  |   16 +++++++++++-
 linux-2.6.11-mm4-iohp-rshah1/drivers/acpi/pci_root.c  |   24 +++++++++++++++++-
 linux-2.6.11-mm4-iohp-rshah1/drivers/parisc/dino.c    |    1 
 linux-2.6.11-mm4-iohp-rshah1/drivers/parisc/lba_pci.c |    2 +
 linux-2.6.11-mm4-iohp-rshah1/drivers/pci/probe.c      |    2 -
 linux-2.6.11-mm4-iohp-rshah1/include/linux/pci.h      |    8 ++++--
 10 files changed, 53 insertions(+), 8 deletions(-)

diff -puN arch/i386/pci/common.c~pci_serparate_device_add arch/i386/pci/common.c
--- linux-2.6.11-mm4-iohp/arch/i386/pci/common.c~pci_serparate_device_add	2005-03-16 13:06:53.259117000 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/arch/i386/pci/common.c	2005-03-16 13:06:53.419273248 -0800
@@ -133,7 +133,7 @@ struct pci_bus * __devinit pcibios_scan_
 
 	printk("PCI: Probing PCI hardware (bus %02x)\n", busnum);
 
-	return pci_scan_bus(busnum, &pci_root_ops, NULL);
+	return pci_scan_bus_parented(NULL, busnum, &pci_root_ops, NULL);
 }
 
 extern u8 pci_cache_line_size;
diff -puN arch/i386/pci/legacy.c~pci_serparate_device_add arch/i386/pci/legacy.c
--- linux-2.6.11-mm4-iohp/arch/i386/pci/legacy.c~pci_serparate_device_add	2005-03-16 13:06:53.263999812 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/arch/i386/pci/legacy.c	2005-03-16 13:06:53.420249810 -0800
@@ -45,6 +45,8 @@ static int __init pci_legacy_init(void)
 
 	printk("PCI: Probing PCI hardware\n");
 	pci_root_bus = pcibios_scan_root(0);
+	if (pci_root_bus)
+		pci_bus_add_devices(pci_root_bus);
 
 	pcibios_fixup_peer_bridges();
 
diff -puN arch/i386/pci/numa.c~pci_serparate_device_add arch/i386/pci/numa.c
--- linux-2.6.11-mm4-iohp/arch/i386/pci/numa.c~pci_serparate_device_add	2005-03-16 13:06:53.267906062 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/arch/i386/pci/numa.c	2005-03-16 13:06:53.421226373 -0800
@@ -115,6 +115,8 @@ static int __init pci_numa_init(void)
 		return 0;
 
 	pci_root_bus = pcibios_scan_root(0);
+	if (pci_root_bus)
+		pci_bus_add_devices(pci_root_bus);
 	if (num_online_nodes() > 1)
 		for_each_online_node(quad) {
 			if (quad == 0)
diff -puN arch/ia64/pci/pci.c~pci_serparate_device_add arch/ia64/pci/pci.c
--- linux-2.6.11-mm4-iohp/arch/ia64/pci/pci.c~pci_serparate_device_add	2005-03-16 13:06:53.272788874 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/arch/ia64/pci/pci.c	2005-03-16 13:06:53.430991997 -0800
@@ -330,7 +330,7 @@ pci_acpi_scan_root(struct acpi_device *d
 	acpi_walk_resources(device->handle, METHOD_NAME__CRS, add_window,
 			&info);
 
-	pbus = pci_scan_bus(bus, &pci_root_ops, controller);
+	pbus = pci_scan_bus_parented(NULL, bus, &pci_root_ops, controller);
 	if (pbus)
 		pcibios_setup_root_windows(pbus, controller);
 
diff -puN drivers/acpi/pci_bind.c~pci_serparate_device_add drivers/acpi/pci_bind.c
--- linux-2.6.11-mm4-iohp/drivers/acpi/pci_bind.c~pci_serparate_device_add	2005-03-16 13:06:53.276695124 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/drivers/acpi/pci_bind.c	2005-03-16 13:06:53.431968560 -0800
@@ -129,6 +129,8 @@ acpi_pci_bind (
 	char			*pathname = NULL;
 	struct acpi_buffer	buffer = {0, NULL};
 	acpi_handle		handle = NULL;
+	struct pci_dev		*dev;
+	struct pci_bus 		*bus;
 
 	ACPI_FUNCTION_TRACE("acpi_pci_bind");
 
@@ -193,8 +195,20 @@ acpi_pci_bind (
 	 * Locate matching device in PCI namespace.  If it doesn't exist
 	 * this typically means that the device isn't currently inserted
 	 * (e.g. docking station, port replicator, etc.).
+	 * We cannot simply search the global pci device list, since
+	 * PCI devices are added to the global pci list when the root
+	 * bridge start ops are run, which may not have happened yet.
 	 */
-	data->dev = pci_find_slot(data->id.bus, PCI_DEVFN(data->id.device, data->id.function));
+	bus = pci_find_bus(data->id.segment, data->id.bus);
+	if (bus) {
+		list_for_each_entry(dev, &bus->devices, bus_list) {
+			if (dev->devfn == PCI_DEVFN(data->id.device,
+						data->id.function)) {
+				data->dev = dev;
+				break;
+			}
+		}
+	}
 	if (!data->dev) {
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
 			"Device %02x:%02x:%02x.%02x not present in PCI namespace\n",
diff -puN drivers/acpi/pci_root.c~pci_serparate_device_add drivers/acpi/pci_root.c
--- linux-2.6.11-mm4-iohp/drivers/acpi/pci_root.c~pci_serparate_device_add	2005-03-16 13:06:53.281577937 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/drivers/acpi/pci_root.c	2005-03-16 13:06:53.432945122 -0800
@@ -46,6 +46,7 @@ ACPI_MODULE_NAME		("pci_root")
 
 static int acpi_pci_root_add (struct acpi_device *device);
 static int acpi_pci_root_remove (struct acpi_device *device, int type);
+static int acpi_pci_root_start (struct acpi_device *device);
 
 static struct acpi_driver acpi_pci_root_driver = {
 	.name =		ACPI_PCI_ROOT_DRIVER_NAME,
@@ -54,6 +55,7 @@ static struct acpi_driver acpi_pci_root_
 	.ops =		{
 				.add =    acpi_pci_root_add,
 				.remove = acpi_pci_root_remove,
+				.start =  acpi_pci_root_start,
 			},
 };
 
@@ -169,6 +171,7 @@ acpi_pci_root_add (
 	if (!root)
 		return_VALUE(-ENOMEM);
 	memset(root, 0, sizeof(struct acpi_pci_root));
+	INIT_LIST_HEAD(&root->node);
 
 	root->handle = device->handle;
 	strcpy(acpi_device_name(device), ACPI_PCI_ROOT_DEVICE_NAME);
@@ -298,12 +301,31 @@ acpi_pci_root_add (
 			root->id.bus);
 
 end:
-	if (result)
+	if (result) {
+		if (!list_empty(&root->node))
+			list_del(&root->node);
 		kfree(root);
+	}
 
 	return_VALUE(result);
 }
 
+static int
+acpi_pci_root_start (
+	struct acpi_device	*device)
+{
+	struct acpi_pci_root	*root;
+
+	ACPI_FUNCTION_TRACE("acpi_pci_root_start");
+
+	list_for_each_entry(root, &acpi_pci_roots, node) {
+		if (root->handle == device->handle) {
+			pci_bus_add_devices(root->bus);
+			return_VALUE(0);
+		}
+	}
+	return_VALUE(-ENODEV);
+}
 
 static int
 acpi_pci_root_remove (
diff -puN drivers/parisc/dino.c~pci_serparate_device_add drivers/parisc/dino.c
--- linux-2.6.11-mm4-iohp/drivers/parisc/dino.c~pci_serparate_device_add	2005-03-16 13:06:53.285484187 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/drivers/parisc/dino.c	2005-03-16 13:06:53.433921685 -0800
@@ -993,6 +993,7 @@ dino_driver_callback(struct parisc_devic
 	bus = pci_scan_bus_parented(&dev->dev, dino_current_bus,
 				    &dino_cfg_ops, NULL);
 	if(bus) {
+		pci_bus_add_devices(bus);
 		/* This code *depends* on scanning being single threaded
 		 * if it isn't, this global bus number count will fail
 		 */
diff -puN drivers/parisc/lba_pci.c~pci_serparate_device_add drivers/parisc/lba_pci.c
--- linux-2.6.11-mm4-iohp/drivers/parisc/lba_pci.c~pci_serparate_device_add	2005-03-16 13:06:53.290366999 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/drivers/parisc/lba_pci.c	2005-03-16 13:06:53.435874810 -0800
@@ -1570,6 +1570,8 @@ lba_driver_probe(struct parisc_device *d
 	lba_bus = lba_dev->hba.hba_bus =
 		pci_scan_bus_parented(&dev->dev, lba_dev->hba.bus_num.start,
 				cfg_ops, NULL);
+	if (lba_bus)
+		pci_bus_add_devices(lba_bus);
 
 	/* This is in lieu of calling pci_assign_unassigned_resources() */
 	if (is_pdc_pat()) {
diff -puN drivers/pci/probe.c~pci_serparate_device_add drivers/pci/probe.c
--- linux-2.6.11-mm4-iohp/drivers/pci/probe.c~pci_serparate_device_add	2005-03-16 13:06:53.294273249 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/drivers/pci/probe.c	2005-03-16 13:06:53.436851372 -0800
@@ -916,8 +916,6 @@ struct pci_bus * __devinit pci_scan_bus_
 
 	b->subordinate = pci_scan_child_bus(b);
 
-	pci_bus_add_devices(b);
-
 	return b;
 
 sys_create_link_err:
diff -puN include/linux/pci.h~pci_serparate_device_add include/linux/pci.h
--- linux-2.6.11-mm4-iohp/include/linux/pci.h~pci_serparate_device_add	2005-03-16 13:06:53.299156062 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/include/linux/pci.h	2005-03-16 13:06:53.449546685 -0800
@@ -732,16 +732,20 @@ void pcibios_update_irq(struct pci_dev *
 /* Generic PCI functions used internally */
 
 extern struct pci_bus *pci_find_bus(int domain, int busnr);
+void pci_bus_add_devices(struct pci_bus *bus);
 struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus, struct pci_ops *ops, void *sysdata);
 static inline struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata)
 {
-	return pci_scan_bus_parented(NULL, bus, ops, sysdata);
+	struct pci_bus *root_bus;
+	root_bus = pci_scan_bus_parented(NULL, bus, ops, sysdata);
+	if (root_bus)
+		pci_bus_add_devices(root_bus);
+	return root_bus;
 }
 int pci_scan_slot(struct pci_bus *bus, int devfn);
 struct pci_dev * pci_scan_single_device(struct pci_bus *bus, int devfn);
 unsigned int pci_scan_child_bus(struct pci_bus *bus);
 void pci_bus_add_device(struct pci_dev *dev);
-void pci_bus_add_devices(struct pci_bus *bus);
 void pci_name_device(struct pci_dev *dev);
 char *pci_class_name(u32 class);
 void pci_read_bridge_bases(struct pci_bus *child);
_

  reply	other threads:[~2005-03-18 21:49 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-18 21:38 [RFC/Patch 0/12] ACPI based root bridge hot-add Rajesh Shah
2005-03-18 21:48 ` Rajesh Shah [this message]
2005-03-18 21:59 ` [Patch 2/12] Fix pci_enable_device() for p2p bridges Rajesh Shah
2005-03-18 22:02 ` [patch 03/12] Make pcibios_fixup_bus() hot-plug safe Rajesh Shah
2005-03-18 22:04 ` [patch 04/12] Prevent duplicate bus numbers when scanning PCI bridge Rajesh Shah
2005-03-18 22:07 ` [patch 05/12] Take the PCI lock when modifying pci bus or device lists Rajesh Shah
2005-03-18 22:09 ` [patch 06/12] Link newly created pci child bus to its parent on creation Rajesh Shah
2005-03-18 22:11 ` [patch 07/12] Make the PCI remove routines safe for failed hot-plug Rajesh Shah
2005-03-19  5:14   ` Greg KH
2005-03-18 22:14 ` [patch 08/12] Remove hot-plugged devices that could not be allocated resources Rajesh Shah
2005-03-18 22:16 ` [patch 09/12] Read bridge resources when fixing up the bus Rajesh Shah
2005-03-18 22:18 ` [patch 10/12] Allow ACPI .add and .start operations to be done independently Rajesh Shah
2005-03-18 22:20 ` [patch 11/12] Export the interface to get PCI id for an ACPI handle Rajesh Shah
2005-03-18 22:22 ` [patch 12/12] ACPI based root bridge hot-add Rajesh Shah
2005-03-19  5:13 ` [RFC/Patch 0/12] " Greg KH
2005-03-21 18:04   ` Rajesh Shah
2005-03-21 18:27     ` Greg KH
2005-03-31 19:06       ` Len Brown
2005-03-19 13:50 ` Paul Ionescu
2005-03-21 19:14   ` [ACPI] " Rajesh Shah

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=20050318134834.A1145@unix-os.sc.intel.com \
    --to=rajesh.shah@intel.com \
    --cc=gregkh@suse.de \
    --cc=len.brown@intel.com \
    --cc=linux-ia64@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@atrey.karlin.mff.cuni.cz \
    --cc=matthew@wil.cx \
    --cc=parisc-linux@parisc-linux.org \
    --cc=pcihpd-discuss@lists.sourceforge.net \
    --cc=tony.luck@intel.com \
    /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