All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mtd: nand: Mark reserved blocks
@ 2023-01-05  9:46 Ashok Reddy Soma
  2023-01-05 10:04 ` Michael Nazzareno Trimarchi
  2023-02-02 13:21 ` Michal Simek
  0 siblings, 2 replies; 6+ messages in thread
From: Ashok Reddy Soma @ 2023-01-05  9:46 UTC (permalink / raw)
  To: u-boot; +Cc: dario.binacchi, michael, sjg, Ashok Reddy Soma

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
"bbt reserved" 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	 (bbt reserved)
  0xff400000	 (bbt reserved)
  0xff800000	 (bbt reserved)
  0xffc00000	 (bbt reserved)
  0x116800000
  0x116c00000
  0x1ff000000	 (bbt reserved)
  0x1ff400000	 (bbt reserved)
  0x1ff800000	 (bbt reserved)
  0x1ffc00000	 (bbt reserved)

Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@amd.com>
Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>
---

Changes in v2:
 - Changed "Reserved for bbt" to (bbt reserved)
 - Updated description and the log in the description

 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..b41e54ec42 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 (bbt reserved)" : "");
+		}
 		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


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

* Re: [PATCH v2] mtd: nand: Mark reserved blocks
  2023-01-05  9:46 [PATCH v2] mtd: nand: Mark reserved blocks Ashok Reddy Soma
@ 2023-01-05 10:04 ` Michael Nazzareno Trimarchi
  2023-02-02 13:21 ` Michal Simek
  1 sibling, 0 replies; 6+ messages in thread
From: Michael Nazzareno Trimarchi @ 2023-01-05 10:04 UTC (permalink / raw)
  To: Ashok Reddy Soma; +Cc: u-boot, dario.binacchi, sjg

Hi

On Thu, Jan 5, 2023 at 10:46 AM Ashok Reddy Soma
<ashok.reddy.soma@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
> "bbt reserved" 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     (bbt reserved)
>   0xff400000     (bbt reserved)
>   0xff800000     (bbt reserved)
>   0xffc00000     (bbt reserved)
>   0x116800000
>   0x116c00000
>   0x1ff000000    (bbt reserved)
>   0x1ff400000    (bbt reserved)
>   0x1ff800000    (bbt reserved)
>   0x1ffc00000    (bbt reserved)
>
> Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@amd.com>
> Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>
> ---
>
> Changes in v2:
>  - Changed "Reserved for bbt" to (bbt reserved)
>  - Updated description and the log in the description
>

Acked-By: Michael Trimarchi <michael@amarulasolutions.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..b41e54ec42 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 (bbt reserved)" : "");
> +               }
>                 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@amarulasolutions.com
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
info@amarulasolutions.com
www.amarulasolutions.com

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

* Re: [PATCH v2] mtd: nand: Mark reserved blocks
  2023-01-05  9:46 [PATCH v2] mtd: nand: Mark reserved blocks Ashok Reddy Soma
  2023-01-05 10:04 ` Michael Nazzareno Trimarchi
@ 2023-02-02 13:21 ` Michal Simek
  2023-02-02 13:44   ` Michael Nazzareno Trimarchi
  1 sibling, 1 reply; 6+ messages in thread
From: Michal Simek @ 2023-02-02 13:21 UTC (permalink / raw)
  To: Ashok Reddy Soma, u-boot, dario.binacchi, Simek, Michal; +Cc: michael, sjg

Hi Dario,

On 1/5/23 10:46, Ashok Reddy Soma 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
> "bbt reserved" 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	 (bbt reserved)
>    0xff400000	 (bbt reserved)
>    0xff800000	 (bbt reserved)
>    0xffc00000	 (bbt reserved)
>    0x116800000
>    0x116c00000
>    0x1ff000000	 (bbt reserved)
>    0x1ff400000	 (bbt reserved)
>    0x1ff800000	 (bbt reserved)
>    0x1ffc00000	 (bbt reserved)
> 
> Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@amd.com>
> Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>
> ---

Are you going to apply this patch?

Thanks,
Michal

-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP/Versal ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal/Versal NET SoCs


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

* Re: [PATCH v2] mtd: nand: Mark reserved blocks
  2023-02-02 13:21 ` Michal Simek
@ 2023-02-02 13:44   ` Michael Nazzareno Trimarchi
  2023-02-02 14:49     ` Michal Simek
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Nazzareno Trimarchi @ 2023-02-02 13:44 UTC (permalink / raw)
  To: Michal Simek
  Cc: Ashok Reddy Soma, U-Boot-Denx, Dario Binacchi, Simek, Michal,
	Simon Glass

Hi

Il gio 2 feb 2023, 14:21 Michal Simek <monstr@monstr.eu> ha scritto:

> Hi Dario,
>
> On 1/5/23 10:46, Ashok Reddy Soma 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
> > "bbt reserved" 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  (bbt reserved)
> >    0xff400000  (bbt reserved)
> >    0xff800000  (bbt reserved)
> >    0xffc00000  (bbt reserved)
> >    0x116800000
> >    0x116c00000
> >    0x1ff000000         (bbt reserved)
> >    0x1ff400000         (bbt reserved)
> >    0x1ff800000         (bbt reserved)
> >    0x1ffc00000         (bbt reserved)
> >
> > Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@amd.com>
> > Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>
> > ---
>
> Are you going to apply this patch?
>

Applied already

Michael

>
> Thanks,
> Michal
>
> --
> Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
> w: www.monstr.eu p: +42-0-721842854
> Maintainer of Linux kernel - Xilinx Microblaze
> Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP/Versal ARM64 SoCs
> U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal/Versal NET SoCs
>
>

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

* Re: [PATCH v2] mtd: nand: Mark reserved blocks
  2023-02-02 13:44   ` Michael Nazzareno Trimarchi
@ 2023-02-02 14:49     ` Michal Simek
  2023-02-27 16:36       ` Dario Binacchi
  0 siblings, 1 reply; 6+ messages in thread
From: Michal Simek @ 2023-02-02 14:49 UTC (permalink / raw)
  To: Michael Nazzareno Trimarchi, Michal Simek
  Cc: Ashok Reddy Soma, U-Boot-Denx, Dario Binacchi, Simon Glass



On 2/2/23 14:44, Michael Nazzareno Trimarchi wrote:
> Hi
> 
> Il gio 2 feb 2023, 14:21 Michal Simek <monstr@monstr.eu 
> <mailto:monstr@monstr.eu>> ha scritto:
> 
>     Hi Dario,
> 
>     On 1/5/23 10:46, Ashok Reddy Soma 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
>      > "bbt reserved" 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  (bbt reserved)
>      >    0xff400000  (bbt reserved)
>      >    0xff800000  (bbt reserved)
>      >    0xffc00000  (bbt reserved)
>      >    0x116800000
>      >    0x116c00000
>      >    0x1ff000000         (bbt reserved)
>      >    0x1ff400000         (bbt reserved)
>      >    0x1ff800000         (bbt reserved)
>      >    0x1ffc00000         (bbt reserved)
>      >
>      > Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@amd.com
>     <mailto:ashok.reddy.soma@amd.com>>
>      > Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com
>     <mailto:michael@amarulasolutions.com>>
>      > ---
> 
>     Are you going to apply this patch?
> 
> 
> Applied already

I looked at u-boot-nand-flash git repo and I can't see it.
Where's the repo where this is merged?

Thanks,
Michal



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

* Re: [PATCH v2] mtd: nand: Mark reserved blocks
  2023-02-02 14:49     ` Michal Simek
@ 2023-02-27 16:36       ` Dario Binacchi
  0 siblings, 0 replies; 6+ messages in thread
From: Dario Binacchi @ 2023-02-27 16:36 UTC (permalink / raw)
  To: Michal Simek
  Cc: Michael Nazzareno Trimarchi, Michal Simek, Ashok Reddy Soma,
	U-Boot-Denx, Simon Glass

Hi Michal,

On Thu, Feb 2, 2023 at 3:50 PM Michal Simek <michal.simek@amd.com> wrote:
>
>
>
> On 2/2/23 14:44, Michael Nazzareno Trimarchi wrote:
> > Hi
> >
> > Il gio 2 feb 2023, 14:21 Michal Simek <monstr@monstr.eu
> > <mailto:monstr@monstr.eu>> ha scritto:
> >
> >     Hi Dario,
> >
> >     On 1/5/23 10:46, Ashok Reddy Soma 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
> >      > "bbt reserved" 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  (bbt reserved)
> >      >    0xff400000  (bbt reserved)
> >      >    0xff800000  (bbt reserved)
> >      >    0xffc00000  (bbt reserved)
> >      >    0x116800000
> >      >    0x116c00000
> >      >    0x1ff000000         (bbt reserved)
> >      >    0x1ff400000         (bbt reserved)
> >      >    0x1ff800000         (bbt reserved)
> >      >    0x1ffc00000         (bbt reserved)
> >      >
> >      > Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@amd.com
> >     <mailto:ashok.reddy.soma@amd.com>>
> >      > Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com
> >     <mailto:michael@amarulasolutions.com>>
> >      > ---
> >
> >     Are you going to apply this patch?
> >
> >
> > Applied already
>
> I looked at u-boot-nand-flash git repo and I can't see it.
> Where's the repo where this is merged?
>
> Thanks,
> Michal
>
>

Applied to nand-next.

Thanks and regards,

Dario

-- 

Dario Binacchi

Senior Embedded Linux Developer

dario.binacchi@amarulasolutions.com

__________________________________


Amarula Solutions SRL

Via Le Canevare 30, 31100 Treviso, Veneto, IT

T. +39 042 243 5310
info@amarulasolutions.com

www.amarulasolutions.com

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

end of thread, other threads:[~2023-02-27 16:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-05  9:46 [PATCH v2] mtd: nand: Mark reserved blocks Ashok Reddy Soma
2023-01-05 10:04 ` Michael Nazzareno Trimarchi
2023-02-02 13:21 ` Michal Simek
2023-02-02 13:44   ` Michael Nazzareno Trimarchi
2023-02-02 14:49     ` Michal Simek
2023-02-27 16:36       ` Dario Binacchi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.