linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Taku Izumi <izumi.taku@jp.fujitsu.com>
To: Taku Izumi <izumi.taku@jp.fujitsu.com>
Cc: linux-pci@vger.kernel.org, bhelgaas@google.com,
	linux-acpi@vger.kernel.org, kaneshige.kenji@jp.fujitsu.com,
	yinghai@kernel.org, jiang.liu@huawei.com
Subject: [PATCH 6/7][RESEND] ACPI, PCI: add hostbridge removal function
Date: Fri, 10 Aug 2012 15:14:55 +0900	[thread overview]
Message-ID: <20120810151455.d881caf4.izumi.taku@jp.fujitsu.com> (raw)
In-Reply-To: <20120810150955.e4ab3c7f.izumi.taku@jp.fujitsu.com>


Currently there's no PCI-related clean-up code
in acpi_pci_root_remove() function.
This patch introduces function for hostbridge removal.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
---
 drivers/acpi/pci_bind.c     |    7 +++++++
 drivers/acpi/pci_root.c     |    8 ++++++++
 drivers/pci/remove.c        |   18 +++++++++++++++++-
 include/acpi/acpi_drivers.h |    1 +
 include/linux/pci.h         |    2 ++
 5 files changed, 35 insertions(+), 1 deletion(-)

Index: Bjorn-next-0718/drivers/pci/remove.c
===================================================================
--- Bjorn-next-0718.orig/drivers/pci/remove.c
+++ Bjorn-next-0718/drivers/pci/remove.c
@@ -143,7 +143,7 @@ void pci_stop_and_remove_behind_bridge(s
 	__pci_remove_behind_bridge(dev);
 }
 
-static void pci_stop_bus_devices(struct pci_bus *bus)
+void pci_stop_bus_devices(struct pci_bus *bus)
 {
 	struct list_head *l, *n;
 
@@ -179,4 +179,20 @@ void pci_stop_bus_device(struct pci_dev 
 
 EXPORT_SYMBOL(pci_stop_and_remove_bus_device);
 EXPORT_SYMBOL(pci_stop_and_remove_behind_bridge);
+EXPORT_SYMBOL(pci_stop_bus_devices);
 EXPORT_SYMBOL_GPL(pci_stop_bus_device);
+
+void pci_remove_host_bridge(struct pci_host_bridge *bridge)
+{
+	struct list_head *l, *n;
+	struct pci_bus *root = bridge->bus;
+
+	list_for_each_safe(l, n, &root->devices)
+		__pci_remove_bus_device(pci_dev_b(l));
+
+	pci_remove_bus(root);
+
+	device_unregister(&bridge->dev);
+}
+EXPORT_SYMBOL(pci_remove_host_bridge);
+
Index: Bjorn-next-0718/drivers/acpi/pci_root.c
===================================================================
--- Bjorn-next-0718.orig/drivers/acpi/pci_root.c
+++ Bjorn-next-0718/drivers/acpi/pci_root.c
@@ -656,9 +656,12 @@ static int acpi_pci_root_remove(struct a
 {
 	struct acpi_pci_root *root = acpi_driver_data(device);
 	struct acpi_pci_driver *driver;
+	struct pci_host_bridge *bridge = to_pci_host_bridge(root->bus->bridge);
 
 	mutex_lock(&acpi_pci_root_lock);
 
+	pci_stop_bus_devices(root->bus);
+
 	list_for_each_entry(driver, &acpi_pci_drivers, node)
 		if (driver->remove)
 			driver->remove(root->device->handle);
@@ -666,6 +669,11 @@ static int acpi_pci_root_remove(struct a
 	device_set_run_wake(root->bus->bridge, false);
 	pci_acpi_remove_bus_pm_notifier(device);
 
+	acpi_pci_irq_del_prt(root->bus);
+	acpi_pci_unbind_root(device);
+
+	pci_remove_host_bridge(bridge);
+
 	list_del_rcu(&root->node);
 	mutex_unlock(&acpi_pci_root_lock);
 	synchronize_rcu();
Index: Bjorn-next-0718/include/linux/pci.h
===================================================================
--- Bjorn-next-0718.orig/include/linux/pci.h
+++ Bjorn-next-0718/include/linux/pci.h
@@ -736,7 +736,9 @@ extern void pci_dev_put(struct pci_dev *
 extern void pci_remove_bus(struct pci_bus *b);
 extern void __pci_remove_bus_device(struct pci_dev *dev);
 extern void pci_stop_and_remove_bus_device(struct pci_dev *dev);
+extern void pci_stop_bus_devices(struct pci_bus *bus);
 extern void pci_stop_bus_device(struct pci_dev *dev);
+extern void pci_remove_host_bridge(struct pci_host_bridge *bridge);
 void pci_setup_cardbus(struct pci_bus *bus);
 extern void pci_sort_breadthfirst(void);
 #define dev_is_pci(d) ((d)->bus == &pci_bus_type)
Index: Bjorn-next-0718/drivers/acpi/pci_bind.c
===================================================================
--- Bjorn-next-0718.orig/drivers/acpi/pci_bind.c
+++ Bjorn-next-0718/drivers/acpi/pci_bind.c
@@ -118,3 +118,10 @@ int acpi_pci_bind_root(struct acpi_devic
 
 	return 0;
 }
+
+void  acpi_pci_unbind_root(struct acpi_device *device)
+{
+	device->ops.bind = NULL;
+	device->ops.unbind = NULL;
+}
+
Index: Bjorn-next-0718/include/acpi/acpi_drivers.h
===================================================================
--- Bjorn-next-0718.orig/include/acpi/acpi_drivers.h
+++ Bjorn-next-0718/include/acpi/acpi_drivers.h
@@ -101,6 +101,7 @@ struct pci_bus;
 
 struct pci_dev *acpi_get_pci_dev(acpi_handle);
 int acpi_pci_bind_root(struct acpi_device *device);
+void acpi_pci_unbind_root(struct acpi_device *device);
 
 /* Arch-defined function to add a bus to the system */
 


  parent reply	other threads:[~2012-08-10  6:15 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-10  6:09 [PATCH 0/7][RESEND] acpi, pci: hostbridge hotplug support Taku Izumi
2012-08-10  6:11 ` [PATCH 1/7][RESEND] x86, PCI: Fix non acpi path pci_sysdata leaking with release_fn Taku Izumi
2012-08-16 16:42   ` Bjorn Helgaas
2012-08-10  6:12 ` [PATCH 2/7][RESEND] PCI: Correctly clean up pci root buses in function pci_remove_bus() Taku Izumi
2012-08-16 17:11   ` Bjorn Helgaas
2012-08-30 15:43     ` Jiang Liu
2012-08-10  6:12 ` [PATCH 3/7][RESEND] ACPI, PCI: Use normal list for struct acpi_pci_driver Taku Izumi
2012-08-10  6:13 ` [PATCH 4/7][RESEND] ACPI, PCI: Notify acpi_pci_drivers when hot-plugging PCI root bridges Taku Izumi
2012-08-10  6:14 ` [PATCH 5/7][RESEND] ACPI, PCI: Protect global lists in drivers/acpi/pci_root.c Taku Izumi
2012-08-16 17:25   ` Bjorn Helgaas
2012-08-10  6:14 ` Taku Izumi [this message]
2012-08-10  6:15 ` [PATCH 7/7][RESEND] ACPI, PCI: add resoruce-assign code for devices under hot-added hostbridge Taku Izumi
2012-08-10 16:41 ` [PATCH 0/7][RESEND] acpi, pci: hostbridge hotplug support Yinghai Lu
2012-08-20  5:02   ` Taku Izumi
2012-08-30  6:23 ` Bjorn Helgaas
2012-08-30  6:33   ` Jiang Liu
2012-08-30 15:48   ` Yinghai Lu
2012-08-30 16:38     ` Jiang Liu
2012-08-30 17:29       ` Yinghai Lu
2012-08-31  0:43     ` Bjorn Helgaas
2012-08-31  1:03       ` Jiang Liu
2012-08-31  5:04         ` Bjorn Helgaas
2012-08-31  5:19           ` Jiang Liu
2012-08-31  5:42             ` Bjorn Helgaas
2012-08-31 16:44               ` Yinghai Lu
2012-09-01  3:56                 ` Jiang Liu
2012-09-03  2:28   ` Taku Izumi
2012-09-03  4:04     ` Jiang Liu

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=20120810151455.d881caf4.izumi.taku@jp.fujitsu.com \
    --to=izumi.taku@jp.fujitsu.com \
    --cc=bhelgaas@google.com \
    --cc=jiang.liu@huawei.com \
    --cc=kaneshige.kenji@jp.fujitsu.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-pci@vger.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).