Commit 5fa80fcd authored by John Rose's avatar John Rose Committed by Greg Kroah-Hartman

[PATCH] dlpar regression for ppc64 - probe change

This patch contains the driver bits for enabling DLPAR and PCI Hotplug
for the new OF-based PCI probe.  This functionality was regressed when
the new PCI approach was introduced.  Please apply if appropriate.
Signed-off-by: default avatarJohn Rose <johnrose@austin.ibm.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 249bb070
...@@ -134,43 +134,6 @@ static void rpadlpar_claim_one_bus(struct pci_bus *b) ...@@ -134,43 +134,6 @@ static void rpadlpar_claim_one_bus(struct pci_bus *b)
rpadlpar_claim_one_bus(child_bus); rpadlpar_claim_one_bus(child_bus);
} }
static int pci_add_secondary_bus(struct device_node *dn,
struct pci_dev *bridge_dev)
{
struct pci_dn *pdn = dn->data;
struct pci_controller *hose = pdn->phb;
struct pci_bus *child;
u8 sec_busno;
/* Get busno of downstream bus */
pci_read_config_byte(bridge_dev, PCI_SECONDARY_BUS, &sec_busno);
/* Allocate and add to children of bridge_dev->bus */
child = pci_add_new_bus(bridge_dev->bus, bridge_dev, sec_busno);
if (!child) {
printk(KERN_ERR "%s: could not add secondary bus\n", __FUNCTION__);
return -ENOMEM;
}
sprintf(child->name, "PCI Bus #%02x", child->number);
/* Fixup subordinate bridge bases and resources */
pcibios_fixup_bus(child);
/* Claim new bus resources */
rpadlpar_claim_one_bus(bridge_dev->bus);
if (hose->last_busno < child->number)
hose->last_busno = child->number;
pdn->bussubno = child->number;
/* ioremap() for child bus, which may or may not succeed */
remap_bus_range(child);
return 0;
}
static struct pci_dev *dlpar_find_new_dev(struct pci_bus *parent, static struct pci_dev *dlpar_find_new_dev(struct pci_bus *parent,
struct device_node *dev_dn) struct device_node *dev_dn)
{ {
...@@ -188,29 +151,41 @@ static struct pci_dev *dlpar_find_new_dev(struct pci_bus *parent, ...@@ -188,29 +151,41 @@ static struct pci_dev *dlpar_find_new_dev(struct pci_bus *parent,
static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn) static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn)
{ {
struct pci_dn *pdn = dn->data; struct pci_dn *pdn = dn->data;
struct pci_controller *hose = pdn->phb; struct pci_controller *phb = pdn->phb;
struct pci_dev *dev = NULL; struct pci_dev *dev = NULL;
/* Scan phb bus for EADS device, adding new one to bus->devices */ rpaphp_eeh_init_nodes(dn);
if (!pci_scan_single_device(hose->bus, pdn->devfn)) { /* Add EADS device to PHB bus, adding new entry to bus->devices */
printk(KERN_ERR "%s: found no device on bus\n", __FUNCTION__); dev = of_create_pci_dev(dn, phb->bus, pdn->devfn);
if (!dev) {
printk(KERN_ERR "%s: failed to create pci dev for %s\n",
__FUNCTION__, dn->full_name);
return NULL; return NULL;
} }
if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
of_scan_pci_bridge(dn, dev);
rpaphp_init_new_devs(dev->subordinate);
/* Claim new bus resources */
rpadlpar_claim_one_bus(dev->bus);
/* ioremap() for child bus, which may or may not succeed */
(void) remap_bus_range(dev->bus);
/* Add new devices to global lists. Register in proc, sysfs. */ /* Add new devices to global lists. Register in proc, sysfs. */
pci_bus_add_devices(hose->bus); pci_bus_add_devices(phb->bus);
/* Confirm new bridge dev was created */ /* Confirm new bridge dev was created */
dev = dlpar_find_new_dev(hose->bus, dn); dev = dlpar_find_new_dev(phb->bus, dn);
if (dev) { if (dev) {
if (dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) { if (dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) {
printk(KERN_ERR "%s: unexpected header type %d\n", printk(KERN_ERR "%s: unexpected header type %d\n",
__FUNCTION__, dev->hdr_type); __FUNCTION__, dev->hdr_type);
return NULL; return NULL;
} }
if (pci_add_secondary_bus(dn, dev))
return NULL;
} }
return dev; return dev;
...@@ -219,7 +194,6 @@ static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn) ...@@ -219,7 +194,6 @@ static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn)
static int dlpar_add_pci_slot(char *drc_name, struct device_node *dn) static int dlpar_add_pci_slot(char *drc_name, struct device_node *dn)
{ {
struct pci_dev *dev; struct pci_dev *dev;
int rc;
if (rpaphp_find_pci_bus(dn)) if (rpaphp_find_pci_bus(dn))
return -EINVAL; return -EINVAL;
...@@ -232,15 +206,6 @@ static int dlpar_add_pci_slot(char *drc_name, struct device_node *dn) ...@@ -232,15 +206,6 @@ static int dlpar_add_pci_slot(char *drc_name, struct device_node *dn)
return -EIO; 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 */ /* Add hotplug slot */
if (rpaphp_add_slot(dn)) { if (rpaphp_add_slot(dn)) {
printk(KERN_ERR "%s: unable to add hotplug slot %s\n", printk(KERN_ERR "%s: unable to add hotplug slot %s\n",
...@@ -435,6 +400,8 @@ int dlpar_remove_pci_slot(char *drc_name, struct device_node *dn) ...@@ -435,6 +400,8 @@ int dlpar_remove_pci_slot(char *drc_name, struct device_node *dn)
__FUNCTION__, drc_name); __FUNCTION__, drc_name);
return -EIO; return -EIO;
} }
} else {
rpaphp_unconfig_pci_adapter(bus);
} }
if (unmap_bus_range(bus)) { if (unmap_bus_range(bus)) {
......
...@@ -93,6 +93,8 @@ extern int rpaphp_claim_resource(struct pci_dev *dev, int resource); ...@@ -93,6 +93,8 @@ extern int rpaphp_claim_resource(struct pci_dev *dev, int resource);
extern int rpaphp_enable_pci_slot(struct slot *slot); extern int rpaphp_enable_pci_slot(struct slot *slot);
extern int register_pci_slot(struct slot *slot); extern int register_pci_slot(struct slot *slot);
extern int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value); extern int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value);
extern void rpaphp_init_new_devs(struct pci_bus *bus);
extern void rpaphp_eeh_init_nodes(struct device_node *dn);
extern int rpaphp_config_pci_adapter(struct pci_bus *bus); extern int rpaphp_config_pci_adapter(struct pci_bus *bus);
extern int rpaphp_unconfig_pci_adapter(struct pci_bus *bus); extern int rpaphp_unconfig_pci_adapter(struct pci_bus *bus);
......
...@@ -154,8 +154,7 @@ exit: ...@@ -154,8 +154,7 @@ exit:
} }
/* Must be called before pci_bus_add_devices */ /* Must be called before pci_bus_add_devices */
static void void rpaphp_fixup_new_pci_devices(struct pci_bus *bus, int fix_bus)
rpaphp_fixup_new_pci_devices(struct pci_bus *bus, int fix_bus)
{ {
struct pci_dev *dev; struct pci_dev *dev;
...@@ -184,6 +183,20 @@ rpaphp_fixup_new_pci_devices(struct pci_bus *bus, int fix_bus) ...@@ -184,6 +183,20 @@ rpaphp_fixup_new_pci_devices(struct pci_bus *bus, int fix_bus)
} }
} }
static void rpaphp_eeh_add_bus_device(struct pci_bus *bus)
{
struct pci_dev *dev;
list_for_each_entry(dev, &bus->devices, bus_list) {
eeh_add_device_late(dev);
if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
struct pci_bus *subbus = dev->subordinate;
if (subbus)
rpaphp_eeh_add_bus_device (subbus);
}
}
}
static int rpaphp_pci_config_bridge(struct pci_dev *dev) static int rpaphp_pci_config_bridge(struct pci_dev *dev)
{ {
u8 sec_busno; u8 sec_busno;
...@@ -217,6 +230,13 @@ static int rpaphp_pci_config_bridge(struct pci_dev *dev) ...@@ -217,6 +230,13 @@ static int rpaphp_pci_config_bridge(struct pci_dev *dev)
return 0; return 0;
} }
void rpaphp_init_new_devs(struct pci_bus *bus)
{
rpaphp_fixup_new_pci_devices(bus, 0);
rpaphp_eeh_add_bus_device(bus);
}
EXPORT_SYMBOL_GPL(rpaphp_init_new_devs);
/***************************************************************************** /*****************************************************************************
rpaphp_pci_config_slot() will configure all devices under the rpaphp_pci_config_slot() will configure all devices under the
given slot->dn and return the the first pci_dev. given slot->dn and return the the first pci_dev.
...@@ -233,36 +253,51 @@ rpaphp_pci_config_slot(struct pci_bus *bus) ...@@ -233,36 +253,51 @@ rpaphp_pci_config_slot(struct pci_bus *bus)
if (!dn || !dn->child) if (!dn || !dn->child)
return NULL; return NULL;
slotno = PCI_SLOT(PCI_DN(dn->child)->devfn); if (systemcfg->platform == PLATFORM_PSERIES_LPAR) {
of_scan_bus(dn, bus);
if (list_empty(&bus->devices)) {
err("%s: No new device found\n", __FUNCTION__);
return NULL;
}
/* pci_scan_slot should find all children */ rpaphp_init_new_devs(bus);
num = pci_scan_slot(bus, PCI_DEVFN(slotno, 0));
if (num) {
rpaphp_fixup_new_pci_devices(bus, 1);
pci_bus_add_devices(bus); pci_bus_add_devices(bus);
} dev = list_entry(&bus->devices, struct pci_dev, bus_list);
if (list_empty(&bus->devices)) { } else {
err("%s: No new device found\n", __FUNCTION__); slotno = PCI_SLOT(PCI_DN(dn->child)->devfn);
return NULL;
} /* pci_scan_slot should find all children */
list_for_each_entry(dev, &bus->devices, bus_list) { num = pci_scan_slot(bus, PCI_DEVFN(slotno, 0));
if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) if (num) {
rpaphp_pci_config_bridge(dev); 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);
rpaphp_eeh_add_bus_device(bus);
}
} }
return dev; return dev;
} }
static void enable_eeh(struct device_node *dn) void rpaphp_eeh_init_nodes(struct device_node *dn)
{ {
struct device_node *sib; struct device_node *sib;
for (sib = dn->child; sib; sib = sib->sibling) for (sib = dn->child; sib; sib = sib->sibling)
enable_eeh(sib); rpaphp_eeh_init_nodes(sib);
eeh_add_device_early(dn); eeh_add_device_early(dn);
return; return;
} }
EXPORT_SYMBOL_GPL(rpaphp_eeh_init_nodes);
static void print_slot_pci_funcs(struct pci_bus *bus) static void print_slot_pci_funcs(struct pci_bus *bus)
{ {
...@@ -289,7 +324,7 @@ int rpaphp_config_pci_adapter(struct pci_bus *bus) ...@@ -289,7 +324,7 @@ int rpaphp_config_pci_adapter(struct pci_bus *bus)
if (!dn) if (!dn)
goto exit; goto exit;
enable_eeh(dn); rpaphp_eeh_init_nodes(dn);
dev = rpaphp_pci_config_slot(bus); dev = rpaphp_pci_config_slot(bus);
if (!dev) { if (!dev) {
err("%s: can't find any devices.\n", __FUNCTION__); err("%s: can't find any devices.\n", __FUNCTION__);
...@@ -331,6 +366,7 @@ int rpaphp_unconfig_pci_adapter(struct pci_bus *bus) ...@@ -331,6 +366,7 @@ int rpaphp_unconfig_pci_adapter(struct pci_bus *bus)
} }
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(rpaphp_unconfig_pci_adapter);
static int setup_pci_hotplug_slot_info(struct slot *slot) static int setup_pci_hotplug_slot_info(struct slot *slot)
{ {
...@@ -444,8 +480,8 @@ int rpaphp_enable_pci_slot(struct slot *slot) ...@@ -444,8 +480,8 @@ int rpaphp_enable_pci_slot(struct slot *slot)
retval = rpaphp_config_pci_adapter(slot->bus); retval = rpaphp_config_pci_adapter(slot->bus);
if (!retval) { if (!retval) {
slot->state = CONFIGURED; slot->state = CONFIGURED;
dbg("%s: PCI devices in slot[%s] has been configured\n", info("%s: devices in slot[%s] configured\n",
__FUNCTION__, slot->name); __FUNCTION__, slot->name);
} else { } else {
slot->state = NOT_CONFIGURED; slot->state = NOT_CONFIGURED;
dbg("%s: no pci_dev struct for adapter in slot[%s]\n", dbg("%s: no pci_dev struct for adapter in slot[%s]\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment