Re: [U-Boot] [PATCH 2/8] spl: nand: sunxi: Fix second case of modulo by zero error

2018-01-24 Thread Miquel Raynal
Hi Maxime,

On Wed, 24 Jan 2018 08:47:31 +0100
Maxime Ripard  wrote:

> On Wed, Jan 24, 2018 at 01:44:48AM +0100, Miquel Raynal wrote:
> > In the nand_read_buffer() step, the seed is calculated by doing a modulo
> > by conf->nseeds which is always zero when not using the randomizer (most
> > of SLC NANDs).
> > 
> > This situation turns out to lead to a run time freeze.
> > 
> > Derive this seed only when the randomizer is enabled (and conf->nseeds
> > logically not zero).  
> 
> Mentionning the first occurence of that issue in your commit log would
> be great, especially since the situation depends on configuration
> options.

Absolutely, I added a reference in the commit message to:
ea3f750c73e3 ("nand: sunxi: Fix modulo by zero error")

Thanks,
Miquèl
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/8] spl: nand: sunxi: Fix second case of modulo by zero error

2018-01-23 Thread Maxime Ripard
On Wed, Jan 24, 2018 at 01:44:48AM +0100, Miquel Raynal wrote:
> In the nand_read_buffer() step, the seed is calculated by doing a modulo
> by conf->nseeds which is always zero when not using the randomizer (most
> of SLC NANDs).
> 
> This situation turns out to lead to a run time freeze.
> 
> Derive this seed only when the randomizer is enabled (and conf->nseeds
> logically not zero).

Mentionning the first occurence of that issue in your commit log would
be great, especially since the situation depends on configuration
options.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 2/8] spl: nand: sunxi: Fix second case of modulo by zero error

2018-01-23 Thread Miquel Raynal
In the nand_read_buffer() step, the seed is calculated by doing a modulo
by conf->nseeds which is always zero when not using the randomizer (most
of SLC NANDs).

This situation turns out to lead to a run time freeze.

Derive this seed only when the randomizer is enabled (and conf->nseeds
logically not zero).

Signed-off-by: Miquel Raynal 
---
 drivers/mtd/nand/sunxi_nand_spl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/sunxi_nand_spl.c 
b/drivers/mtd/nand/sunxi_nand_spl.c
index eed4472bdc..06695fc15f 100644
--- a/drivers/mtd/nand/sunxi_nand_spl.c
+++ b/drivers/mtd/nand/sunxi_nand_spl.c
@@ -475,11 +475,12 @@ static int nand_detect_config(struct nfc_config *conf, 
u32 offs, void *dest)
 static int nand_read_buffer(struct nfc_config *conf, uint32_t offs,
unsigned int size, void *dest)
 {
-   int first_seed, page, ret;
+   int first_seed = 0, page, ret;
 
size = ALIGN(size, conf->page_size);
page = offs / conf->page_size;
-   first_seed = page % conf->nseeds;
+   if (conf->randomize)
+   first_seed = page % conf->nseeds;
 
for (; size; size -= conf->page_size) {
if (nand_load_page(conf, offs))
-- 
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot