[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20210319102117.47774faf@xps13>
Date: Fri, 19 Mar 2021 10:23:38 +0100
From: Miquel Raynal <miquel.raynal@...tlin.com>
To: Yoshio Furuyama <ytc-mb-yfuruyama7@...xia.com>
Cc: richard@....at, vigneshr@...com, linux-mtd@...ts.infradead.org,
linux-kernel@...r.kernel.org, Patrick Doyle <pdoyle@...bot.com>
Subject: Re: [PATCH v1] mtd: nand: Fix BBT update issue
Hi Yoshio,
+ Patrick
Yoshio Furuyama <ytc-mb-yfuruyama7@...xia.com> wrote on Tue, 16 Feb
2021 09:37:55 +0900:
> Fixed issue of manages BBT (Bad Block Table).
> It didn't mark correctly when a specific block was bad block.
>
> This issue occurs when the bad block mark (3-bit chunk) is
> crosses over 32 bit (e.g. Block10, Block21...) unit.
>
Thanks for the patch and sorry for the very long wait period, I wanted
to understand better the issue but I didn't had the time to do it.
Would you mind having a look at Patrick's fix merged in U-Boot a year
ago:
commit 06fc4573b9d0878dd1d3b302884601263fe6e85f
Author: Doyle, Patrick <pdoyle@...bot.com>
Date: Wed Jul 15 14:46:34 2020 +0000
Fix corner case in bad block table handling.
In the unlikely event that both blocks 10 and 11 are marked as bad (on a
32 bit machine), then the process of marking block 10 as bad stomps on
cached entry for block 11. There are (of course) other examples.
Signed-off-by: Patrick Doyle <pdoyle@...bot.com>
Reviewed-by: Richard Weinberger <richard@....at>
diff --git a/drivers/mtd/nand/bbt.c b/drivers/mtd/nand/bbt.c
index 84d60b86521..294daee7b22 100644
--- a/drivers/mtd/nand/bbt.c
+++ b/drivers/mtd/nand/bbt.c
@@ -127,7 +127,7 @@ int nanddev_bbt_set_block_status(struct nand_device *nand, unsigned int entry,
unsigned int rbits = bits_per_block + offs - BITS_PER_LONG;
pos[1] &= ~GENMASK(rbits - 1, 0);
- pos[1] |= val >> rbits;
+ pos[1] |= val >> (bits_per_block - rbits);
}
return 0;
It looks both patches fix different errors but I wonder if merging Patrick's patch first would not make more sense.
Ideally, could you please send a series with the two patches, perhaps
Patrick's patch first, then yours, adding a Fixes and Cc: stable tags
to both?
> Signed-off-by: Yoshio Furuyama <ytc-mb-yfuruyama7@...xia.com>
> ---
> drivers/mtd/nand/bbt.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mtd/nand/bbt.c b/drivers/mtd/nand/bbt.c
> index 044adf913854..979c47e61381 100644
> --- a/drivers/mtd/nand/bbt.c
> +++ b/drivers/mtd/nand/bbt.c
> @@ -112,18 +112,20 @@ int nanddev_bbt_set_block_status(struct nand_device *nand, unsigned int entry,
> ((entry * bits_per_block) / BITS_PER_LONG);
> unsigned int offs = (entry * bits_per_block) % BITS_PER_LONG;
> unsigned long val = status & GENMASK(bits_per_block - 1, 0);
> + unsigned long shift = ((bits_per_block + offs <= BITS_PER_LONG) ?
> + (offs + bits_per_block - 1) : (BITS_PER_LONG - 1));
>
> if (entry >= nanddev_neraseblocks(nand))
> return -ERANGE;
>
> - pos[0] &= ~GENMASK(offs + bits_per_block - 1, offs);
> + pos[0] &= ~GENMASK(shift, offs);
> pos[0] |= val << offs;
>
> if (bits_per_block + offs > BITS_PER_LONG) {
> unsigned int rbits = bits_per_block + offs - BITS_PER_LONG;
>
> pos[1] &= ~GENMASK(rbits - 1, 0);
> - pos[1] |= val >> rbits;
> + pos[1] |= (val >> (BITS_PER_LONG - offs));
> }
>
> return 0;
Thanks,
Miquèl
Powered by blists - more mailing lists