Skip to contentSkip to conversation

powerpc: initialize drconf variables

PATCH Applied Chandru 3 participants 5 messages Feb 4, 2009 – Feb 8, 2009

Subsystems (2)
lore
Share & tools
lore

Chandru

author
#0 lore raw

PATCH 1/1 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 of device-tree and will skip the memory represented in /proc/device-tree/ibm,dynamic-reconfiguration-memory node of device-tree.

---

 kexec/arch/ppc64/kexec-ppc64.c |   25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)
kexec/arch/ppc64/kexec-ppc64.c renamed from kexec/arch/ppc64/kexec-ppc64.c.orig +24 -1
@@ -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) < 0) {
+		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) < 0) {
+		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);

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#1 lore raw

kexec/arch/ppc64/kexec-ppc64.c static int get_dyn_reconf_base_ranges(vo · line 159

Quoted 8 lines · Chandru
kexec/arch/ppc64/kexec-ppc64.c renamed from kexec/arch/ppc64/kexec-ppc64.c.orig +7 -0
+	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) < 0) {
    fread(buf, 1, 8, file) != 8

kexec/arch/ppc64/kexec-ppc64.c static int get_dyn_reconf_base_ranges(vo · line 179

Quoted 3 lines
kexec/arch/ppc64/kexec-ppc64.c renamed from kexec/arch/ppc64/kexec-ppc64.c.orig +2 -0
 	}
+	/* first 4 bytes tell the number of lmbs */
+	if (fread(buf, 1, 4, file) < 0) {
    fread(buf, 1, 4, file) != 4 

Regards,
Bernhard

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

author
#2 lore raw
Quoted 12 lines · On Wednesday 04 February 2009 22:18:56 Bernhard Walle wrote:

kexec/arch/ppc64/kexec-ppc64.c static int get_dyn_reconf_base_ranges(vo · line 159

Quoted 8 lines · Chandru
kexec/arch/ppc64/kexec-ppc64.c renamed from kexec/arch/ppc64/kexec-ppc64.c.orig +7 -0
+	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) < 0) {
    fread(buf, 1, 8, file) != 8
Quoted 5 lines

kexec/arch/ppc64/kexec-ppc64.c static int get_dyn_reconf_base_ranges(vo · line 179

Quoted 3 lines
kexec/arch/ppc64/kexec-ppc64.c renamed from kexec/arch/ppc64/kexec-ppc64.c.orig +2 -0
 	}
+	/* first 4 bytes tell the number of lmbs */
+	if (fread(buf, 1, 4, file) < 0) {
    fread(buf, 1, 4, file) != 4 

Thanks for pointing out the correction Bernhard. I will update the patch and send it again.

Thanks,
Chandru

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

author Reviewed-by Bernhard Walle
#3 lore raw
In reply to Bernhard Walle

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.

---

 kexec/arch/ppc64/kexec-ppc64.c |   25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)
kexec/arch/ppc64/kexec-ppc64.c renamed from kexec/arch/ppc64/kexec-ppc64.c.orig +24 -1
@@ -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);

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

Applied
#4 lore raw
Quoted 9 lines · Chandru

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.

Thanks, applied.

Signature · 9 lines
Simon Horman
  VA Linux Systems Japan K.K., Sydney, Australia Satellite Office
  H: www.vergenet.net/~horms/             W: www.valinux.co.jp/en


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec