diff options
author | Jeff Garzik <jgarzik@pobox.com> | 2005-09-14 08:01:25 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-09-14 08:01:25 -0400 |
commit | d7f6884ae0ae6e406ec3500fcde16e8f51642460 (patch) | |
tree | efceb246a4fa12921b7dbd3946a88fa257684405 /drivers/pci/hotplug | |
parent | cd28ab6a4e50a7601d22752aa7ce0c8197b10bdf (diff) | |
parent | 2f4ba45a75d6383b4a1201169a808ffea416ffa0 (diff) |
Merge /spare/repo/linux-2.6/
Diffstat (limited to 'drivers/pci/hotplug')
29 files changed, 438 insertions, 794 deletions
diff --git a/drivers/pci/hotplug/Kconfig b/drivers/pci/hotplug/Kconfig index 9c4a39ee89b..2f1289eebb3 100644 --- a/drivers/pci/hotplug/Kconfig +++ b/drivers/pci/hotplug/Kconfig @@ -78,7 +78,7 @@ config HOTPLUG_PCI_IBM config HOTPLUG_PCI_ACPI tristate "ACPI PCI Hotplug driver" - depends on ACPI_BUS && HOTPLUG_PCI + depends on ACPI && HOTPLUG_PCI help Say Y here if you have a system that supports PCI Hotplug using ACPI. @@ -157,7 +157,7 @@ config HOTPLUG_PCI_SHPC_POLL_EVENT_MODE config HOTPLUG_PCI_SHPC_PHPRM_LEGACY bool "For AMD SHPC only: Use $HRT for resource/configuration" - depends on HOTPLUG_PCI_SHPC && !ACPI_BUS + depends on HOTPLUG_PCI_SHPC && !ACPI help Say Y here for AMD SHPC. You have to select this option if you are using this driver on platform with AMD SHPC. diff --git a/drivers/pci/hotplug/Makefile b/drivers/pci/hotplug/Makefile index 31a307004b9..3c71e3077ff 100644 --- a/drivers/pci/hotplug/Makefile +++ b/drivers/pci/hotplug/Makefile @@ -41,8 +41,7 @@ acpiphp-objs := acpiphp_core.o \ rpaphp-objs := rpaphp_core.o \ rpaphp_pci.o \ - rpaphp_slot.o \ - rpaphp_vio.o + rpaphp_slot.o rpadlpar_io-objs := rpadlpar_core.o \ rpadlpar_sysfs.o @@ -51,7 +50,7 @@ pciehp-objs := pciehp_core.o \ pciehp_ctrl.o \ pciehp_pci.o \ pciehp_hpc.o -ifdef CONFIG_ACPI_BUS +ifdef CONFIG_ACPI pciehp-objs += pciehprm_acpi.o else pciehp-objs += pciehprm_nonacpi.o @@ -62,7 +61,7 @@ shpchp-objs := shpchp_core.o \ shpchp_pci.o \ shpchp_sysfs.o \ shpchp_hpc.o -ifdef CONFIG_ACPI_BUS +ifdef CONFIG_ACPI shpchp-objs += shpchprm_acpi.o else ifdef CONFIG_HOTPLUG_PCI_SHPC_PHPRM_LEGACY diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h index 46b294a1241..061ead21ef1 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h @@ -23,7 +23,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * Send feedback to <greg@kroah.com>, <dely.l.sy@intel.com> + * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> * */ #ifndef _PCIEHP_H @@ -302,7 +302,7 @@ static inline void return_resource(struct pci_resource **head, struct pci_resour static inline void make_slot_name(char *buffer, int buffer_size, struct slot *slot) { - snprintf(buffer, buffer_size, "%d", slot->number); + snprintf(buffer, buffer_size, "%04d_%04d", slot->bus, slot->number); } enum php_ctlr_type { diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c index df4915dbc32..cafc7eadcf8 100644 --- a/drivers/pci/hotplug/pciehp_core.c +++ b/drivers/pci/hotplug/pciehp_core.c @@ -23,7 +23,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * Send feedback to <greg@kroah.com>, <dely.l.sy@intel.com> + * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> * */ diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c index 0dbcf04aa35..0e094760152 100644 --- a/drivers/pci/hotplug/pciehp_ctrl.c +++ b/drivers/pci/hotplug/pciehp_ctrl.c @@ -23,7 +23,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * Send feedback to <greg@kroah.com>, <dely.l.sy@intel.com> + * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> * */ diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 1cda30bd6e4..7a0e27f0e06 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -23,7 +23,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * Send feedback to <greg@kroah.com>,<dely.l.sy@intel.com> + * Send feedback to <greg@kroah.com>,<kristen.c.accardi@intel.com> * */ diff --git a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c index 723b12c0bb7..33b539b34f7 100644 --- a/drivers/pci/hotplug/pciehp_pci.c +++ b/drivers/pci/hotplug/pciehp_pci.c @@ -23,7 +23,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * Send feedback to <greg@kroah.com>, <dely.l.sy@intel.com> + * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> * */ diff --git a/drivers/pci/hotplug/pciehprm.h b/drivers/pci/hotplug/pciehprm.h index 966775ffb0f..05f20fbc5f5 100644 --- a/drivers/pci/hotplug/pciehprm.h +++ b/drivers/pci/hotplug/pciehprm.h @@ -23,7 +23,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * Send feedback to <greg@kroah.com>, <dely.l.sy@intel.com> + * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> * */ diff --git a/drivers/pci/hotplug/pciehprm_acpi.c b/drivers/pci/hotplug/pciehprm_acpi.c index 57f4e6d1b27..1406db35b08 100644 --- a/drivers/pci/hotplug/pciehprm_acpi.c +++ b/drivers/pci/hotplug/pciehprm_acpi.c @@ -20,7 +20,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * Send feedback to <dely.l.sy@intel.com> + * Send feedback to <kristen.c.accardi@intel.com> * */ @@ -1696,15 +1696,15 @@ void pciehprm_enable_card( pci_bus->number = func->bus; devfn = PCI_DEVFN(func->device, func->function); - rc = pci_bus_read_config_word(pci_bus, devfn, PCI_COMMAND, &command); + rc = pci_bus_read_config_word(pci_bus, devfn, PCI_COMMAND, &cmd); if (card_type == PCI_HEADER_TYPE_BRIDGE) { - rc = pci_bus_read_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, &bcommand); + rc = pci_bus_read_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, &bcmd); } - cmd = command = command | PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE + command = cmd | PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE | PCI_COMMAND_IO | PCI_COMMAND_MEMORY; - bcmd = bcommand = bcommand | PCI_BRIDGE_CTL_NO_ISA; + bcommand = bcmd | PCI_BRIDGE_CTL_NO_ISA; ab = find_acpi_bridge_by_bus(acpi_bridges_head, ctrl->seg, ctrl->bus); if (ab) { diff --git a/drivers/pci/hotplug/pciehprm_nonacpi.c b/drivers/pci/hotplug/pciehprm_nonacpi.c index 79a0aa6238e..3622965f896 100644 --- a/drivers/pci/hotplug/pciehprm_nonacpi.c +++ b/drivers/pci/hotplug/pciehprm_nonacpi.c @@ -23,7 +23,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * Send feedback to <greg@kroah.com>, <dely.l.sy@intel.com> + * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> * */ diff --git a/drivers/pci/hotplug/pciehprm_nonacpi.h b/drivers/pci/hotplug/pciehprm_nonacpi.h index 87c90e85ede..b10603b0e95 100644 --- a/drivers/pci/hotplug/pciehprm_nonacpi.h +++ b/drivers/pci/hotplug/pciehprm_nonacpi.h @@ -23,7 +23,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * Send feedback to <greg@kroah.com>, <dely.l.sy@intel.com> + * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> * */ diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c index 86b384e4271..ad1017da865 100644 --- a/drivers/pci/hotplug/rpadlpar_core.c +++ b/drivers/pci/hotplug/rpadlpar_core.c @@ -19,33 +19,36 @@ #include <asm/pci-bridge.h> #include <asm/semaphore.h> #include <asm/rtas.h> +#include <asm/vio.h> #include "../pci.h" #include "rpaphp.h" #include "rpadlpar.h" static DECLARE_MUTEX(rpadlpar_sem); +#define DLPAR_MODULE_NAME "rpadlpar_io" + #define NODE_TYPE_VIO 1 #define NODE_TYPE_SLOT 2 #define NODE_TYPE_PHB 3 -static struct device_node *find_php_slot_vio_node(char *drc_name) +static struct device_node *find_vio_slot_node(char *drc_name) { - struct device_node *child; struct device_node *parent = of_find_node_by_name(NULL, "vdevice"); - char *loc_code; + struct device_node *dn = NULL; + char *name; + int rc; if (!parent) return NULL; - for (child = of_get_next_child(parent, NULL); - child; child = of_get_next_child(parent, child)) { - loc_code = get_property(child, "ibm,loc-code", NULL); - if (loc_code && !strncmp(loc_code, drc_name, strlen(drc_name))) - return child; + while ((dn = of_get_next_child(parent, dn))) { + rc = rpaphp_get_drc_props(dn, NULL, &name, NULL, NULL); + if ((rc == 0) && (!strcmp(drc_name, name))) + break; } - return NULL; + return dn; } /* Find dlpar-capable pci node that contains the specified name and type */ @@ -67,7 +70,7 @@ static struct device_node *find_php_slot_pci_node(char *drc_name, return np; } -static struct device_node *find_newly_added_node(char *drc_name, int *node_type) +static struct device_node *find_dlpar_node(char *drc_name, int *node_type) { struct device_node *dn; @@ -83,7 +86,7 @@ static struct device_node *find_newly_added_node(char *drc_name, int *node_type) return dn; } - dn = find_php_slot_vio_node(drc_name); + dn = find_vio_slot_node(drc_name); if (dn) { *node_type = NODE_TYPE_VIO; return dn; @@ -92,14 +95,14 @@ static struct device_node *find_newly_added_node(char *drc_name, int *node_type) return NULL; } -static struct slot *find_slot(char *drc_name) +static struct slot *find_slot(struct device_node *dn) { struct list_head *tmp, *n; struct slot *slot; list_for_each_safe(tmp, n, &rpaphp_slot_head) { slot = list_entry(tmp, struct slot, rpaphp_slot_list); - if (strcmp(slot->location, drc_name) == 0) + if (slot->dn == dn) return slot; } @@ -131,7 +134,8 @@ static void rpadlpar_claim_one_bus(struct pci_bus *b) static int pci_add_secondary_bus(struct device_node *dn, struct pci_dev *bridge_dev) { - struct pci_controller *hose = dn->phb; + struct pci_dn *pdn = dn->data; + struct pci_controller *hose = pdn->phb; struct pci_bus *child; u8 sec_busno; @@ -156,7 +160,7 @@ static int pci_add_secondary_bus(struct device_node *dn, if (hose->last_busno < child->number) hose->last_busno = child->number; - dn->bussubno = child->number; + pdn->bussubno = child->number; /* ioremap() for child bus, which may or may not succeed */ remap_bus_range(child); @@ -164,13 +168,28 @@ static int pci_add_secondary_bus(struct device_node *dn, return 0; } +static struct pci_dev *dlpar_find_new_dev(struct pci_bus *parent, + struct device_node *dev_dn) +{ + struct pci_dev *tmp = NULL; + struct device_node *child_dn; + + list_for_each_entry(tmp, &parent->devices, bus_list) { + child_dn = pci_device_to_OF_node(tmp); + if (child_dn == dev_dn) + return tmp; + } + return NULL; +} + static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn) { - struct pci_controller *hose = dn->phb; + struct pci_dn *pdn = dn->data; + struct pci_controller *hose = pdn->phb; struct pci_dev *dev = NULL; /* Scan phb bus for EADS device, adding new one to bus->devices */ - if (!pci_scan_single_device(hose->bus, dn->devfn)) { + if (!pci_scan_single_device(hose->bus, pdn->devfn)) { printk(KERN_ERR "%s: found no device on bus\n", __FUNCTION__); return NULL; } @@ -179,49 +198,28 @@ static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn) pci_bus_add_devices(hose->bus); /* Confirm new bridge dev was created */ - dev = rpaphp_find_pci_dev(dn); - if (!dev) { - printk(KERN_ERR "%s: failed to add pci device\n", __FUNCTION__); - return NULL; - } + dev = dlpar_find_new_dev(hose->bus, dn); + if (dev) { + if (dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) { + printk(KERN_ERR "%s: unexpected header type %d\n", + __FUNCTION__, dev->hdr_type); + return NULL; + } - if (dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) { - printk(KERN_ERR "%s: unexpected header type %d\n", - __FUNCTION__, dev->hdr_type); - return NULL; + if (pci_add_secondary_bus(dn, dev)) + return NULL; } - if (pci_add_secondary_bus(dn, dev)) - return NULL; - return dev; } -static int dlpar_pci_remove_bus(struct pci_dev *bridge_dev) +static int dlpar_add_pci_slot(char *drc_name, struct device_node *dn) { - struct pci_bus *secondary_bus; + struct pci_dev *dev; + int rc; - if (!bridge_dev) { - printk(KERN_ERR "%s: unexpected null device\n", - __FUNCTION__); + if (rpaphp_find_pci_bus(dn)) return -EINVAL; - } - - secondary_bus = bridge_dev->subordinate; - - if (unmap_bus_range(secondary_bus)) { - printk(KERN_ERR "%s: failed to unmap bus range\n", - __FUNCTION__); - return -ERANGE; - } - - pci_remove_bus_device(bridge_dev); - return 0; -} - -static inline int dlpar_add_pci_slot(char *drc_name, struct device_node *dn) -{ - struct pci_dev *dev; /* Add pci bus */ dev = dlpar_pci_add_bus(dn); @@ -231,6 +229,21 @@ static inline int dlpar_add_pci_slot(char *drc_name, struct device_node *dn) return -EIO; } + if (dn->child) { + rc = rpaphp_config_pci_adapter(dev->subordinate); + if (rc < 0) { + printk(KERN_ERR "%s: unable to enable slot %s\n", + __FUNCTION__, drc_name); + return -EIO; + } + } + + /* Add hotplug slot */ + if (rpaphp_add_slot(dn)) { + printk(KERN_ERR "%s: unable to add hotplug slot %s\n", + __FUNCTION__, drc_name); + return -EIO; + } return 0; } @@ -255,47 +268,69 @@ static int dlpar_remove_root_bus(struct pci_controller *phb) return 0; } -static int dlpar_remove_phb(struct slot *slot) +static int dlpar_remove_phb(char *drc_name, struct device_node *dn) { - struct pci_controller *phb; - struct device_node *dn; + struct slot *slot; + struct pci_dn *pdn; int rc = 0; - dn = slot->dn; - if (!dn) { - printk(KERN_ERR "%s: unexpected NULL slot device node\n", - __FUNCTION__); - return -EIO; - } - - phb = dn->phb; - if (!phb) { - printk(KERN_ERR "%s: unexpected NULL phb pointer\n", - __FUNCTION__); - return -EIO; - } + if (!rpaphp_find_pci_bus(dn)) + return -EINVAL; - if (rpaphp_remove_slot(slot)) { - printk(KERN_ERR "%s: unable to remove hotplug slot %s\n", - __FUNCTION__, slot->location); - return -EIO; + slot = find_slot(dn); + if (slot) { + /* Remove hotplug slot */ + if (rpaphp_remove_slot(slot)) { + printk(KERN_ERR + "%s: unable to remove hotplug slot %s\n", + __FUNCTION__, drc_name); + return -EIO; + } } - rc = dlpar_remove_root_bus(phb); + pdn = dn->data; + BUG_ON(!pdn || !pdn->phb); + rc = dlpar_remove_root_bus(pdn->phb); if (rc < 0) return rc; + pdn->phb = NULL; + return 0; } -static int dlpar_add_phb(struct device_node *dn) +static int dlpar_add_phb(char *drc_name, struct device_node *dn) { struct pci_controller *phb; + if (PCI_DN(dn)->phb) { + /* PHB already exists */ + return -EINVAL; + } + phb = init_phb_dynamic(dn); if (!phb) + return -EIO; + + if (rpaphp_add_slot(dn)) { + printk(KERN_ERR "%s: unable to add hotplug slot %s\n", + __FUNCTION__, drc_name); + return -EIO; + } + return 0; +} + +static int dlpar_add_vio_slot(char *drc_name, struct device_node *dn) +{ + if (vio_find_node(dn)) return -EINVAL; + if (!vio_register_device_node(dn)) { + printk(KERN_ERR + "%s: failed to register vio node %s\n", + __FUNCTION__, drc_name); + return -EIO; + } return 0; } @@ -316,18 +351,13 @@ int dlpar_add_slot(char *drc_name) { struct device_node *dn = NULL; int node_type; - int rc = 0; + int rc = -EIO; if (down_interruptible(&rpadlpar_sem)) return -ERESTARTSYS; - /* Check for existing hotplug slot */ - if (find_slot(drc_name)) { - rc = -EINVAL; - goto exit; - } - - dn = find_newly_added_node(drc_name, &node_type); + /* Find newly added node */ + dn = find_dlpar_node(drc_name, &node_type); if (!dn) { rc = -ENODEV; goto exit; @@ -335,24 +365,17 @@ int dlpar_add_slot(char *drc_name) switch (node_type) { case NODE_TYPE_VIO: - /* Just add hotplug slot */ + rc = dlpar_add_vio_slot(drc_name, dn); break; case NODE_TYPE_SLOT: rc = dlpar_add_pci_slot(drc_name, dn); break; case NODE_TYPE_PHB: - rc = dlpar_add_phb(dn); + rc = dlpar_add_phb(drc_name, dn); break; - default: - printk("%s: unexpected node type\n", __FUNCTION__); - return -EIO; } - if (!rc && rpaphp_add_slot(dn)) { - printk(KERN_ERR "%s: unable to add hotplug slot %s\n", - __FUNCTION__, drc_name); - rc = -EIO; - } + printk(KERN_INFO "%s: slot %s added\n", DLPAR_MODULE_NAME, drc_name); exit: up(&rpadlpar_sem); return rc; @@ -366,17 +389,17 @@ exit: * of an I/O Slot. * Return Codes: * 0 Success - * -EIO Internal Error + * -EINVAL Vio dev doesn't exist */ -int dlpar_remove_vio_slot(struct slot *slot, char *drc_name) +static int dlpar_remove_vio_slot(char *drc_name, struct device_node *dn) { - /* Remove hotplug slot */ + struct vio_dev *vio_dev; - if (rpaphp_remove_slot(slot)) { - printk(KERN_ERR "%s: unable to remove hotplug slot %s\n", - __FUNCTION__, drc_name); - return -EIO; - } + vio_dev = vio_find_node(dn); + if (!vio_dev) + return -EINVAL; + + vio_unregister_device(vio_dev); return 0; } @@ -391,31 +414,34 @@ int dlpar_remove_vio_slot(struct slot *slot, char *drc_name) * -ENODEV Not a valid drc_name * -EIO Internal PCI Error */ -int dlpar_remove_pci_slot(struct slot *slot, char *drc_name) +int dlpar_remove_pci_slot(char *drc_name, struct device_node *dn) { - struct pci_dev *bridge_dev; + struct pci_bus *bus; + struct slot *slot; - bridge_dev = slot->bridge; - if (!bridge_dev) { - printk(KERN_ERR "%s: unexpected null bridge device\n", - __FUNCTION__); - return -EIO; - } + bus = rpaphp_find_pci_bus(dn); + if (!bus) + return -EINVAL; - /* Remove hotplug slot */ - if (rpaphp_remove_slot(slot)) { - printk(KERN_ERR "%s: unable to remove hotplug slot %s\n", - __FUNCTION__, drc_name); - return -EIO; + slot = find_slot(dn); + if (slot) { + /* Remove hotplug slot */ + if (rpaphp_remove_slot(slot)) { + printk(KERN_ERR + "%s: unable to remove hotplug slot %s\n", + __FUNCTION__, drc_name); + return -EIO; + } } - /* Remove pci bus */ - - if (dlpar_pci_remove_bus(bridge_dev)) { - printk(KERN_ERR "%s: unable to remove pci bus %s\n", - __FUNCTION__, drc_name); - return -EIO; + if (unmap_bus_range(bus)) { + printk(KERN_ERR "%s: failed to unmap bus range\n", + __FUNCTION__); + return -ERANGE; } + + BUG_ON(!bus->self); + pci_remove_bus_device(bus->self); return 0; } @@ -434,38 +460,31 @@ int dlpar_remove_pci_slot(struct slot *slot, char *drc_name) */ int dlpar_remove_slot(char *drc_name) { - struct slot *slot; + struct device_node *dn; + int node_type; int rc = 0; if (down_interruptible(&rpadlpar_sem)) return -ERESTARTSYS; - if (!find_php_slot_vio_node(drc_name) && - !find_php_slot_pci_node(drc_name, "SLOT") && - !find_php_slot_pci_node(drc_name, "PHB")) { + dn = find_dlpar_node(drc_name, &node_type); + if (!dn) { rc = -ENODEV; goto exit; } - slot = find_slot(drc_name); - if (!slot) { - rc = -EINVAL; - goto exit; - } - - if (slot->type == PHB) { - rc = dlpar_remove_phb(slot); - } else { - switch (slot->dev_type) { - case PCI_DEV: - rc = dlpar_remove_pci_slot(slot, drc_name); - break; - - case VIO_DEV: - rc = dlpar_remove_vio_slot(slot, drc_name); - break; - } + switch (node_type) { + case NODE_TYPE_VIO: + rc = dlpar_remove_vio_slot(drc_name, dn); + break; + case NODE_TYPE_PHB: + rc = dlpar_remove_phb(drc_name, dn); + break; + case NODE_TYPE_SLOT: + rc = dlpar_remove_pci_slot(drc_name, dn); + break; } + printk(KERN_INFO "%s: slot %s removed\n", DLPAR_MODULE_NAME, drc_name); exit: up(&rpadlpar_sem); return rc; diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h index 81746e6e0e0..61d94d1e29c 100644 --- a/drivers/pci/hotplug/rpaphp.h +++ b/drivers/pci/hotplug/rpaphp.h @@ -30,10 +30,6 @@ #include <linux/pci.h> #include "pci_hotplug.h" -#define PHB 2 -#define HOTPLUG 1 -#define EMBEDDED 0 - #define DR_INDICATOR 9002 #define DR_ENTITY_SENSE 9003 @@ -61,10 +57,6 @@ extern int debug; #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg) #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) -/* slot types */ -#define VIO_DEV 1 -#define PCI_DEV 2 - /* slot states */ #define NOT_VALID 3 @@ -72,11 +64,6 @@ extern int debug; #define CONFIGURED 1 #define EMPTY 0 -struct rpaphp_pci_func { - struct pci_dev *pci_dev; - struct list_head sibling; -}; - /* * struct slot - slot information for each *physical* slot */ @@ -88,15 +75,9 @@ struct slot { u32 power_domain; char *name; char *location; - u8 removable; - u8 dev_type; /* VIO or PCI */ - struct device_node *dn; /* slot's device_node in OFDT */ - /* dn has phb info */ - struct pci_dev *bridge; /* slot's pci_dev in pci_devices */ - union { - struct list_head *pci_devs; /* pci_devs in PCI slot */ - struct vio_dev *vio_dev; /* vio_dev in VIO slot */ - } dev; + struct device_node *dn; + struct pci_bus *bus; + struct list_head *pci_devs; struct hotplug_slot *hotplug_slot; }; @@ -107,13 +88,13 @@ extern int num_slots; /* function prototypes */ /* rpaphp_pci.c */ -extern struct pci_dev *rpaphp_find_pci_dev(struct device_node *dn); +extern struct pci_bus *rpaphp_find_pci_bus(struct device_node *dn); extern int rpaphp_claim_resource(struct pci_dev *dev, int resource); extern int rpaphp_enable_pci_slot(struct slot *slot); extern int register_pci_slot(struct slot *slot); extern int rpaphp_unconfig_pci_adapter(struct slot *slot); extern int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value); -extern struct hotplug_slot *rpaphp_find_hotplug_slot(struct pci_dev *dev); +extern int rpaphp_config_pci_adapter(struct pci_bus *bus); /* rpaphp_core.c */ extern int rpaphp_add_slot(struct device_node *dn); @@ -121,12 +102,6 @@ extern int rpaphp_remove_slot(struct slot *slot); extern int rpaphp_get_drc_props(struct device_node *dn, int *drc_index, char **drc_name, char **drc_type, int *drc_power_domain); -/* rpaphp_vio.c */ -extern int rpaphp_get_vio_adapter_status(struct slot *slot, int is_init, u8 * value); -extern int rpaphp_unconfig_vio_adapter(struct slot *slot); -extern int register_vio_slot(struct device_node *dn); -extern int rpaphp_enable_vio_slot(struct slot *slot); - /* rpaphp_slot.c */ extern void dealloc_slot_struct(struct slot *slot); extern struct slot *alloc_slot_struct(struct device_node *dn, int drc_index, char *drc_name, int power_domain); diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c index 29117a3a328..c830ff0acdc 100644 --- a/drivers/pci/hotplug/rpaphp_core.c +++ b/drivers/pci/hotplug/rpaphp_core.c @@ -152,17 +152,7 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 * value) int retval = 0; down(&rpaphp_sem); - /* have to go through this */ - switch (slot->dev_type) { - case PCI_DEV: - retval = rpaphp_get_pci_adapter_status(slot, 0, value); - break; - case VIO_DEV: - retval = rpaphp_get_vio_adapter_status(slot, 0, value); - break; - default: - retval = -EINVAL; - } + retval = rpaphp_get_pci_adapter_status(slot, 0, value); up(&rpaphp_sem); return retval; } @@ -317,34 +307,6 @@ static int is_php_dn(struct device_node *dn, int **indexes, int **names, return 0; } -static int is_dr_dn(struct device_node *dn, int **indexes, int **names, - int **types, int **power_domains, int **my_drc_index) -{ - int rc; - - *my_drc_index = (int *) get_property(dn, "ibm,my-drc-index", NULL); - if(!*my_drc_index) - return (0); - - if (!dn->parent) - return (0); - - rc = get_children_props(dn->parent, indexes, names, types, - power_domains); - return (rc >= 0); -} - -static inline int is_vdevice_root(struct device_node *dn) -{ - return !strcmp(dn->name, "vdevice"); -} - -int is_dlpar_type(const char *type_str) -{ - /* Only register DLPAR-capable nodes of drc-type PHB or SLOT */ - return (!strcmp(type_str, "PHB") || !strcmp(type_str, "SLOT")); -} - /**************************************************************** * rpaphp not only registers PCI hotplug slots(HOTPLUG), * but also logical DR slots(EMBEDDED). @@ -356,54 +318,33 @@ int rpaphp_add_slot(struct device_node *dn) { struct slot *slot; int retval = 0; - int i, *my_drc_index, slot_type; + int i; int *indexes, *names, *types, *power_domains; char *name, *type; dbg("Entry %s: dn->full_name=%s\n", __FUNCTION__, dn->full_name); - if (dn->parent && is_vdevice_root(dn->parent)) { - /* register a VIO device */ - retval = register_vio_slot(dn); - goto exit; - } - /* register PCI devices */ if (dn->name != 0 && strcmp(dn->name, "pci") == 0) { - if (is_php_dn(dn, &indexes, &names, &types, &power_domains)) - slot_type = HOTPLUG; - else if (is_dr_dn(dn, &indexes, &names, &types, &power_domains, &my_drc_index)) - slot_type = EMBEDDED; - else goto exit; + if (!is_php_dn(dn, &indexes, &names, &types, &power_domains)) + goto exit; name = (char *) &names[1]; type = (char *) &types[1]; for (i = 0; i < indexes[0]; i++, - name += (strlen(name) + 1), type += (strlen(type) + 1)) { - - if (slot_type == HOTPLUG || - (slot_type == EMBEDDED && - indexes[i + 1] == my_drc_index[0] && - is_dlpar_type(type))) { - if (!(slot = alloc_slot_struct(dn, indexes[i + 1], name, - power_domains[i + 1]))) { - retval = -ENOMEM; - goto exit; - } - if (!strcmp(type, "PHB")) - slot->type = PHB; - else if (slot_type == EMBEDDED) - slot->type = EMBEDDED; - else - slot->type = simple_strtoul(type, NULL, 10); + name += (strlen(name) + 1), type += (strlen(type) + 1)) { + + if (!(slot = alloc_slot_struct(dn, indexes[i + 1], name, + power_domains[i + 1]))) { + retval = -ENOMEM; + goto exit; + } + slot->type = simple_strtoul(type, NULL, 10); - dbg(" Found drc-index:0x%x drc-name:%s drc-type:%s\n", + dbg("Found drc-index:0x%x drc-name:%s drc-type:%s\n", indexes[i + 1], name, type); - retval = register_pci_slot(slot); - if (slot_type == EMBEDDED) - goto exit; - } + retval = register_pci_slot(slot); } } exit: @@ -412,31 +353,6 @@ exit: return retval; } -/* - * init_slots - initialize 'struct slot' structures for each slot - * - */ -static void init_slots(void) -{ - struct device_node *dn; - - for (dn = find_all_nodes(); dn; dn = dn->next) - rpaphp_add_slot(dn); -} - -static int __init init_rpa(void) -{ - - init_MUTEX(&rpaphp_sem); - - /* initialize internal data structure etc. */ - init_slots(); - if (!num_slots) - return -ENODEV; - - return 0; -} - static void __exit cleanup_slots(void) { struct list_head *tmp, *n; @@ -458,10 +374,18 @@ static void __exit cleanup_slots(void) static int __init rpaphp_init(void) { + struct device_node *dn = NULL; + info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); + init_MUTEX(&rpaphp_sem); - /* read all the PRA info from the system */ - return init_rpa(); + while ((dn = of_find_node_by_type(dn, "pci"))) + rpaphp_add_slot(dn); + + if (!num_slots) + return -ENODEV; + + return 0; } static void __exit rpaphp_exit(void) @@ -481,16 +405,7 @@ static int enable_slot(struct hotplug_slot *hotplug_slot) dbg("ENABLING SLOT %s\n", slot->name); down(&rpaphp_sem); - switch (slot->dev_type) { - case PCI_DEV: - retval = rpaphp_enable_pci_slot(slot); - break; - case VIO_DEV: - retval = rpaphp_enable_vio_slot(slot); - break; - default: - retval = -EINVAL; - } + retval = rpaphp_enable_pci_slot(slot); up(&rpaphp_sem); exit: dbg("%s - Exit: rc[%d]\n", __FUNCTION__, retval); @@ -511,16 +426,7 @@ static int disable_slot(struct hotplug_slot *hotplug_slot) dbg("DISABLING SLOT %s\n", slot->name); down(&rpaphp_sem); - switch (slot->dev_type) { - case PCI_DEV: - retval = rpaphp_unconfig_pci_adapter(slot); - break; - case VIO_DEV: - retval = rpaphp_unconfig_vio_adapter(slot); - break; - default: - retval = -ENODEV; - } + retval = rpaphp_unconfig_pci_adapter(slot); up(&rpaphp_sem); exit: dbg("%s - Exit: rc[%d]\n", __FUNCTION__, retval); diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c index d8305a935aa..49e4d10a648 100644 --- a/drivers/pci/hotplug/rpaphp_pci.c +++ b/drivers/pci/hotplug/rpaphp_pci.c @@ -30,22 +30,35 @@ #include "rpaphp.h" -struct pci_dev *rpaphp_find_pci_dev(struct device_node *dn) +static struct pci_bus *find_bus_among_children(struct pci_bus *bus, + struct device_node *dn) { - struct pci_dev *dev = NULL; - char bus_id[BUS_ID_SIZE]; + struct pci_bus *child = NULL; + struct list_head *tmp; + struct device_node *busdn; + + busdn = pci_bus_to_OF_node(bus); + if (busdn == dn) + return bus; - sprintf(bus_id, "%04x:%02x:%02x.%d", dn->phb->global_number, - dn->busno, PCI_SLOT(dn->devfn), PCI_FUNC(dn->devfn)); - for_each_pci_dev(dev) { - if (!strcmp(pci_name(dev), bus_id)) { + list_for_each(tmp, &bus->children) { + child = find_bus_among_children(pci_bus_b(tmp), dn); + if (child) break; - } } - return dev; + return child; } -EXPORT_SYMBOL_GPL(rpaphp_find_pci_dev); +struct pci_bus *rpaphp_find_pci_bus(struct device_node *dn) +{ + struct pci_dn *pdn = dn->data; + + if (!pdn || !pdn->phb || !pdn->phb->bus) + return NULL; + + return find_bus_among_children(pdn->phb->bus, dn); +} +EXPORT_SYMBOL_GPL(rpaphp_find_pci_bus); int rpaphp_claim_resource(struct pci_dev *dev, int resource) { @@ -69,11 +82,6 @@ int rpaphp_claim_resource(struct pci_dev *dev, int resource) EXPORT_SYMBOL_GPL(rpaphp_claim_resource); -static struct pci_dev *rpaphp_find_bridge_pdev(struct slot *slot) -{ - return rpaphp_find_pci_dev(slot->dn); -} - static int rpaphp_get_sensor_state(struct slot *slot, int *state) { int rc; @@ -116,39 +124,27 @@ static int rpaphp_get_sensor_state(struct slot *slot, int *state) */ int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value) { + struct pci_bus *bus; int state, rc; - struct device_node *child_dn; - struct pci_dev *child_dev = NULL; *value = NOT_VALID; rc = rpaphp_get_sensor_state(slot, &state); if (rc) goto exit; - if ((state == EMPTY) || (slot->type == PHB)) { - dbg("slot is empty\n"); + if (state == EMPTY) *value = EMPTY; - } else if (state == PRESENT) { if (!is_init) { /* at run-time slot->state can be changed by */ /* config/unconfig adapter */ *value = slot->state; } else { - child_dn = slot->dn->child; - if (child_dn) - child_dev = rpaphp_find_pci_dev(child_dn); - - if (child_dev) - *value = CONFIGURED; - else if (!child_dn) - dbg("%s: %s is not valid OFDT node\n", - __FUNCTION__, slot->dn->full_name); - else { - err("%s: can't find pdev of adapter in slot[%s]\n", - __FUNCTION__, slot->dn->full_name); + bus = rpaphp_find_pci_bus(slot->dn); + if (bus && !list_empty(&bus->devices)) + *value = CONFIGURED; + else *value = NOT_CONFIGURED; - } } } exit: @@ -186,39 +182,6 @@ rpaphp_fixup_new_pci_devices(struct pci_bus *bus, int fix_bus) } } -static int rpaphp_pci_config_bridge(struct pci_dev *dev); - -/***************************************************************************** - rpaphp_pci_config_slot() will configure all devices under the - given slot->dn and return the the first pci_dev. - *****************************************************************************/ -static struct pci_dev * -rpaphp_pci_config_slot(struct device_node *dn, struct pci_bus *bus) -{ - struct device_node *eads_first_child = dn->child; - struct pci_dev *dev = NULL; - int num; - - dbg("Enter %s: dn=%s bus=%s\n", __FUNCTION__, dn->full_name, bus->name); - - if (eads_first_child) { - /* pci_scan_slot should find all children of EADs */ - num = pci_scan_slot(bus, PCI_DEVFN(PCI_SLOT(eads_first_child->devfn), 0)); - if (num) { - rpaphp_fixup_new_pci_devices(bus, 1); - pci_bus_add_devices(bus); - } - dev = rpaphp_find_pci_dev(eads_first_child); - if (!dev) { - err("No new device found\n"); - return NULL; - } - if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) - rpaphp_pci_config_bridge(dev); - } - return dev; -} - static int rpaphp_pci_config_bridge(struct pci_dev *dev) { u8 sec_busno; @@ -252,6 +215,42 @@ static int rpaphp_pci_config_bridge(struct pci_dev *dev) return 0; } +/***************************************************************************** + rpaphp_pci_config_slot() will configure all devices under the + given slot->dn and return the the first pci_dev. + *****************************************************************************/ +static struct pci_dev * +rpaphp_pci_config_slot(struct pci_bus *bus) +{ + struct device_node *dn = pci_bus_to_OF_node(bus); + struct pci_dev *dev = NULL; + int slotno; + int num; + + dbg("Enter %s: dn=%s bus=%s\n", __FUNCTION__, dn->full_name, bus->name); + if (!dn || !dn->child) + return NULL; + + slotno = PCI_SLOT(PCI_DN(dn->child)->devfn); + + /* pci_scan_slot should find all children */ + num = pci_scan_slot(bus, PCI_DEVFN(slotno, 0)); + if (num) { + rpaphp_fixup_new_pci_devices(bus, 1); + pci_bus_add_devices(bus); + } + if (list_empty(&bus->devices)) { + err("%s: No new device found\n", __FUNCTION__); + return NULL; + } + list_for_each_entry(dev, &bus->devices, bus_list) { + if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) + rpaphp_pci_config_bridge(dev); + } + + return dev; +} + static void enable_eeh(struct device_node *dn) { struct device_node *sib; @@ -263,49 +262,44 @@ static void enable_eeh(struct device_node *dn) } -static void print_slot_pci_funcs(struct slot *slot) +static void print_slot_pci_funcs(struct pci_bus *bus) { + struct device_node *dn; struct pci_dev *dev; - if (slot->dev_type == 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)); - } + dn = pci_bus_to_OF_node(bus); + if (!dn) + return; + + dbg("%s: pci_devs of slot[%s]\n", __FUNCTION__, dn->full_name); + list_for_each_entry (dev, &bus->devices, bus_list) + dbg("\t%s\n", pci_name(dev)); return; } -static int rpaphp_config_pci_adapter(struct slot *slot) +int rpaphp_config_pci_adapter(struct pci_bus *bus) { - struct pci_bus *pci_bus; + struct device_node *dn = pci_bus_to_OF_node(bus); struct pci_dev *dev; int rc = -ENODEV; - dbg("Entry %s: slot[%s]\n", __FUNCTION__, slot->name); - - if (slot->bridge) { + dbg("Entry %s: slot[%s]\n", __FUNCTION__, dn->full_name); + if (!dn) + goto exit; - pci_bus = slot->bridge->subordinate; - if (!pci_bus) { - err("%s: can't find bus structure\n", __FUNCTION__); - goto exit; - } - enable_eeh(slot->dn); - dev = rpaphp_pci_config_slot(slot->dn, pci_bus); - if (!dev) { - err("%s: can't find any devices.\n", __FUNCTION__); - goto exit; - } - print_slot_pci_funcs(slot); - rc = 0; - } else { - /* slot is not enabled */ - err("slot doesn't have pci_dev structure\n"); + enable_eeh(dn); + dev = rpaphp_pci_config_slot(bus); + if (!dev) { + err("%s: can't find any devices.\n", __FUNCTION__); + goto exit; } + print_slot_pci_funcs(bus); + rc = 0; exit: dbg("Exit %s: rc=%d\n", __FUNCTION__, rc); return rc; } +EXPORT_SYMBOL_GPL(rpaphp_config_pci_adapter); static void rpaphp_eeh_remove_bus_device(struct pci_dev *dev) { @@ -327,13 +321,14 @@ static void rpaphp_eeh_remove_bus_device(struct pci_dev *dev) int rpaphp_unconfig_pci_adapter(struct slot *slot) { - struct pci_dev *dev; + struct pci_dev *dev, *tmp; int retval = 0; - list_for_each_entry(dev, slot->dev.pci_devs, bus_list) + list_for_each_entry_safe(dev, tmp, slot->pci_devs, bus_list) { rpaphp_eeh_remove_bus_device(dev); + pci_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); @@ -356,66 +351,41 @@ static int setup_pci_hotplug_slot_info(struct slot *slot) return 0; } -static int set_phb_slot_name(struct slot *slot) +static void set_slot_name(struct slot *slot) { - struct device_node *dn; - struct pci_controller *phb; - struct pci_bus *bus; - - dn = slot->dn; - if (!dn) { - return -EINVAL; - } - phb = dn->phb; - if (!phb) { - return -EINVAL; - } - bus = phb->bus; - if (!bus) { - return -EINVAL; - } + struct pci_bus *bus = slot->bus; + struct pci_dev *bridge; - sprintf(slot->name, "%04x:%02x:%02x.%x", pci_domain_nr(bus), - bus->number, 0, 0); - return 0; + bridge = bus->self; + if (bridge) + strcpy(slot->name, pci_name(bridge)); + else + sprintf(slot->name, "%04x:%02x:00.0", pci_domain_nr(bus), + bus->number); } static int setup_pci_slot(struct slot *slot) { + struct device_node *dn = slot->dn; struct pci_bus *bus; - int rc; - if (slot->type == PHB) { - rc = set_phb_slot_name(slot); - if (rc < 0) { - err("%s: failed to set phb slot name\n", __FUNCTION__); - goto exit_rc; - } - } else { - slot->bridge = rpaphp_find_bridge_pdev(slot); - if (!slot->bridge) { - /* slot being added doesn't have pci_dev yet */ - err("%s: no pci_dev for bridge dn %s\n", - __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)); + BUG_ON(!dn); + bus = rpaphp_find_pci_bus(dn); + if (!bus) { + err("%s: no pci_bus for dn %s\n", __FUNCTION__, dn->full_name); + goto exit_rc; } + slot->bus = bus; + slot->pci_devs = &bus->devices; + set_slot_name(slot); + /* find slot's pci_dev if it's not empty */ if (slot->hotplug_slot->info->adapter_status == EMPTY) { slot->state = EMPTY; /* slot is empty */ } else { /* slot is occupied */ - if (!(slot->dn->child)) { + if (!dn->child) { /* non-empty slot has to have child */ err("%s: slot[%s]'s device_node doesn't have child for adapter\n", __FUNCTION__, slot->name); @@ -425,7 +395,7 @@ static int setup_pci_slot(struct slot *slot) if (slot->hotplug_slot->info->adapter_status == NOT_CONFIGURED) { dbg("%s CONFIGURING pci adapter in slot[%s]\n", __FUNCTION__, slot->name); - if (rpaphp_config_pci_adapter(slot)) { + if (rpaphp_config_pci_adapter(slot->bus)) { err("%s: CONFIG pci adapter failed\n", __FUNCTION__); goto exit_rc; } @@ -435,8 +405,8 @@ static int setup_pci_slot(struct slot *slot) __FUNCTION__, slot->name); goto exit_rc; } - print_slot_pci_funcs(slot); - if (!list_empty(slot->dev.pci_devs)) { + print_slot_pci_funcs(slot->bus); + if (!list_empty(slot->pci_devs)) { slot->state = CONFIGURED; } else { /* DLPAR add as opposed to @@ -454,11 +424,6 @@ int register_pci_slot(struct slot *slot) { int rc = -EINVAL; - slot->dev_type = PCI_DEV; - if ((slot->type == EMBEDDED) || (slot->type == PHB)) - slot->removable = 0; - else - slot->removable = 1; if (setup_pci_hotplug_slot_info(slot)) goto exit_rc; if (setup_pci_slot(slot)) @@ -479,7 +444,7 @@ int rpaphp_enable_pci_slot(struct slot *slot) /* if slot is not empty, enable the adapter */ if (state == PRESENT) { dbg("%s : slot[%s] is occupied.\n", __FUNCTION__, slot->name); - retval = rpaphp_config_pci_adapter(slot); + retval = rpaphp_config_pci_adapter(slot->bus); if (!retval) { slot->state = CONFIGURED; dbg("%s: PCI devices in slot[%s] has been configured\n", @@ -502,37 +467,3 @@ exit: dbg("%s - Exit: rc[%d]\n", __FUNCTION__, retval); return retval; } - -struct hotplug_slot *rpaphp_find_hotplug_slot(struct pci_dev *dev) -{ - struct list_head *tmp, *n; - struct slot *slot; - - list_for_each_safe(tmp, n, &rpaphp_slot_head) { - struct pci_bus *bus; - struct list_head *ln; - - slot = list_entry(tmp, struct slot, rpaphp_slot_list); - if (slot->bridge == NULL) { - if (slot->dev_type == PCI_DEV) { - printk(KERN_WARNING "PCI slot missing bridge %s %s \n", - slot->name, slot->location); - } - continue; - } - - bus = slot->bridge->subordinate; - if (!bus) { - continue; /* should never happen? */ - } - for (ln = bus->devices.next; ln != &bus->devices; ln = ln->next) { - struct pci_dev *pdev = pci_dev_b(ln); - if (pdev == dev) - return slot->hotplug_slot; - } - } - - return NULL; -} - -EXPORT_SYMBOL_GPL(rpaphp_find_hotplug_slot); diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c index ff2cbf0652d..0e881549508 100644 --- a/drivers/pci/hotplug/rpaphp_slot.c +++ b/drivers/pci/hotplug/rpaphp_slot.c @@ -30,35 +30,6 @@ #include <asm/rtas.h> #include "rpaphp.h" -static ssize_t removable_read_file (struct hotplug_slot *php_slot, char *buf) -{ - u8 value; - int retval = -ENOENT; - struct slot *slot = (struct slot *)php_slot->private; - - if (!slot) - return retval; - - value = slot->removable; - retval = sprintf (buf, "%d\n", value); - return retval; -} - -static struct hotplug_slot_attribute hotplug_slot_attr_removable = { - .attr = {.name = "phy_removable", .mode = S_IFREG | S_IRUGO}, - .show = removable_read_file, -}; - -static void rpaphp_sysfs_add_attr_removable (struct hotplug_slot *slot) -{ - sysfs_create_file(&slot->kobj, &hotplug_slot_attr_removable.attr); -} - -static void rpaphp_sysfs_remove_attr_removable (struct hotplug_slot *slot) -{ - sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_removable.attr); -} - static ssize_t location_read_file (struct hotplug_slot *php_slot, char *buf) { char *value; @@ -176,9 +147,6 @@ int deregister_slot(struct slot *slot) /* remove "phy_location" file */ rpaphp_sysfs_remove_attr_location(php_slot); - /* remove "phy_removable" file */ - rpaphp_sysfs_remove_attr_removable(php_slot); - retval = pci_hp_deregister(php_slot); if (retval) err("Problem unregistering a slot %s\n", slot->name); @@ -212,21 +180,13 @@ int register_slot(struct slot *slot) /* create "phy_locatoin" file */ rpaphp_sysfs_add_attr_location(slot->hotplug_slot); - /* create "phy_removable" file */ - rpaphp_sysfs_add_attr_removable(slot->hotplug_slot); - /* add slot to our internal list */ dbg("%s adding slot[%s] to rpaphp_slot_list\n", __FUNCTION__, slot->name); list_add(&slot->rpaphp_slot_list, &rpaphp_slot_head); - - if (slot->dev_type == VIO_DEV) - info("Slot [%s](VIO location=%s) registered\n", - slot->name, slot->location); - else - info("Slot [%s](PCI location=%s) registered\n", - slot->name, slot->location); + info("Slot [%s](PCI location=%s) registered\n", slot->name, + slot->location); num_slots++; return 0; } @@ -235,21 +195,17 @@ int rpaphp_get_power_status(struct slot *slot, u8 * value) { int rc = 0, level; - if (slot->type == HOTPLUG) { - rc = rtas_get_power_level(slot->power_domain, &level); - if (!rc) { - dbg("%s the power level of slot %s(pwd-domain:0x%x) is %d\n", - __FUNCTION__, slot->name, slot->power_domain, level); - *value = level; - } else - err("failed to get power-level for slot(%s), rc=0x%x\n", - slot->location, rc); - } else { - dbg("%s report POWER_ON for EMBEDDED or PHB slot %s\n", - __FUNCTION__, slot->location); - *value = (u8) POWER_ON; + rc = rtas_get_power_level(slot->power_domain, &level); + if (rc < 0) { + err("failed to get power-level for slot(%s), rc=0x%x\n", + slot->location, rc); + return rc; } + dbg("%s the power level of slot %s(pwd-domain:0x%x) is %d\n", + __FUNCTION__, slot->name, slot->power_domain, level); + *value = level; + return rc; } diff --git a/drivers/pci/hotplug/rpaphp_vio.c b/drivers/pci/hotplug/rpaphp_vio.c deleted file mode 100644 index 74df6a305e6..00000000000 --- a/drivers/pci/hotplug/rpaphp_vio.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - * RPA Hot Plug Virtual I/O device functions - * Copyright (C) 2004 Linda Xie <lxie@us.ibm.com> - * - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or - * NON INFRINGEMENT. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Send feedback to <lxie@us.ibm.com> - * - */ -#include <asm/vio.h> -#include "rpaphp.h" - -/* - * get_vio_adapter_status - get the status of a slot - * - * status: - * - * 1-- adapter is configured - * 2-- adapter is not configured - * 3-- not valid - */ -inline int rpaphp_get_vio_adapter_status(struct slot *slot, int is_init, u8 *value) -{ - *value = slot->state; - return 0; -} - -int rpaphp_unconfig_vio_adapter(struct slot *slot) -{ - int retval = 0; - - dbg("Entry %s: slot[%s]\n", __FUNCTION__, slot->name); - if (!slot->dev.vio_dev) { - info("%s: no VIOA in slot[%s]\n", __FUNCTION__, slot->name); - retval = -EINVAL; - goto exit; - } - /* remove the device from the vio core */ - vio_unregister_device(slot->dev.vio_dev); - slot->state = NOT_CONFIGURED; - info("%s: adapter in slot[%s] unconfigured.\n", __FUNCTION__, slot->name); -exit: - dbg("Exit %s, rc=0x%x\n", __FUNCTION__, retval); - return retval; -} - -static int setup_vio_hotplug_slot_info(struct slot *slot) -{ - slot->hotplug_slot->info->power_status = 1; - rpaphp_get_vio_adapter_status(slot, 1, - &slot->hotplug_slot->info->adapter_status); - return 0; -} - -int register_vio_slot(struct device_node *dn) -{ - u32 *index; - char *name; - int rc = -EINVAL; - struct slot *slot = NULL; - - rc = rpaphp_get_drc_props(dn, NULL, &name, NULL, NULL); - if (rc < 0) - goto exit_rc; - index = (u32 *) get_property(dn, "ibm,my-drc-index", NULL); - if (!index) - goto exit_rc; - if (!(slot = alloc_slot_struct(dn, *index, name, 0))) { - rc = -ENOMEM; - goto exit_rc; - } - slot->dev_type = VIO_DEV; - slot->dev.vio_dev = vio_find_node(dn); - if (slot->dev.vio_dev) { - /* - * rpaphp is the only owner of vio devices and - * does not need extra reference taken by - * vio_find_node - */ - put_device(&slot->dev.vio_dev->dev); - } else - slot->dev.vio_dev = vio_register_device_node(dn); - if (slot->dev.vio_dev) - slot->state = CONFIGURED; - else - slot->state = NOT_CONFIGURED; - if (setup_vio_hotplug_slot_info(slot)) - goto exit_rc; - strcpy(slot->name, slot->dev.vio_dev->dev.bus_id); - info("%s: registered VIO device[name=%s vio_dev=%p]\n", - __FUNCTION__, slot->name, slot->dev.vio_dev); - rc = register_slot(slot); -exit_rc: - if (rc && slot) - dealloc_slot_struct(slot); - return (rc); -} - -int rpaphp_enable_vio_slot(struct slot *slot) -{ - int retval = 0; - - if ((slot->dev.vio_dev = vio_register_device_node(slot->dn))) { - info("%s: VIO adapter %s in slot[%s] has been configured\n", - __FUNCTION__, slot->dn->name, slot->name); - slot->state = CONFIGURED; - } else { - info("%s: no vio_dev struct for adapter in slot[%s]\n", - __FUNCTION__, slot->name); - slot->state = NOT_CONFIGURED; - } - - return retval; -} diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c index 323041fd41d..b1409441c1c 100644 --- a/drivers/pci/hotplug/sgi_hotplug.c +++ b/drivers/pci/hotplug/sgi_hotplug.c @@ -32,14 +32,15 @@ MODULE_LICENSE("GPL"); MODULE_AUTHOR("SGI (prarit@sgi.com, dickie@sgi.com, habeck@sgi.com)"); MODULE_DESCRIPTION("SGI Altix Hot Plug PCI Controller Driver"); -#define PCIIO_ASIC_TYPE_TIOCA 4 -#define PCI_SLOT_ALREADY_UP 2 /* slot already up */ -#define PCI_SLOT_ALREADY_DOWN 3 /* slot already down */ -#define PCI_L1_ERR 7 /* L1 console command error */ -#define PCI_EMPTY_33MHZ 15 /* empty 33 MHz bus */ -#define PCI_L1_QSIZE 128 /* our L1 message buffer size */ -#define SN_MAX_HP_SLOTS 32 /* max number of hotplug slots */ -#define SGI_HOTPLUG_PROM_REV 0x0420 /* Min. required PROM version */ +#define PCIIO_ASIC_TYPE_TIOCA 4 +#define PCI_SLOT_ALREADY_UP 2 /* slot already up */ +#define PCI_SLOT_ALREADY_DOWN 3 /* slot already down */ +#define PCI_L1_ERR 7 /* L1 console command error */ +#define PCI_EMPTY_33MHZ 15 /* empty 33 MHz bus */ +#define PCI_L1_QSIZE 128 /* our L1 message buffer size */ +#define SN_MAX_HP_SLOTS 32 /* max hotplug slots */ +#define SGI_HOTPLUG_PROM_REV 0x0430 /* Min. required PROM version */ +#define SN_SLOT_NAME_SIZE 33 /* size of name string */ /* internal list head */ static struct list_head sn_hp_list; @@ -51,6 +52,7 @@ struct slot { /* this struct for glue internal only */ struct hotplug_slot *hotplug_slot; struct list_head hp_list; + char physical_path[SN_SLOT_NAME_SIZE]; }; struct pcibr_slot_enable_resp { @@ -70,7 +72,7 @@ enum sn_pci_req_e { static int enable_slot(struct hotplug_slot *slot); static int disable_slot(struct hotplug_slot *slot); -static int get_power_status(struct hotplug_slot *slot, u8 *value); +static inline int get_power_status(struct hotplug_slot *slot, u8 *value); static struct hotplug_slot_ops sn_hotplug_slot_ops = { .owner = THIS_MODULE, @@ -81,6 +83,21 @@ static struct hotplug_slot_ops sn_hotplug_slot_ops = { static DECLARE_MUTEX(sn_hotplug_sem); +static ssize_t path_show (struct hotplug_slot *bss_hotplug_slot, + char *buf) +{ + int retval = -ENOENT; + struct slot *slot = bss_hotplug_slot->private; + + if (!slot) + return retval; + + retval = sprintf (buf, "%s\n", slot->physical_path); + return retval; +} + +static struct hotplug_slot_attribute sn_slot_path_attr = __ATTR_RO(path); + static int sn_pci_slot_valid(struct pci_bus *pci_bus, int device) { struct pcibus_info *pcibus_info; @@ -120,15 +137,15 @@ static int sn_pci_bus_valid(struct pci_bus *pci_bus) /* Only register slots in I/O Bricks that support hotplug */ bricktype = MODULE_GET_BTYPE(pcibus_info->pbi_moduleid); switch (bricktype) { - case L1_BRICKTYPE_IX: - case L1_BRICKTYPE_PX: - case L1_BRICKTYPE_IA: - case L1_BRICKTYPE_PA: - return 1; - break; - default: - return -EPERM; - break; + case L1_BRICKTYPE_IX: + case L1_BRICKTYPE_PX: + case L1_BRICKTYPE_IA: + case L1_BRICKTYPE_PA: + return 1; + break; + default: + return -EPERM; + break; } return -EIO; @@ -142,13 +159,12 @@ static int sn_hp_slot_private_alloc(struct hotplug_slot *bss_hotplug_slot, pcibus_info = SN_PCIBUS_BUSSOFT_INFO(pci_bus); - bss_hotplug_slot->private = kcalloc(1, sizeof(struct slot), - GFP_KERNEL); - if (!bss_hotplug_slot->private) + slot = kcalloc(1, sizeof(*slot), GFP_KERNEL); + if (!slot) return -ENOMEM; - slot = (struct slot *)bss_hotplug_slot->private; + bss_hotplug_slot->private = slot; - bss_hotplug_slot->name = kmalloc(33, GFP_KERNEL); + bss_hotplug_slot->name = kmalloc(SN_SLOT_NAME_SIZE, GFP_KERNEL); if (!bss_hotplug_slot->name) { kfree(bss_hotplug_slot->private); return -ENOMEM; @@ -156,16 +172,16 @@ static int sn_hp_slot_private_alloc(struct hotplug_slot *bss_hotplug_slot, slot->device_num = device; slot->pci_bus = pci_bus; - - sprintf(bss_hotplug_slot->name, "module_%c%c%c%c%.2d_b_%d_s_%d", + sprintf(bss_hotplug_slot->name, "%04x:%02x:%02x", + pci_domain_nr(pci_bus), + ((int)pcibus_info->pbi_buscommon.bs_persist_busnum) & 0xf, + device + 1); + sprintf(slot->physical_path, "module_%c%c%c%c%.2d", '0'+RACK_GET_CLASS(MODULE_GET_RACK(pcibus_info->pbi_moduleid)), '0'+RACK_GET_GROUP(MODULE_GET_RACK(pcibus_info->pbi_moduleid)), '0'+RACK_GET_NUM(MODULE_GET_RACK(pcibus_info->pbi_moduleid)), MODULE_GET_BTCHAR(pcibus_info->pbi_moduleid), - MODULE_GET_BPOS(pcibus_info->pbi_moduleid), - ((int)pcibus_info->pbi_buscommon.bs_persist_busnum) & 0xf, - device + 1); - + MODULE_GET_BPOS(pcibus_info->pbi_moduleid)); slot->hotplug_slot = bss_hotplug_slot; list_add(&slot->hp_list, &sn_hp_list); @@ -175,14 +191,14 @@ static int sn_hp_slot_private_alloc(struct hotplug_slot *bss_hotplug_slot, static struct hotplug_slot * sn_hp_destroy(void) { struct slot *slot; - struct list_head *list; struct hotplug_slot *bss_hotplug_slot = NULL; - list_for_each(list, &sn_hp_list) { - slot = list_entry(list, struct slot, hp_list); + list_for_each_entry(slot, &sn_hp_list, hp_list) { bss_hotplug_slot = slot->hotplug_slot; list_del(&((struct slot *)bss_hotplug_slot->private)-> hp_list); + sysfs_remove_file(&bss_hotplug_slot->kobj, + &sn_slot_path_attr.attr); break; } return bss_hotplug_slot; @@ -190,7 +206,6 @@ static struct hotplug_slot * sn_hp_destroy(void) static void sn_bus_alloc_data(struct pci_dev *dev) { - struct list_head *node; struct pci_bus *subordinate_bus; struct pci_dev *child; @@ -199,66 +214,29 @@ static void sn_bus_alloc_data(struct pci_dev *dev) /* Recursively sets up the sn_irq_info structs */ if (dev->subordinate) { subordinate_bus = dev->subordinate; - list_for_each(node, &subordinate_bus->devices) { - child = list_entry(node, struct pci_dev, bus_list); + list_for_each_entry(child, &subordinate_bus->devices, bus_list) sn_bus_alloc_data(child); - } } } static void sn_bus_free_data(struct pci_dev *dev) { - struct list_head *node; struct pci_bus *subordinate_bus; struct pci_dev *child; /* Recursively clean up sn_irq_info structs */ if (dev->subordinate) { subordinate_bus = dev->subordinate; - list_for_each(node, &subordinate_bus->devices) { - child = list_entry(node, struct pci_dev, bus_list); + list_for_each_entry(child, &subordinate_bus->devices, bus_list) sn_bus_free_data(child); - } } sn_pci_unfixup_slot(dev); } -static u8 sn_power_status_get(struct hotplug_slot *bss_hotplug_slot) -{ - struct slot *slot = (struct slot *)bss_hotplug_slot->private; - struct pcibus_info *pcibus_info; - u8 retval; - - pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus); - retval = pcibus_info->pbi_enabled_devices & (1 << slot->device_num); - - return retval ? 1 : 0; -} - -static void sn_slot_mark_enable(struct hotplug_slot *bss_hotplug_slot, - int device_num) -{ - struct slot *slot = (struct slot *)bss_hotplug_slot->private; - struct pcibus_info *pcibus_info; - - pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus); - pcibus_info->pbi_enabled_devices |= (1 << device_num); -} - -static void sn_slot_mark_disable(struct hotplug_slot *bss_hotplug_slot, - int device_num) -{ - struct slot *slot = (struct slot *)bss_hotplug_slot->private; - struct pcibus_info *pcibus_info; - - pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus); - pcibus_info->pbi_enabled_devices &= ~(1 << device_num); -} - static int sn_slot_enable(struct hotplug_slot *bss_hotplug_slot, int device_num) { - struct slot *slot = (struct slot *)bss_hotplug_slot->private; + struct slot *slot = bss_hotplug_slot->private; struct pcibus_info *pcibus_info; struct pcibr_slot_enable_resp resp; int rc; @@ -273,7 +251,7 @@ static int sn_slot_enable(struct hotplug_slot *bss_hotplug_slot, if (rc == PCI_SLOT_ALREADY_UP) { dev_dbg(slot->pci_bus->self, "is already active\n"); - return -EPERM; + return 1; /* return 1 to user */ } if (rc == PCI_L1_ERR) { @@ -290,7 +268,8 @@ static int sn_slot_enable(struct hotplug_slot *bss_hotplug_slot, return -EIO; } - sn_slot_mark_enable(bss_hotplug_slot, device_num); + pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus); + pcibus_info->pbi_enabled_devices |= (1 << device_num); return 0; } @@ -298,7 +277,7 @@ static int sn_slot_enable(struct hotplug_slot *bss_hotplug_slot, static int sn_slot_disable(struct hotplug_slot *bss_hotplug_slot, int device_num, int action) { - struct slot *slot = (struct slot *)bss_hotplug_slot->private; + struct slot *slot = bss_hotplug_slot->private; struct pcibus_info *pcibus_info; struct pcibr_slot_disable_resp resp; int rc; @@ -307,43 +286,44 @@ static int sn_slot_disable(struct hotplug_slot *bss_hotplug_slot, rc = sal_pcibr_slot_disable(pcibus_info, device_num, action, &resp); - if (action == PCI_REQ_SLOT_ELIGIBLE && rc == PCI_SLOT_ALREADY_DOWN) { + if ((action == PCI_REQ_SLOT_ELIGIBLE) && + (rc == PCI_SLOT_ALREADY_DOWN)) { dev_dbg(slot->pci_bus->self, "Slot %s already inactive\n"); - return -ENODEV; + return 1; /* return 1 to user */ } - if (action == PCI_REQ_SLOT_ELIGIBLE && rc == PCI_EMPTY_33MHZ) { + if ((action == PCI_REQ_SLOT_ELIGIBLE) && (rc == PCI_EMPTY_33MHZ)) { dev_dbg(slot->pci_bus->self, "Cannot remove last 33MHz card\n"); return -EPERM; } - if (action == PCI_REQ_SLOT_ELIGIBLE && rc == PCI_L1_ERR) { + if ((action == PCI_REQ_SLOT_ELIGIBLE) && (rc == PCI_L1_ERR)) { dev_dbg(slot->pci_bus->self, "L1 failure %d with message \n%s\n", resp.resp_sub_errno, resp.resp_l1_msg); return -EPERM; } - if (action == PCI_REQ_SLOT_ELIGIBLE && rc) { + if ((action == PCI_REQ_SLOT_ELIGIBLE) && rc) { dev_dbg(slot->pci_bus->self, "remove failed with error %d sub-error %d\n", rc, resp.resp_sub_errno); return -EIO; } - if (action == PCI_REQ_SLOT_ELIGIBLE && !rc) + if ((action == PCI_REQ_SLOT_ELIGIBLE) && !rc) return 0; - if (action == PCI_REQ_SLOT_DISABLE && !rc) { - sn_slot_mark_disable(bss_hotplug_slot, device_num); + if ((action == PCI_REQ_SLOT_DISABLE) && !rc) { + pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus); + pcibus_info->pbi_enabled_devices &= ~(1 << device_num); dev_dbg(slot->pci_bus->self, "remove successful\n"); return 0; } - if (action == PCI_REQ_SLOT_DISABLE && rc) { + if ((action == PCI_REQ_SLOT_DISABLE) && rc) { dev_dbg(slot->pci_bus->self,"remove failed rc = %d\n", rc); - return rc; } return rc; @@ -351,7 +331,7 @@ static int sn_slot_disable(struct hotplug_slot *bss_hotplug_slot, static int enable_slot(struct hotplug_slot *bss_hotplug_slot) { - struct slot *slot = (struct slot *)bss_hotplug_slot->private; + struct slot *slot = bss_hotplug_slot->private; struct pci_bus *new_bus = NULL; struct pci_dev *dev; int func, num_funcs; @@ -371,8 +351,8 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot) return rc; } - num_funcs = pci_scan_slot(slot->pci_bus, PCI_DEVFN(slot->device_num+1, - PCI_FUNC(0))); + num_funcs = pci_scan_slot(slot->pci_bus, + PCI_DEVFN(slot->device_num + 1, 0)); if (!num_funcs) { dev_dbg(slot->pci_bus->self, "no device in slot\n"); up(&sn_hotplug_sem); @@ -391,8 +371,6 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot) dev = pci_get_slot(slot->pci_bus, PCI_DEVFN(slot->device_num + 1, PCI_FUNC(func))); - - if (dev) { if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { unsigned char sec_bus; @@ -431,7 +409,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot) static int disable_slot(struct hotplug_slot *bss_hotplug_slot) { - struct slot *slot = (struct slot *)bss_hotplug_slot->private; + struct slot *slot = bss_hotplug_slot->private; struct pci_dev *dev; int func; int rc; @@ -448,7 +426,7 @@ static int disable_slot(struct hotplug_slot *bss_hotplug_slot) /* Free the SN resources assigned to the Linux device.*/ for (func = 0; func < 8; func++) { dev = pci_get_slot(slot->pci_bus, - PCI_DEVFN(slot->device_num+1, + PCI_DEVFN(slot->device_num + 1, PCI_FUNC(func))); if (dev) { /* @@ -477,10 +455,15 @@ static int disable_slot(struct hotplug_slot *bss_hotplug_slot) return rc; } -static int get_power_status(struct hotplug_slot *bss_hotplug_slot, u8 *value) +static inline int get_power_status(struct hotplug_slot *bss_hotplug_slot, + u8 *value) { + struct slot *slot = bss_hotplug_slot->private; + struct pcibus_info *pcibus_info; + + pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus); down(&sn_hotplug_sem); - *value = sn_power_status_get(bss_hotplug_slot); + *value = pcibus_info->pbi_enabled_devices & (1 << slot->device_num); up(&sn_hotplug_sem); return 0; } @@ -508,7 +491,7 @@ static int sn_hotplug_slot_register(struct pci_bus *pci_bus) if (sn_pci_slot_valid(pci_bus, device) != 1) continue; - bss_hotplug_slot = kcalloc(1,sizeof(struct hotplug_slot), + bss_hotplug_slot = kcalloc(1, sizeof(*bss_hotplug_slot), GFP_KERNEL); if (!bss_hotplug_slot) { rc = -ENOMEM; @@ -516,7 +499,7 @@ static int sn_hotplug_slot_register(struct pci_bus *pci_bus) } bss_hotplug_slot->info = - kcalloc(1,sizeof(struct hotplug_slot_info), + kcalloc(1, sizeof(struct hotplug_slot_info), GFP_KERNEL); if (!bss_hotplug_slot->info) { rc = -ENOMEM; @@ -535,6 +518,11 @@ static int sn_hotplug_slot_register(struct pci_bus *pci_bus) rc = pci_hp_register(bss_hotplug_slot); if (rc) goto register_err; + + rc = sysfs_create_file(&bss_hotplug_slot->kobj, + &sn_slot_path_attr.attr); + if (rc) + goto register_err; } dev_dbg(pci_bus->self, "Registered bus with hotplug\n"); return rc; @@ -564,14 +552,14 @@ static int sn_pci_hotplug_init(void) int rc; int registered = 0; - INIT_LIST_HEAD(&sn_hp_list); - if (sn_sal_rev() < SGI_HOTPLUG_PROM_REV) { - printk(KERN_ERR "%s: PROM version must be greater than 4.05\n", + printk(KERN_ERR "%s: PROM version must be greater than 4.30\n", __FUNCTION__); return -EPERM; } + INIT_LIST_HEAD(&sn_hp_list); + while ((pci_bus = pci_find_next_bus(pci_bus))) { if (!pci_bus->sysdata) continue; @@ -584,9 +572,9 @@ static int sn_pci_hotplug_init(void) dev_dbg(pci_bus->self, "valid hotplug bus\n"); rc = sn_hotplug_slot_register(pci_bus); - if (!rc) + if (!rc) { registered = 1; - else { + } else { registered = 0; break; } @@ -599,9 +587,8 @@ static void sn_pci_hotplug_exit(void) { struct hotplug_slot *bss_hotplug_slot; - while ((bss_hotplug_slot = sn_hp_destroy())) { + while ((bss_hotplug_slot = sn_hp_destroy())) pci_hp_deregister(bss_hotplug_slot); - } if (!list_empty(&sn_hp_list)) printk(KERN_ERR "%s: internal list is not empty\n", __FILE__); diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h index 67b6a3370ce..b7d1c61d6bb 100644 --- a/drivers/pci/hotplug/shpchp.h +++ b/drivers/pci/hotplug/shpchp.h @@ -23,7 +23,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * Send feedback to <greg@kroah.com>,<dely.l.sy@intel.com> + * Send feedback to <greg@kroah.com>,<kristen.c.accardi@intel.com> * */ #ifndef _SHPCHP_H @@ -411,7 +411,7 @@ static inline void return_resource(struct pci_resource **head, struct pci_resour static inline void make_slot_name(char *buffer, int buffer_size, struct slot *slot) { - snprintf(buffer, buffer_size, "%d", slot->number); + snprintf(buffer, buffer_size, "%04d_%04d", slot->bus, slot->number); } enum php_ctlr_type { diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c index a70a5c5705f..6f7d8a29957 100644 --- a/drivers/pci/hotplug/shpchp_core.c +++ b/drivers/pci/hotplug/shpchp_core.c @@ -23,7 +23,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * Send feedback to <greg@kroah.com>, <dely.l.sy@intel.com> + * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> * */ diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c index 490a9553a06..783b5abb071 100644 --- a/drivers/pci/hotplug/shpchp_ctrl.c +++ b/drivers/pci/hotplug/shpchp_ctrl.c @@ -23,7 +23,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * Send feedback to <greg@kroah.com>, <dely.l.sy@intel.com> + * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> * */ diff --git a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c index 38c5d906669..8d98410bf1c 100644 --- a/drivers/pci/hotplug/shpchp_hpc.c +++ b/drivers/pci/hotplug/shpchp_hpc.c @@ -23,7 +23,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * Send feedback to <greg@kroah.com>,<dely.l.sy@intel.com> + * Send feedback to <greg@kroah.com>,<kristen.c.accardi@intel.com> * */ diff --git a/drivers/pci/hotplug/shpchp_pci.c b/drivers/pci/hotplug/shpchp_pci.c index 90113e9cd69..d867099114e 100644 --- a/drivers/pci/hotplug/shpchp_pci.c +++ b/drivers/pci/hotplug/shpchp_pci.c @@ -23,7 +23,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * Send feedback to <greg@kroah.com>, <dely.l.sy@intel.com> + * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> * */ diff --git a/drivers/pci/hotplug/shpchprm.h b/drivers/pci/hotplug/shpchprm.h index 88aeb978c91..057b192ce58 100644 --- a/drivers/pci/hotplug/shpchprm.h +++ b/drivers/pci/hotplug/shpchprm.h @@ -23,7 +23,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * Send feedback to <greg@kroah.com>, <dely.l.sy@intel.com> + * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> * */ diff --git a/drivers/pci/hotplug/shpchprm_acpi.c b/drivers/pci/hotplug/shpchprm_acpi.c index 7957cdc72cd..d37b31658ed 100644 --- a/drivers/pci/hotplug/shpchprm_acpi.c +++ b/drivers/pci/hotplug/shpchprm_acpi.c @@ -20,7 +20,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * Send feedback to <dely.l.sy@intel.com> + * Send feedback to <kristen.c.accardi@intel.com> * */ diff --git a/drivers/pci/hotplug/shpchprm_legacy.c b/drivers/pci/hotplug/shpchprm_legacy.c index 37fa77a9828..ba6c549c9b9 100644 --- a/drivers/pci/hotplug/shpchprm_legacy.c +++ b/drivers/pci/hotplug/shpchprm_legacy.c @@ -23,7 +23,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * Send feedback to <greg@kroah.com>,<dely.l.sy@intel.com> + * Send feedback to <greg@kroah.com>,<kristen.c.accardi@intel.com> * */ diff --git a/drivers/pci/hotplug/shpchprm_legacy.h b/drivers/pci/hotplug/shpchprm_legacy.h index 29ccea5e57e..21bda74ddfa 100644 --- a/drivers/pci/hotplug/shpchprm_legacy.h +++ b/drivers/pci/hotplug/shpchprm_legacy.h @@ -23,7 +23,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * Send feedback to <greg@kroah.com>, <dely.l.sy@intel.com> + * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> * */ diff --git a/drivers/pci/hotplug/shpchprm_nonacpi.c b/drivers/pci/hotplug/shpchprm_nonacpi.c index 88f4d9f4188..5f75ef7f3df 100644 --- a/drivers/pci/hotplug/shpchprm_nonacpi.c +++ b/drivers/pci/hotplug/shpchprm_nonacpi.c @@ -23,7 +23,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * Send feedback to <greg@kroah.com>, <dely.l.sy@intel.com> + * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> * */ diff --git a/drivers/pci/hotplug/shpchprm_nonacpi.h b/drivers/pci/hotplug/shpchprm_nonacpi.h index 6bc8668023c..cddaaa5ee1b 100644 --- a/drivers/pci/hotplug/shpchprm_nonacpi.h +++ b/drivers/pci/hotplug/shpchprm_nonacpi.h @@ -23,7 +23,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * Send feedback to <greg@kroah.com>, <dely.l.sy@intel.com> + * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> * */ |