mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-11 07:30:16 +00:00
PCI: rpaphp: Add drc-info support for hotplug slot registration
Split physical PCI slot registration scanning into separate routines that support the old ibm,drc-* properties and one that supports the new compressed ibm,drc-info property. Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com> Acked-by: Bjorn Helgaas <bhelgaas@google.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/1573449697-5448-7-git-send-email-tyreld@linux.ibm.com
This commit is contained in:
parent
52e2b0f165
commit
efeda8fada
@ -328,23 +328,48 @@ static int is_php_dn(struct device_node *dn, const int **indexes,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
static int rpaphp_drc_info_add_slot(struct device_node *dn)
|
||||||
* rpaphp_add_slot -- declare a hotplug slot to the hotplug subsystem.
|
{
|
||||||
* @dn: device node of slot
|
struct slot *slot;
|
||||||
*
|
struct property *info;
|
||||||
* This subroutine will register a hotpluggable slot with the
|
struct of_drc_info drc;
|
||||||
* PCI hotplug infrastructure. This routine is typically called
|
char drc_name[MAX_DRC_NAME_LEN];
|
||||||
* during boot time, if the hotplug slots are present at boot time,
|
const __be32 *cur;
|
||||||
* or is called later, by the dlpar add code, if the slot is
|
u32 count;
|
||||||
* being dynamically added during runtime.
|
int retval = 0;
|
||||||
*
|
|
||||||
* If the device node points at an embedded (built-in) slot, this
|
info = of_find_property(dn, "ibm,drc-info", NULL);
|
||||||
* routine will just return without doing anything, since embedded
|
if (!info)
|
||||||
* slots cannot be hotplugged.
|
return 0;
|
||||||
*
|
|
||||||
* To remove a slot, it suffices to call rpaphp_deregister_slot().
|
cur = of_prop_next_u32(info, NULL, &count);
|
||||||
*/
|
if (cur)
|
||||||
int rpaphp_add_slot(struct device_node *dn)
|
cur++;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
of_read_drc_info_cell(&info, &cur, &drc);
|
||||||
|
if (!is_php_type(drc.drc_type))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
sprintf(drc_name, "%s%d", drc.drc_name_prefix, drc.drc_name_suffix_start);
|
||||||
|
|
||||||
|
slot = alloc_slot_struct(dn, drc.drc_index_start, drc_name, drc.drc_power_domain);
|
||||||
|
if (!slot)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
slot->type = simple_strtoul(drc.drc_type, NULL, 10);
|
||||||
|
retval = rpaphp_enable_slot(slot);
|
||||||
|
if (!retval)
|
||||||
|
retval = rpaphp_register_slot(slot);
|
||||||
|
|
||||||
|
if (retval)
|
||||||
|
dealloc_slot_struct(slot);
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rpaphp_drc_add_slot(struct device_node *dn)
|
||||||
{
|
{
|
||||||
struct slot *slot;
|
struct slot *slot;
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
@ -352,9 +377,6 @@ int rpaphp_add_slot(struct device_node *dn)
|
|||||||
const int *indexes, *names, *types, *power_domains;
|
const int *indexes, *names, *types, *power_domains;
|
||||||
char *name, *type;
|
char *name, *type;
|
||||||
|
|
||||||
if (!dn->name || strcmp(dn->name, "pci"))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* If this is not a hotplug slot, return without doing anything. */
|
/* If this is not a hotplug slot, return without doing anything. */
|
||||||
if (!is_php_dn(dn, &indexes, &names, &types, &power_domains))
|
if (!is_php_dn(dn, &indexes, &names, &types, &power_domains))
|
||||||
return 0;
|
return 0;
|
||||||
@ -393,6 +415,33 @@ int rpaphp_add_slot(struct device_node *dn)
|
|||||||
/* XXX FIXME: reports a failure only if last entry in loop failed */
|
/* XXX FIXME: reports a failure only if last entry in loop failed */
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rpaphp_add_slot -- declare a hotplug slot to the hotplug subsystem.
|
||||||
|
* @dn: device node of slot
|
||||||
|
*
|
||||||
|
* This subroutine will register a hotpluggable slot with the
|
||||||
|
* PCI hotplug infrastructure. This routine is typically called
|
||||||
|
* during boot time, if the hotplug slots are present at boot time,
|
||||||
|
* or is called later, by the dlpar add code, if the slot is
|
||||||
|
* being dynamically added during runtime.
|
||||||
|
*
|
||||||
|
* If the device node points at an embedded (built-in) slot, this
|
||||||
|
* routine will just return without doing anything, since embedded
|
||||||
|
* slots cannot be hotplugged.
|
||||||
|
*
|
||||||
|
* To remove a slot, it suffices to call rpaphp_deregister_slot().
|
||||||
|
*/
|
||||||
|
int rpaphp_add_slot(struct device_node *dn)
|
||||||
|
{
|
||||||
|
if (!dn->name || strcmp(dn->name, "pci"))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (of_find_property(dn, "ibm,drc-info", NULL))
|
||||||
|
return rpaphp_drc_info_add_slot(dn);
|
||||||
|
else
|
||||||
|
return rpaphp_drc_add_slot(dn);
|
||||||
|
}
|
||||||
EXPORT_SYMBOL_GPL(rpaphp_add_slot);
|
EXPORT_SYMBOL_GPL(rpaphp_add_slot);
|
||||||
|
|
||||||
static void __exit cleanup_slots(void)
|
static void __exit cleanup_slots(void)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user