All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@collabora.com>
To: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Michal Simek <monstr@monstr.eu>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Tudor Ambarus <Tudor.Ambarus@microchip.com>,
	Richard Weinberger <richard@nod.at>,
	linux-mtd@lists.infradead.org,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Naga Sureshkumar Relli <nagasure@xilinx.com>
Subject: Re: [PATCH v3 11/13] mtd: rawnand: Expose monolithic read/write_page_raw() helpers
Date: Mon, 4 May 2020 10:54:20 +0200	[thread overview]
Message-ID: <20200504105420.5eadef7c@collabora.com> (raw)
In-Reply-To: <20200504082414.7327-12-miquel.raynal@bootlin.com>

On Mon,  4 May 2020 10:24:12 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> The current nand_read/write_page_raw() helpers are already widely used
> but do not fit the purpose of "constrained" controllers which cannot,
> for instance, separate command/address cycles with data cycles.
> 
> Workaround this issue by proposing alternative helpers that cannot be

								^can

> used by controller drivers instead.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
>  drivers/mtd/nand/raw/nand_base.c | 79 ++++++++++++++++++++++++++++++++
>  include/linux/mtd/rawnand.h      |  8 +++-
>  2 files changed, 85 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
> index 413974df8a5e..6ec24eee355b 100644
> --- a/drivers/mtd/nand/raw/nand_base.c
> +++ b/drivers/mtd/nand/raw/nand_base.c
> @@ -2638,6 +2638,48 @@ int nand_read_page_raw(struct nand_chip *chip, uint8_t *buf, int oob_required,
>  }
>  EXPORT_SYMBOL(nand_read_page_raw);
>  
> +/**
> + * nand_monolithic_read_page_raw - Monolithic page read in raw mode
> + * @chip: NAND chip info structure
> + * @buf: buffer to store read data
> + * @oob_required: caller requires OOB data read to chip->oob_poi
> + * @page: page number to read
> + *
> + * This is a raw page read, ie. without any error detection/correction.
> + * Monolithic means we are requesting all the relevant data (main plus
> + * eventually OOB) to be loaded in the NAND cache and sent over the
> + * bus (from the NAND chip to the NAND controller) in a single
> + * operation. This is an alternative to nand_read_page_raw(), which
> + * first reads the main data, and if the OOB data is requested too,
> + * then reads more data on the bus. Indeed, this approach is not
> + * well supported by all controller drivers.

I'd drop the last sentence. The rest looks good.

> + */
> +int nand_monolithic_read_page_raw(struct nand_chip *chip, u8 *buf,
> +				  int oob_required, int page)
> +{
> +	struct mtd_info *mtd = nand_to_mtd(chip);
> +	unsigned int size = mtd->writesize;
> +	u8 *read_buf = buf;
> +	int ret;
> +
> +	if (oob_required) {
> +		size += mtd->oobsize;
> +
> +		if (buf != chip->data_buf)
> +			read_buf = nand_get_data_buf(chip);
> +	}
> +
> +	ret = nand_read_page_op(chip, page, 0, read_buf, size);
> +	if (ret)
> +		return ret;
> +
> +	if (buf != chip->data_buf)
> +		memcpy(buf, read_buf, mtd->writesize);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(nand_monolithic_read_page_raw);
> +
>  /**
>   * nand_read_page_raw_syndrome - [INTERN] read raw page data without ecc
>   * @chip: nand chip info structure
> @@ -3646,6 +3688,43 @@ int nand_write_page_raw(struct nand_chip *chip, const uint8_t *buf,
>  }
>  EXPORT_SYMBOL(nand_write_page_raw);
>  
> +/**
> + * nand_monolithic_write_page_raw - Monolithic page write in raw mode
> + * @chip: NAND chip info structure
> + * @buf: data buffer to write
> + * @oob_required: must write chip->oob_poi to OOB
> + * @page: page number to write
> + *
> + * This is a raw page write, ie. without any error detection/correction.
> + * Monolithic means we are requesting all the relevant data (main plus
> + * eventually OOB) to be sent over the bus and effectively programmed
> + * into the NAND chip arrays in a single operation. This is an
> + * alternative to nand_write_page_raw(), which first sends the main
> + * data, then eventually send the OOB data by latching more data
> + * cycles on the NAND bus, and finally sends the program command to
> + * synchronyze the NAND chip cache. Indeed, this approach is not well
> + * supported by all controller drivers.

Ditto.

With this addressed:

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>

> + */
> +int nand_monolithic_write_page_raw(struct nand_chip *chip, const u8 *buf,
> +				   int oob_required, int page)
> +{
> +	struct mtd_info *mtd = nand_to_mtd(chip);
> +	unsigned int size = mtd->writesize;
> +	u8 *write_buf = (u8 *)buf;
> +
> +	if (oob_required) {
> +		size += mtd->oobsize;
> +
> +		if (buf != chip->data_buf) {
> +			write_buf = nand_get_data_buf(chip);
> +			memcpy(write_buf, buf, mtd->writesize);
> +		}
> +	}
> +
> +	return nand_prog_page_op(chip, page, 0, write_buf, size);
> +}
> +EXPORT_SYMBOL(nand_monolithic_write_page_raw);
> +
>  /**
>   * nand_write_page_raw_syndrome - [INTERN] raw page write function
>   * @chip: nand chip info structure
> diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h
> index 70380c91731c..830e05dd1e1d 100644
> --- a/include/linux/mtd/rawnand.h
> +++ b/include/linux/mtd/rawnand.h
> @@ -1328,13 +1328,17 @@ int nand_read_oob_std(struct nand_chip *chip, int page);
>  int nand_get_set_features_notsupp(struct nand_chip *chip, int addr,
>  				  u8 *subfeature_param);
>  
> -/* Default read_page_raw implementation */
> +/* Default read_page_raw implementations */
>  int nand_read_page_raw(struct nand_chip *chip, uint8_t *buf, int oob_required,
>  		       int page);
> +int nand_monolithic_read_page_raw(struct nand_chip *chip, uint8_t *buf,
> +				  int oob_required, int page);
>  
> -/* Default write_page_raw implementation */
> +/* Default write_page_raw implementations */
>  int nand_write_page_raw(struct nand_chip *chip, const uint8_t *buf,
>  			int oob_required, int page);
> +int nand_monolithic_write_page_raw(struct nand_chip *chip, const uint8_t *buf,
> +				   int oob_required, int page);
>  
>  /* Reset and initialize a NAND device */
>  int nand_reset(struct nand_chip *chip, int chipnr);


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

  reply	other threads:[~2020-05-04  8:54 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-04  8:24 [PATCH v3 00/13] Supporting restricted NAND controllers Miquel Raynal
2020-05-04  8:24 ` [PATCH v3 01/13] mtd: rawnand: Translate obscure bitfields into readable macros Miquel Raynal
2020-05-04  8:24 ` [PATCH v3 02/13] mtd: rawnand: Reorder the nand_chip->options flags Miquel Raynal
2020-05-04  8:24 ` [PATCH v3 03/13] mtd: rawnand: Rename a NAND chip option Miquel Raynal
2020-05-04  8:24 ` [PATCH v3 04/13] mtd: rawnand: Fix comments about the use of bufpoi Miquel Raynal
2020-05-04  8:24 ` [PATCH v3 05/13] mtd: rawnand: Rename the use_bufpoi variables Miquel Raynal
2020-05-04  8:24 ` [PATCH v3 06/13] mtd: rawnand: Avoid indirect access to ->data_buf() Miquel Raynal
2020-05-04  8:24 ` [PATCH v3 07/13] mtd: rawnand: Add a helper to check supported operations Miquel Raynal
2020-05-04  8:24 ` [PATCH v3 08/13] mtd: rawnand: Give the possibility to verify a read operation is supported Miquel Raynal
2020-05-04  8:42   ` Boris Brezillon
2020-05-04  8:24 ` [PATCH v3 09/13] mtd: rawnand: onfi: Adapt the parameter page read to constraint controllers Miquel Raynal
2020-05-04  8:47   ` Boris Brezillon
2020-05-04  9:01     ` Miquel Raynal
2020-05-04  8:24 ` [PATCH v3 10/13] mtd: rawnand: jedec: " Miquel Raynal
2020-05-04  8:51   ` Boris Brezillon
2020-05-04  8:57     ` Miquel Raynal
2020-05-04  8:24 ` [PATCH v3 11/13] mtd: rawnand: Expose monolithic read/write_page_raw() helpers Miquel Raynal
2020-05-04  8:54   ` Boris Brezillon [this message]
2020-05-04  8:24 ` [PATCH v3 12/13] mtd: rawnand: Allow controllers to overload soft ECC hooks Miquel Raynal
2020-05-04  8:24 ` [PATCH v3 13/13] mtd: rawnand: micron: Allow controllers to overload raw accessors 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=20200504105420.5eadef7c@collabora.com \
    --to=boris.brezillon@collabora.com \
    --cc=Tudor.Ambarus@microchip.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=monstr@monstr.eu \
    --cc=nagasure@xilinx.com \
    --cc=richard@nod.at \
    --cc=thomas.petazzoni@bootlin.com \
    --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.