Skip to contentSkip to conversation

mips: bcm47xx: allow retrieval of complete nvram contents

PATCH In review Arend van Spriel 2 participants 8 messages May 21, 2015 – May 29, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mips: bcm47xx: allow retrieval of complete nvram contents

From: Hante Meuleman <[email protected]>

Host platforms such as routers supported by OpenWrt can support NVRAM reading directly from internal NVRAM store. The brcmfmac for one requires the complete nvram contents to select what needs to be sent to wireless device.

---
Change log:
-----------
V2: - correct header length for nvram_find_and_copy().
- get rid of 'NVRAM_SPACE - 2' magic.

---
 arch/mips/bcm47xx/nvram.c     | 61 ++++++++++++++++++++++++++++++++-----------
 include/linux/bcm47xx_nvram.h | 15 +++++++++++
 2 files changed, 61 insertions(+), 15 deletions(-)
arch/mips/bcm47xx/nvram.c +46 -15
index 95d028c..f4f62d3 100644
@@ -94,17 +94,22 @@ static int nvram_find_and_copy(void __iomem *iobase, u32 lim)
 	return -ENXIO;
 
 found:
-	if (header->len > size)
-		pr_err("The nvram size accoridng to the header seems to be bigger than the partition on flash\n");
-	if (header->len > NVRAM_SPACE)
-		pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
-		       header->len, NVRAM_SPACE - 1);
-
 	src = (u32 *)header;
 	dst = (u32 *)nvram_buf;
 	for (i = 0; i < sizeof(struct nvram_header); i += 4)
 		*dst++ = __raw_readl(src++);
-	for (; i < header->len && i < NVRAM_SPACE && i < size; i += 4)
+	header = (struct nvram_header *)nvram_buf;
+	if (header->len > size) {
+		pr_err("The nvram size according to the header seems to be bigger than the partition on flash\n");
+		header->len = size;
+	}
+	if (header->len >= NVRAM_SPACE) {
+		pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
+		       header->len, NVRAM_SPACE - 1);
+		header->len = NVRAM_SPACE - 1;
+	}
+	/* proceed reading data after header */
+	for (; i < header->len; i += 4)
 		*dst++ = readl(src++);
 	nvram_buf[NVRAM_SPACE - 1] = '\0';
 
@@ -139,6 +144,7 @@ static int nvram_init(void)
 #ifdef CONFIG_MTD
 	struct mtd_info *mtd;
 	struct nvram_header header;
+	struct nvram_header *pheader;
 	size_t bytes_read;
 	int err;
 
@@ -147,20 +153,21 @@ static int nvram_init(void)
 		return -ENODEV;
 
 	err = mtd_read(mtd, 0, sizeof(header), &bytes_read, (uint8_t *)&header);
-	if (!err && header.magic == NVRAM_MAGIC) {
-		u8 *dst = (uint8_t *)nvram_buf;
-		size_t len = header.len;
-
-		if (len >= NVRAM_SPACE) {
-			len = NVRAM_SPACE - 1;
+	if (!err && header.magic == NVRAM_MAGIC &&
+	    header.len > sizeof(header)) {
+		if (header.len >= NVRAM_SPACE) {
 			pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
-				header.len, len);
+				header.len, NVRAM_SPACE);
+			header.len = NVRAM_SPACE - 1;
 		}
 
-		err = mtd_read(mtd, 0, len, &bytes_read, dst);
+		err = mtd_read(mtd, 0, header.len, &bytes_read,
+			       (u8 *)nvram_buf);
 		if (err)
 			return err;
 
+		pheader = (struct nvram_header *)nvram_buf;
+		pheader->len = header.len;
 		return 0;
 	}
 #endif
@@ -219,3 +226,27 @@ int bcm47xx_nvram_gpio_pin(const char *name)
 	return -ENOENT;
 }
 EXPORT_SYMBOL(bcm47xx_nvram_gpio_pin);
+
+char *bcm47xx_nvram_get_contents(size_t *nvram_size)
+{
+	int err;
+	char *nvram;
+	struct nvram_header *header;
+
+	if (!nvram_buf[0]) {
+		err = nvram_init();
+		if (err)
+			return NULL;
+	}
+
+	header = (struct nvram_header *)nvram_buf;
+	*nvram_size = header->len - sizeof(struct nvram_header);
+	nvram = vmalloc(*nvram_size);
+	if (!nvram)
+		return NULL;
+	memcpy(nvram, &nvram_buf[sizeof(struct nvram_header)], *nvram_size);
+
+	return nvram;
+}
+EXPORT_SYMBOL(bcm47xx_nvram_get_contents);
+
include/linux/bcm47xx_nvram.h +15 -0
index b12b07e..c73927c 100644
@@ -10,11 +10,17 @@
 
 #include <linux/types.h>
 #include <linux/kernel.h>
+#include <linux/vmalloc.h>
 
 #ifdef CONFIG_BCM47XX
 int bcm47xx_nvram_init_from_mem(u32 base, u32 lim);
 int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len);
 int bcm47xx_nvram_gpio_pin(const char *name);
+char *bcm47xx_nvram_get_contents(size_t *val_len);
+static inline void bcm47xx_nvram_release_contents(char *nvram)
+{
+	vfree(nvram);
+};
 #else
 static inline int bcm47xx_nvram_init_from_mem(u32 base, u32 lim)
 {
@@ -29,6 +35,15 @@ static inline int bcm47xx_nvram_gpio_pin(const char *name)
 {
 	return -ENOTSUPP;
 };
+
+static inline char *bcm47xx_nvram_get_contents(size_t *val_len)
+{
+	return NULL;
+};
+
+static inline void bcm47xx_nvram_release_contents(char *nvram)
+{
+};
 #endif
 
 #endif /* __BCM47XX_NVRAM_H */
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 35 lines · Arend van Spriel

From: Hante Meuleman <[email protected]>

Host platforms such as routers supported by OpenWrt can support NVRAM reading directly from internal NVRAM store. The brcmfmac for one requires the complete nvram contents to select what needs to be sent to wireless device.

---
Change log:
-----------
V2: - correct header length for nvram_find_and_copy().
- get rid of 'NVRAM_SPACE - 2' magic.

---
 arch/mips/bcm47xx/nvram.c     | 61 ++++++++++++++++++++++++++++++++-----------
 include/linux/bcm47xx_nvram.h | 15 +++++++++++
 2 files changed, 61 insertions(+), 15 deletions(-)
arch/mips/bcm47xx/nvram.c +0 -4
index 95d028c..f4f62d3 100644
@@ -94,17 +94,22 @@ static int nvram_find_and_copy(void __iomem *iobase, u32 lim)
 	return -ENXIO;
 
 found:
-	if (header->len > size)
-		pr_err("The nvram size accoridng to the header seems to be bigger than the partition on flash\n");
-	if (header->len > NVRAM_SPACE)
-		pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",

arch/mips/bcm47xx/nvram.c static int nvram_find_and_copy(void __iomem *iobase, u32 lim) · line 103

Quoted 10 lines
arch/mips/bcm47xx/nvram.c +3 -3
-		       header->len, NVRAM_SPACE - 1);
-
 	src = (u32 *)header;
 	dst = (u32 *)nvram_buf;
 	for (i = 0; i < sizeof(struct nvram_header); i += 4)
 		*dst++ = __raw_readl(src++);
-	for (; i < header->len && i < NVRAM_SPACE && i < size; i += 4)
+	header = (struct nvram_header *)nvram_buf;
+	if (header->len > size) {
+		pr_err("The nvram size according to the header seems to be bigger than the partition on flash\n");

Thanks for fixing a typo. ;-)

arch/mips/bcm47xx/nvram.c static int nvram_find_and_copy(void __iomem *iobase, u32 lim) · line 104

Quoted 1 line
arch/mips/bcm47xx/nvram.c +1 -0
+		header->len = size;

I haven't seen this error case, I just added it to be save.

arch/mips/bcm47xx/nvram.c static int nvram_find_and_copy(void __iomem *iobase, u32 lim) · line 110

Quoted 6 lines
arch/mips/bcm47xx/nvram.c +6 -0
+	}
+	if (header->len >= NVRAM_SPACE) {
+		pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
+		       header->len, NVRAM_SPACE - 1);
+		header->len = NVRAM_SPACE - 1;
+	}

After fixing the length the header is better, but it also contains a CRC, which is still wrong, but we ignore it and I do not think we have to check.

I still think that the best approach would be to remove the nvram header and add a extra variable storing the actual size of the nvram buf. I also think this would make some of this code easier.

Quoted 56 lines
arch/mips/bcm47xx/nvram.c +21 -8
+	/* proceed reading data after header */
+	for (; i < header->len; i += 4)
 		*dst++ = readl(src++);
 	nvram_buf[NVRAM_SPACE - 1] = '\0';
 
@@ -139,6 +144,7 @@ static int nvram_init(void)
 #ifdef CONFIG_MTD
 	struct mtd_info *mtd;
 	struct nvram_header header;
+	struct nvram_header *pheader;
 	size_t bytes_read;
 	int err;
 
@@ -147,20 +153,21 @@ static int nvram_init(void)
 		return -ENODEV;
 
 	err = mtd_read(mtd, 0, sizeof(header), &bytes_read, (uint8_t *)&header);
-	if (!err && header.magic == NVRAM_MAGIC) {
-		u8 *dst = (uint8_t *)nvram_buf;
-		size_t len = header.len;
-
-		if (len >= NVRAM_SPACE) {
-			len = NVRAM_SPACE - 1;
+	if (!err && header.magic == NVRAM_MAGIC &&
+	    header.len > sizeof(header)) {
+		if (header.len >= NVRAM_SPACE) {
 			pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
-				header.len, len);
+				header.len, NVRAM_SPACE);
+			header.len = NVRAM_SPACE - 1;
 		}
 
-		err = mtd_read(mtd, 0, len, &bytes_read, dst);
+		err = mtd_read(mtd, 0, header.len, &bytes_read,
+			       (u8 *)nvram_buf);
 		if (err)
 			return err;
 
+		pheader = (struct nvram_header *)nvram_buf;
+		pheader->len = header.len;
 		return 0;
 	}
 #endif
@@ -219,3 +226,27 @@ int bcm47xx_nvram_gpio_pin(const char *name)
 	return -ENOENT;
 }
 EXPORT_SYMBOL(bcm47xx_nvram_gpio_pin);
+
+char *bcm47xx_nvram_get_contents(size_t *nvram_size)
+{
+	int err;
+	char *nvram;
+	struct nvram_header *header;
+
+	if (!nvram_buf[0]) {
+		err = nvram_init();

arch/mips/bcm47xx/nvram.c int bcm47xx_nvram_gpio_pin(const char *name) · line 247

Quoted 10 lines
arch/mips/bcm47xx/nvram.c +10 -0
+		if (err)
+			return NULL;
+	}
+
+	header = (struct nvram_header *)nvram_buf;
+	*nvram_size = header->len - sizeof(struct nvram_header);
+	nvram = vmalloc(*nvram_size);
+	if (!nvram)
+		return NULL;
+	memcpy(nvram, &nvram_buf[sizeof(struct nvram_header)], *nvram_size);

I have no real opinion if we need to copy it or provide a pointer to the nvram buf. I trust brcmfmac that it does not screw around with this data. ;-)

Quoted 44 lines
arch/mips/bcm47xx/nvram.c +5 -0
+
+	return nvram;
+}
+EXPORT_SYMBOL(bcm47xx_nvram_get_contents);
+
include/linux/bcm47xx_nvram.h +15 -0
index b12b07e..c73927c 100644
@@ -10,11 +10,17 @@
 
 #include <linux/types.h>
 #include <linux/kernel.h>
+#include <linux/vmalloc.h>
 
 #ifdef CONFIG_BCM47XX
 int bcm47xx_nvram_init_from_mem(u32 base, u32 lim);
 int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len);
 int bcm47xx_nvram_gpio_pin(const char *name);
+char *bcm47xx_nvram_get_contents(size_t *val_len);
+static inline void bcm47xx_nvram_release_contents(char *nvram)
+{
+	vfree(nvram);
+};
 #else
 static inline int bcm47xx_nvram_init_from_mem(u32 base, u32 lim)
 {
@@ -29,6 +35,15 @@ static inline int bcm47xx_nvram_gpio_pin(const char *name)
 {
 	return -ENOTSUPP;
 };
+
+static inline char *bcm47xx_nvram_get_contents(size_t *val_len)
+{
+	return NULL;
+};
+
+static inline void bcm47xx_nvram_release_contents(char *nvram)
+{
+};
 #endif
 
 #endif /* __BCM47XX_NVRAM_H */
#2 lore raw
Quoted 51 lines · Hauke Mehrtens
Quoted 35 lines · Arend van Spriel

From: Hante Meuleman<[email protected]>

Host platforms such as routers supported by OpenWrt can support NVRAM reading directly from internal NVRAM store. The brcmfmac for one requires the complete nvram contents to select what needs to be sent to wireless device.

---
Change log:
-----------
V2: - correct header length for nvram_find_and_copy().
- get rid of 'NVRAM_SPACE - 2' magic.

---
  arch/mips/bcm47xx/nvram.c     | 61 ++++++++++++++++++++++++++++++++-----------
  include/linux/bcm47xx_nvram.h | 15 +++++++++++
  2 files changed, 61 insertions(+), 15 deletions(-)
arch/mips/bcm47xx/nvram.c +0 -4
index 95d028c..f4f62d3 100644
@@ -94,17 +94,22 @@ static int nvram_find_and_copy(void __iomem *iobase, u32 lim)
  	return -ENXIO;
 
  found:
-	if (header->len>  size)
-		pr_err("The nvram size accoridng to the header seems to be bigger than the partition on flash\n");
-	if (header->len>  NVRAM_SPACE)
-		pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",

arch/mips/bcm47xx/nvram.c static int nvram_find_and_copy(void __iomem *iobase, u32 lim) · line 103

Quoted 10 lines
arch/mips/bcm47xx/nvram.c +3 -3
-		       header->len, NVRAM_SPACE - 1);
-
  	src = (u32 *)header;
  	dst = (u32 *)nvram_buf;
  	for (i = 0; i<  sizeof(struct nvram_header); i += 4)
  		*dst++ = __raw_readl(src++);
-	for (; i<  header->len&&  i<  NVRAM_SPACE&&  i<  size; i += 4)
+	header = (struct nvram_header *)nvram_buf;
+	if (header->len>  size) {
+		pr_err("The nvram size according to the header seems to be bigger than the partition on flash\n");

Thanks for fixing a typo. ;-)

Quoted 3 lines

arch/mips/bcm47xx/nvram.c static int nvram_find_and_copy(void __iomem *iobase, u32 lim) · line 104

Quoted 1 line
arch/mips/bcm47xx/nvram.c +1 -0
+		header->len = size;

I haven't seen this error case, I just added it to be save.

It does seem an unlikely error case. At least it would probably been noticed during production writing the content to flash.

Quoted 11 lines

arch/mips/bcm47xx/nvram.c static int nvram_find_and_copy(void __iomem *iobase, u32 lim) · line 110

Quoted 6 lines
arch/mips/bcm47xx/nvram.c +6 -0
+	}
+	if (header->len>= NVRAM_SPACE) {
+		pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
+		       header->len, NVRAM_SPACE - 1);
+		header->len = NVRAM_SPACE - 1;
+	}

After fixing the length the header is better, but it also contains a CRC, which is still wrong, but we ignore it and I do not think we have to check.

Quoted 3 lines

I still think that the best approach would be to remove the nvram header and add a extra variable storing the actual size of the nvram buf. I also think this would make some of this code easier.

Let's do that then.

Quoted 62 lines
Quoted 62 lines
arch/mips/bcm47xx/nvram.c +27 -8
+	/* proceed reading data after header */
+	for (; i<  header->len; i += 4)
  		*dst++ = readl(src++);
  	nvram_buf[NVRAM_SPACE - 1] = '\0';
 
@@ -139,6 +144,7 @@ static int nvram_init(void)
  #ifdef CONFIG_MTD
  	struct mtd_info *mtd;
  	struct nvram_header header;
+	struct nvram_header *pheader;
  	size_t bytes_read;
  	int err;
 
@@ -147,20 +153,21 @@ static int nvram_init(void)
  		return -ENODEV;
 
  	err = mtd_read(mtd, 0, sizeof(header),&bytes_read, (uint8_t *)&header);
-	if (!err&&  header.magic == NVRAM_MAGIC) {
-		u8 *dst = (uint8_t *)nvram_buf;
-		size_t len = header.len;
-
-		if (len>= NVRAM_SPACE) {
-			len = NVRAM_SPACE - 1;
+	if (!err&&  header.magic == NVRAM_MAGIC&&
+	    header.len>  sizeof(header)) {
+		if (header.len>= NVRAM_SPACE) {
  			pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
-				header.len, len);
+				header.len, NVRAM_SPACE);
+			header.len = NVRAM_SPACE - 1;
  		}
 
-		err = mtd_read(mtd, 0, len,&bytes_read, dst);
+		err = mtd_read(mtd, 0, header.len,&bytes_read,
+			       (u8 *)nvram_buf);
  		if (err)
  			return err;
 
+		pheader = (struct nvram_header *)nvram_buf;
+		pheader->len = header.len;
  		return 0;
  	}
  #endif
@@ -219,3 +226,27 @@ int bcm47xx_nvram_gpio_pin(const char *name)
  	return -ENOENT;
  }
  EXPORT_SYMBOL(bcm47xx_nvram_gpio_pin);
+
+char *bcm47xx_nvram_get_contents(size_t *nvram_size)
+{
+	int err;
+	char *nvram;
+	struct nvram_header *header;
+
+	if (!nvram_buf[0]) {
+		err = nvram_init();
+		if (err)
+			return NULL;
+	}
+
+	header = (struct nvram_header *)nvram_buf;
+	*nvram_size = header->len - sizeof(struct nvram_header);
Quoted 8 lines

arch/mips/bcm47xx/nvram.c int bcm47xx_nvram_gpio_pin(const char *name)

Quoted 4 lines
arch/mips/bcm47xx/nvram.c +4 -0
+	nvram = vmalloc(*nvram_size);
+	if (!nvram)
+		return NULL;
+	memcpy(nvram,&nvram_buf[sizeof(struct nvram_header)], *nvram_size);

I have no real opinion if we need to copy it or provide a pointer to the nvram buf. I trust brcmfmac that it does not screw around with this data. ;-)

I would not dare. Most variables are pitch black magic to me.

Regards,
Arend

Quoted 44 lines
Quoted 44 lines
arch/mips/bcm47xx/nvram.c +5 -0
+
+	return nvram;
+}
+EXPORT_SYMBOL(bcm47xx_nvram_get_contents);
+
include/linux/bcm47xx_nvram.h +15 -0
index b12b07e..c73927c 100644
@@ -10,11 +10,17 @@
 
  #include<linux/types.h>
  #include<linux/kernel.h>
+#include<linux/vmalloc.h>
 
  #ifdef CONFIG_BCM47XX
  int bcm47xx_nvram_init_from_mem(u32 base, u32 lim);
  int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len);
  int bcm47xx_nvram_gpio_pin(const char *name);
+char *bcm47xx_nvram_get_contents(size_t *val_len);
+static inline void bcm47xx_nvram_release_contents(char *nvram)
+{
+	vfree(nvram);
+};
  #else
  static inline int bcm47xx_nvram_init_from_mem(u32 base, u32 lim)
  {
@@ -29,6 +35,15 @@ static inline int bcm47xx_nvram_gpio_pin(const char *name)
  {
  	return -ENOTSUPP;
  };
+
+static inline char *bcm47xx_nvram_get_contents(size_t *val_len)
+{
+	return NULL;
+};
+
+static inline void bcm47xx_nvram_release_contents(char *nvram)
+{
+};
  #endif
 
  #endif /* __BCM47XX_NVRAM_H */
#3 lore raw
Quoted 76 lines · Arend van Spriel
Quoted 56 lines · Hauke Mehrtens
Quoted 42 lines · Arend van Spriel

From: Hante Meuleman<[email protected]>

Host platforms such as routers supported by OpenWrt can support NVRAM reading directly from internal NVRAM store. The brcmfmac for one requires the complete nvram contents to select what needs to be sent to wireless device.

---
Change log:
-----------
V2: - correct header length for nvram_find_and_copy().
- get rid of 'NVRAM_SPACE - 2' magic.
---
arch/mips/bcm47xx/nvram.c | 61
++++++++++++++++++++++++++++++++-----------
include/linux/bcm47xx_nvram.h | 15 +++++++++++

2 files changed, 61 insertions(+), 15 deletions(-)
arch/mips/bcm47xx/nvram.c +0 -0
index 95d028c..f4f62d3 100644
@@ -94,17 +94,22 @@ static int nvram_find_and_copy(void __iomem
 *iobase, u32 lim)
 return -ENXIO;
 

found:
- if (header->len> size)
- pr_err("The nvram size accoridng to the header seems to be bigger than the partition on flash\n");
- if (header->len> NVRAM_SPACE)
- pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
- header->len, NVRAM_SPACE - 1);
-
src = (u32 *)header;

Quoted 8 lines

dst = (u32 *)nvram_buf;
for (i = 0; i< sizeof(struct nvram_header); i += 4) *dst++ = __raw_readl(src++);
- for (; i< header->len&& i< NVRAM_SPACE&& i< size; i += 4)
+ header = (struct nvram_header *)nvram_buf;
+ if (header->len> size) {
+ pr_err("The nvram size according to the header seems to be bigger than the partition on flash\n");

Thanks for fixing a typo. ;-)

Quoted 3 lines
Quoted 1 line

+ header->len = size;

I haven't seen this error case, I just added it to be save.

It does seem an unlikely error case. At least it would probably been noticed during production writing the content to flash.

Quoted 12 lines
Quoted 7 lines

+ }
+ if (header->len>= NVRAM_SPACE) {
+ pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
+ header->len, NVRAM_SPACE - 1);
+ header->len = NVRAM_SPACE - 1;
+ }

After fixing the length the header is better, but it also contains a CRC, which is still wrong, but we ignore it and I do not think we have to check.

Quoted 5 lines
Quoted 3 lines

I still think that the best approach would be to remove the nvram header and add a extra variable storing the actual size of the nvram buf. I also think this would make some of this code easier.

Let's do that then.

Hi Hauke,

Forgot to ask. What is the reason for using the fixed nvram space. Could we allocate it using vzalloc()?

Regards,
Arend

Quoted 125 lines
Quoted 63 lines
Quoted 63 lines

+ /* proceed reading data after header */
+ for (; i< header->len; i += 4)
*dst++ = readl(src++);
nvram_buf[NVRAM_SPACE - 1] = '\0';

arch/mips/bcm47xx/nvram.c +4 -6
@@ -139,6 +144,7 @@ static int nvram_init(void)
 #ifdef CONFIG_MTD
 struct mtd_info *mtd;
 struct nvram_header header;
+ struct nvram_header *pheader;
 size_t bytes_read;
 int err;
 
@@ -147,20 +153,21 @@ static int nvram_init(void)
 return -ENODEV;
 
 err = mtd_read(mtd, 0, sizeof(header),&bytes_read, (uint8_t *)&header);
- if (!err&& header.magic == NVRAM_MAGIC) {
- u8 *dst = (uint8_t *)nvram_buf;
- size_t len = header.len;
-
- if (len>= NVRAM_SPACE) {
- len = NVRAM_SPACE - 1;
+ if (!err&& header.magic == NVRAM_MAGIC&&
+ header.len> sizeof(header)) {
+ if (header.len>= NVRAM_SPACE) {

pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
- header.len, len);
+ header.len, NVRAM_SPACE);
+ header.len = NVRAM_SPACE - 1;
}

- err = mtd_read(mtd, 0, len,&bytes_read, dst);
+ err = mtd_read(mtd, 0, header.len,&bytes_read,
+ (u8 *)nvram_buf);
if (err)
return err;

+ pheader = (struct nvram_header *)nvram_buf;
+ pheader->len = header.len;
return 0;
}
#endif

arch/mips/bcm47xx/nvram.c +15 -0
@@ -219,3 +226,27 @@ int bcm47xx_nvram_gpio_pin(const char *name)
 return -ENOENT;
 }
 EXPORT_SYMBOL(bcm47xx_nvram_gpio_pin);
+
+char *bcm47xx_nvram_get_contents(size_t *nvram_size)
+{
+ int err;
+ char *nvram;
+ struct nvram_header *header;
+
+ if (!nvram_buf[0]) {
+ err = nvram_init();
+ if (err)
+ return NULL;
+ }
+
+ header = (struct nvram_header *)nvram_buf;
+ *nvram_size = header->len - sizeof(struct nvram_header);
Quoted 8 lines

arch/mips/bcm47xx/nvram.c int bcm47xx_nvram_gpio_pin(const char *name)

Quoted 4 lines
arch/mips/bcm47xx/nvram.c +4 -0
+ nvram = vmalloc(*nvram_size);
+ if (!nvram)
+ return NULL;
+ memcpy(nvram,&nvram_buf[sizeof(struct nvram_header)], *nvram_size);

I have no real opinion if we need to copy it or provide a pointer to the nvram buf. I trust brcmfmac that it does not screw around with this data. ;-)

I would not dare. Most variables are pitch black magic to me.

Regards,
Arend

Quoted 46 lines
Quoted 46 lines
arch/mips/bcm47xx/nvram.c +5 -0
+
+ return nvram;
+}
+EXPORT_SYMBOL(bcm47xx_nvram_get_contents);
+
include/linux/bcm47xx_nvram.h +15 -0
index b12b07e..c73927c 100644
@@ -10,11 +10,17 @@
 
 #include<linux/types.h>
 #include<linux/kernel.h>
+#include<linux/vmalloc.h>
 
 #ifdef CONFIG_BCM47XX
 int bcm47xx_nvram_init_from_mem(u32 base, u32 lim);
 int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len);
 int bcm47xx_nvram_gpio_pin(const char *name);
+char *bcm47xx_nvram_get_contents(size_t *val_len);
+static inline void bcm47xx_nvram_release_contents(char *nvram)
+{
+ vfree(nvram);
+};
 #else
 static inline int bcm47xx_nvram_init_from_mem(u32 base, u32 lim)
 {
@@ -29,6 +35,15 @@ static inline int bcm47xx_nvram_gpio_pin(const
 char *name)
 {
 return -ENOTSUPP;
 };
+
+static inline char *bcm47xx_nvram_get_contents(size_t *val_len)
+{
+ return NULL;
+};
+
+static inline void bcm47xx_nvram_release_contents(char *nvram)
+{
+};
 #endif
 

#endif /* __BCM47XX_NVRAM_H */

maintainer
#4 lore raw
Quoted 81 lines · Arend van Spriel
Quoted 80 lines · Arend van Spriel
Quoted 56 lines · Hauke Mehrtens
Quoted 42 lines · Arend van Spriel

From: Hante Meuleman<[email protected]>

Host platforms such as routers supported by OpenWrt can support NVRAM reading directly from internal NVRAM store. The brcmfmac for one requires the complete nvram contents to select what needs to be sent to wireless device.

---
Change log:
-----------
V2: - correct header length for nvram_find_and_copy().
- get rid of 'NVRAM_SPACE - 2' magic.
---
arch/mips/bcm47xx/nvram.c | 61
++++++++++++++++++++++++++++++++-----------
include/linux/bcm47xx_nvram.h | 15 +++++++++++

2 files changed, 61 insertions(+), 15 deletions(-)
arch/mips/bcm47xx/nvram.c +0 -0
index 95d028c..f4f62d3 100644
@@ -94,17 +94,22 @@ static int nvram_find_and_copy(void __iomem
 *iobase, u32 lim)
 return -ENXIO;
 

found:
- if (header->len> size)
- pr_err("The nvram size accoridng to the header seems to be bigger than the partition on flash\n");
- if (header->len> NVRAM_SPACE)
- pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
- header->len, NVRAM_SPACE - 1);
-
src = (u32 *)header;

Quoted 8 lines

dst = (u32 *)nvram_buf;
for (i = 0; i< sizeof(struct nvram_header); i += 4) *dst++ = __raw_readl(src++);
- for (; i< header->len&& i< NVRAM_SPACE&& i< size; i += 4)
+ header = (struct nvram_header *)nvram_buf;
+ if (header->len> size) {
+ pr_err("The nvram size according to the header seems to be bigger than the partition on flash\n");

Thanks for fixing a typo. ;-)

Quoted 3 lines
Quoted 1 line

+ header->len = size;

I haven't seen this error case, I just added it to be save.

It does seem an unlikely error case. At least it would probably been noticed during production writing the content to flash.

Quoted 15 lines
Quoted 7 lines

+ }
+ if (header->len>= NVRAM_SPACE) {
+ pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
+ header->len, NVRAM_SPACE - 1);
+ header->len = NVRAM_SPACE - 1;
+ }

After fixing the length the header is better, but it also contains a CRC, which is still wrong, but we ignore it and I do not think we have to check.

I still think that the best approach would be to remove the nvram header and add a extra variable storing the actual size of the nvram buf. I also think this would make some of this code easier.

Quoted 6 lines
Quoted 1 line

Let's do that then.

Hi Hauke,

Forgot to ask. What is the reason for using the fixed nvram space. Could we allocate it using vzalloc()?

On mips this is needed very early in the boot process at least for the older SoCs using ssb. In this state we can not allocate memory.

Hauke

Quoted 130 lines

Regards,
Arend

Quoted 125 lines
Quoted 63 lines
Quoted 63 lines

+ /* proceed reading data after header */
+ for (; i< header->len; i += 4)
*dst++ = readl(src++);
nvram_buf[NVRAM_SPACE - 1] = '\0';

arch/mips/bcm47xx/nvram.c +4 -6
@@ -139,6 +144,7 @@ static int nvram_init(void)
 #ifdef CONFIG_MTD
 struct mtd_info *mtd;
 struct nvram_header header;
+ struct nvram_header *pheader;
 size_t bytes_read;
 int err;
 
@@ -147,20 +153,21 @@ static int nvram_init(void)
 return -ENODEV;
 
 err = mtd_read(mtd, 0, sizeof(header),&bytes_read, (uint8_t *)&header);
- if (!err&& header.magic == NVRAM_MAGIC) {
- u8 *dst = (uint8_t *)nvram_buf;
- size_t len = header.len;
-
- if (len>= NVRAM_SPACE) {
- len = NVRAM_SPACE - 1;
+ if (!err&& header.magic == NVRAM_MAGIC&&
+ header.len> sizeof(header)) {
+ if (header.len>= NVRAM_SPACE) {

pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
- header.len, len);
+ header.len, NVRAM_SPACE);
+ header.len = NVRAM_SPACE - 1;
}

- err = mtd_read(mtd, 0, len,&bytes_read, dst);
+ err = mtd_read(mtd, 0, header.len,&bytes_read,
+ (u8 *)nvram_buf);
if (err)
return err;

+ pheader = (struct nvram_header *)nvram_buf;
+ pheader->len = header.len;
return 0;
}
#endif

arch/mips/bcm47xx/nvram.c +15 -0
@@ -219,3 +226,27 @@ int bcm47xx_nvram_gpio_pin(const char *name)
 return -ENOENT;
 }
 EXPORT_SYMBOL(bcm47xx_nvram_gpio_pin);
+
+char *bcm47xx_nvram_get_contents(size_t *nvram_size)
+{
+ int err;
+ char *nvram;
+ struct nvram_header *header;
+
+ if (!nvram_buf[0]) {
+ err = nvram_init();
+ if (err)
+ return NULL;
+ }
+
+ header = (struct nvram_header *)nvram_buf;
+ *nvram_size = header->len - sizeof(struct nvram_header);
Quoted 8 lines

arch/mips/bcm47xx/nvram.c int bcm47xx_nvram_gpio_pin(const char *name)

Quoted 4 lines
arch/mips/bcm47xx/nvram.c +4 -0
+ nvram = vmalloc(*nvram_size);
+ if (!nvram)
+ return NULL;
+ memcpy(nvram,&nvram_buf[sizeof(struct nvram_header)], *nvram_size);

I have no real opinion if we need to copy it or provide a pointer to the nvram buf. I trust brcmfmac that it does not screw around with this data. ;-)

I would not dare. Most variables are pitch black magic to me.

Regards,
Arend

Quoted 46 lines
Quoted 46 lines
arch/mips/bcm47xx/nvram.c +5 -0
+
+ return nvram;
+}
+EXPORT_SYMBOL(bcm47xx_nvram_get_contents);
+
include/linux/bcm47xx_nvram.h +15 -0
index b12b07e..c73927c 100644
@@ -10,11 +10,17 @@
 
 #include<linux/types.h>
 #include<linux/kernel.h>
+#include<linux/vmalloc.h>
 
 #ifdef CONFIG_BCM47XX
 int bcm47xx_nvram_init_from_mem(u32 base, u32 lim);
 int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len);
 int bcm47xx_nvram_gpio_pin(const char *name);
+char *bcm47xx_nvram_get_contents(size_t *val_len);
+static inline void bcm47xx_nvram_release_contents(char *nvram)
+{
+ vfree(nvram);
+};
 #else
 static inline int bcm47xx_nvram_init_from_mem(u32 base, u32 lim)
 {
@@ -29,6 +35,15 @@ static inline int bcm47xx_nvram_gpio_pin(const
 char *name)
 {
 return -ENOTSUPP;
 };
+
+static inline char *bcm47xx_nvram_get_contents(size_t *val_len)
+{
+ return NULL;
+};
+
+static inline void bcm47xx_nvram_release_contents(char *nvram)
+{
+};
 #endif
 

#endif /* __BCM47XX_NVRAM_H */

#5 lore raw
Quoted 86 lines · Hauke Mehrtens
Quoted 83 lines · Arend van Spriel
Quoted 81 lines · Arend van Spriel
Quoted 56 lines · Hauke Mehrtens
Quoted 42 lines · Arend van Spriel

From: Hante Meuleman<[email protected]>

Host platforms such as routers supported by OpenWrt can support NVRAM reading directly from internal NVRAM store. The brcmfmac for one requires the complete nvram contents to select what needs to be sent to wireless device.

---
Change log:
-----------
V2: - correct header length for nvram_find_and_copy().
- get rid of 'NVRAM_SPACE - 2' magic.
---
arch/mips/bcm47xx/nvram.c | 61
++++++++++++++++++++++++++++++++-----------
include/linux/bcm47xx_nvram.h | 15 +++++++++++

2 files changed, 61 insertions(+), 15 deletions(-)
arch/mips/bcm47xx/nvram.c +0 -0
index 95d028c..f4f62d3 100644
@@ -94,17 +94,22 @@ static int nvram_find_and_copy(void __iomem
 *iobase, u32 lim)
 return -ENXIO;
 

found:
- if (header->len> size)
- pr_err("The nvram size accoridng to the header seems to be bigger than the partition on flash\n");
- if (header->len> NVRAM_SPACE)
- pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
- header->len, NVRAM_SPACE - 1);
-
src = (u32 *)header;

Quoted 8 lines

dst = (u32 *)nvram_buf;
for (i = 0; i< sizeof(struct nvram_header); i += 4) *dst++ = __raw_readl(src++);
- for (; i< header->len&& i< NVRAM_SPACE&& i< size; i += 4)
+ header = (struct nvram_header *)nvram_buf;
+ if (header->len> size) {
+ pr_err("The nvram size according to the header seems to be bigger than the partition on flash\n");

Thanks for fixing a typo. ;-)

Quoted 3 lines
Quoted 1 line

+ header->len = size;

I haven't seen this error case, I just added it to be save.

It does seem an unlikely error case. At least it would probably been noticed during production writing the content to flash.

Quoted 8 lines
Quoted 7 lines

+ }
+ if (header->len>= NVRAM_SPACE) {
+ pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
+ header->len, NVRAM_SPACE - 1);
+ header->len = NVRAM_SPACE - 1;
+ }

Quoted 7 lines

After fixing the length the header is better, but it also contains a CRC, which is still wrong, but we ignore it and I do not think we have to check.

I still think that the best approach would be to remove the nvram header and add a extra variable storing the actual size of the nvram buf. I also think this would make some of this code easier.

Let's do that then.

Quoted 7 lines
Quoted 4 lines

Hi Hauke,

Forgot to ask. What is the reason for using the fixed nvram space. Could we allocate it using vzalloc()?

On mips this is needed very early in the boot process at least for the older SoCs using ssb. In this state we can not allocate memory.

I suspected that, but wanted to be sure.

Thanks,
Arend

Quoted 132 lines

Hauke

Quoted 130 lines

Regards,
Arend

Quoted 125 lines
Quoted 63 lines
Quoted 63 lines

+ /* proceed reading data after header */
+ for (; i< header->len; i += 4)
*dst++ = readl(src++);
nvram_buf[NVRAM_SPACE - 1] = '\0';

arch/mips/bcm47xx/nvram.c +4 -6
@@ -139,6 +144,7 @@ static int nvram_init(void)
 #ifdef CONFIG_MTD
 struct mtd_info *mtd;
 struct nvram_header header;
+ struct nvram_header *pheader;
 size_t bytes_read;
 int err;
 
@@ -147,20 +153,21 @@ static int nvram_init(void)
 return -ENODEV;
 
 err = mtd_read(mtd, 0, sizeof(header),&bytes_read, (uint8_t *)&header);
- if (!err&&  header.magic == NVRAM_MAGIC) {
- u8 *dst = (uint8_t *)nvram_buf;
- size_t len = header.len;
-
- if (len>= NVRAM_SPACE) {
- len = NVRAM_SPACE - 1;
+ if (!err&&  header.magic == NVRAM_MAGIC&&
+ header.len>  sizeof(header)) {
+ if (header.len>= NVRAM_SPACE) {

pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
- header.len, len);
+ header.len, NVRAM_SPACE);
+ header.len = NVRAM_SPACE - 1;
}

- err = mtd_read(mtd, 0, len,&bytes_read, dst);
+ err = mtd_read(mtd, 0, header.len,&bytes_read,
+ (u8 *)nvram_buf);
if (err)
return err;

+ pheader = (struct nvram_header *)nvram_buf;
+ pheader->len = header.len;
return 0;
}
#endif

arch/mips/bcm47xx/nvram.c +15 -0
@@ -219,3 +226,27 @@ int bcm47xx_nvram_gpio_pin(const char *name)
 return -ENOENT;
 }
 EXPORT_SYMBOL(bcm47xx_nvram_gpio_pin);
+
+char *bcm47xx_nvram_get_contents(size_t *nvram_size)
+{
+ int err;
+ char *nvram;
+ struct nvram_header *header;
+
+ if (!nvram_buf[0]) {
+ err = nvram_init();
+ if (err)
+ return NULL;
+ }
+
+ header = (struct nvram_header *)nvram_buf;
+ *nvram_size = header->len - sizeof(struct nvram_header);
Quoted 8 lines

arch/mips/bcm47xx/nvram.c int bcm47xx_nvram_gpio_pin(const char *name)

Quoted 4 lines
arch/mips/bcm47xx/nvram.c +4 -0
+ nvram = vmalloc(*nvram_size);
+ if (!nvram)
+ return NULL;
+ memcpy(nvram,&nvram_buf[sizeof(struct nvram_header)], *nvram_size);

I have no real opinion if we need to copy it or provide a pointer to the nvram buf. I trust brcmfmac that it does not screw around with this data. ;-)

I would not dare. Most variables are pitch black magic to me.

Regards,
Arend

Quoted 46 lines
Quoted 46 lines
arch/mips/bcm47xx/nvram.c +5 -0
+
+ return nvram;
+}
+EXPORT_SYMBOL(bcm47xx_nvram_get_contents);
+
include/linux/bcm47xx_nvram.h +15 -0
index b12b07e..c73927c 100644
@@ -10,11 +10,17 @@
 
 #include<linux/types.h>
 #include<linux/kernel.h>
+#include<linux/vmalloc.h>
 
 #ifdef CONFIG_BCM47XX
 int bcm47xx_nvram_init_from_mem(u32 base, u32 lim);
 int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len);
 int bcm47xx_nvram_gpio_pin(const char *name);
+char *bcm47xx_nvram_get_contents(size_t *val_len);
+static inline void bcm47xx_nvram_release_contents(char *nvram)
+{
+ vfree(nvram);
+};
 #else
 static inline int bcm47xx_nvram_init_from_mem(u32 base, u32 lim)
 {
@@ -29,6 +35,15 @@ static inline int bcm47xx_nvram_gpio_pin(const
 char *name)
 {
 return -ENOTSUPP;
 };
+
+static inline char *bcm47xx_nvram_get_contents(size_t *val_len)
+{
+ return NULL;
+};
+
+static inline void bcm47xx_nvram_release_contents(char *nvram)
+{
+};
 #endif
 

#endif /* __BCM47XX_NVRAM_H */

maintainer
#6 lore raw
Quoted 90 lines · Arend van Spriel
Quoted 89 lines · Hauke Mehrtens
Quoted 86 lines · Arend van Spriel
Quoted 76 lines · Arend van Spriel
Quoted 56 lines · Hauke Mehrtens
Quoted 42 lines · Arend van Spriel

From: Hante Meuleman<[email protected]>

Host platforms such as routers supported by OpenWrt can support NVRAM reading directly from internal NVRAM store. The brcmfmac for one requires the complete nvram contents to select what needs to be sent to wireless device.

---
Change log:
-----------
V2: - correct header length for nvram_find_and_copy().
- get rid of 'NVRAM_SPACE - 2' magic.
---
arch/mips/bcm47xx/nvram.c | 61
++++++++++++++++++++++++++++++++-----------
include/linux/bcm47xx_nvram.h | 15 +++++++++++

2 files changed, 61 insertions(+), 15 deletions(-)
arch/mips/bcm47xx/nvram.c +0 -0
index 95d028c..f4f62d3 100644
@@ -94,17 +94,22 @@ static int nvram_find_and_copy(void __iomem
 *iobase, u32 lim)
 return -ENXIO;
 

found:
- if (header->len> size)
- pr_err("The nvram size accoridng to the header seems to be bigger than the partition on flash\n");
- if (header->len> NVRAM_SPACE)
- pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
- header->len, NVRAM_SPACE - 1);
-
src = (u32 *)header;

Quoted 8 lines

dst = (u32 *)nvram_buf;
for (i = 0; i< sizeof(struct nvram_header); i += 4) *dst++ = __raw_readl(src++);
- for (; i< header->len&& i< NVRAM_SPACE&& i< size; i += 4)
+ header = (struct nvram_header *)nvram_buf;
+ if (header->len> size) {
+ pr_err("The nvram size according to the header seems to be bigger than the partition on flash\n");

Thanks for fixing a typo. ;-)

Quoted 3 lines
Quoted 1 line

+ header->len = size;

I haven't seen this error case, I just added it to be save.

It does seem an unlikely error case. At least it would probably been noticed during production writing the content to flash.

Quoted 12 lines
Quoted 7 lines

+ }
+ if (header->len>= NVRAM_SPACE) {
+ pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
+ header->len, NVRAM_SPACE - 1);
+ header->len = NVRAM_SPACE - 1;
+ }

After fixing the length the header is better, but it also contains a CRC, which is still wrong, but we ignore it and I do not think we have to check.

Quoted 6 lines
Quoted 4 lines

I still think that the best approach would be to remove the nvram header
and add a extra variable storing the actual size of the nvram buf. I also think this would make some of this code easier.

Let's do that then.

Hi Hauke,

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Forgot to ask. What is the reason for using the fixed nvram space. Could we allocate it using vzalloc()?

On mips this is needed very early in the boot process at least for the older SoCs using ssb. In this state we can not allocate memory.

I suspected that, but wanted to be sure.

We tried to use some kind of allocation mechanism, because the nvram partitions of different devices have different sizes. The older devices mostly have small partitions and the newer ons bigger. With the arm SoCs we do not need the nvram so early and can use some normal allocation mechanism.

Hauke

#7 lore raw
Quoted 99 lines · Hauke Mehrtens
Quoted 96 lines · Arend van Spriel
Quoted 94 lines · Hauke Mehrtens
Quoted 82 lines · Arend van Spriel
Quoted 81 lines · Arend van Spriel
Quoted 56 lines · Hauke Mehrtens
Quoted 42 lines · Arend van Spriel

From: Hante Meuleman<[email protected]>

Host platforms such as routers supported by OpenWrt can support NVRAM reading directly from internal NVRAM store. The brcmfmac for one requires the complete nvram contents to select what needs to be sent to wireless device.

---
Change log:
-----------
V2: - correct header length for nvram_find_and_copy().
- get rid of 'NVRAM_SPACE - 2' magic.
---
arch/mips/bcm47xx/nvram.c | 61
++++++++++++++++++++++++++++++++-----------
include/linux/bcm47xx_nvram.h | 15 +++++++++++

2 files changed, 61 insertions(+), 15 deletions(-)
arch/mips/bcm47xx/nvram.c +0 -0
index 95d028c..f4f62d3 100644
@@ -94,17 +94,22 @@ static int nvram_find_and_copy(void __iomem
 *iobase, u32 lim)
 return -ENXIO;
 

found:
- if (header->len> size)
- pr_err("The nvram size accoridng to the header seems to be bigger than the partition on flash\n");
- if (header->len> NVRAM_SPACE)
- pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
- header->len, NVRAM_SPACE - 1);
-
src = (u32 *)header;

Quoted 8 lines

dst = (u32 *)nvram_buf;
for (i = 0; i< sizeof(struct nvram_header); i += 4)
*dst++ = __raw_readl(src++);
- for (; i< header->len&& i< NVRAM_SPACE&& i< size; i += 4)
+ header = (struct nvram_header *)nvram_buf;
+ if (header->len> size) {
+ pr_err("The nvram size according to the header seems to be bigger than the partition on flash\n");

Thanks for fixing a typo. ;-)

Quoted 3 lines
Quoted 1 line

+ header->len = size;

I haven't seen this error case, I just added it to be save.

It does seem an unlikely error case. At least it would probably been noticed during production writing the content to flash.

Quoted 16 lines
Quoted 7 lines

+ }
+ if (header->len>= NVRAM_SPACE) {
+ pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
+ header->len, NVRAM_SPACE - 1);
+ header->len = NVRAM_SPACE - 1;
+ }

After fixing the length the header is better, but it also contains a CRC, which is still wrong, but we ignore it and I do not think we have to check.

I still think that the best approach would be to remove the nvram header
and add a extra variable storing the actual size of the nvram buf. I also think this would make some of this code easier.

Quoted 6 lines
Quoted 1 line

Let's do that then.

Hi Hauke,

Forgot to ask. What is the reason for using the fixed nvram space. Could we allocate it using vzalloc()?

On mips this is needed very early in the boot process at least for the older SoCs using ssb. In this state we can not allocate memory.

Quoted 8 lines
Quoted 2 lines

I suspected that, but wanted to be sure.

We tried to use some kind of allocation mechanism, because the nvram partitions of different devices have different sizes. The older devices mostly have small partitions and the newer ons bigger. With the arm SoCs we do not need the nvram so early and can use some normal allocation mechanism.

Yes, but that means that static buffer sits there doing nothing or could that be put under Kconfig and only be used for the devices needing early access.

Regards,
Arend