All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: "Álvaro Fernández Rojas" <noltari@gmail.com>
Cc: vigneshr@ti.com, kdasu.kdev@gmail.com, richard@nod.at,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linaro-mm-sig@lists.linaro.org, linux-mtd@lists.infradead.org,
	bcm-kernel-feedback-list@broadcom.com,
	computersforpeace@gmail.com, sumit.semwal@linaro.org,
	linux-media@vger.kernel.org
Subject: Re: [PATCH v2] nand: brcmnand: correctly verify erased pages
Date: Mon, 11 May 2020 18:43:33 +0200	[thread overview]
Message-ID: <20200511184333.20d5a560@xps13> (raw)
In-Reply-To: <20200505082055.2843847-1-noltari@gmail.com>

Hi Álvaro,

Álvaro Fernández Rojas <noltari@gmail.com> wrote on Tue,  5 May 2020
10:20:55 +0200:

> The current code checks that the whole OOB area is erased.
> This is a problem when JFFS2 cleanmarkers are added to the OOB, since it will
> fail due to the usable OOB bytes not being 0xff.
> Correct this by only checking that the ECC aren't 0xff.
> 
> Fixes: 02b88eea9f9c ("mtd: brcmnand: Add check for erased page bitflips")
> 

This extra space between the Fixes tag and your SoB should be removed

> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> ---
>  v2: Add Fixes tag
> 
>  drivers/mtd/nand/raw/brcmnand/brcmnand.c | 22 ++++++++++++++++++----
>  1 file changed, 18 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> index e4e3ceeac38f..546f0807b887 100644
> --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> @@ -2018,6 +2018,7 @@ static int brcmnand_read_by_pio(struct mtd_info *mtd, struct nand_chip *chip,
>  static int brcmstb_nand_verify_erased_page(struct mtd_info *mtd,
>  		  struct nand_chip *chip, void *buf, u64 addr)
>  {
> +	struct mtd_oob_region oobecc;
>  	int i, sas;
>  	void *oob = chip->oob_poi;
>  	int bitflips = 0;
> @@ -2035,11 +2036,24 @@ static int brcmstb_nand_verify_erased_page(struct mtd_info *mtd,
>  	if (ret)
>  		return ret;
>  
> -	for (i = 0; i < chip->ecc.steps; i++, oob += sas) {
> +	for (i = 0; i < chip->ecc.steps; i++) {
>  		ecc_chunk = buf + chip->ecc.size * i;
> -		ret = nand_check_erased_ecc_chunk(ecc_chunk,
> -						  chip->ecc.size,
> -						  oob, sas, NULL, 0,
> +
> +		ret = nand_check_erased_ecc_chunk(ecc_chunk, chip->ecc.size,
> +						  NULL, 0, NULL, 0,
> +						  chip->ecc.strength);
> +		if (ret < 0)
> +			return ret;
> +
> +		bitflips = max(bitflips, ret);
> +	}
> +
> +	for (i = 0; mtd->ooblayout->ecc(mtd, i, &oobecc) != -ERANGE; i++)
> +	{
> +		ret = nand_check_erased_ecc_chunk(NULL, 0,
> +						  oob + oobecc.offset,
> +						  oobecc.length,
> +						  NULL, 0,
>  						  chip->ecc.strength);
>  		if (ret < 0)
>  			return 

If I understand correctly, the cleanmarker is in the "available OOB
area", which is somewhere in the OOB area between the bad block marker
and the ECC bytes. I think that checking the data buffer and the ECC
area only is enough and we can probably leave the remaining spare OOB
area.

But instead of calling nand_check_erased_ecc_chunk twice, just call:

    nand_check_erased_ecc_chunk(data, datalen, ecc, ecclen, NULL, 0,
                                strength); 

And also please clarify your commit log: you are not "just checking the
ECC bytes" but you are checking both the main area and the ECC bytes.


Thanks,
Miquèl

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

WARNING: multiple messages have this Message-ID (diff)
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: "Álvaro Fernández Rojas" <noltari@gmail.com>
Cc: computersforpeace@gmail.com, kdasu.kdev@gmail.com,
	richard@nod.at, vigneshr@ti.com, sumit.semwal@linaro.org,
	linux-mtd@lists.infradead.org,
	bcm-kernel-feedback-list@broadcom.com,
	linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
	dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org
Subject: Re: [PATCH v2] nand: brcmnand: correctly verify erased pages
Date: Mon, 11 May 2020 18:43:33 +0200	[thread overview]
Message-ID: <20200511184333.20d5a560@xps13> (raw)
In-Reply-To: <20200505082055.2843847-1-noltari@gmail.com>

Hi Álvaro,

Álvaro Fernández Rojas <noltari@gmail.com> wrote on Tue,  5 May 2020
10:20:55 +0200:

> The current code checks that the whole OOB area is erased.
> This is a problem when JFFS2 cleanmarkers are added to the OOB, since it will
> fail due to the usable OOB bytes not being 0xff.
> Correct this by only checking that the ECC aren't 0xff.
> 
> Fixes: 02b88eea9f9c ("mtd: brcmnand: Add check for erased page bitflips")
> 

This extra space between the Fixes tag and your SoB should be removed

> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> ---
>  v2: Add Fixes tag
> 
>  drivers/mtd/nand/raw/brcmnand/brcmnand.c | 22 ++++++++++++++++++----
>  1 file changed, 18 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> index e4e3ceeac38f..546f0807b887 100644
> --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> @@ -2018,6 +2018,7 @@ static int brcmnand_read_by_pio(struct mtd_info *mtd, struct nand_chip *chip,
>  static int brcmstb_nand_verify_erased_page(struct mtd_info *mtd,
>  		  struct nand_chip *chip, void *buf, u64 addr)
>  {
> +	struct mtd_oob_region oobecc;
>  	int i, sas;
>  	void *oob = chip->oob_poi;
>  	int bitflips = 0;
> @@ -2035,11 +2036,24 @@ static int brcmstb_nand_verify_erased_page(struct mtd_info *mtd,
>  	if (ret)
>  		return ret;
>  
> -	for (i = 0; i < chip->ecc.steps; i++, oob += sas) {
> +	for (i = 0; i < chip->ecc.steps; i++) {
>  		ecc_chunk = buf + chip->ecc.size * i;
> -		ret = nand_check_erased_ecc_chunk(ecc_chunk,
> -						  chip->ecc.size,
> -						  oob, sas, NULL, 0,
> +
> +		ret = nand_check_erased_ecc_chunk(ecc_chunk, chip->ecc.size,
> +						  NULL, 0, NULL, 0,
> +						  chip->ecc.strength);
> +		if (ret < 0)
> +			return ret;
> +
> +		bitflips = max(bitflips, ret);
> +	}
> +
> +	for (i = 0; mtd->ooblayout->ecc(mtd, i, &oobecc) != -ERANGE; i++)
> +	{
> +		ret = nand_check_erased_ecc_chunk(NULL, 0,
> +						  oob + oobecc.offset,
> +						  oobecc.length,
> +						  NULL, 0,
>  						  chip->ecc.strength);
>  		if (ret < 0)
>  			return 

If I understand correctly, the cleanmarker is in the "available OOB
area", which is somewhere in the OOB area between the bad block marker
and the ECC bytes. I think that checking the data buffer and the ECC
area only is enough and we can probably leave the remaining spare OOB
area.

But instead of calling nand_check_erased_ecc_chunk twice, just call:

    nand_check_erased_ecc_chunk(data, datalen, ecc, ecclen, NULL, 0,
                                strength); 

And also please clarify your commit log: you are not "just checking the
ECC bytes" but you are checking both the main area and the ECC bytes.


Thanks,
Miquèl

  reply	other threads:[~2020-05-11 16:43 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-04  9:29 [PATCH] nand: brcmnand: correctly verify erased pages Álvaro Fernández Rojas
2020-05-04  9:29 ` Álvaro Fernández Rojas
2020-05-04  9:29 ` Álvaro Fernández Rojas
2020-05-04 21:43 ` Florian Fainelli
2020-05-04 21:43   ` Florian Fainelli
2020-05-04 21:43   ` Florian Fainelli
2020-05-05  8:24   ` Álvaro Fernández Rojas
2020-05-05  8:20 ` [PATCH v2] " Álvaro Fernández Rojas
2020-05-05  8:20   ` Álvaro Fernández Rojas
2020-05-05  8:20   ` Álvaro Fernández Rojas
2020-05-11 16:43   ` Miquel Raynal [this message]
2020-05-11 16:43     ` Miquel Raynal
2020-05-12  6:51   ` [PATCH v3] mtd: rawnand: " Álvaro Fernández Rojas
2020-05-12  6:51     ` Álvaro Fernández Rojas
2020-05-12  6:51     ` Álvaro Fernández Rojas
2020-05-12  7:16     ` Miquel Raynal
2020-05-12  7:16       ` Miquel Raynal
2020-05-12  7:16       ` Miquel Raynal
2020-05-12  7:24       ` Álvaro Fernández Rojas
2020-05-12  7:24         ` Álvaro Fernández Rojas
2020-05-12  7:24         ` Álvaro Fernández Rojas
2020-05-12  7:34         ` Miquel Raynal
2020-05-12  7:34           ` Miquel Raynal
2020-05-12  7:34           ` Miquel Raynal
2020-05-12  8:24           ` Álvaro Fernández Rojas
2020-05-12  8:24             ` Álvaro Fernández Rojas
2020-05-12  8:24             ` Álvaro Fernández Rojas
2020-05-12  8:24     ` [PATCH v4] " Álvaro Fernández Rojas
2020-05-12  8:24       ` Álvaro Fernández Rojas
2020-05-12  8:24       ` Álvaro Fernández Rojas
2020-05-24 19:16       ` Miquel Raynal
2020-05-24 19:16         ` Miquel Raynal
2020-05-24 19:16         ` Miquel Raynal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200511184333.20d5a560@xps13 \
    --to=miquel.raynal@bootlin.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=computersforpeace@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kdasu.kdev@gmail.com \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=noltari@gmail.com \
    --cc=richard@nod.at \
    --cc=sumit.semwal@linaro.org \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.