diff options
author | Bharata B Rao <bharata@linux.vnet.ibm.com> | 2016-05-12 09:34:15 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2016-06-14 02:06:13 -0400 |
commit | 45b64ee64970dee9392229302efe1d1567e8d304 (patch) | |
tree | 955367018622b6f4c0999181f9934f26df252bca | |
parent | e70bd3ae914ec40d8505ed842d14285aac50b77a (diff) |
powerpc/numa: Fix multiple bugs in memory_hotplug_max()
memory_hotplug_max() uses hot_add_drconf_memory_max() to get maxmimum
addressable memory by referring to ibm,dyanamic-memory property. There
are three problems with the current approach:
1 hot_add_drconf_memory_max() assumes that ibm,dynamic-memory includes
all the LMBs of the guest, but that is not true for PowerKVM which
populates only DR LMBs (LMBs that can be hotplugged/removed) in that
property.
2 hot_add_drconf_memory_max() multiplies lmb-size with lmb-count to arrive
at the max possible address. Since ibm,dynamic-memory doesn't include
RMA LMBs, the address thus obtained will be less than the actual max
address. For example, if max possible memory size is 32G, with lmb-size
of 256MB there can be 127 LMBs in ibm,dynamic-memory (1 LMB for RMA
which won't be present here). hot_add_drconf_memory_max() would then
return the max addressable memory as 127 * 256MB = 31.75GB, the max
address should have been 32G which is what ibm,lrdr-capacity shows.
3 In PowerKVM, there can be a gap between the end of boot time RAM and
beginning of hotplug RAM area. So just multiplying lmb-count with
lmb-size will not provide the correct max possible address for PowerKVM.
This patch fixes 1 by using ibm,lrdr-capacity property to return the max
addressable memory whenever the property is present. Then it fixes 2 & 3
by fetching the address of the last LMB in ibm,dynamic-memory property.
Fixes: cd34206e949b ("powerpc: Add memory_hotplug_max()")
Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r-- | arch/powerpc/mm/numa.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c index 4a87ccb8970f..f8b1da776712 100644 --- a/arch/powerpc/mm/numa.c +++ b/arch/powerpc/mm/numa.c | |||
@@ -1164,17 +1164,33 @@ int hot_add_scn_to_nid(unsigned long scn_addr) | |||
1164 | static u64 hot_add_drconf_memory_max(void) | 1164 | static u64 hot_add_drconf_memory_max(void) |
1165 | { | 1165 | { |
1166 | struct device_node *memory = NULL; | 1166 | struct device_node *memory = NULL; |
1167 | struct device_node *dn = NULL; | ||
1167 | unsigned int drconf_cell_cnt = 0; | 1168 | unsigned int drconf_cell_cnt = 0; |
1168 | u64 lmb_size = 0; | 1169 | u64 lmb_size = 0; |
1169 | const __be32 *dm = NULL; | 1170 | const __be32 *dm = NULL; |
1171 | const __be64 *lrdr = NULL; | ||
1172 | struct of_drconf_cell drmem; | ||
1173 | |||
1174 | dn = of_find_node_by_path("/rtas"); | ||
1175 | if (dn) { | ||
1176 | lrdr = of_get_property(dn, "ibm,lrdr-capacity", NULL); | ||
1177 | of_node_put(dn); | ||
1178 | if (lrdr) | ||
1179 | return be64_to_cpup(lrdr); | ||
1180 | } | ||
1170 | 1181 | ||
1171 | memory = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory"); | 1182 | memory = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory"); |
1172 | if (memory) { | 1183 | if (memory) { |
1173 | drconf_cell_cnt = of_get_drconf_memory(memory, &dm); | 1184 | drconf_cell_cnt = of_get_drconf_memory(memory, &dm); |
1174 | lmb_size = of_get_lmb_size(memory); | 1185 | lmb_size = of_get_lmb_size(memory); |
1186 | |||
1187 | /* Advance to the last cell, each cell has 6 32 bit integers */ | ||
1188 | dm += (drconf_cell_cnt - 1) * 6; | ||
1189 | read_drconf_cell(&drmem, &dm); | ||
1175 | of_node_put(memory); | 1190 | of_node_put(memory); |
1191 | return drmem.base_addr + lmb_size; | ||
1176 | } | 1192 | } |
1177 | return lmb_size * drconf_cell_cnt; | 1193 | return 0; |
1178 | } | 1194 | } |
1179 | 1195 | ||
1180 | /* | 1196 | /* |