public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v2 0/5] Add continuous read mode support
@ 2022-11-02  6:14 Leo Yu
  2022-11-02  6:14 ` [PATCH v2 1/5] mtd: spinand: Add continuous read mode configuration Leo Yu
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Leo Yu @ 2022-11-02  6:14 UTC (permalink / raw)
  To: dario.binacchi, michael, miquel.raynal, u-boot; +Cc: jaimeliao.tw, Leo Yu

v2:
 Fix missing definition of totallen in mtd_oob_ops structure
 in include/linux/mtd/mtd.h.

This patch series add continuous read mode support for SPI NAND
devices.

Leo Yu (5):
  mtd: spinand: Add continuous read mode configuration
  mtd: spinand: Add continuous read mode initialization
  cmd: mtd: Add total length of read operation
  mtd: spinand: Add continuous read operation
  mtd: spinand: macronix: Add continuous read mode flag for devices

 cmd/mtd.c                       |   2 +
 drivers/mtd/nand/spi/core.c     | 140 +++++++++++++++++++++++++++++++-
 drivers/mtd/nand/spi/macronix.c |  10 +--
 include/linux/mtd/mtd.h         |   2 +
 include/linux/mtd/spinand.h     |   5 ++
 5 files changed, 153 insertions(+), 6 deletions(-)

--
2.17.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/5] mtd: spinand: Add continuous read mode configuration
  2022-11-02  6:14 [PATCH v2 0/5] Add continuous read mode support Leo Yu
@ 2022-11-02  6:14 ` Leo Yu
  2022-11-02  6:14 ` [PATCH v2 2/5] mtd: spinand: Add continuous read mode initialization Leo Yu
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Leo Yu @ 2022-11-02  6:14 UTC (permalink / raw)
  To: dario.binacchi, michael, miquel.raynal, u-boot; +Cc: jaimeliao.tw, Leo Yu

This patch sets the "CONT" bit in the configuration register
and adds a flag for identifying continuous read mode capability.

Signed-off-by: Leo Yu <liangyanyu13@gmail.com>
---
 drivers/mtd/nand/spi/core.c | 12 ++++++++++++
 include/linux/mtd/spinand.h |  2 ++
 2 files changed, 14 insertions(+)

diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index 134bf22c80..2419c267d6 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -216,6 +216,18 @@ static int spinand_init_quad_enable(struct spinand_device *spinand)
 			       enable ? CFG_QUAD_ENABLE : 0);
 }

+static int spinand_continuous_read_enable(struct spinand_device *spinand,
+					  bool enable)
+{
+	int ret = spinand_upd_cfg(spinand, CFG_CONT_READ_ENABLE,
+				  enable ? CFG_CONT_READ_ENABLE : 0);
+
+	if (!ret)
+		spinand->use_continuous_read = enable;
+
+	return ret;
+}
+
 static int spinand_ecc_enable(struct spinand_device *spinand,
 			      bool enable)
 {
diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h
index 15bcd59f34..e6a5478b0a 100644
--- a/include/linux/mtd/spinand.h
+++ b/include/linux/mtd/spinand.h
@@ -131,6 +131,7 @@
 #define REG_CFG			0xb0
 #define CFG_OTP_ENABLE		BIT(6)
 #define CFG_ECC_ENABLE		BIT(4)
+#define CFG_CONT_READ_ENABLE	BIT(2)
 #define CFG_QUAD_ENABLE		BIT(0)

 /* status register */
@@ -247,6 +248,7 @@ struct spinand_ecc_info {

 #define SPINAND_HAS_QE_BIT		BIT(0)
 #define SPINAND_HAS_CR_FEAT_BIT		BIT(1)
+#define SPINAND_HAS_CONT_READ_BIT	BIT(2)

 /**
  * struct spinand_info - Structure used to describe SPI NAND chips
--
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/5] mtd: spinand: Add continuous read mode initialization
  2022-11-02  6:14 [PATCH v2 0/5] Add continuous read mode support Leo Yu
  2022-11-02  6:14 ` [PATCH v2 1/5] mtd: spinand: Add continuous read mode configuration Leo Yu
@ 2022-11-02  6:14 ` Leo Yu
  2022-11-02  6:14 ` [PATCH v2 3/5] cmd: mtd: Add total length of read operation Leo Yu
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Leo Yu @ 2022-11-02  6:14 UTC (permalink / raw)
  To: dario.binacchi, michael, miquel.raynal, u-boot; +Cc: jaimeliao.tw, Leo Yu

Add continuous read mode status and initialize the default status
to false.

Signed-off-by: Leo Yu <liangyanyu13@gmail.com>
---
 drivers/mtd/nand/spi/core.c | 8 ++++++++
 include/linux/mtd/spinand.h | 3 +++
 2 files changed, 11 insertions(+)

diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index 2419c267d6..9d628f6f26 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -216,6 +216,11 @@ static int spinand_init_quad_enable(struct spinand_device *spinand)
 			       enable ? CFG_QUAD_ENABLE : 0);
 }

+static void spinand_init_continuous_read(struct spinand_device *spinand)
+{
+	spinand->use_continuous_read = false;
+}
+
 static int spinand_continuous_read_enable(struct spinand_device *spinand,
 					  bool enable)
 {
@@ -1126,6 +1131,9 @@ static int spinand_init(struct spinand_device *spinand)

 	mtd->oobavail = ret;

+	/* Init continuous read mode */
+	spinand_init_continuous_read(spinand);
+
 	return 0;

 err_cleanup_nanddev:
diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h
index e6a5478b0a..f3a77ea317 100644
--- a/include/linux/mtd/spinand.h
+++ b/include/linux/mtd/spinand.h
@@ -337,6 +337,7 @@ struct spinand_info {
  *		the stack
  * @manufacturer: SPI NAND manufacturer information
  * @priv: manufacturer private data
+ * @use_continuous_read: indicate the continuous read mode status
  */
 struct spinand_device {
 	struct nand_device base;
@@ -367,6 +368,8 @@ struct spinand_device {
 	u8 *scratchbuf;
 	const struct spinand_manufacturer *manufacturer;
 	void *priv;
+
+	bool use_continuous_read;
 };

 /**
--
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 3/5] cmd: mtd: Add total length of read operation
  2022-11-02  6:14 [PATCH v2 0/5] Add continuous read mode support Leo Yu
  2022-11-02  6:14 ` [PATCH v2 1/5] mtd: spinand: Add continuous read mode configuration Leo Yu
  2022-11-02  6:14 ` [PATCH v2 2/5] mtd: spinand: Add continuous read mode initialization Leo Yu
@ 2022-11-02  6:14 ` Leo Yu
  2022-11-07 14:51   ` Miquel Raynal
  2022-11-02  6:14 ` [PATCH v2 4/5] mtd: spinand: Add continuous " Leo Yu
  2022-11-02  6:14 ` [PATCH v2 5/5] mtd: spinand: macronix: Add continuous read mode flag for devices Leo Yu
  4 siblings, 1 reply; 8+ messages in thread
From: Leo Yu @ 2022-11-02  6:14 UTC (permalink / raw)
  To: dario.binacchi, michael, miquel.raynal, u-boot; +Cc: jaimeliao.tw, Leo Yu

This patch bypasses the limitation of length for read operations
in MTD test module. Thus, the total length of a read operation
can be passed down to the continuous read operation in SPI NAND
layer.

Signed-off-by: Leo Yu <liangyanyu13@gmail.com>
---
 cmd/mtd.c               | 2 ++
 include/linux/mtd/mtd.h | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/cmd/mtd.c b/cmd/mtd.c
index ad5cc9827d..0b601e08a3 100644
--- a/cmd/mtd.c
+++ b/cmd/mtd.c
@@ -335,6 +335,8 @@ static int do_mtd_io(struct cmd_tbl *cmdtp, int flag, int argc,
 	io_op.ooblen = woob ? mtd->oobsize : 0;
 	io_op.datbuf = buf;
 	io_op.oobbuf = woob ? &buf[len] : NULL;
+	/* Total length of this read operation passed by user */
+	io_op.totallen = len;

 	/* Search for the first good block after the given offset */
 	off = start_off;
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index ff635bd716..df8a231c82 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -79,6 +79,7 @@ struct mtd_erase_region_info {
  *		mode = MTD_OPS_PLACE_OOB or MTD_OPS_RAW)
  * @datbuf:	data buffer - if NULL only oob data are read/written
  * @oobbuf:	oob data buffer
+ * @totallen:   total number of data bytes to read in one read operation (for continuous read mode)
  */
 struct mtd_oob_ops {
 	unsigned int	mode;
@@ -89,6 +90,7 @@ struct mtd_oob_ops {
 	uint32_t	ooboffs;
 	uint8_t		*datbuf;
 	uint8_t		*oobbuf;
+	size_t		totallen;
 };

 #ifdef CONFIG_SYS_NAND_MAX_OOBFREE
--
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 4/5] mtd: spinand: Add continuous read operation
  2022-11-02  6:14 [PATCH v2 0/5] Add continuous read mode support Leo Yu
                   ` (2 preceding siblings ...)
  2022-11-02  6:14 ` [PATCH v2 3/5] cmd: mtd: Add total length of read operation Leo Yu
@ 2022-11-02  6:14 ` Leo Yu
  2022-11-02  6:14 ` [PATCH v2 5/5] mtd: spinand: macronix: Add continuous read mode flag for devices Leo Yu
  4 siblings, 0 replies; 8+ messages in thread
From: Leo Yu @ 2022-11-02  6:14 UTC (permalink / raw)
  To: dario.binacchi, michael, miquel.raynal, u-boot; +Cc: jaimeliao.tw, Leo Yu

The flow of continuous read operation is: firstly, starting
with the page read command and the 1st page data will be
read into the cache after the read latency tRD. Secondly,
issuing the Read From Cache commands (03h/0Bh/3Bh/6Bh/BBh/EBh)
to read out the data from cache continuously. After all the
data is read out, the host should pull CS# high to terminate
this continuous read operation and wait tRST for the NAND
device resets read operation.

The continuous read usage is enabled by reading multiple pages
(at least greater than 1 page size) and the column address is
"don't care" in this operation, since the data output for each
page will always start from byte 0 and a full page data should
be read out for each page.

On the other hand, since the continuous read mode can only read
the entire page of data and cannot read the oob data, the dynamic
mode switching is added to enable continuous read mode and disable
continuous read mode in spinand_continuous_read to avoid abnormal
writing and erasing operations.

The performance of continuous read mode is as follows. Set the
flash to QSPI mode and run 25MHz direct mapping mode on the SPI
bus and use the MTD test module to show the performance of
continuous reads.

Signed-off-by: Leo Yu <liangyanyu13@gmail.com>
---
 drivers/mtd/nand/spi/core.c | 120 +++++++++++++++++++++++++++++++++++-
 1 file changed, 119 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index 9d628f6f26..b28962f921 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -269,7 +269,10 @@ static int spinand_read_from_cache_op(struct spinand_device *spinand,
 	u16 column = 0;
 	int ret;

-	if (req->datalen) {
+	if (spinand->use_continuous_read) {
+		buf = req->databuf.in;
+		nbytes = req->datalen;
+	} else if (req->datalen) {
 		adjreq.datalen = nanddev_page_size(nand);
 		adjreq.dataoffs = 0;
 		adjreq.databuf.in = spinand->databuf;
@@ -312,6 +315,9 @@ static int spinand_read_from_cache_op(struct spinand_device *spinand,
 		op.addr.val += op.data.nbytes;
 	}

+	if (spinand->use_continuous_read)
+		return 0;
+
 	if (req->datalen)
 		memcpy(req->databuf.in, spinand->databuf + req->dataoffs,
 		       req->datalen);
@@ -577,6 +583,105 @@ static int spinand_write_page(struct spinand_device *spinand,
 	return ret;
 }

+static int spinand_continuous_read(struct mtd_info *mtd, loff_t from,
+				   struct mtd_oob_ops *req,
+				   struct nand_io_iter *iter)
+{
+	struct spinand_device *spinand = mtd_to_spinand(mtd);
+	struct nand_device *nand = mtd_to_nanddev(mtd);
+	int ret = 0;
+
+	bool enable_cont_read = true;
+	bool enable_ecc = false;
+
+	/*
+	 * Since the continuous read mode can only read the entire page of data
+	 * and cannot read the oob data, therefore, only ECC-Free SPI-NAND support
+	 * continuous read mode now.
+	 */
+	iter->req.mode = MTD_OPS_RAW;
+	iter->req.ooblen = 0;
+
+	req->retlen = 0;
+
+	/* Read the first unaligned page with conventional read */
+	if (from & (nanddev_page_size(nand) - 1)) {
+		pr_debug("address not aligned\n");
+
+		iter->req.databuf.in = req->datbuf;
+		iter->req.dataoffs = nanddev_offs_to_pos(nand, from, &iter->req.pos);
+		iter->req.datalen = nanddev_page_size(nand) - iter->req.dataoffs;
+
+		schedule();
+		ret = spinand_select_target(spinand, iter->req.pos.target);
+		if (ret)
+			return ret;
+
+		spinand_read_page(spinand, &iter->req, enable_ecc);
+		if (ret)
+			return ret;
+
+		req->retlen += iter->req.datalen;
+	}
+
+	iter->req.dataoffs = nanddev_offs_to_pos(nand, from + req->retlen, &iter->req.pos);
+	iter->req.databuf.in = req->datbuf + req->retlen;
+	iter->req.datalen = req->totallen - req->retlen;
+
+	schedule();
+	ret = spinand_continuous_read_enable(spinand, enable_cont_read);
+	if (ret)
+		return ret;
+
+	ret = spinand_select_target(spinand, iter->req.pos.target);
+	if (ret) {
+		req->retlen = 0;
+		goto continuous_read_error;
+	}
+
+	/*
+	 * The continuous read operation including: firstly, starting with the
+	 * page read command and the 1 st page data will be read into the cache
+	 * after the read latency tRD. Secondly, Issuing the Read From Cache
+	 * commands (03h/0Bh/3Bh/6Bh/BBh/EBh) to read out the data from cache
+	 * continuously.
+	 *
+	 * The cache is divided into two halves, while one half of the cache is
+	 * outputting the data, the other half will be loaded for the new data;
+	 * therefore, the host can read out the data continuously from page to
+	 * page. Multiple of Read From Cache commands can be issued in one
+	 * continuous read operation, each Read From Cache command is required
+	 * to read multiple 4-byte data exactly; otherwise, the data output will
+	 * be out of sequence from one Read From Cache command to another Read
+	 * From Cache command.
+	 *
+	 * After all the data is read out, the host should pull CS# high to
+	 * terminate this continuous read operation and wait a 6us of tRST for
+	 * the NAND device resets read operation. The data output for each page
+	 * will always start from byte 0 and a full page data should be read out
+	 * for each page.
+	 */
+	ret = spinand_read_page(spinand, &iter->req, enable_ecc);
+	if (ret) {
+		req->retlen = 0;
+		goto continuous_read_error;
+	}
+
+	ret = spinand_reset_op(spinand);
+	if (ret) {
+		req->retlen = 0;
+		goto continuous_read_error;
+	}
+
+	req->retlen += iter->req.datalen;
+
+continuous_read_error:
+	enable_cont_read = false;
+	ret = spinand_continuous_read_enable(spinand, enable_cont_read);
+
+	return ret;
+}
+
 static int spinand_mtd_read(struct mtd_info *mtd, loff_t from,
 			    struct mtd_oob_ops *ops)
 {
@@ -594,6 +699,18 @@ static int spinand_mtd_read(struct mtd_info *mtd, loff_t from,
 #ifndef __UBOOT__
 	mutex_lock(&spinand->lock);
 #endif
+	/*
+	 * If the device supports continuous read mode and the read length is greater
+	 * than one page size, the device will enter the continuous read mode. This mode
+	 * helps avoiding issuing a page read command and read from cache command
+	 * again, and improves the performance of reading continuous pages.
+	 */
+	if ((spinand->flags & SPINAND_HAS_CONT_READ_BIT) &&
+	    (ops->totallen > nanddev_page_size(nand))) {
+		ret = spinand_continuous_read(mtd, from, ops, &iter);
+
+		goto continuous_read_finish;
+	}

 	nanddev_io_for_each_page(nand, from, ops, &iter) {
 		schedule();
@@ -622,6 +739,7 @@ static int spinand_mtd_read(struct mtd_info *mtd, loff_t from,
 		ops->oobretlen += iter.req.ooblen;
 	}

+continuous_read_finish:
 #ifndef __UBOOT__
 	mutex_unlock(&spinand->lock);
 #endif
--
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 5/5] mtd: spinand: macronix: Add continuous read mode flag for devices
  2022-11-02  6:14 [PATCH v2 0/5] Add continuous read mode support Leo Yu
                   ` (3 preceding siblings ...)
  2022-11-02  6:14 ` [PATCH v2 4/5] mtd: spinand: Add continuous " Leo Yu
@ 2022-11-02  6:14 ` Leo Yu
  4 siblings, 0 replies; 8+ messages in thread
From: Leo Yu @ 2022-11-02  6:14 UTC (permalink / raw)
  To: dario.binacchi, michael, miquel.raynal, u-boot; +Cc: jaimeliao.tw, Leo Yu

Add continuous read mode flag to the devices support continuous read
mode in ID table.

Signed-off-by: Leo Yu <liangyanyu13@gmail.com>
---
 drivers/mtd/nand/spi/macronix.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/nand/spi/macronix.c b/drivers/mtd/nand/spi/macronix.c
index 6d643a8000..ae0374783f 100644
--- a/drivers/mtd/nand/spi/macronix.c
+++ b/drivers/mtd/nand/spi/macronix.c
@@ -128,7 +128,7 @@ static const struct spinand_info macronix_spinand_table[] = {
 		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
 					      &write_cache_variants,
 					      &update_cache_variants),
-		     SPINAND_HAS_QE_BIT,
+		     SPINAND_HAS_QE_BIT | SPINAND_HAS_CONT_READ_BIT,
 		     SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout,
 				     mx35lf1ge4ab_ecc_get_status)),
 	SPINAND_INFO("MX35UF2GE4AD", 0xa6,
@@ -137,7 +137,7 @@ static const struct spinand_info macronix_spinand_table[] = {
 		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
 					      &write_cache_variants,
 					      &update_cache_variants),
-		     SPINAND_HAS_QE_BIT,
+		     SPINAND_HAS_QE_BIT | SPINAND_HAS_CONT_READ_BIT,
 		     SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout,
 				     mx35lf1ge4ab_ecc_get_status)),
 	SPINAND_INFO("MX35UF2GE4AC", 0xa2,
@@ -146,7 +146,7 @@ static const struct spinand_info macronix_spinand_table[] = {
 		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
 					      &write_cache_variants,
 					      &update_cache_variants),
-		     SPINAND_HAS_QE_BIT,
+		     SPINAND_HAS_QE_BIT | SPINAND_HAS_CONT_READ_BIT,
 		     SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout,
 				     mx35lf1ge4ab_ecc_get_status)),
 	SPINAND_INFO("MX35UF1GE4AD", 0x96,
@@ -155,7 +155,7 @@ static const struct spinand_info macronix_spinand_table[] = {
 		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
 					      &write_cache_variants,
 					      &update_cache_variants),
-		     SPINAND_HAS_QE_BIT,
+		     SPINAND_HAS_QE_BIT | SPINAND_HAS_CONT_READ_BIT,
 		     SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout,
 				     mx35lf1ge4ab_ecc_get_status)),
 	SPINAND_INFO("MX35UF1GE4AC", 0x92,
@@ -164,7 +164,7 @@ static const struct spinand_info macronix_spinand_table[] = {
 		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
 					      &write_cache_variants,
 					      &update_cache_variants),
-		     SPINAND_HAS_QE_BIT,
+		     SPINAND_HAS_QE_BIT | SPINAND_HAS_CONT_READ_BIT,
 		     SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout,
 				     mx35lf1ge4ab_ecc_get_status)),

--
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 3/5] cmd: mtd: Add total length of read operation
  2022-11-02  6:14 ` [PATCH v2 3/5] cmd: mtd: Add total length of read operation Leo Yu
@ 2022-11-07 14:51   ` Miquel Raynal
  2022-11-08  9:49     ` Liang-Yan Yu
  0 siblings, 1 reply; 8+ messages in thread
From: Miquel Raynal @ 2022-11-07 14:51 UTC (permalink / raw)
  To: Leo Yu; +Cc: dario.binacchi, michael, u-boot, jaimeliao.tw

Hi Leo,

liangyanyu13@gmail.com wrote on Wed,  2 Nov 2022 14:14:30 +0800:

> This patch bypasses the limitation of length for read operations
> in MTD test module. Thus, the total length of a read operation
> can be passed down to the continuous read operation in SPI NAND
> layer.
> 
> Signed-off-by: Leo Yu <liangyanyu13@gmail.com>
> ---
>  cmd/mtd.c               | 2 ++
>  include/linux/mtd/mtd.h | 2 ++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/cmd/mtd.c b/cmd/mtd.c
> index ad5cc9827d..0b601e08a3 100644
> --- a/cmd/mtd.c
> +++ b/cmd/mtd.c
> @@ -335,6 +335,8 @@ static int do_mtd_io(struct cmd_tbl *cmdtp, int flag, int argc,
>  	io_op.ooblen = woob ? mtd->oobsize : 0;
>  	io_op.datbuf = buf;
>  	io_op.oobbuf = woob ? &buf[len] : NULL;
> +	/* Total length of this read operation passed by user */
> +	io_op.totallen = len;

Where is this used?

> 
>  	/* Search for the first good block after the given offset */
>  	off = start_off;
> diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
> index ff635bd716..df8a231c82 100644
> --- a/include/linux/mtd/mtd.h
> +++ b/include/linux/mtd/mtd.h
> @@ -79,6 +79,7 @@ struct mtd_erase_region_info {
>   *		mode = MTD_OPS_PLACE_OOB or MTD_OPS_RAW)
>   * @datbuf:	data buffer - if NULL only oob data are read/written
>   * @oobbuf:	oob data buffer
> + * @totallen:   total number of data bytes to read in one read operation (for continuous read mode)
>   */
>  struct mtd_oob_ops {
>  	unsigned int	mode;
> @@ -89,6 +90,7 @@ struct mtd_oob_ops {
>  	uint32_t	ooboffs;
>  	uint8_t		*datbuf;
>  	uint8_t		*oobbuf;
> +	size_t		totallen;
>  };
> 
>  #ifdef CONFIG_SYS_NAND_MAX_OOBFREE
> --
> 2.17.1
> 


Thanks,
Miquèl

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 3/5] cmd: mtd: Add total length of read operation
  2022-11-07 14:51   ` Miquel Raynal
@ 2022-11-08  9:49     ` Liang-Yan Yu
  0 siblings, 0 replies; 8+ messages in thread
From: Liang-Yan Yu @ 2022-11-08  9:49 UTC (permalink / raw)
  To: Miquel Raynal; +Cc: dario.binacchi, michael, u-boot, jaimeliao.tw

Hi Miquel,

>
> Hi Leo,
>
> liangyanyu13@gmail.com wrote on Wed,  2 Nov 2022 14:14:30 +0800:
>
> > This patch bypasses the limitation of length for read operations
> > in MTD test module. Thus, the total length of a read operation
> > can be passed down to the continuous read operation in SPI NAND
> > layer.
> >
> > Signed-off-by: Leo Yu <liangyanyu13@gmail.com>
> > ---
> >  cmd/mtd.c               | 2 ++
> >  include/linux/mtd/mtd.h | 2 ++
> >  2 files changed, 4 insertions(+)
> >
> > diff --git a/cmd/mtd.c b/cmd/mtd.c
> > index ad5cc9827d..0b601e08a3 100644
> > --- a/cmd/mtd.c
> > +++ b/cmd/mtd.c
> > @@ -335,6 +335,8 @@ static int do_mtd_io(struct cmd_tbl *cmdtp, int flag, int argc,
> >       io_op.ooblen = woob ? mtd->oobsize : 0;
> >       io_op.datbuf = buf;
> >       io_op.oobbuf = woob ? &buf[len] : NULL;
> > +     /* Total length of this read operation passed by user */
> > +     io_op.totallen = len;
>
> Where is this used?

It is used in spinand_mtd_read function (drivers/mtd/nand/spi/core.c)
as a condition to trigger
continuous read mode (please refer to patch[4/5]). This member stores
the total length of a
read operation. The reason why this member is added is because the mtd
command sets
the length of an operation to one page if has_pages flag is set. This
limits spinand_mtd_read
to receive length greater than one page. Which means there is no way
to trigger continuous
mode. Thus, I added this member to bypass the limitation.

> >
> >       /* Search for the first good block after the given offset */
> >       off = start_off;
> > diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
> > index ff635bd716..df8a231c82 100644
> > --- a/include/linux/mtd/mtd.h
> > +++ b/include/linux/mtd/mtd.h
> > @@ -79,6 +79,7 @@ struct mtd_erase_region_info {
> >   *           mode = MTD_OPS_PLACE_OOB or MTD_OPS_RAW)
> >   * @datbuf:  data buffer - if NULL only oob data are read/written
> >   * @oobbuf:  oob data buffer
> > + * @totallen:   total number of data bytes to read in one read operation (for continuous read mode)
> >   */
> >  struct mtd_oob_ops {
> >       unsigned int    mode;
> > @@ -89,6 +90,7 @@ struct mtd_oob_ops {
> >       uint32_t        ooboffs;
> >       uint8_t         *datbuf;
> >       uint8_t         *oobbuf;
> > +     size_t          totallen;
> >  };
> >
> >  #ifdef CONFIG_SYS_NAND_MAX_OOBFREE
> > --
> > 2.17.1
> >
>
>
> Thanks,
> Miquèl

Best,
Leo Yu

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-11-08 12:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-02  6:14 [PATCH v2 0/5] Add continuous read mode support Leo Yu
2022-11-02  6:14 ` [PATCH v2 1/5] mtd: spinand: Add continuous read mode configuration Leo Yu
2022-11-02  6:14 ` [PATCH v2 2/5] mtd: spinand: Add continuous read mode initialization Leo Yu
2022-11-02  6:14 ` [PATCH v2 3/5] cmd: mtd: Add total length of read operation Leo Yu
2022-11-07 14:51   ` Miquel Raynal
2022-11-08  9:49     ` Liang-Yan Yu
2022-11-02  6:14 ` [PATCH v2 4/5] mtd: spinand: Add continuous " Leo Yu
2022-11-02  6:14 ` [PATCH v2 5/5] mtd: spinand: macronix: Add continuous read mode flag for devices Leo Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox