Skip to content

Commit 572f524

Browse files
hmynenigregkh
authored andcommitted
powerpc/pseries/dlpar: Search DRC index from ibm,drc-indexes for IO add
[ Upstream commit 41a1452 ] 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: 02b98ff ("powerpc/pseries/dlpar: Add device tree nodes for DLPAR IO add") Reported-by: Kowshik Jois <[email protected]> Signed-off-by: Haren Myneni <[email protected]> Tested-by: Amit Machhiwal <[email protected]> Reviewed-by: Tyrel Datwyler <[email protected]> Signed-off-by: Madhavan Srinivasan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Sasha Levin <[email protected]>
1 parent a12e57c commit 572f524

File tree

1 file changed

+50
-2
lines changed
  • arch/powerpc/platforms/pseries

1 file changed

+50
-2
lines changed

arch/powerpc/platforms/pseries/dlpar.c

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,45 @@ get_device_node_with_drc_info(u32 index)
404404
return NULL;
405405
}
406406

407+
static struct device_node *
408+
get_device_node_with_drc_indexes(u32 drc_index)
409+
{
410+
struct device_node *np = NULL;
411+
u32 nr_indexes, index;
412+
int i, rc;
413+
414+
for_each_node_with_property(np, "ibm,drc-indexes") {
415+
/*
416+
* First element in the array is the total number of
417+
* DRC indexes returned.
418+
*/
419+
rc = of_property_read_u32_index(np, "ibm,drc-indexes",
420+
0, &nr_indexes);
421+
if (rc)
422+
goto out_put_np;
423+
424+
/*
425+
* Retrieve DRC index from the list and return the
426+
* device node if matched with the specified index.
427+
*/
428+
for (i = 0; i < nr_indexes; i++) {
429+
rc = of_property_read_u32_index(np, "ibm,drc-indexes",
430+
i+1, &index);
431+
if (rc)
432+
goto out_put_np;
433+
434+
if (drc_index == index)
435+
return np;
436+
}
437+
}
438+
439+
return NULL;
440+
441+
out_put_np:
442+
of_node_put(np);
443+
return NULL;
444+
}
445+
407446
static int dlpar_hp_dt_add(u32 index)
408447
{
409448
struct device_node *np, *nodes;
@@ -423,10 +462,19 @@ static int dlpar_hp_dt_add(u32 index)
423462
goto out;
424463
}
425464

465+
/*
466+
* Recent FW provides ibm,drc-info property. So search
467+
* for the user specified DRC index from ibm,drc-info
468+
* property. If this property is not available, search
469+
* in the indexes array from ibm,drc-indexes property.
470+
*/
426471
np = get_device_node_with_drc_info(index);
427472

428-
if (!np)
429-
return -EIO;
473+
if (!np) {
474+
np = get_device_node_with_drc_indexes(index);
475+
if (!np)
476+
return -EIO;
477+
}
430478

431479
/* Next, configure the connector. */
432480
nodes = dlpar_configure_connector(cpu_to_be32(index), np);

0 commit comments

Comments
 (0)