From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, linux-pci@atrey.karlin.mff.cuni.cz
Cc: johnrose@austin.ibm.com
Subject: [PATCH] [PATCH] remove redundant devices list
Date: Fri, 1 Apr 2005 15:47:51 -0800 [thread overview]
Message-ID: <11123992711084@kroah.com> (raw)
In-Reply-To: <11123992711877@kroah.com>
ChangeSet 1.2181.16.12, 2005/03/17 14:31:26-08:00, johnrose@austin.ibm.com
[PATCH] [PATCH] remove redundant devices list
The RPA PCI Hotplug module creates and maintains a list of devices for
each slot. This is redundant, because the PCI structures already
maintain such a list. This patch changes the module to use the list
provided in the pci_bus structure.
Signed-off-by: John Rose <johnrose@austin.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/pci/hotplug/rpaphp.h | 2
drivers/pci/hotplug/rpaphp_pci.c | 105 +++++++-------------------------------
drivers/pci/hotplug/rpaphp_slot.c | 11 ---
3 files changed, 22 insertions(+), 96 deletions(-)
diff -Nru a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h
--- a/drivers/pci/hotplug/rpaphp.h 2005-04-01 15:36:22 -08:00
+++ b/drivers/pci/hotplug/rpaphp.h 2005-04-01 15:36:22 -08:00
@@ -94,7 +94,7 @@
/* dn has phb info */
struct pci_dev *bridge; /* slot's pci_dev in pci_devices */
union {
- struct list_head pci_funcs; /* pci_devs in PCI slot */
+ struct list_head *pci_devs; /* pci_devs in PCI slot */
struct vio_dev *vio_dev; /* vio_dev in VIO slot */
} dev;
struct hotplug_slot *hotplug_slot;
diff -Nru a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c
--- a/drivers/pci/hotplug/rpaphp_pci.c 2005-04-01 15:36:22 -08:00
+++ b/drivers/pci/hotplug/rpaphp_pci.c 2005-04-01 15:36:22 -08:00
@@ -130,11 +130,11 @@
*value = EMPTY;
}
else if (state == PRESENT) {
- if (!is_init)
+ if (!is_init) {
/* at run-time slot->state can be changed by */
/* config/unconfig adapter */
*value = slot->state;
- else {
+ } else {
child_dn = slot->dn->child;
if (child_dn)
child_dev = rpaphp_find_pci_dev(child_dn);
@@ -263,56 +263,17 @@
}
-#ifdef DEBUG
static void print_slot_pci_funcs(struct slot *slot)
{
- struct list_head *l;
+ struct pci_dev *dev;
if (slot->dev_type == PCI_DEV) {
- printk("pci_funcs of slot[%s]\n", slot->name);
- if (list_empty(&slot->dev.pci_funcs))
- printk(" pci_funcs is EMPTY\n");
-
- list_for_each (l, &slot->dev.pci_funcs) {
- struct rpaphp_pci_func *func =
- list_entry(l, struct rpaphp_pci_func, sibling);
- printk(" FOUND dev=%s\n", pci_name(func->pci_dev));
- }
+ dbg("%s: pci_devs of slot[%s]\n", __FUNCTION__, slot->name);
+ list_for_each_entry (dev, slot->dev.pci_devs, bus_list)
+ dbg("\t%s\n", pci_name(dev));
}
return;
}
-#else
-static void print_slot_pci_funcs(struct slot *slot)
-{
- return;
-}
-#endif
-
-static int init_slot_pci_funcs(struct slot *slot)
-{
- struct device_node *child;
-
- for (child = slot->dn->child; child != NULL; child = child->sibling) {
- struct pci_dev *pdev = rpaphp_find_pci_dev(child);
-
- if (pdev) {
- struct rpaphp_pci_func *func;
- func = kmalloc(sizeof(struct rpaphp_pci_func), GFP_KERNEL);
- if (!func)
- return -ENOMEM;
- memset(func, 0, sizeof(struct rpaphp_pci_func));
- INIT_LIST_HEAD(&func->sibling);
- func->pci_dev = pdev;
- list_add_tail(&func->sibling, &slot->dev.pci_funcs);
- print_slot_pci_funcs(slot);
- } else {
- err("%s: dn=%s has no pci_dev\n",
- __FUNCTION__, child->full_name);
- return -EIO;
- }
- }
- return 0;
-}
static int rpaphp_config_pci_adapter(struct slot *slot)
{
@@ -335,13 +296,8 @@
err("%s: can't find any devices.\n", __FUNCTION__);
goto exit;
}
- /* associate corresponding pci_dev */
- rc = init_slot_pci_funcs(slot);
- if (rc)
- goto exit;
print_slot_pci_funcs(slot);
- if (!list_empty(&slot->dev.pci_funcs))
- rc = 0;
+ rc = 0;
} else {
/* slot is not enabled */
err("slot doesn't have pci_dev structure\n");
@@ -371,34 +327,16 @@
int rpaphp_unconfig_pci_adapter(struct slot *slot)
{
+ struct pci_dev *dev;
int retval = 0;
- struct list_head *ln, *tmp;
- dbg("Entry %s: slot[%s]\n", __FUNCTION__, slot->name);
- if (list_empty(&slot->dev.pci_funcs)) {
- err("%s: slot[%s] doesn't have any devices.\n", __FUNCTION__,
- slot->name);
-
- retval = -EINVAL;
- goto exit;
- }
- /* remove the devices from the pci core */
- list_for_each_safe (ln, tmp, &slot->dev.pci_funcs) {
- struct rpaphp_pci_func *func;
-
- func = list_entry(ln, struct rpaphp_pci_func, sibling);
- if (func->pci_dev) {
- pci_remove_bus_device(func->pci_dev);
- rpaphp_eeh_remove_bus_device(func->pci_dev);
- }
- kfree(func);
- }
- INIT_LIST_HEAD(&slot->dev.pci_funcs);
+ list_for_each_entry(dev, slot->dev.pci_devs, bus_list)
+ rpaphp_eeh_remove_bus_device(dev);
+
+ pci_remove_behind_bridge(slot->bridge);
slot->state = NOT_CONFIGURED;
info("%s: devices in slot[%s] unconfigured.\n", __FUNCTION__,
slot->name);
-exit:
- dbg("Exit %s, rc=0x%x\n", __FUNCTION__, retval);
return retval;
}
@@ -444,6 +382,7 @@
static int setup_pci_slot(struct slot *slot)
{
+ struct pci_bus *bus;
int rc;
if (slot->type == PHB) {
@@ -460,6 +399,12 @@
__FUNCTION__, slot->name);
goto exit_rc;
}
+
+ bus = slot->bridge->subordinate;
+ if (!bus)
+ goto exit_rc;
+ slot->dev.pci_devs = &bus->devices;
+
dbg("%s set slot->name to %s\n", __FUNCTION__,
pci_name(slot->bridge));
strcpy(slot->name, pci_name(slot->bridge));
@@ -484,22 +429,15 @@
err("%s: CONFIG pci adapter failed\n", __FUNCTION__);
goto exit_rc;
}
- } else if (slot->hotplug_slot->info->adapter_status == CONFIGURED) {
- if (init_slot_pci_funcs(slot)) {
- err("%s: init_slot_pci_funcs failed\n", __FUNCTION__);
- goto exit_rc;
- }
- } else {
+ } else if (slot->hotplug_slot->info->adapter_status != CONFIGURED) {
err("%s: slot[%s]'s adapter_status is NOT_VALID.\n",
__FUNCTION__, slot->name);
goto exit_rc;
}
-
print_slot_pci_funcs(slot);
- if (!list_empty(&slot->dev.pci_funcs)) {
+ if (!list_empty(slot->dev.pci_devs)) {
slot->state = CONFIGURED;
-
} else {
/* DLPAR add as opposed to
* boot time */
@@ -521,7 +459,6 @@
slot->removable = 0;
else
slot->removable = 1;
- INIT_LIST_HEAD(&slot->dev.pci_funcs);
if (setup_pci_hotplug_slot_info(slot))
goto exit_rc;
if (setup_pci_slot(slot))
diff -Nru a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c
--- a/drivers/pci/hotplug/rpaphp_slot.c 2005-04-01 15:36:22 -08:00
+++ b/drivers/pci/hotplug/rpaphp_slot.c 2005-04-01 15:36:22 -08:00
@@ -98,17 +98,6 @@
void dealloc_slot_struct(struct slot *slot)
{
- struct list_head *ln, *n;
-
- if (slot->dev_type == PCI_DEV) {
- list_for_each_safe (ln, n, &slot->dev.pci_funcs) {
- struct rpaphp_pci_func *func;
-
- func = list_entry(ln, struct rpaphp_pci_func, sibling);
- kfree(func);
- }
- }
-
kfree(slot->hotplug_slot->info);
kfree(slot->hotplug_slot->name);
kfree(slot->hotplug_slot);
next prev parent reply other threads:[~2005-04-02 0:03 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-01 23:45 [BK PATCH] PCI update for 2.6.12-rc1 Greg KH
2005-04-01 23:47 ` PCI: increase the size of the pci.ids strings Greg KH
2005-04-01 23:47 ` Remove item from feature-removal-schedule.txt that was already removed from the kernel Greg KH
2005-04-01 23:47 ` PCI: add CONFIG_PCI_NAMES to the feature-removal-schedule.txt file Greg KH
2005-04-01 23:47 ` [PATCH] PCI: sync up with the latest pci.ids file from sf.net Greg KH
2005-04-01 23:47 ` [PATCH] PCI: Add PCI device ID for new Mellanox HCA Greg KH
2005-04-01 23:47 ` [PATCH] PCI: Patch for Serverworks chips in hotplug environment Greg KH
2005-04-01 23:47 ` PCI: fix an oops in some pci devices on hotplug remove when their resources are being freed Greg KH
2005-04-01 23:47 ` [PATCH] PCI: trivial DBG tidy-up Greg KH
2005-04-01 23:47 ` [PATCH] PCI Hotplug: remove code duplication in drivers/pci/hotplug/ibmphp_pci.c Greg KH
2005-04-01 23:47 ` [PATCH] PCI Hotplug: only call ibmphp_remove_resource() if argument is not NULL Greg KH
2005-04-01 23:47 ` [PATCH] PCI: 80 column lines Greg KH
2005-04-01 23:47 ` Greg KH [this message]
2005-04-01 23:47 ` [PATCH] PCI busses are structs, not integers Greg KH
2005-04-01 23:47 ` [PATCH] pci_ids.h correction for Intel ICH7M Greg KH
2005-04-01 23:47 ` [PATCH] sort-out-pci_rom_address_enable-vs-ioresource_rom_enable.patch Greg KH
2005-04-01 23:47 ` [PATCH] arch/i386/pci/i386.c: Use new for_each_pci_dev macro Greg KH
2005-04-01 23:47 ` PCI Hotplug: enforce the rule that a hotplug slot needs a release function Greg KH
2005-04-01 23:47 ` [PATCH] PCI Hotplug: add documentation about release pointer Greg KH
2005-04-01 23:47 ` [PATCH] PCI: Quirk for Asus M5N Greg KH
2005-04-01 23:47 ` [PATCH] drivers/pci/hotplug/cpqphp_core.c: fix a check after use Greg KH
2005-04-01 23:47 ` [PATCH] PCI: shrink drivers/pci/proc.c::pci_seq_start() Greg KH
2005-04-01 23:47 ` [PATCH] PCI: handle multiple video cards on the same bus Greg KH
2005-04-01 23:47 ` [PATCH] PCI: remove pci_find_device usage from pci sysfs code Greg KH
2005-04-01 23:47 ` [PATCH] drivers/pci/msi.c: fix a check after use Greg KH
2005-04-01 23:47 ` PCI: clean up the dynamic id logic a little bit Greg KH
2005-04-01 23:47 ` [PATCH] PCI: create PCI_DEBUG config option to make it easier for users to enable pci debugging Greg KH
2005-04-02 12:20 ` [PATCH] PCI Hotplug: remove code duplication in drivers/pci/hotplug/ibmphp_pci.c Rolf Eike Beer
2005-04-02 19:26 ` Andrew Morton
2005-04-08 0:07 ` Greg KH
2005-04-08 7:02 ` Rolf Eike Beer
2005-04-02 1:10 ` PCI: fix an oops in some pci devices on hotplug remove when their resources are being freed Matthew Wilcox
2005-04-02 3:31 ` Greg KH
2005-04-02 3:53 ` Matthew Wilcox
2005-04-02 4:04 ` Greg KH
2005-04-04 20:11 ` PCI: increase the size of the pci.ids strings Giuseppe Bilotta
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=11123992711084@kroah.com \
--to=gregkh@suse.de \
--cc=greg@kroah.com \
--cc=johnrose@austin.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@atrey.karlin.mff.cuni.cz \
/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