From: Tyrel Datwyler <tyreld@linux.ibm.com>
To: mpe@ellerman.id.au
Cc: nathanl@linux.ibm.com, Tyrel Datwyler <tyreld@linux.ibm.com>,
tlfalcon@linux.ibm.com, linux-pci@vger.kernel.org,
bhelgaas@google.com, linuxppc-dev@lists.ozlabs.org
Subject: [PATCH v2 6/9] PCI: rpaphp: Add drc-info support for hotplug slot registration
Date: Sun, 10 Nov 2019 23:21:33 -0600 [thread overview]
Message-ID: <1573449697-5448-7-git-send-email-tyreld@linux.ibm.com> (raw)
In-Reply-To: <1573449697-5448-1-git-send-email-tyreld@linux.ibm.com>
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>
---
drivers/pci/hotplug/rpaphp_core.c | 89 ++++++++++++++++++++++++++++++---------
1 file changed, 69 insertions(+), 20 deletions(-)
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
index e18e9a0..75d5771 100644
--- a/drivers/pci/hotplug/rpaphp_core.c
+++ b/drivers/pci/hotplug/rpaphp_core.c
@@ -328,23 +328,48 @@ static int is_php_dn(struct device_node *dn, const int **indexes,
return 1;
}
-/**
- * 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)
+static int rpaphp_drc_info_add_slot(struct device_node *dn)
+{
+ struct slot *slot;
+ struct property *info;
+ struct of_drc_info drc;
+ char drc_name[MAX_DRC_NAME_LEN];
+ const __be32 *cur;
+ u32 count;
+ int retval = 0;
+
+ info = of_find_property(dn, "ibm,drc-info", NULL);
+ if (!info)
+ return 0;
+
+ cur = of_prop_next_u32(info, NULL, &count);
+ if (cur)
+ 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;
int retval = 0;
@@ -352,9 +377,6 @@ int rpaphp_add_slot(struct device_node *dn)
const int *indexes, *names, *types, *power_domains;
char *name, *type;
- if (!dn->name || strcmp(dn->name, "pci"))
- return 0;
-
/* If this is not a hotplug slot, return without doing anything. */
if (!is_php_dn(dn, &indexes, &names, &types, &power_domains))
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 */
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);
static void __exit cleanup_slots(void)
--
2.7.4
next prev parent reply other threads:[~2019-11-11 5:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-11 5:21 [PATCH v2 0/9] Fixes and Enablement of ibm,drc-info property Tyrel Datwyler
2019-11-11 5:21 ` [PATCH v2 1/9] powerpc/pseries: Fix bad drc_index_start value parsing of drc-info entry Tyrel Datwyler
2019-11-14 9:08 ` Michael Ellerman
2019-11-11 5:21 ` [PATCH v2 2/9] powerpc/pseries: Fix drc-info mappings of logical cpus to drc-index Tyrel Datwyler
2019-11-11 5:21 ` [PATCH v2 3/9] powerpc/pseries: Add cpu DLPAR support for drc-info property Tyrel Datwyler
2019-11-11 5:21 ` [PATCH v2 4/9] PCI: rpaphp: Fix up pointer to first drc-info entry Tyrel Datwyler
2019-11-11 5:21 ` [PATCH v2 5/9] PCI: rpaphp: Don't rely on firmware feature to imply drc-info support Tyrel Datwyler
2019-11-11 5:21 ` Tyrel Datwyler [this message]
2019-11-11 5:21 ` [PATCH v2 7/9] PCI: rpaphp: annotate and correctly byte swap DRC properties Tyrel Datwyler
2019-11-11 5:21 ` [PATCH v2 7/9] PCI: rpaphp: Annotate " Tyrel Datwyler
2019-11-11 5:21 ` [PATCH v2 8/9] PCI: rpaphp: Correctly match ibm, my-drc-index to drc-name when using drc-info Tyrel Datwyler
2019-11-11 5:21 ` [PATCH v2 9/9] powerpc/pseries: Enable support for ibm, drc-info property Tyrel Datwyler
2019-11-11 19:49 ` [PATCH v2 0/9] Fixes and Enablement of ibm,drc-info property Bjorn Helgaas
2019-11-12 10:50 ` Michael Ellerman
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=1573449697-5448-7-git-send-email-tyreld@linux.ibm.com \
--to=tyreld@linux.ibm.com \
--cc=bhelgaas@google.com \
--cc=linux-pci@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=nathanl@linux.ibm.com \
--cc=tlfalcon@linux.ibm.com \
/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;
as well as URLs for NNTP newsgroup(s).