From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org, pcihpd-discuss@lists.sourceforge.net
Subject: Re: [PATCH] PCI hotplug changes for 2.5.63
Date: Mon, 24 Feb 2003 17:16 -0800 [thread overview]
Message-ID: <10461357663921@kroah.com> (raw)
In-Reply-To: <1046135763287@kroah.com>
ChangeSet 1.1022.1.8, 2003/02/24 16:28:58-08:00, rmk@arm.linux.org.uk
[PATCH] PCI: Make hot unplugging of PCI buses work
Here's the updated patch:
- Scott spotted a leak my handling of procfs wrt buses.
- I've also killed pci_remove_device() entirely - it is now inlined.
- After one of Alan's mails, I decided that pci_remove_behind_bridge()
is a much better name than pci_remove_all_bus_devices()
diff -Nru a/drivers/pci/hotplug.c b/drivers/pci/hotplug.c
--- a/drivers/pci/hotplug.c Mon Feb 24 17:15:33 2003
+++ b/drivers/pci/hotplug.c Mon Feb 24 17:15:33 2003
@@ -10,6 +10,7 @@
#define DBG(x...)
#endif
+static void pci_free_resources(struct pci_dev *dev);
#ifdef CONFIG_HOTPLUG
int pci_hotplug (struct device *dev, char **envp, int num_envp,
@@ -185,7 +186,13 @@
{
if (pci_dev_driver(dev))
return -EBUSY;
- pci_remove_device(dev);
+ device_unregister(&dev->dev);
+ list_del(&dev->bus_list);
+ list_del(&dev->global_list);
+ pci_free_resources(dev);
+#ifdef CONFIG_PROC_FS
+ pci_proc_detach_device(dev);
+#endif
return 0;
}
EXPORT_SYMBOL(pci_remove_device_safe);
@@ -233,15 +240,33 @@
}
/**
- * pci_remove_device - remove a pci device
+ * pci_remove_bus_device - remove a PCI device and any children
* @dev: the device to remove
*
- * Delete the device structure from the device lists,
- * remove the /proc entry, and notify userspace (/sbin/hotplug).
+ * Remove a PCI device from the device lists, informing the drivers
+ * that the device has been removed. We also remove any subordinate
+ * buses and children in a depth-first manner.
+ *
+ * For each device we remove, delete the device structure from the
+ * device lists, remove the /proc entry, and notify userspace
+ * (/sbin/hotplug).
*/
-void
-pci_remove_device(struct pci_dev *dev)
+void pci_remove_bus_device(struct pci_dev *dev)
{
+ if (dev->subordinate) {
+ struct pci_bus *b = dev->subordinate;
+
+ pci_remove_behind_bridge(dev);
+
+#ifdef CONFIG_PROC_FS
+ pci_proc_detach_bus(b);
+#endif
+
+ list_del(&b->node);
+ kfree(b);
+ dev->subordinate = NULL;
+ }
+
device_unregister(&dev->dev);
list_del(&dev->bus_list);
list_del(&dev->global_list);
@@ -249,9 +274,33 @@
#ifdef CONFIG_PROC_FS
pci_proc_detach_device(dev);
#endif
+
+ kfree(dev);
+}
+
+/**
+ * pci_remove_behind_bridge - remove all devices behind a PCI bridge
+ * @dev: PCI bridge device
+ *
+ * Remove all devices on the bus, except for the parent bridge.
+ * This also removes any child buses, and any devices they may
+ * contain in a depth-first manner.
+ */
+void pci_remove_behind_bridge(struct pci_dev *dev)
+{
+ struct list_head *l, *n;
+
+ if (dev->subordinate) {
+ list_for_each_safe(l, n, &dev->subordinate->devices) {
+ struct pci_dev *dev = pci_dev_b(l);
+
+ pci_remove_bus_device(dev);
+ }
+ }
}
#ifdef CONFIG_HOTPLUG
EXPORT_SYMBOL(pci_insert_device);
-EXPORT_SYMBOL(pci_remove_device);
+EXPORT_SYMBOL(pci_remove_bus_device);
+EXPORT_SYMBOL(pci_remove_behind_bridge);
#endif
diff -Nru a/include/linux/pci.h b/include/linux/pci.h
--- a/include/linux/pci.h Mon Feb 24 17:15:33 2003
+++ b/include/linux/pci.h Mon Feb 24 17:15:33 2003
@@ -645,7 +645,8 @@
int pci_register_driver(struct pci_driver *);
void pci_unregister_driver(struct pci_driver *);
void pci_insert_device(struct pci_dev *, struct pci_bus *);
-void pci_remove_device(struct pci_dev *);
+void pci_remove_bus_device(struct pci_dev *);
+void pci_remove_behind_bridge(struct pci_dev *);
struct pci_driver *pci_dev_driver(const struct pci_dev *);
const struct pci_device_id *pci_match_device(const struct pci_device_id *ids, const struct pci_dev *dev);
unsigned int pci_do_scan_bus(struct pci_bus *bus);
next prev parent reply other threads:[~2003-02-25 1:15 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-02-25 1:13 [BK PATCH] PCI hotplug changes for 2.5.63 Greg KH
2003-02-25 1:15 ` [PATCH] " Greg KH
2003-02-25 1:15 ` Greg KH
2003-02-25 1:16 ` Greg KH
2003-02-25 1:16 ` Greg KH
2003-02-25 1:16 ` Greg KH
2003-02-25 1:16 ` Greg KH
2003-02-25 1:16 ` Greg KH
2003-02-25 1:16 ` Greg KH [this message]
2003-02-25 1:16 ` Greg KH
2003-02-25 1:16 ` Greg KH
2003-02-25 1:16 ` Greg KH
2003-02-25 1:16 ` Greg KH
2003-02-25 1:16 ` Greg KH
2003-02-25 1:16 ` Greg KH
2003-02-28 23:59 ` [BK PATCH] " Greg KH
2003-03-01 18:55 ` Linus Torvalds
2003-03-01 21:38 ` Greg KH
2003-03-01 22:00 ` Linus Torvalds
2003-03-01 22:25 ` Greg KH
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=10461357663921@kroah.com \
--to=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pcihpd-discuss@lists.sourceforge.net \
/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.