[PATCH] powerpc: initialize drconf variables
Chandru
chandru at in.ibm.com
Fri Feb 6 01:37:17 EST 2009
The initialization of lmb_size and num_of_lmbs got removed as part of the
'kexec memory ranges dynamic allocation' patch to kexec-tools (which added
realloc_memory_ranges() code to kexec-tools). These variables are pertinent
to ppc64 systems with ibm,dynamic-reconfiguration-memory node in device-tree,
i.e systems with /proc/device-tree/ibm,dynamic-reconfiguration-memory. The
following patch adds code to initialize the variables back again in kexec-tools.
Without this patch kexec-tools will think that it needs to save only the memory
represented in memory@ nodes and will skip the memory in
/proc/device-tree/ibm,dynamic-reconfiguration-memory node of the device-tree.
Signed-off-by: Chandru S <chandru at linux.vnet.ibm.com>
Reviewed-by: Bernhard Walle <bwalle at suse.de>
---
kexec/arch/ppc64/kexec-ppc64.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
--- kexec-tools/kexec/arch/ppc64/kexec-ppc64.c.orig 2009-02-04 05:38:44.000000000 -0500
+++ kexec-tools/kexec/arch/ppc64/kexec-ppc64.c 2009-02-04 20:16:30.000000000 -0500
@@ -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);
More information about the kexec
mailing list