linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Rickard Andersson <rickaran@axis.com>
Cc: linux-mtd@lists.infradead.org
Subject: Re: [PATCH 1/2] mtd: rawnand: Use the ->init_data_interface() hook
Date: Tue, 19 May 2020 11:04:46 +0200	[thread overview]
Message-ID: <20200519110446.76945463@xps13> (raw)
In-Reply-To: <20200514091342.16924-1-rickaran@axis.com>

Hi Rickard,

Rickard Andersson <rickaran@axis.com> wrote on Thu, 14 May 2020
11:13:41 +0200:

> From: Rickard x Andersson <rickaran@axis.com>
> 
> Check if the NAND vendor provided hook works and check that
> the NAND controller can handle the timings.
> 
> Signed-off-by: Rickard x Andersson <rickaran@axis.com>
> ---
>  drivers/mtd/nand/raw/nand_base.c | 31 +++++++++++++++++++++++++++++--
>  1 file changed, 29 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
> index 8744f0033f78..974050a04f23 100644
> --- a/drivers/mtd/nand/raw/nand_base.c
> +++ b/drivers/mtd/nand/raw/nand_base.c
> @@ -955,6 +955,30 @@ static int nand_setup_data_interface(struct nand_chip *chip, int chipnr)
>  	return ret;
>  }
>  
> +static int nand_try_init_data_interface(struct nand_chip *chip)
> +{
> +	int ret = chip->ops.init_data_interface(chip);
> +
> +	if (!ret) {
> +		/*
> +		 * Pass NAND_DATA_IFACE_CHECK_ONLY to only check if the
> +		 * controller supports the requested timings.
> +		 */
> +		ret = chip->controller->ops->setup_data_interface(chip,
> +						 NAND_DATA_IFACE_CHECK_ONLY,
> +						 &chip->data_interface);

I would like this to happen in Toshiba's code. Imagine you can try
several timings, the vendor code should be able to check by itself the
controller supports the timings.

I think you can drop this "try init data interface" and move the
content to Toshiba's driver.

> +	}
> +
> +	if (ret) {
> +		/* The provided data interface timings did not work */
> +		chip->ops.init_data_interface = NULL;
> +		memset(&chip->data_interface, 0,
> +		       sizeof(struct nand_data_interface));
> +	}
> +
> +	return ret;
> +}
> +
>  /**
>   * nand_choose_data_interface - find the best data interface and timings
>   * @chip: The NAND chip
> @@ -980,8 +1004,11 @@ static int nand_choose_data_interface(struct nand_chip *chip)
>  	 * ->init_data_interface() is expected to update the entire chip's
>  	 * nand_data_interface structure.
>  	 */
> -	if (nand_has_init_data_interface(chip))
> -		return chip->ops.init_data_interface(chip);

I renamed it "choose_data_interface" now, you can pull changes from
Github.

> +	if (nand_has_init_data_interface(chip)) {
> +		ret = nand_try_init_data_interface(chip);
> +		if (!ret)
> +			return 0;

I'm fine with a fallback on the regular ONFI research though, which in
this case would choose timings mode 0 I guess. Can you validate?

On my side I changed the code on Github and now a negative return code
just silently fails so that we fallback on mode 0.

> +	}
>  
>  	/*
>  	 * First try to identify the best timings from ONFI parameters and

Thanks,
Miquèl

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

      parent reply	other threads:[~2020-05-19  9:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <richard@nod.at;>
2020-05-14  9:13 ` [PATCH 1/2] mtd: rawnand: Use the ->init_data_interface() hook Rickard Andersson
2020-05-14  9:13   ` [PATCH 2/2] mtd: rawnand: Add timings for Kioxia TH58NVG2S3HBAI4 Rickard Andersson
2020-05-19 12:08     ` Miquel Raynal
2020-05-19  9:04   ` Miquel Raynal [this message]

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=20200519110446.76945463@xps13 \
    --to=miquel.raynal@bootlin.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=rickaran@axis.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;
as well as URLs for NNTP newsgroup(s).