linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Boris Brezillon <bbrezillon@kernel.org>
To: Schrempf Frieder <frieder.schrempf@kontron.de>
Cc: "miquel.raynal@bootlin.com" <miquel.raynal@bootlin.com>,
	"richard@nod.at" <richard@nod.at>,
	David Woodhouse <dwmw2@infradead.org>,
	Brian Norris <computersforpeace@gmail.com>,
	Marek Vasut <marek.vasut@gmail.com>,
	"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 2/5] mtd: nand: Make flags for bad block marker position more granular
Date: Wed, 30 Jan 2019 14:38:49 +0100	[thread overview]
Message-ID: <20190130143849.73501e65@bbrezillon> (raw)
In-Reply-To: <20190130130111.32724-3-frieder.schrempf@kontron.de>

On Wed, 30 Jan 2019 13:01:47 +0000
Schrempf Frieder <frieder.schrempf@kontron.de> wrote:

> From: Frieder Schrempf <frieder.schrempf@kontron.de>
> 
> To be able to check and set bad block markers in the first and
> second page of a block independently of each other, we create
> separate flags for both cases.
> 
> Previously NAND_BBM_SECONDPAGE meant, that both, the first and the
> second page were used. With this patch NAND_BBM_FIRSTPAGE stands for
> using the first page and NAND_BBM_SECONDPAGE for using the second
> page.
> 
> This patch is only for preparation of subsequent changes and does
> not implement the logic to actually handle both flags separately.
> 
> Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>

Reviewed-by: Boris Brezillon <bbrezillon@kernel.org>

> ---
>  drivers/mtd/nand/raw/nand_amd.c      | 2 +-
>  drivers/mtd/nand/raw/nand_base.c     | 6 ++++--
>  drivers/mtd/nand/raw/nand_bbt.c      | 3 ++-
>  drivers/mtd/nand/raw/nand_esmt.c     | 2 +-
>  drivers/mtd/nand/raw/nand_hynix.c    | 2 +-
>  drivers/mtd/nand/raw/nand_macronix.c | 2 +-
>  drivers/mtd/nand/raw/nand_micron.c   | 2 +-
>  drivers/mtd/nand/raw/nand_samsung.c  | 2 +-
>  drivers/mtd/nand/raw/nand_toshiba.c  | 2 +-
>  drivers/mtd/nand/raw/sh_flctl.c      | 2 +-
>  include/linux/mtd/rawnand.h          | 1 +
>  11 files changed, 15 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/nand_amd.c b/drivers/mtd/nand/raw/nand_amd.c
> index 6e248bdcc797..6202cbf7ee8d 100644
> --- a/drivers/mtd/nand/raw/nand_amd.c
> +++ b/drivers/mtd/nand/raw/nand_amd.c
> @@ -40,7 +40,7 @@ static void amd_nand_decode_id(struct nand_chip *chip)
>  static int amd_nand_init(struct nand_chip *chip)
>  {
>  	if (nand_is_slc(chip))
> -		chip->options |= NAND_BBM_SECONDPAGE;
> +		chip->options |= NAND_BBM_FIRSTPAGE | NAND_BBM_SECONDPAGE;
>  
>  	return 0;
>  }
> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
> index c6199cc68d2f..9ef7b86cdc42 100644
> --- a/drivers/mtd/nand/raw/nand_base.c
> +++ b/drivers/mtd/nand/raw/nand_base.c
> @@ -302,7 +302,8 @@ static int nand_block_bad(struct nand_chip *chip, loff_t ofs)
>  		ofs += mtd->erasesize - mtd->writesize;
>  
>  	page = (int)(ofs >> chip->page_shift) & chip->pagemask;
> -	page_end = page + ((chip->options & NAND_BBM_SECONDPAGE) ? 2 : 1);
> +	page_end = page + (((chip->options & NAND_BBM_FIRSTPAGE) &&
> +			    (chip->options & NAND_BBM_SECONDPAGE)) ? 2 : 1);
>  
>  	for (; page < page_end; page++) {
>  		res = chip->ecc.read_oob(chip, page);
> @@ -550,7 +551,8 @@ static int nand_default_block_markbad(struct nand_chip *chip, loff_t ofs)
>  
>  		i++;
>  		ofs += mtd->writesize;
> -	} while ((chip->options & NAND_BBM_SECONDPAGE) && i < 2);
> +	} while ((chip->options & NAND_BBM_FIRSTPAGE) &&
> +		 (chip->options & NAND_BBM_SECONDPAGE) && i < 2);
>  
>  	return ret;
>  }
> diff --git a/drivers/mtd/nand/raw/nand_bbt.c b/drivers/mtd/nand/raw/nand_bbt.c
> index 862eaa3a0552..c095c04d566d 100644
> --- a/drivers/mtd/nand/raw/nand_bbt.c
> +++ b/drivers/mtd/nand/raw/nand_bbt.c
> @@ -466,7 +466,8 @@ static int create_bbt(struct nand_chip *this, uint8_t *buf,
>  
>  	pr_info("Scanning device for bad blocks\n");
>  
> -	if (this->options & NAND_BBM_SECONDPAGE)
> +	if ((this->options & NAND_BBM_FIRSTPAGE) &&
> +	    (this->options & NAND_BBM_SECONDPAGE))
>  		numpages = 2;
>  	else
>  		numpages = 1;
> diff --git a/drivers/mtd/nand/raw/nand_esmt.c b/drivers/mtd/nand/raw/nand_esmt.c
> index 80d2d3a1b5f2..99a8092969a7 100644
> --- a/drivers/mtd/nand/raw/nand_esmt.c
> +++ b/drivers/mtd/nand/raw/nand_esmt.c
> @@ -36,7 +36,7 @@ static void esmt_nand_decode_id(struct nand_chip *chip)
>  static int esmt_nand_init(struct nand_chip *chip)
>  {
>  	if (nand_is_slc(chip))
> -		chip->options |= NAND_BBM_SECONDPAGE;
> +		chip->options |= NAND_BBM_FIRSTPAGE | NAND_BBM_SECONDPAGE;
>  
>  	return 0;
>  }
> diff --git a/drivers/mtd/nand/raw/nand_hynix.c b/drivers/mtd/nand/raw/nand_hynix.c
> index 2789bf3857c9..e685d70c1618 100644
> --- a/drivers/mtd/nand/raw/nand_hynix.c
> +++ b/drivers/mtd/nand/raw/nand_hynix.c
> @@ -674,7 +674,7 @@ static int hynix_nand_init(struct nand_chip *chip)
>  	if (!nand_is_slc(chip))
>  		chip->options |= NAND_BBM_LASTPAGE;
>  	else
> -		chip->options |= NAND_BBM_SECONDPAGE;
> +		chip->options |= NAND_BBM_FIRSTPAGE | NAND_BBM_SECONDPAGE;
>  
>  	hynix = kzalloc(sizeof(*hynix), GFP_KERNEL);
>  	if (!hynix)
> diff --git a/drivers/mtd/nand/raw/nand_macronix.c b/drivers/mtd/nand/raw/nand_macronix.c
> index 6db7ced4b96b..e287e71347c5 100644
> --- a/drivers/mtd/nand/raw/nand_macronix.c
> +++ b/drivers/mtd/nand/raw/nand_macronix.c
> @@ -62,7 +62,7 @@ static void macronix_nand_fix_broken_get_timings(struct nand_chip *chip)
>  static int macronix_nand_init(struct nand_chip *chip)
>  {
>  	if (nand_is_slc(chip))
> -		chip->options |= NAND_BBM_SECONDPAGE;
> +		chip->options |= NAND_BBM_FIRSTPAGE | NAND_BBM_SECONDPAGE;
>  
>  	macronix_nand_fix_broken_get_timings(chip);
>  
> diff --git a/drivers/mtd/nand/raw/nand_micron.c b/drivers/mtd/nand/raw/nand_micron.c
> index ea6b6e80d6f8..ca80e09783c7 100644
> --- a/drivers/mtd/nand/raw/nand_micron.c
> +++ b/drivers/mtd/nand/raw/nand_micron.c
> @@ -448,7 +448,7 @@ static int micron_nand_init(struct nand_chip *chip)
>  		goto err_free_manuf_data;
>  
>  	if (mtd->writesize == 2048)
> -		chip->options |= NAND_BBM_SECONDPAGE;
> +		chip->options |= NAND_BBM_FIRSTPAGE | NAND_BBM_SECONDPAGE;
>  
>  	ondie = micron_supports_on_die_ecc(chip);
>  
> diff --git a/drivers/mtd/nand/raw/nand_samsung.c b/drivers/mtd/nand/raw/nand_samsung.c
> index 3be737139210..ace50522dd19 100644
> --- a/drivers/mtd/nand/raw/nand_samsung.c
> +++ b/drivers/mtd/nand/raw/nand_samsung.c
> @@ -123,7 +123,7 @@ static int samsung_nand_init(struct nand_chip *chip)
>  	if (!nand_is_slc(chip))
>  		chip->options |= NAND_BBM_LASTPAGE;
>  	else
> -		chip->options |= NAND_BBM_SECONDPAGE;
> +		chip->options |= NAND_BBM_FIRSTPAGE | NAND_BBM_SECONDPAGE;
>  
>  	return 0;
>  }
> diff --git a/drivers/mtd/nand/raw/nand_toshiba.c b/drivers/mtd/nand/raw/nand_toshiba.c
> index 222a66bf0aa6..0031e6727193 100644
> --- a/drivers/mtd/nand/raw/nand_toshiba.c
> +++ b/drivers/mtd/nand/raw/nand_toshiba.c
> @@ -147,7 +147,7 @@ static void toshiba_nand_decode_id(struct nand_chip *chip)
>  static int toshiba_nand_init(struct nand_chip *chip)
>  {
>  	if (nand_is_slc(chip))
> -		chip->options |=  NAND_BBM_SECONDPAGE;
> +		chip->options |= NAND_BBM_FIRSTPAGE | NAND_BBM_SECONDPAGE;
>  
>  	/* Check that chip is BENAND and ECC mode is on-die */
>  	if (nand_is_slc(chip) && chip->ecc.mode == NAND_ECC_ON_DIE &&
> diff --git a/drivers/mtd/nand/raw/sh_flctl.c b/drivers/mtd/nand/raw/sh_flctl.c
> index 2017b00fadd8..971d9afd55e5 100644
> --- a/drivers/mtd/nand/raw/sh_flctl.c
> +++ b/drivers/mtd/nand/raw/sh_flctl.c
> @@ -1176,7 +1176,7 @@ static int flctl_probe(struct platform_device *pdev)
>  	if (pdata->flcmncr_val & SEL_16BIT)
>  		nand->options |= NAND_BUSWIDTH_16;
>  
> -	nand->options |= NAND_BBM_SECONDPAGE;
> +	nand->options |= NAND_BBM_FIRSTPAGE | NAND_BBM_SECONDPAGE;
>  
>  	pm_runtime_enable(&pdev->dev);
>  	pm_runtime_resume(&pdev->dev);
> diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h
> index da785d92e26e..23ad4ad790af 100644
> --- a/include/linux/mtd/rawnand.h
> +++ b/include/linux/mtd/rawnand.h
> @@ -176,6 +176,7 @@ enum nand_ecc_algo {
>   * Position within the block: Each of these pages needs to be checked for a
>   * bad block marking pattern.
>   */
> +#define NAND_BBM_FIRSTPAGE		0x01000000
>  #define NAND_BBM_SECONDPAGE		0x02000000
>  #define NAND_BBM_LASTPAGE		0x04000000
>  


  reply	other threads:[~2019-01-30 13:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-30 13:01 [PATCH v3 0/5] mtd: rawnand: Support bad block markers in first, second or last page Schrempf Frieder
2019-01-30 13:01 ` [PATCH v3 1/5] mtd: nand: Always store info about bad block markers in chip struct Schrempf Frieder
2019-01-30 13:28   ` Boris Brezillon
2019-01-30 13:37     ` Schrempf Frieder
2019-01-30 13:01 ` [PATCH v3 2/5] mtd: nand: Make flags for bad block marker position more granular Schrempf Frieder
2019-01-30 13:38   ` Boris Brezillon [this message]
2019-01-30 13:01 ` [PATCH v3 3/5] mtd: rawnand: Support bad block markers in first, second or last page Schrempf Frieder
2019-01-30 13:01 ` [PATCH v3 4/5] mtd: rawnand: ESMT: Also use the last page for bad block markers Schrempf Frieder
2019-01-30 13:01 ` [PATCH v3 5/5] mtd: rawnand: AMD: " Schrempf Frieder

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=20190130143849.73501e65@bbrezillon \
    --to=bbrezillon@kernel.org \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=frieder.schrempf@kontron.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).