public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] nand_spl_simple: store ecc data on the stack
@ 2011-12-11 17:22 Stefano Babic
  2011-12-12  0:08 ` Ilya Yanok
                   ` (4 more replies)
  0 siblings, 5 replies; 29+ messages in thread
From: Stefano Babic @ 2011-12-11 17:22 UTC (permalink / raw)
  To: u-boot

Currently nand_spl_simple puts it's temp data at 0x10000 offset in SDRAM
which is likely to contain already loaded data.
The patch saves the oob data and the ecc on the stack replacing
the fixed address in RAM.

Signed-off-by: Stefano Babic <sbabic@denx.de>
CC: Ilya Yanok <yanok@emcraft.com>
CC: Scott Wood <scottwood@freescale.com>
CC: Tom Rini <tom.rini@gmail.com>
CC: Simon Schwarz <simonschwarzcor@googlemail.com>
CC: Wolfgang Denk <wd@denx.de>
CC: Heiko Schocher <hs@denx.de>
---

Note: Ilya has already submitted a patch to fix this issue:

http://patchwork.ozlabs.org/patch/128018/

after discussing on ML about booting linux from SPL,
we agree about putting the data on the stack.

drivers/mtd/nand/nand_spl_simple.c |   27 ++++++---------------------
 1 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/drivers/mtd/nand/nand_spl_simple.c b/drivers/mtd/nand/nand_spl_simple.c
index ed821f2..a3d1af0 100644
--- a/drivers/mtd/nand/nand_spl_simple.c
+++ b/drivers/mtd/nand/nand_spl_simple.c
@@ -145,9 +145,9 @@ static int nand_is_bad_block(int block)
 static int nand_read_page(int block, int page, uchar *dst)
 {
 	struct nand_chip *this = mtd.priv;
-	u_char *ecc_calc;
-	u_char *ecc_code;
-	u_char *oob_data;
+	u_char ecc_calc[CONFIG_SYS_NAND_ECCSTEPS * CONFIG_SYS_NAND_ECCBYTES];
+	u_char ecc_code[CONFIG_SYS_NAND_ECCTOTAL];
+	u_char oob_data[CONFIG_SYS_NAND_OOBSIZE];
 	int i;
 	int eccsize = CONFIG_SYS_NAND_ECCSIZE;
 	int eccbytes = CONFIG_SYS_NAND_ECCBYTES;
@@ -155,14 +155,6 @@ static int nand_read_page(int block, int page, uchar *dst)
 	uint8_t *p = dst;
 	int stat;
 
-	/*
-	 * No malloc available for now, just use some temporary locations
-	 * in SDRAM
-	 */
-	ecc_calc = (u_char *)(CONFIG_SYS_SDRAM_BASE + 0x10000);
-	ecc_code = ecc_calc + 0x100;
-	oob_data = ecc_calc + 0x200;
-
 	nand_command(block, page, 0, NAND_CMD_READOOB);
 	this->read_buf(&mtd, oob_data, CONFIG_SYS_NAND_OOBSIZE);
 	nand_command(block, page, 0, NAND_CMD_READ0);
@@ -185,9 +177,9 @@ static int nand_read_page(int block, int page, uchar *dst)
 static int nand_read_page(int block, int page, void *dst)
 {
 	struct nand_chip *this = mtd.priv;
-	u_char *ecc_calc;
-	u_char *ecc_code;
-	u_char *oob_data;
+	u_char ecc_calc[CONFIG_SYS_NAND_ECCSTEPS * CONFIG_SYS_NAND_ECCBYTES];
+	u_char ecc_code[CONFIG_SYS_NAND_ECCTOTAL];
+	u_char oob_data[CONFIG_SYS_NAND_OOBSIZE];
 	int i;
 	int eccsize = CONFIG_SYS_NAND_ECCSIZE;
 	int eccbytes = CONFIG_SYS_NAND_ECCBYTES;
@@ -197,13 +189,6 @@ static int nand_read_page(int block, int page, void *dst)
 
 	nand_command(block, page, 0, NAND_CMD_READ0);
 
-	/* No malloc available for now, just use some temporary locations
-	 * in SDRAM
-	 */
-	ecc_calc = (u_char *)(CONFIG_SYS_SDRAM_BASE + 0x10000);
-	ecc_code = ecc_calc + 0x100;
-	oob_data = ecc_calc + 0x200;
-
 	for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
 		if (this->ecc.mode != NAND_ECC_SOFT)
 			this->ecc.hwctl(&mtd, NAND_ECC_READ);
-- 
1.7.5.4

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

end of thread, other threads:[~2012-02-03 21:47 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-11 17:22 [U-Boot] [PATCH] nand_spl_simple: store ecc data on the stack Stefano Babic
2011-12-12  0:08 ` Ilya Yanok
2011-12-13 10:33   ` Stefano Babic
2011-12-13 11:30 ` [U-Boot] [PATCH V2] " Stefano Babic
2011-12-13 15:58   ` Tom Rini
2011-12-13 17:31     ` Stefano Babic
2011-12-13 17:50 ` [U-Boot] [PATCH V3] " Stefano Babic
2011-12-13 18:04   ` Tom Rini
2011-12-13 18:18     ` Wolfgang Denk
2011-12-13 18:33       ` Tom Rini
2011-12-13 18:45         ` Scott Wood
2011-12-13 18:54           ` Tom Rini
2011-12-13 19:26           ` Stefano Babic
2011-12-13 18:48       ` stefano babic
2011-12-13 18:52     ` Scott Wood
2011-12-13 18:54       ` Tom Rini
2011-12-13 18:47   ` Scott Wood
2011-12-13 19:33 ` [U-Boot] [PATCH V4] " Stefano Babic
2011-12-13 21:30   ` Tom Rini
2011-12-14  8:22   ` Simon Schwarz
2011-12-14  8:49     ` Stefano Babic
     [not found]       ` <4EE9B7F8.5060305@gmail.com>
2011-12-15  9:53         ` Stefano Babic
2012-01-10 23:01   ` Scott Wood
2012-01-10 23:24     ` Tom Rini
2012-02-03 20:17       ` Albert ARIBAUD
2012-02-03 21:47         ` Tom Rini
2011-12-15  9:55 ` [U-Boot] [PATCH V5] " Stefano Babic
2011-12-15 22:18   ` Scott Wood
2012-01-05 23:12   ` Scott Wood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox