SHA256
1
0
forked from pool/kexec-tools
kexec-tools/kexec-tools-ppc64-reinit.diff

69 lines
1.8 KiB
Diff
Raw Normal View History

From: Chandru S <chandru@linux.vnet.ibm.com>
Subject: [PATCH] powerpc: initialize drconf variables
References: bnc #468571
The ppc64-memory-ranges-dynamic.diff patch which added
realloc_memory_ranges() code to kexec-tools somehow removed
the initialization of lmb-size and num_of_lmbs required in
case of /proc/ibm,dynamic-reconfiguration-memory node.
Add the code here to initialize them back again in kexec-tools
Signed-off-by: Chandru S <chandru@linux.vnet.ibm.com>
Acked-by: Bernhard Walle <bwalle@suse.de>
---
kexec/arch/ppc64/kexec-ppc64.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
--- a/kexec/arch/ppc64/kexec-ppc64.c
+++ b/kexec/arch/ppc64/kexec-ppc64.c
@@ -96,7 +96,7 @@ err1:
}
-static int realloc_memory_ranges()
+static int realloc_memory_ranges(void)
{
size_t memory_range_len;
@@ -150,6 +150,23 @@ static int get_dyn_reconf_base_ranges(vo
FILE *file;
int i, n;
+ strcpy(fname, "/proc/device-tree/");
+ strcat(fname, "ibm,dynamic-reconfiguration-memory/ibm,lmb-size");
+ if ((file = fopen(fname, "r")) == NULL) {
+ perror(fname);
+ return -1;
+ }
+ if (fread(buf, 1, 8, file) != 8) {
+ perror(fname);
+ fclose(file);
+ return -1;
+ }
+ /*
+ * lmb_size, num_of_lmbs(global variables) are
+ * initialized once here.
+ */
+ lmb_size = ((uint64_t *)buf)[0];
+ fclose(file);
strcpy(fname, "/proc/device-tree/");
strcat(fname,
@@ -158,8 +175,14 @@ static int get_dyn_reconf_base_ranges(vo
perror(fname);
return -1;
}
+ /* first 4 bytes tell the number of lmbs */
+ if (fread(buf, 1, 4, file) != 4) {
+ perror(fname);
+ fclose(file);
+ return -1;
+ }
+ num_of_lmbs = ((unsigned int *)buf)[0];
- fseek(file, 4, SEEK_SET);
for (i = 0; i < num_of_lmbs; i++) {
if ((n = fread(buf, 1, 24, file)) < 0) {
perror(fname);