[PATCH] mtd: nand: Mark reserved blocks

Soma, Ashok Reddy ashok.reddy.soma at amd.com
Thu Jan 5 10:38:05 CET 2023


Hi Michael,

> -----Original Message-----
> From: Michael Nazzareno Trimarchi <michael at amarulasolutions.com>
> Sent: Thursday, January 5, 2023 3:05 PM
> To: Soma, Ashok Reddy <ashok.reddy.soma at amd.com>
> Cc: u-boot at lists.denx.de; dario.binacchi at amarulasolutions.com;
> sjg at chromium.org
> Subject: Re: [PATCH] mtd: nand: Mark reserved blocks
> 
> Hi Ashok
> 
> On Thu, Jan 5, 2023 at 10:28 AM Ashok Reddy Soma
> <ashok.reddy.soma at amd.com> wrote:
> >
> > Reserved blocks are used for storing bad block tables. With "nand bad"
> > command, these reserved blocks are shown as bad blocks. This is
> > leading to confusion when compared with Linux bad blocks. Hence,
> > display "Reserved for bbt" when printing reserved blocks with "nand bad"
> command.
> >
> > To acheive this, return 2 which represents reserved from
> > nand_isbad_bbt() instead of 1 in case of reserved blocks and catch it in
> cmd/nand.c.
> >
> > "nand bad" command display's hexadecimal numbers, so add "0x" prefix.
> >
> > Example log will show up as below.
> >
> > ZynqMP> nand bad
> >
> > Device 0 bad blocks:
> >   0x00400000
> >   0x16800000
> >   0x16c00000
> >   0x17000000
> >   0x3d800000
> >   0x3e400000
> >   0xe8400000
> >   0xff000000     <--- Reserved for bbt
> >   0xff400000     <--- Reserved for bbt
> >   0xff800000     <--- Reserved for bbt
> >   0xffc00000     <--- Reserved for bbt
> >   0x116800000
> >   0x116c00000
> >   0x1ff000000    <--- Reserved for bbt
> >   0x1ff400000    <--- Reserved for bbt
> >   0x1ff800000    <--- Reserved for bbt
> >   0x1ffc00000    <--- Reserved for bbt
> >
> > Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma at amd.com>
> > ---
> >
> >  cmd/nand.c                      | 9 ++++++---
> >  drivers/mtd/nand/raw/nand_bbt.c | 3 ++-
> >  2 files changed, 8 insertions(+), 4 deletions(-)
> >
> > diff --git a/cmd/nand.c b/cmd/nand.c
> > index 9a723f5757..feb6b0e3ec 100644
> > --- a/cmd/nand.c
> > +++ b/cmd/nand.c
> > @@ -567,9 +567,12 @@ static int do_nand(struct cmd_tbl *cmdtp, int
> > flag, int argc,
> >
> >         if (strcmp(cmd, "bad") == 0) {
> >                 printf("\nDevice %d bad blocks:\n", dev);
> > -               for (off = 0; off < mtd->size; off += mtd->erasesize)
> > -                       if (nand_block_isbad(mtd, off))
> > -                               printf("  %08llx\n", (unsigned long long)off);
> > +               for (off = 0; off < mtd->size; off += mtd->erasesize) {
> > +                       ret = nand_block_isbad(mtd, off);
> > +                       if (ret)
> > +                               printf("  0x%08llx%s\n", (unsigned long long)off,
> > +                                      ret == 2 ? "\t <--- Reserved for bbt" : "");
> > +               }
> 
> Look good but suggest to use something more simple like (bbt reserved)
> without <---
> 
> Reviewed-by: Michael Trimarchi <michael at amarulasolutions.com>

Thanks for the review.
I will change it to (bbt reserved) and send v2.

Thanks,
Ashok

> 
> >                 return 0;
> >         }
> >
> > diff --git a/drivers/mtd/nand/raw/nand_bbt.c
> > b/drivers/mtd/nand/raw/nand_bbt.c index 911472e91e..cd451870a6
> 100644
> > --- a/drivers/mtd/nand/raw/nand_bbt.c
> > +++ b/drivers/mtd/nand/raw/nand_bbt.c
> > @@ -1330,6 +1330,7 @@ int nand_isreserved_bbt(struct mtd_info *mtd,
> loff_t offs)
> >   * @mtd: MTD device structure
> >   * @offs: offset in the device
> >   * @allowbbt: allow access to bad block table region
> > + * Return: 0 - good block, 1- bad block, 2 - reserved block
> >   */
> >  int nand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt)
> > { @@ -1348,7 +1349,7 @@ int nand_isbad_bbt(struct mtd_info *mtd,
> > loff_t offs, int allowbbt)
> >         case BBT_BLOCK_WORN:
> >                 return 1;
> >         case BBT_BLOCK_RESERVED:
> > -               return allowbbt ? 0 : 1;
> > +               return allowbbt ? 0 : 2;
> >         }
> >         return 1;
> >  }
> > --
> > 2.17.1
> >
> 
> 
> --
> Michael Nazzareno Trimarchi
> Co-Founder & Chief Executive Officer
> M. +39 347 913 2170
> michael at amarulasolutions.com
> __________________________________
> 
> Amarula Solutions BV
> Joop Geesinkweg 125, 1114 AB, Amsterdam, NL T. +31 (0)85 111 9172
> info at amarulasolutions.com www.amarulasolutions.com


More information about the U-Boot mailing list