linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] More ppc64 nvram code cleanup
@ 2010-11-12  4:53 Jim Keniston
  2010-11-12  4:53 ` [PATCH 1/4] Fix powerpc nvram init order Jim Keniston
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Jim Keniston @ 2010-11-12  4:53 UTC (permalink / raw)
  To: linuxppc-dev

This series contains some fixups to Ben Herrenschmidt's Aug. 2 patch
set, "[RFC] Clean up ppc64 nvram code" --
http://lists.ozlabs.org/pipermail/linuxppc-dev/2010-August/084601.html

These patches apply atop Ben's 11-patch series.
---

Jim Keniston (4):
      Handle partition names >= 12 chars
      Fix NVRAM partition list setup
      Fix nvram_create_partition() arg order
      Fix powerpc nvram init order


 arch/powerpc/kernel/nvram_64.c         |   31 +++++++++++--------------------
 arch/powerpc/platforms/pseries/nvram.c |    8 ++++----
 2 files changed, 15 insertions(+), 24 deletions(-)

--
Jim Keniston
IBM Linux Technology Center
Beaverton, OR

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/4] Fix powerpc nvram init order
  2010-11-12  4:53 [PATCH 0/4] More ppc64 nvram code cleanup Jim Keniston
@ 2010-11-12  4:53 ` Jim Keniston
  2010-11-12  4:54 ` [PATCH 2/4] Fix nvram_create_partition() arg order Jim Keniston
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Jim Keniston @ 2010-11-12  4:53 UTC (permalink / raw)
  To: linuxppc-dev

Don't run pseries_nvram_init_log_partition() until after the partition
list has been initialized.  Fixes a boot-time crash.

Signed-off-by: Jim Keniston <jkenisto@us.ibm.com>
---

 arch/powerpc/platforms/pseries/nvram.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/nvram.c b/arch/powerpc/platforms/pseries/nvram.c
index e3acb0b..e1a43d9 100644
--- a/arch/powerpc/platforms/pseries/nvram.c
+++ b/arch/powerpc/platforms/pseries/nvram.c
@@ -318,7 +318,7 @@ static int __init pseries_nvram_init_log_partition(void)
 	
 	return 0;
 }
-machine_arch_initcall(pseries, pseries_nvram_init_log_partition);
+machine_late_initcall(pseries, pseries_nvram_init_log_partition);
 
 int __init pSeries_nvram_init(void)
 {

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/4] Fix nvram_create_partition() arg order
  2010-11-12  4:53 [PATCH 0/4] More ppc64 nvram code cleanup Jim Keniston
  2010-11-12  4:53 ` [PATCH 1/4] Fix powerpc nvram init order Jim Keniston
@ 2010-11-12  4:54 ` Jim Keniston
  2010-11-12  4:54 ` [PATCH 3/4] Fix NVRAM partition list setup Jim Keniston
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Jim Keniston @ 2010-11-12  4:54 UTC (permalink / raw)
  To: linuxppc-dev

Use the correct arg order when calling nvram_create_partition().

Signed-off-by: Jim Keniston <jkenisto@us.ibm.com>
---

 arch/powerpc/platforms/pseries/nvram.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/nvram.c b/arch/powerpc/platforms/pseries/nvram.c
index e1a43d9..4b705dc 100644
--- a/arch/powerpc/platforms/pseries/nvram.c
+++ b/arch/powerpc/platforms/pseries/nvram.c
@@ -292,7 +292,7 @@ static int __init pseries_nvram_init_log_partition(void)
 	/* Create one if we didn't find */
 	if (!p) {
 		p = nvram_create_partition(NVRAM_LOG_PART_NAME, NVRAM_SIG_OS,
-					   NVRAM_MIN_REQ, NVRAM_MAX_REQ);
+					   NVRAM_MAX_REQ, NVRAM_MIN_REQ);
 		/* No room for it, try to get rid of any OS partition
 		 * and try again
 		 */
@@ -301,8 +301,8 @@ static int __init pseries_nvram_init_log_partition(void)
 				" partition, deleting all OS partitions...");
 			nvram_remove_partition(NULL, NVRAM_SIG_OS);
 			p = nvram_create_partition(NVRAM_LOG_PART_NAME,
-						   NVRAM_SIG_OS, NVRAM_MIN_REQ,
-						   NVRAM_MAX_REQ);
+						   NVRAM_SIG_OS, NVRAM_MAX_REQ,
+						   NVRAM_MIN_REQ);
 		}
 	}
 

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/4] Fix NVRAM partition list setup
  2010-11-12  4:53 [PATCH 0/4] More ppc64 nvram code cleanup Jim Keniston
  2010-11-12  4:53 ` [PATCH 1/4] Fix powerpc nvram init order Jim Keniston
  2010-11-12  4:54 ` [PATCH 2/4] Fix nvram_create_partition() arg order Jim Keniston
@ 2010-11-12  4:54 ` Jim Keniston
  2010-11-12  4:54 ` [PATCH 4/4] Handle partition names >= 12 chars Jim Keniston
  2010-11-30  5:25 ` [PATCH 0/4] More ppc64 nvram code cleanup Benjamin Herrenschmidt
  4 siblings, 0 replies; 6+ messages in thread
From: Jim Keniston @ 2010-11-12  4:54 UTC (permalink / raw)
  To: linuxppc-dev

Simplify creation and use of the NVRAM partition list.

Signed-off-by: Jim Keniston <jkenisto@us.ibm.com>
---

 arch/powerpc/kernel/nvram_64.c |   26 ++++++++------------------
 1 files changed, 8 insertions(+), 18 deletions(-)

diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
index d467f8c..19122d4 100644
--- a/arch/powerpc/kernel/nvram_64.c
+++ b/arch/powerpc/kernel/nvram_64.c
@@ -51,7 +51,7 @@ struct nvram_partition {
 	unsigned int index;
 };
 
-static struct nvram_partition * nvram_part;
+static LIST_HEAD(nvram_partitions);
 
 static loff_t dev_nvram_llseek(struct file *file, loff_t offset, int origin)
 {
@@ -196,13 +196,11 @@ static struct miscdevice nvram_dev = {
 #ifdef DEBUG_NVRAM
 static void __init nvram_print_partitions(char * label)
 {
-	struct list_head * p;
 	struct nvram_partition * tmp_part;
 	
 	printk(KERN_WARNING "--------%s---------\n", label);
 	printk(KERN_WARNING "indx\t\tsig\tchks\tlen\tname\n");
-	list_for_each(p, &nvram_part->partition) {
-		tmp_part = list_entry(p, struct nvram_partition, partition);
+	list_for_each_entry(tmp_part, &nvram_partitions, partition) {
 		printk(KERN_WARNING "%4d    \t%02x\t%02x\t%d\t%s\n",
 		       tmp_part->index, tmp_part->header.signature,
 		       tmp_part->header.checksum, tmp_part->header.length,
@@ -250,7 +248,7 @@ int __init nvram_remove_partition(const char *name, int sig)
 	struct nvram_partition *part, *prev, *tmp;
 	int rc;
 
-	list_for_each_entry(part, &nvram_part->partition, partition) {
+	list_for_each_entry(part, &nvram_partitions, partition) {
 		if (part->header.signature != sig)
 			continue;
 		if (name && strncmp(name, part->header.name, 12))
@@ -269,7 +267,7 @@ int __init nvram_remove_partition(const char *name, int sig)
 
 	/* Merge contiguous ones */
 	prev = NULL;
-	list_for_each_entry_safe(part, tmp, &nvram_part->partition, partition) {
+	list_for_each_entry_safe(part, tmp, &nvram_partitions, partition) {
 		if (part->header.signature != NVRAM_SIG_FREE) {
 			prev = NULL;
 			continue;
@@ -333,7 +331,7 @@ loff_t __init nvram_create_partition(const char *name, int sig,
 
 	/* Find a free partition that will give us the maximum needed size 
 	   If can't find one that will give us the minimum size needed */
-	list_for_each_entry(part, &nvram_part->partition, partition) {
+	list_for_each_entry(part, &nvram_partitions, partition) {
 		if (part->header.signature != NVRAM_SIG_FREE)
 			continue;
 
@@ -412,7 +410,7 @@ int nvram_get_partition_size(loff_t data_index)
 {
 	struct nvram_partition *part;
 	
-	list_for_each_entry(part, &nvram_part->partition, partition) {
+	list_for_each_entry(part, &nvram_partitions, partition) {
 		if (part->index + NVRAM_HEADER_LEN == data_index)
 			return (part->header.length - 1) * NVRAM_BLOCK_LEN;
 	}
@@ -430,7 +428,7 @@ loff_t nvram_find_partition(const char *name, int sig, int *out_size)
 {
 	struct nvram_partition *p;
 
-	list_for_each_entry(p, &nvram_part->partition, partition) {
+	list_for_each_entry(p, &nvram_partitions, partition) {
 		if (p->header.signature == sig &&
 		    (!name || !strncmp(p->header.name, name, 12))) {
 			if (out_size)
@@ -499,7 +497,7 @@ static int __init nvram_scan_partitions(void)
 		
 		memcpy(&tmp_part->header, &phead, NVRAM_HEADER_LEN);
 		tmp_part->index = cur_index;
-		list_add_tail(&tmp_part->partition, &nvram_part->partition);
+		list_add_tail(&tmp_part->partition, &nvram_partitions);
 		
 		cur_index += phead.length * NVRAM_BLOCK_LEN;
 	}
@@ -526,14 +524,6 @@ static int __init nvram_init(void)
 		return rc;
 	}
   	
-  	/* initialize our anchor for the nvram partition list */
-  	nvram_part = kmalloc(sizeof(struct nvram_partition), GFP_KERNEL);
-  	if (!nvram_part) {
-  		printk(KERN_ERR "nvram_init: Failed kmalloc\n");
-  		return -ENOMEM;
-  	}
-  	INIT_LIST_HEAD(&nvram_part->partition);
-  
   	/* Get all the NVRAM partitions */
   	error = nvram_scan_partitions();
   	if (error) {

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/4] Handle partition names >= 12 chars
  2010-11-12  4:53 [PATCH 0/4] More ppc64 nvram code cleanup Jim Keniston
                   ` (2 preceding siblings ...)
  2010-11-12  4:54 ` [PATCH 3/4] Fix NVRAM partition list setup Jim Keniston
@ 2010-11-12  4:54 ` Jim Keniston
  2010-11-30  5:25 ` [PATCH 0/4] More ppc64 nvram code cleanup Benjamin Herrenschmidt
  4 siblings, 0 replies; 6+ messages in thread
From: Jim Keniston @ 2010-11-12  4:54 UTC (permalink / raw)
  To: linuxppc-dev

The name field in the nvram_header can be < 12 chars, null-terminated,
or 12 chars without the null.  Handle this safely.

Signed-off-by: Jim Keniston <jkenisto@us.ibm.com>
---

 arch/powerpc/kernel/nvram_64.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
index 19122d4..cda7c3f 100644
--- a/arch/powerpc/kernel/nvram_64.c
+++ b/arch/powerpc/kernel/nvram_64.c
@@ -42,6 +42,7 @@ struct nvram_header {
 	unsigned char signature;
 	unsigned char checksum;
 	unsigned short length;
+	/* Terminating null required only for names < 12 chars. */
 	char name[12];
 };
 
@@ -201,7 +202,7 @@ static void __init nvram_print_partitions(char * label)
 	printk(KERN_WARNING "--------%s---------\n", label);
 	printk(KERN_WARNING "indx\t\tsig\tchks\tlen\tname\n");
 	list_for_each_entry(tmp_part, &nvram_partitions, partition) {
-		printk(KERN_WARNING "%4d    \t%02x\t%02x\t%d\t%s\n",
+		printk(KERN_WARNING "%4d    \t%02x\t%02x\t%d\t%12s\n",
 		       tmp_part->index, tmp_part->header.signature,
 		       tmp_part->header.checksum, tmp_part->header.length,
 		       tmp_part->header.name);
@@ -256,7 +257,7 @@ int __init nvram_remove_partition(const char *name, int sig)
 
 		/* Make partition a free partition */
 		part->header.signature = NVRAM_SIG_FREE;
-		sprintf(part->header.name, "wwwwwwwwwwww");
+		strncpy(part->header.name, "wwwwwwwwwwww", 12);
 		part->header.checksum = nvram_checksum(&part->header);
 		rc = nvram_write_header(part);
 		if (rc <= 0) {

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/4] More ppc64 nvram code cleanup
  2010-11-12  4:53 [PATCH 0/4] More ppc64 nvram code cleanup Jim Keniston
                   ` (3 preceding siblings ...)
  2010-11-12  4:54 ` [PATCH 4/4] Handle partition names >= 12 chars Jim Keniston
@ 2010-11-30  5:25 ` Benjamin Herrenschmidt
  4 siblings, 0 replies; 6+ messages in thread
From: Benjamin Herrenschmidt @ 2010-11-30  5:25 UTC (permalink / raw)
  To: Jim Keniston; +Cc: linuxppc-dev

On Thu, 2010-11-11 at 20:53 -0800, Jim Keniston wrote:
> This series contains some fixups to Ben Herrenschmidt's Aug. 2 patch
> set, "[RFC] Clean up ppc64 nvram code" --
> http://lists.ozlabs.org/pipermail/linuxppc-dev/2010-August/084601.html
> 
> These patches apply atop Ben's 11-patch series.
> ---
> 
> Jim Keniston (4):
>       Handle partition names >= 12 chars
>       Fix NVRAM partition list setup
>       Fix nvram_create_partition() arg order
>       Fix powerpc nvram init order

I've folded the first two (or a slightly different variant) in my series
and applied the two next on top. I'll post that new version of the
series to the list after a few tests today and will include it in next
in a couple of days, possibly along with your other patches provided
they survive my review :-)

Cheers,
Ben.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-11-30  5:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-12  4:53 [PATCH 0/4] More ppc64 nvram code cleanup Jim Keniston
2010-11-12  4:53 ` [PATCH 1/4] Fix powerpc nvram init order Jim Keniston
2010-11-12  4:54 ` [PATCH 2/4] Fix nvram_create_partition() arg order Jim Keniston
2010-11-12  4:54 ` [PATCH 3/4] Fix NVRAM partition list setup Jim Keniston
2010-11-12  4:54 ` [PATCH 4/4] Handle partition names >= 12 chars Jim Keniston
2010-11-30  5:25 ` [PATCH 0/4] More ppc64 nvram code cleanup Benjamin Herrenschmidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).