In case of NV-DIMM slots, let's add /pmem DT nodes. Signed-off-by: Eric Auger <eric.au...@redhat.com>
--- v6 -> v7 - does the same rework as for fdt_add_memory_node --- hw/arm/boot.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index 4caaf91583..45e29b7b4a 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -450,6 +450,32 @@ 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; + 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) { + goto out; + } + + /* only set the NUMA ID if it is specified */ + if (numa_node_id >= 0) { + ret = qemu_fdt_setprop_cell(fdt, nodename, + "numa-node-id", numa_node_id); + } +out: + g_free(nodename); + return ret; +} + static void fdt_add_psci_node(void *fdt) { uint32_t cpu_suspend_fn; @@ -546,6 +572,20 @@ static int fdt_add_hotpluggable_memory_nodes(void *fdt, } break; } + case MEMORY_DEVICE_INFO_KIND_NVDIMM: + { + PCDIMMDeviceInfo *di = mi->u.nvdimm.data; + + ret = fdt_add_pmem_node(fdt, acells, di->addr, + scells, di->size, di->node); + if (ret) { + fprintf(stderr, + "couldn't add NVDIMM /memory@%"PRIx64" node\n", + di->addr); + goto out; + } + break; + } default: fprintf(stderr, "%s memory nodes are not yet supported\n", MemoryDeviceInfoKind_str(mi->type)); -- 2.20.1