diff options
author | Chandru <chandru@in.ibm.com> | 2009-02-06 12:07:17 +0530 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2009-02-08 20:19:46 +0900 |
commit | 0f15c4319a6f26d55ad0ddb58c1c43068091c570 (patch) | |
tree | cc43b5e7628b7ce0dbf919683b1bbdbba69c740e /kexec/arch/ppc64/kexec-ppc64.c | |
parent | 988a8a9c29230233abf7772bc3dce00603f3011a (diff) |
powerpc: initialize drconf variables
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@linux.vnet.ibm.com>
Reviewed-by: Bernhard Walle <bwalle@suse.de>
Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'kexec/arch/ppc64/kexec-ppc64.c')
-rw-r--r-- | kexec/arch/ppc64/kexec-ppc64.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/kexec/arch/ppc64/kexec-ppc64.c b/kexec/arch/ppc64/kexec-ppc64.c index 8d4e42b..758e547 100644 --- a/kexec/arch/ppc64/kexec-ppc64.c +++ b/kexec/arch/ppc64/kexec-ppc64.c @@ -150,6 +150,23 @@ static int get_dyn_reconf_base_ranges(void) 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(void) 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); |