From 895c0483abc4abd4db6f1b7374fd1130d803e578 Mon Sep 17 00:00:00 2001 From: jhibbits Date: Sat, 19 May 2018 03:45:38 +0000 Subject: [PATCH] Add yet another option for gathering available memory On some POWER9 systems, 'reg' denotes the full memory in the system, while 'linux,usable-memory' denotes the usable memory. Some memory is reserved for NVLink usage, so is partitioned off. Submitted by: Breno Leitao --- sys/powerpc/ofw/ofw_machdep.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sys/powerpc/ofw/ofw_machdep.c b/sys/powerpc/ofw/ofw_machdep.c index c86d6131b033..bb2cccd3ace6 100644 --- a/sys/powerpc/ofw/ofw_machdep.c +++ b/sys/powerpc/ofw/ofw_machdep.c @@ -342,6 +342,16 @@ ofw_mem_regions(struct mem_region *memp, int *memsz, res = parse_ofw_memory(phandle, "reg", &memp[msz]); msz += res/sizeof(struct mem_region); + + /* + * On POWER9 Systems we might have both linux,usable-memory and + * reg properties. 'reg' denotes all available memory, but we + * must use 'linux,usable-memory', a subset, as some memory + * regions are reserved for NVLink. + */ + if (OF_getproplen(phandle, "linux,usable-memory") >= 0) + res = parse_ofw_memory(phandle, "linux,usable-memory", + &availp[asz]); if (OF_getproplen(phandle, "available") >= 0) res = parse_ofw_memory(phandle, "available", &availp[asz]);