<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p><span
style="color: rgb(29, 28, 29); font-family: Slack-Lato, Slack-Fractions, appleLogo, sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: common-ligatures; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">Haren,
        could you please add the below tag:</span></p>
    <p><span
style="color: rgb(29, 28, 29); font-family: Slack-Lato, Slack-Fractions, appleLogo, sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: common-ligatures; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"><br>
      </span><span aria-label="" class="c-mrkdwn__br"
        data-stringify-type="paragraph-break"
style="box-sizing: inherit; height: 8px; display: block; color: rgb(29, 28, 29); font-family: Slack-Lato, Slack-Fractions, appleLogo, sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: common-ligatures; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"></span><span
style="color: rgb(29, 28, 29); font-family: Slack-Lato, Slack-Fractions, appleLogo, sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: common-ligatures; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">Reported-by:<span> </span></span><span
        class="c-mrkdwn__highlight"
style="box-sizing: inherit; background-color: var(--dt_color-surf-hgl-3); color: rgb(29, 28, 29); font-family: Slack-Lato, Slack-Fractions, appleLogo, sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: common-ligatures; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Kowshik
        Jois<<a class="moz-txt-link-abbreviated" href="mailto:kowsjois@linux.ibm.com">kowsjois@linux.ibm.com</a></span></p>
    <p><span class="c-mrkdwn__highlight"
style="box-sizing: inherit; background-color: var(--dt_color-surf-hgl-3); color: rgb(29, 28, 29); font-family: Slack-Lato, Slack-Fractions, appleLogo, sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: common-ligatures; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><br>
      </span></p>
    <p><span class="c-mrkdwn__highlight"
style="box-sizing: inherit; background-color: var(--dt_color-surf-hgl-3); color: rgb(29, 28, 29); font-family: Slack-Lato, Slack-Fractions, appleLogo, sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: common-ligatures; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Regards,</span></p>
    <p><span class="c-mrkdwn__highlight"
style="box-sizing: inherit; background-color: var(--dt_color-surf-hgl-3); color: rgb(29, 28, 29); font-family: Slack-Lato, Slack-Fractions, appleLogo, sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: common-ligatures; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Kowshik
        Jois B S<br>
      </span></p>
    <p><span
style="color: rgb(29, 28, 29); font-family: Slack-Lato, Slack-Fractions, appleLogo, sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: common-ligatures; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"><br>
      </span></p>
    <div class="moz-cite-prefix">On 01/05/25 09:40, Haren Myneni wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:20250501041056.1281055-1-haren@linux.ibm.com">
      <pre wrap="" class="moz-quote-pre">IO hotplug add event is handled in the user space with drmgr tool.
After the device is enabled, the user space uses /sys/kerne/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. But old FW
provides 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: 02b98ff44a57 ("powerpc/pseries/dlpar: Add device tree nodes for DLPAR IO add")
Signed-off-by: Haren Myneni <a class="moz-txt-link-rfc2396E" href="mailto:haren@linux.ibm.com"><haren@linux.ibm.com></a>
---
 arch/powerpc/platforms/pseries/dlpar.c | 52 +++++++++++++++++++++++++-
 1 file changed, 50 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
index 213aa26dc8b3..979487da6522 100644
--- a/arch/powerpc/platforms/pseries/dlpar.c
+++ b/arch/powerpc/platforms/pseries/dlpar.c
@@ -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);
</pre>
    </blockquote>
  </body>
</html>