All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yinghai Lu <yinghai@kernel.org>
To: Bjorn Helgaas <bhelgaas@google.com>,
	Taku Izumi <izumi.taku@jp.fujitsu.com>,
	Jiang Liu <jiang.liu@huawei.com>, x86 <x86@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-acpi@vger.kernel.org, Yinghai Lu <yinghai@kernel.org>
Subject: [PATCH part4 03/11] PCI: Add pci_stop_and_remove_bus()
Date: Sun,  2 Sep 2012 14:54:13 -0700	[thread overview]
Message-ID: <1346622861-30865-4-git-send-email-yinghai@kernel.org> (raw)
In-Reply-To: <1346622861-30865-1-git-send-email-yinghai@kernel.org>

It supports both pci root bus and pci bus under pci bridge.

-v2: clear pci_bridge's subordinate.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 drivers/pci/remove.c |   32 ++++++++++++++++++++++++++++++++
 include/linux/pci.h  |    1 +
 2 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c
index b9f553b..94407d4 100644
--- a/drivers/pci/remove.c
+++ b/drivers/pci/remove.c
@@ -136,3 +136,35 @@ void pci_stop_and_remove_behind_bridge(struct pci_dev *dev)
 	if (dev->subordinate)
 		pci_remove_bus_devices(dev->subordinate);
 }
+
+static void pci_stop_host_bridge(struct pci_host_bridge *bridge)
+{
+	device_unregister(&bridge->dev);
+}
+/*
+ * it will support pci root bus too, in that case we need
+ *  stop and remove host bridge
+ */
+void pci_stop_and_remove_bus(struct pci_bus *bus)
+{
+	struct pci_host_bridge *host_bridge = NULL;
+	struct pci_dev *pci_bridge = NULL;
+
+	pci_stop_bus_devices(bus);
+
+	if (pci_is_root_bus(bus)) {
+		host_bridge = to_pci_host_bridge(bus->bridge);
+		pci_stop_host_bridge(host_bridge);
+	} else
+		pci_bridge = bus->self;
+
+	pci_remove_bus_devices(bus);
+
+	pci_remove_bus(bus);
+
+	if (host_bridge)
+		host_bridge->bus = NULL;
+
+	if (pci_bridge)
+		pci_bridge->subordinate = NULL;
+}
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 4446448..8b2c722 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -738,6 +738,7 @@ extern void pci_remove_bus(struct pci_bus *b);
 extern void pci_stop_and_remove_bus_device(struct pci_dev *dev);
 void pci_stop_bus_devices(struct pci_bus *bus);
 void pci_stop_and_remove_behind_bridge(struct pci_dev *dev);
+void pci_stop_and_remove_bus(struct pci_bus *bus);
 void pci_setup_cardbus(struct pci_bus *bus);
 extern void pci_sort_breadthfirst(void);
 #define dev_is_pci(d) ((d)->bus == &pci_bus_type)
-- 
1.7.7

  parent reply	other threads:[~2012-09-02 21:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-02 21:54 [PATCH part4 00/11] PCI, ACPI: pci root bus hotplug support - part4 Yinghai Lu
2012-09-02 21:54 ` [PATCH part4 01/11] PCI: Fix a device reference count leakage issue in pci_dev_present() Yinghai Lu
2012-09-02 21:54 ` [PATCH part4 02/11] PCI: Correctly clean up pci root buses in function pci_remove_bus() Yinghai Lu
2012-09-02 21:54 ` Yinghai Lu [this message]
2012-09-02 21:54 ` [PATCH part4 04/11] PCI: Fix an access-after-free issue in function pci_stop_and_remove_bus() Yinghai Lu
2012-09-02 21:54 ` [PATCH part4 05/11] PCI, acpiphp: Separate out hot-add support of pci host bridge Yinghai Lu
2012-09-02 21:54 ` [PATCH part4 06/11] PCI, ACPI: Make acpi_pci_root_remove remove pci root bus too Yinghai Lu
2012-09-02 21:54 ` [PATCH part4 07/11] PCI, ACPI: Add pci_root_hp hot removal notification support Yinghai Lu
2012-09-02 21:54 ` [PATCH part4 08/11] PCI, ACPI: Add alloc_acpi_hp_work() Yinghai Lu
2012-09-02 21:54 ` [PATCH part4 09/11] PCI, acpiphp: Use acpi_hp_work Yinghai Lu
2012-09-02 21:54 ` [PATCH part4 10/11] PCI, pci_root_hp: " Yinghai Lu
2012-09-02 21:54 ` [PATCH part4 11/11] PCI, ACPI: Make kacpi_hotplug_wq static 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=1346622861-30865-4-git-send-email-yinghai@kernel.org \
    --to=yinghai@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=bhelgaas@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=izumi.taku@jp.fujitsu.com \
    --cc=jiang.liu@huawei.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=x86@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.