mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Martin Hundebøll" <martin@geanix.com>
To: "Rouven Czerwinski" <r.czerwinski@pengutronix.de>,
	"Måns Rullgård" <mans@mansr.com>,
	"Miquel Raynal" <miquel.raynal@bootlin.com>,
	"Richard Weinberger" <richard@nod.at>,
	"Vignesh Raghavendra" <vigneshr@ti.com>,
	JaimeLiao <jaimeliao.tw@gmail.com>
Cc: kernel@pengutronix.de, linux-mtd@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mtd: rawnand: check nand support for cache reads
Date: Fri, 22 Sep 2023 12:04:39 +0200	[thread overview]
Message-ID: <e7e2c33d3f769b0afb88badbbedc41102ce95ee5.camel@geanix.com> (raw)
In-Reply-To: <20230922100116.145090-1-r.czerwinski@pengutronix.de>

On Fri, 2023-09-22 at 12:01 +0200, Rouven Czerwinski wrote:
> Both the JEDEC and ONFI specification say that read cache sequential
> support is an optional command. This means that we not only need to
> check whether the individual controller implements the command, we
> also
> need to check the parameter pages for both ONFI and JEDEC NAND
> flashes
> before enabling sequential cache reads.
> 
> This fixes support for NAND flashes which don't support enabling
> cache
> reads, i.e. Samsung K9F4G08U0F or Toshiba TC58NVG0S3HTA00.
> 
> Sequential cache reads are no only available for ONFI and JEDEC
> devices,
> if individual vendors implement this, it needs to be enabled per
> vendor.
> 
> Tested on i.MX6Q with a Samsung NAND flash chip that doesn't support
> sequential reads.
> 
> Fixes: 003fe4b9545b ("mtd: rawnand: Support for sequential cache
> reads")
> 
> Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
> ---
> @Martin, Måns:
> I would appreciate if you could test this on your hardware.
> 
> @Miguel:
> I didn't have the time to test this on ONFI/JEDEC devices with
> support
> yet, I'd be fine if you hold off merging this.
> 
>  drivers/mtd/nand/raw/nand_base.c  | 3 +++
>  drivers/mtd/nand/raw/nand_jedec.c | 3 +++
>  drivers/mtd/nand/raw/nand_onfi.c  | 3 +++
>  include/linux/mtd/jedec.h         | 3 +++
>  include/linux/mtd/onfi.h          | 1 +
>  include/linux/mtd/rawnand.h       | 1 +
>  6 files changed, 14 insertions(+)
> 
> diff --git a/drivers/mtd/nand/raw/nand_base.c
> b/drivers/mtd/nand/raw/nand_base.c
> index d4b55155aeae..1fcac403cee6 100644
> --- a/drivers/mtd/nand/raw/nand_base.c
> +++ b/drivers/mtd/nand/raw/nand_base.c
> @@ -5110,6 +5110,9 @@ static void
> rawnand_check_cont_read_support(struct nand_chip *chip)
>  {
>         struct mtd_info *mtd = nand_to_mtd(chip);
>  
> +       if (!chip->parameters.supports_read_cache)
> +               return;
> +
>         if (chip->read_retries)
>                 return;
>  
> diff --git a/drivers/mtd/nand/raw/nand_jedec.c
> b/drivers/mtd/nand/raw/nand_jedec.c
> index 836757717660..e6ecbc4b2493 100644
> --- a/drivers/mtd/nand/raw/nand_jedec.c
> +++ b/drivers/mtd/nand/raw/nand_jedec.c
> @@ -94,6 +94,9 @@ int nand_jedec_detect(struct nand_chip *chip)
>                 goto free_jedec_param_page;
>         }
>  
> +       if (p->opt_cmd[0] & JEDEC_OPT_CMD_READ_CACHE)
> +               chip->parameters.supports_read_cache;

Missing ` = true` here ?

> +
>         memorg->pagesize = le32_to_cpu(p->byte_per_page);
>         mtd->writesize = memorg->pagesize;
>  
> diff --git a/drivers/mtd/nand/raw/nand_onfi.c
> b/drivers/mtd/nand/raw/nand_onfi.c
> index f15ef90aec8c..bf79bf2b5866 100644
> --- a/drivers/mtd/nand/raw/nand_onfi.c
> +++ b/drivers/mtd/nand/raw/nand_onfi.c
> @@ -303,6 +303,9 @@ int nand_onfi_detect(struct nand_chip *chip)
>                            ONFI_FEATURE_ADDR_TIMING_MODE, 1);
>         }
>  
> +       if (le16_to_cpu(p->opt_cmd) & ONFI_OPT_CMD_READ_CACHE)
> +               chip->parameters.supports_read_cache;

And here?

// Martin
> +
>         onfi = kzalloc(sizeof(*onfi), GFP_KERNEL);
>         if (!onfi) {
>                 ret = -ENOMEM;
> diff --git a/include/linux/mtd/jedec.h b/include/linux/mtd/jedec.h
> index 0b6b59f7cfbd..56047a4e54c9 100644
> --- a/include/linux/mtd/jedec.h
> +++ b/include/linux/mtd/jedec.h
> @@ -21,6 +21,9 @@ struct jedec_ecc_info {
>  /* JEDEC features */
>  #define JEDEC_FEATURE_16_BIT_BUS       (1 << 0)
>  
> +/* JEDEC Optional Commands */
> +#define JEDEC_OPT_CMD_READ_CACHE       BIT(1)
> +
>  struct nand_jedec_params {
>         /* rev info and features block */
>         /* 'J' 'E' 'S' 'D'  */
> diff --git a/include/linux/mtd/onfi.h b/include/linux/mtd/onfi.h
> index a7376f9beddf..55ab2e4d62f9 100644
> --- a/include/linux/mtd/onfi.h
> +++ b/include/linux/mtd/onfi.h
> @@ -55,6 +55,7 @@
>  #define ONFI_SUBFEATURE_PARAM_LEN      4
>  
>  /* ONFI optional commands SET/GET FEATURES supported? */
> +#define ONFI_OPT_CMD_READ_CACHE                BIT(1)
>  #define ONFI_OPT_CMD_SET_GET_FEATURES  BIT(2)
>  
>  struct nand_onfi_params {
> diff --git a/include/linux/mtd/rawnand.h
> b/include/linux/mtd/rawnand.h
> index 90a141ba2a5a..766856fcaba8 100644
> --- a/include/linux/mtd/rawnand.h
> +++ b/include/linux/mtd/rawnand.h
> @@ -233,6 +233,7 @@ struct nand_parameters {
>         /* Generic parameters */
>         const char *model;
>         bool supports_set_get_features;
> +       bool supports_read_cache;
>         DECLARE_BITMAP(set_feature_list, ONFI_FEATURE_NUMBER);
>         DECLARE_BITMAP(get_feature_list, ONFI_FEATURE_NUMBER);
>  


  reply	other threads:[~2023-09-22 10:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-22 10:01 Rouven Czerwinski
2023-09-22 10:04 ` Martin Hundebøll [this message]
2023-09-22 10:07   ` Rouven Czerwinski
2023-09-22 11:20 ` kernel test robot
2023-09-22 14:04 ` Miquel Raynal
2023-09-29 17:00 ` kernel test robot

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=e7e2c33d3f769b0afb88badbbedc41102ce95ee5.camel@geanix.com \
    --to=martin@geanix.com \
    --cc=jaimeliao.tw@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=mans@mansr.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=r.czerwinski@pengutronix.de \
    --cc=richard@nod.at \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®