powerpc/pseries/dlpar: Search DRC index from ibm,drc-indexes for IO add

[ Upstream commit 41a1452759 ]

IO hotplug add event is handled in the user space with drmgr tool.
After the device is enabled, the user space uses /sys/kernel/dlpar
interface with “dt add index <drc_index>” to update the device tree.
The kernel interface (dlpar_hp_dt_add()) finds the parent node for
the specified ‘drc_index’ from ibm,drc-info property. The recent FW
provides this property from 2017 onwards. But KVM guest code in
some releases is still using the older SLOF firmware which has
ibm,drc-indexes property instead of ibm,drc-info.

If the ibm,drc-info is not available, this patch adds changes to
search ‘drc_index’ from the indexes array in ibm,drc-indexes
property to support old FW.

Fixes: 02b98ff44a ("powerpc/pseries/dlpar: Add device tree nodes for DLPAR IO add")
Reported-by: Kowshik Jois <kowsjois@linux.ibm.com>
Signed-off-by: Haren Myneni <haren@linux.ibm.com>
Tested-by: Amit Machhiwal <amachhiw@linux.ibm.com>
Reviewed-by: Tyrel Datwyler <tyreld@linux.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20250531235002.239213-1-haren@linux.ibm.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Haren Myneni 2025-05-31 16:50:02 -07:00 committed by Greg Kroah-Hartman
parent c9c7b91bc1
commit 3f91bec308

View File

@ -404,6 +404,45 @@ get_device_node_with_drc_info(u32 index)
return NULL;
}
static struct device_node *
get_device_node_with_drc_indexes(u32 drc_index)
{
struct device_node *np = NULL;
u32 nr_indexes, index;
int i, rc;
for_each_node_with_property(np, "ibm,drc-indexes") {
/*
* First element in the array is the total number of
* DRC indexes returned.
*/
rc = of_property_read_u32_index(np, "ibm,drc-indexes",
0, &nr_indexes);
if (rc)
goto out_put_np;
/*
* Retrieve DRC index from the list and return the
* device node if matched with the specified index.
*/
for (i = 0; i < nr_indexes; i++) {
rc = of_property_read_u32_index(np, "ibm,drc-indexes",
i+1, &index);
if (rc)
goto out_put_np;
if (drc_index == index)
return np;
}
}
return NULL;
out_put_np:
of_node_put(np);
return NULL;
}
static int dlpar_hp_dt_add(u32 index)
{
struct device_node *np, *nodes;
@ -423,10 +462,19 @@ static int dlpar_hp_dt_add(u32 index)
goto out;
}
/*
* Recent FW provides ibm,drc-info property. So search
* for the user specified DRC index from ibm,drc-info
* property. If this property is not available, search
* in the indexes array from ibm,drc-indexes property.
*/
np = get_device_node_with_drc_info(index);
if (!np)
return -EIO;
if (!np) {
np = get_device_node_with_drc_indexes(index);
if (!np)
return -EIO;
}
/* Next, configure the connector. */
nodes = dlpar_configure_connector(cpu_to_be32(index), np);