Message ID | 20180124004454.5759-3-miquel.raynal@free-electrons.com |
---|---|
State | Changes Requested |
Delegated to: | Jagannadha Sutradharudu Teki |
Headers | show |
Series | Bring NAND support to Nintendo NES Classic | expand |
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
Hi Maxime, On Wed, 24 Jan 2018 08:47:31 +0100 Maxime Ripard <maxime.ripard@free-electrons.com> 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
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))
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 <miquel.raynal@free-electrons.com> --- drivers/mtd/nand/sunxi_nand_spl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)