linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] nvram fixes
@ 2013-10-30 13:47 Cédric Le Goater
  2013-10-30 13:47 ` [PATCH 1/3] powerpc/nvram: scan partitions only once Cédric Le Goater
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Cédric Le Goater @ 2013-10-30 13:47 UTC (permalink / raw)
  To: benh; +Cc: Cédric Le Goater, linuxppc-dev

Hi,

Here are a few fixes for nvram, mostly endian issues. The patches are 
based on 3.12-rc7.

Cedric Le Goater (3):
  powerpc/nvram: scan partitions only once
  powerpc/nvram: fix endian issue when reading the NVRAM size
  powerpc/nvram: fix endian issue when reading the partition length

 arch/powerpc/kernel/nvram_64.c         |   10 ++++++++--
 arch/powerpc/platforms/chrp/nvram.c    |    4 ++--
 arch/powerpc/platforms/pseries/nvram.c |   10 +++++-----
 3 files changed, 15 insertions(+), 9 deletions(-)

Cheers,

C.

-- 
1.7.10.4

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

* [PATCH 1/3] powerpc/nvram: scan partitions only once
  2013-10-30 13:47 [PATCH 0/3] nvram fixes Cédric Le Goater
@ 2013-10-30 13:47 ` Cédric Le Goater
  2013-10-30 13:47 ` [PATCH 2/3] powerpc/nvram: fix endian issue when reading the NVRAM size Cédric Le Goater
  2013-10-30 13:47 ` [PATCH 3/3] powerpc/nvram: fix endian issue when using the partition length Cédric Le Goater
  2 siblings, 0 replies; 4+ messages in thread
From: Cédric Le Goater @ 2013-10-30 13:47 UTC (permalink / raw)
  To: benh; +Cc: Cedric Le Goater, linuxppc-dev

From: Cedric Le Goater <clg@fr.ibm.com>

nvram_scan_partitions() is called twice when initializing the "lnx,oops-log"
partition and the "ibm,rtas-log" partition. This fills the partition list
with duplicate entries. This patch moves the partition scan in the init
routine pseries_nvram_init_log_partitions() which is called only once.

Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
---
 arch/powerpc/platforms/pseries/nvram.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/nvram.c b/arch/powerpc/platforms/pseries/nvram.c
index d276cd3..2498d4d 100644
--- a/arch/powerpc/platforms/pseries/nvram.c
+++ b/arch/powerpc/platforms/pseries/nvram.c
@@ -429,9 +429,6 @@ static int __init pseries_nvram_init_os_partition(struct nvram_os_partition
 	loff_t p;
 	int size;
 
-	/* Scan nvram for partitions */
-	nvram_scan_partitions();
-
 	/* Look for ours */
 	p = nvram_find_partition(part->name, NVRAM_SIG_OS, &size);
 
@@ -795,6 +792,9 @@ static int __init pseries_nvram_init_log_partitions(void)
 {
 	int rc;
 
+	/* Scan nvram for partitions */
+	nvram_scan_partitions();
+
 	rc = pseries_nvram_init_os_partition(&rtas_log_partition);
 	nvram_init_oops_partition(rc == 0);
 	return 0;
-- 
1.7.10.4

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

* [PATCH 2/3] powerpc/nvram: fix endian issue when reading the NVRAM size
  2013-10-30 13:47 [PATCH 0/3] nvram fixes Cédric Le Goater
  2013-10-30 13:47 ` [PATCH 1/3] powerpc/nvram: scan partitions only once Cédric Le Goater
@ 2013-10-30 13:47 ` Cédric Le Goater
  2013-10-30 13:47 ` [PATCH 3/3] powerpc/nvram: fix endian issue when using the partition length Cédric Le Goater
  2 siblings, 0 replies; 4+ messages in thread
From: Cédric Le Goater @ 2013-10-30 13:47 UTC (permalink / raw)
  To: benh; +Cc: Cedric Le Goater, linuxppc-dev

From: Cedric Le Goater <clg@fr.ibm.com>

Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
---
 arch/powerpc/platforms/chrp/nvram.c    |    4 ++--
 arch/powerpc/platforms/pseries/nvram.c |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/platforms/chrp/nvram.c b/arch/powerpc/platforms/chrp/nvram.c
index d3ceff0..9ef8cc3 100644
--- a/arch/powerpc/platforms/chrp/nvram.c
+++ b/arch/powerpc/platforms/chrp/nvram.c
@@ -66,7 +66,7 @@ static void chrp_nvram_write(int addr, unsigned char val)
 void __init chrp_nvram_init(void)
 {
 	struct device_node *nvram;
-	const unsigned int *nbytes_p;
+	const __be32 *nbytes_p;
 	unsigned int proplen;
 
 	nvram = of_find_node_by_type(NULL, "nvram");
@@ -79,7 +79,7 @@ void __init chrp_nvram_init(void)
 		return;
 	}
 
-	nvram_size = *nbytes_p;
+	nvram_size = be32_to_cpup(nbytes_p);
 
 	printk(KERN_INFO "CHRP nvram contains %u bytes\n", nvram_size);
 	of_node_put(nvram);
diff --git a/arch/powerpc/platforms/pseries/nvram.c b/arch/powerpc/platforms/pseries/nvram.c
index 2498d4d..057fc89 100644
--- a/arch/powerpc/platforms/pseries/nvram.c
+++ b/arch/powerpc/platforms/pseries/nvram.c
@@ -804,7 +804,7 @@ machine_arch_initcall(pseries, pseries_nvram_init_log_partitions);
 int __init pSeries_nvram_init(void)
 {
 	struct device_node *nvram;
-	const unsigned int *nbytes_p;
+	const __be32 *nbytes_p;
 	unsigned int proplen;
 
 	nvram = of_find_node_by_type(NULL, "nvram");
@@ -817,7 +817,7 @@ int __init pSeries_nvram_init(void)
 		return -EIO;
 	}
 
-	nvram_size = *nbytes_p;
+	nvram_size = be32_to_cpup(nbytes_p);
 
 	nvram_fetch = rtas_token("nvram-fetch");
 	nvram_store = rtas_token("nvram-store");
-- 
1.7.10.4

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

* [PATCH 3/3] powerpc/nvram: fix endian issue when using the partition length
  2013-10-30 13:47 [PATCH 0/3] nvram fixes Cédric Le Goater
  2013-10-30 13:47 ` [PATCH 1/3] powerpc/nvram: scan partitions only once Cédric Le Goater
  2013-10-30 13:47 ` [PATCH 2/3] powerpc/nvram: fix endian issue when reading the NVRAM size Cédric Le Goater
@ 2013-10-30 13:47 ` Cédric Le Goater
  2 siblings, 0 replies; 4+ messages in thread
From: Cédric Le Goater @ 2013-10-30 13:47 UTC (permalink / raw)
  To: benh; +Cc: Cedric Le Goater, linuxppc-dev

From: Cedric Le Goater <clg@fr.ibm.com>

When reading partitions, the length has to be translated from 
big endian to the endian order of the host. Similarly, when writing 
partitions, the length needs to be in big endian order.

The userspace tool 'nvram' needs a similar fix as it is reading
and writing partitions through /dev/nram :

    http://sourceforge.net/p/powerpc-utils/mailman/message/31571277/

Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
---
 arch/powerpc/kernel/nvram_64.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
index 8213ee1..fd82c28 100644
--- a/arch/powerpc/kernel/nvram_64.c
+++ b/arch/powerpc/kernel/nvram_64.c
@@ -223,9 +223,13 @@ static int __init nvram_write_header(struct nvram_partition * part)
 {
 	loff_t tmp_index;
 	int rc;
-	
+	struct nvram_header phead;
+
+	memcpy(&phead, &part->header, NVRAM_HEADER_LEN);
+	phead.length = cpu_to_be16(phead.length);
+
 	tmp_index = part->index;
-	rc = ppc_md.nvram_write((char *)&part->header, NVRAM_HEADER_LEN, &tmp_index); 
+	rc = ppc_md.nvram_write((char *)&phead, NVRAM_HEADER_LEN, &tmp_index);
 
 	return rc;
 }
@@ -505,6 +509,8 @@ int __init nvram_scan_partitions(void)
 
 		memcpy(&phead, header, NVRAM_HEADER_LEN);
 
+		phead.length = be16_to_cpu(phead.length);
+
 		err = 0;
 		c_sum = nvram_checksum(&phead);
 		if (c_sum != phead.checksum) {
-- 
1.7.10.4

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

end of thread, other threads:[~2013-10-30 13:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-30 13:47 [PATCH 0/3] nvram fixes Cédric Le Goater
2013-10-30 13:47 ` [PATCH 1/3] powerpc/nvram: scan partitions only once Cédric Le Goater
2013-10-30 13:47 ` [PATCH 2/3] powerpc/nvram: fix endian issue when reading the NVRAM size Cédric Le Goater
2013-10-30 13:47 ` [PATCH 3/3] powerpc/nvram: fix endian issue when using the partition length Cédric Le Goater

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).