@@ -454,6 +454,36 @@ out:
return ret;
}
+static int fdt_add_pmem_node(void *fdt, uint32_t acells, hwaddr mem_base,
+ uint32_t scells, hwaddr mem_len,
+ int numa_node_id)
+{
+ char *nodename = NULL;
+ int ret;
+
+ nodename = g_strdup_printf("/pmem@%" PRIx64, mem_base);
+ qemu_fdt_add_subnode(fdt, nodename);
+ qemu_fdt_setprop_string(fdt, nodename, "compatible", "pmem-region");
+ ret = qemu_fdt_setprop_sized_cells(fdt, nodename, "reg", acells, mem_base,
+ scells, mem_len);
+ if (ret < 0) {
+ fprintf(stderr, "couldn't set %s/reg\n", nodename);
+ goto out;
+ }
+ if (numa_node_id < 0) {
+ goto out;
+ }
+
+ ret = qemu_fdt_setprop_cell(fdt, nodename, "numa-node-id", numa_node_id);
+ if (ret < 0) {
+ fprintf(stderr, "couldn't set %s/numa-node-id\n", nodename);
+ }
+
+out:
+ g_free(nodename);
+ return ret;
+}
+
static void fdt_add_psci_node(void *fdt)
{
uint32_t cpu_suspend_fn;
@@ -541,7 +571,8 @@ static int fdt_add_hotpluggable_memory_nodes(void *fdt,
di = !is_nvdimm ? mi->u.dimm.data : mi->u.nvdimm.data;
if (is_nvdimm) {
- ret = -ENOENT; /* NV-DIMM not yet supported */
+ ret = fdt_add_pmem_node(fdt, acells, di->addr,
+ scells, di->size, di->node);
} else {
ret = fdt_add_memory_node(fdt, acells, di->addr,
scells, di->size, di->node);
In case of NV-DIMM slots, let's add /pmem DT nodes. Signed-off-by: Eric Auger <eric.auger@redhat.com> --- hw/arm/boot.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-)