You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
2.6 KiB
93 lines
2.6 KiB
3 months ago
|
commit 9ea191d15f4b279923a4c83a94b83436c79e3482
|
||
|
Author: Haren Myneni <haren@linux.ibm.com>
|
||
|
Date: Tue Aug 13 14:40:23 2024 -0700
|
||
|
|
||
|
drmgr/pci: Enable in-kernel functionality to update device tree
|
||
|
|
||
|
drmgr updates the device tree by writing to /proc/ppc64/ofdt. Also
|
||
|
invokes configure_connector RTAS call to retrieve new device nodes
|
||
|
for IO ADD. But this functionality need /dev/mem access which is
|
||
|
restricted under system lockdown.
|
||
|
|
||
|
The kernel updates provided a sysfs file (/sys/kernel/dlpar) that
|
||
|
will allow drmgr command invoke the following interfaces to update
|
||
|
the device tree.
|
||
|
|
||
|
dt add index <DRC index> ---> To add new device nodes to the device
|
||
|
tree which is used for IO ADD.
|
||
|
|
||
|
dt remove index <DRC index> ---> To remove device nodes for IO
|
||
|
REMOVE
|
||
|
|
||
|
This patch checks the kernel interface for the availability of
|
||
|
device tree update feature and adds do_dt_kernel_dlpar() to invoke
|
||
|
the above kernel interfaces.
|
||
|
|
||
|
Signed-off-by: Haren Myneni <haren@linux.ibm.com>
|
||
|
Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com>
|
||
|
|
||
|
diff --git a/src/drmgr/common.c b/src/drmgr/common.c
|
||
|
index bfec0b9..70f4dfd 100644
|
||
|
--- a/src/drmgr/common.c
|
||
|
+++ b/src/drmgr/common.c
|
||
|
@@ -1504,6 +1504,12 @@ int kernel_dlpar_exists(void)
|
||
|
if (strstr(buf, "cpu"))
|
||
|
return 1;
|
||
|
break;
|
||
|
+ case DRC_TYPE_PCI:
|
||
|
+ case DRC_TYPE_PHB:
|
||
|
+ case DRC_TYPE_SLOT:
|
||
|
+ if (strstr(buf, "dt"))
|
||
|
+ return 1;
|
||
|
+ break;
|
||
|
default:
|
||
|
return 0;
|
||
|
}
|
||
|
diff --git a/src/drmgr/common_pci.c b/src/drmgr/common_pci.c
|
||
|
index 759589a..109e0d2 100644
|
||
|
--- a/src/drmgr/common_pci.c
|
||
|
+++ b/src/drmgr/common_pci.c
|
||
|
@@ -1619,3 +1619,32 @@ int disable_hp_children(char *drc_name)
|
||
|
}
|
||
|
return 0;
|
||
|
}
|
||
|
+
|
||
|
+/*
|
||
|
+ * kernel interface to update device tree nodes.
|
||
|
+ * dlpar dt [add|remove] index <#drc index>
|
||
|
+ */
|
||
|
+int do_dt_kernel_dlpar(uint32_t index, int action)
|
||
|
+{
|
||
|
+ char cmdbuf[256];
|
||
|
+ int offset;
|
||
|
+
|
||
|
+ offset = sprintf(cmdbuf, "%s ", "dt");
|
||
|
+
|
||
|
+ switch (action) {
|
||
|
+ case ADD:
|
||
|
+ offset += sprintf(cmdbuf + offset, "add ");
|
||
|
+ break;
|
||
|
+ case REMOVE:
|
||
|
+ offset += sprintf(cmdbuf + offset, "remove ");
|
||
|
+ break;
|
||
|
+ default:
|
||
|
+ /* Should not happen */
|
||
|
+ say(ERROR, "Invalid action type specified\n");
|
||
|
+ return -EINVAL;
|
||
|
+ }
|
||
|
+
|
||
|
+ offset += sprintf(cmdbuf + offset, "index 0x%x", index);
|
||
|
+
|
||
|
+ return do_kernel_dlpar(cmdbuf, offset);
|
||
|
+}
|
||
|
diff --git a/src/drmgr/dr.h b/src/drmgr/dr.h
|
||
|
index 60c31c4..72ede55 100644
|
||
|
--- a/src/drmgr/dr.h
|
||
|
+++ b/src/drmgr/dr.h
|
||
|
@@ -188,4 +188,5 @@ static inline int do_kernel_dlpar(const char *cmd, int len)
|
||
|
{
|
||
|
return do_kernel_dlpar_common(cmd, len, 0);
|
||
|
}
|
||
|
+int do_dt_kernel_dlpar(uint32_t, int);
|
||
|
#endif
|