All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 00/10] mtd: nand: rework nand_ecc_ctrl interface for OOB
@ 2012-04-28  1:29 Brian Norris
  2012-04-28  1:29 ` [PATCH v3 01/10] mtd: nand: add 'oob_required' argument to NAND {read, write}_page interfaces Brian Norris
                   ` (10 more replies)
  0 siblings, 11 replies; 30+ messages in thread
From: Brian Norris @ 2012-04-28  1:29 UTC (permalink / raw)
  To: linux-mtd
  Cc: Lei Wen, Li Yang, Mike Dunn, Prabhakar Kushwaha,
	Artem Bityutskiy, Dmitry Eremin-Solenikov,
	Jean-Christophe PLAGNIOL-VILLARD, Kevin Cernekee, Wolfram Sang,
	Matthieu CASTET, Huang Shijie, Shmulik Ladkani, Florian Fainelli,
	Scott Wood, Jamie Iles, Thomas Gleixner, Brian Norris,
	David Woodhouse, Axel Lin, Bastian Hecht

Hello again,

This is the third (final?) version of my patches to change the nand_chip and
nand_ecc_ctrl interfaces so that the nand_ecc_ctrl functions have information
about whether the higher layers actually need OOB data to be read/written
from/to the NAND device.

Changes for v3:

 This version implements the boolean parameter 'int oob_required', where a
 non-zero value indicates the driver must read/write OOB data to chip->oob_poi.
 A zero value indicates apathy from the upper layer.

 Patches 3-10 are new, where I try to utilize the 'oob_required' parameter for
 a number of different drivers. Not all were easy (or even possible), since
 software-based ECC obviously requires the OOB data in a buffer even when the
 upper layer doesn't need it. Similarly, some "hardware ECC" seems to work off
 of an in-memory buffer.

Please refer to previous communications for other info.

I could not compile all the affected drivers, since some required ARCH-specific
builds that I am not familiar with.

Developers: if you care about your driver, please compile test and review to be
sure I'm doing things safely for you.

Note to the maintainers: please do NOT accept any of the patches 3-10 without
an explicit ACK from someone who knows the driver. I think they're simple, but
I am not certain. And it is totally safe to ignore one or several of those
patches independently.

Thanks for reviewing!

Brian

Brian Norris (10):
  mtd: nand: add 'oob_required' argument to NAND {read,write}_page
    interfaces
  mtd: nand: pass proper 'oob_required' parameter
  mtd: Blackfin NFC: utilize oob_required parameter
  mtd: cafe_nand: utilize oob_required parameter
  mtd: denali: utilize oob_required parameter
  mtd: eLBD NAND: utilize oob_required parameter
  mtd: IFC NAND: utilize oob_required parameter
  mtd: gpmi-nand: utilize oob_requested parameter
  mtd: nand: utilize oob_required parameter
  mtd: pxa3xx_nand: utilize oob_required parameter

 drivers/mtd/nand/atmel_nand.c          |    5 +-
 drivers/mtd/nand/bcm_umi_bch.c         |   10 +++--
 drivers/mtd/nand/bcm_umi_nand.c        |    2 +-
 drivers/mtd/nand/bf5xx_nand.c          |   10 +++--
 drivers/mtd/nand/cafe_nand.c           |   16 +++++---
 drivers/mtd/nand/denali.c              |   12 +++--
 drivers/mtd/nand/docg4.c               |   12 +++---
 drivers/mtd/nand/fsl_elbc_nand.c       |   17 ++++----
 drivers/mtd/nand/fsl_ifc_nand.c        |   16 ++++----
 drivers/mtd/nand/fsmc_nand.c           |    3 +-
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c |   41 ++++++++++---------
 drivers/mtd/nand/nand_base.c           |   70 ++++++++++++++++++++------------
 drivers/mtd/nand/pxa3xx_nand.c         |   11 +++--
 drivers/mtd/nand/sh_flctl.c            |    4 +-
 include/linux/mtd/nand.h               |   11 +++--
 15 files changed, 138 insertions(+), 102 deletions(-)

-- 
1.7.5.4.2.g519b1

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

* [PATCH v3 01/10] mtd: nand: add 'oob_required' argument to NAND {read, write}_page interfaces
  2012-04-28  1:29 [PATCH v3 00/10] mtd: nand: rework nand_ecc_ctrl interface for OOB Brian Norris
@ 2012-04-28  1:29 ` Brian Norris
  2012-04-29 11:36   ` [PATCH v3 01/10] mtd: nand: add 'oob_required' argument to NAND {read,write}_page interfaces Shmulik Ladkani
  2012-04-28  1:29 ` [PATCH v3 02/10] mtd: nand: pass proper 'oob_required' parameter Brian Norris
                   ` (9 subsequent siblings)
  10 siblings, 1 reply; 30+ messages in thread
From: Brian Norris @ 2012-04-28  1:29 UTC (permalink / raw)
  To: linux-mtd
  Cc: Li Yang, Mike Dunn, Prabhakar Kushwaha, Artem Bityutskiy,
	Lei Wen, Jean-Christophe PLAGNIOL-VILLARD, Kevin Cernekee,
	Wolfram Sang, Matthieu CASTET, Huang Shijie, Shmulik Ladkani,
	Florian Fainelli, Scott Wood, Jamie Iles, Thomas Gleixner,
	Brian Norris, David Woodhouse, Axel Lin, Bastian Hecht

New NAND controllers can perform read/write via HW engines which don't expose
OOB data in their DMA mode. To reflect this, we should rework the nand_chip /
nand_ecc_ctrl interfaces that assume that drivers will always read/write OOB
data in the nand_chip.oob_poi buffer. A better interface includes a boolean
argument that explicitly tells the callee when OOB data is requested by the
calling layer (for reading/writing to/from nand_chip.oob_poi).

This patch adds the 'oob_required' parameter to each relevant {read,write}_page
interface; all 'oob_required' parameters are left unused for now. The next
patch will set the parameter properly in the nand_base.c callers, and follow-up
patches will make use of 'oob_required' in some of the callee functions.

Note that currently, there is no harm in ignoring the 'oob_required' parameter
and *always* utilizing nand_chip.oob_poi, but there can be
performance/complexity/design benefits from avoiding filling oob_poi in the
common case. I will try to implement this for some drivers which can be ported
easily.

Note: I couldn't compile-test all of these easily, as some had ARCH
dependencies.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
v3: 'bool use_oob' -> 'int oob_required'
    A few mistakes corrected (missed users, wrong 'oob_required' value)

 drivers/mtd/nand/atmel_nand.c          |    5 ++-
 drivers/mtd/nand/bcm_umi_bch.c         |   10 +++--
 drivers/mtd/nand/bcm_umi_nand.c        |    2 +-
 drivers/mtd/nand/bf5xx_nand.c          |    4 +-
 drivers/mtd/nand/cafe_nand.c           |   13 ++++---
 drivers/mtd/nand/denali.c              |    8 ++--
 drivers/mtd/nand/docg4.c               |   12 +++---
 drivers/mtd/nand/fsl_elbc_nand.c       |   11 ++----
 drivers/mtd/nand/fsl_ifc_nand.c        |   10 ++---
 drivers/mtd/nand/fsmc_nand.c           |    3 +-
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c |    8 ++--
 drivers/mtd/nand/nand_base.c           |   56 ++++++++++++++++++++------------
 drivers/mtd/nand/pxa3xx_nand.c         |    5 ++-
 drivers/mtd/nand/sh_flctl.c            |    4 +-
 include/linux/mtd/nand.h               |   11 +++---
 15 files changed, 90 insertions(+), 72 deletions(-)

diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 2165576..ab13400 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -324,9 +324,10 @@ static int atmel_nand_calculate(struct mtd_info *mtd,
  * mtd:        mtd info structure
  * chip:       nand chip info structure
  * buf:        buffer to store read data
+ * oob_required:    caller expects OOB data read to chip->oob_poi
  */
-static int atmel_nand_read_page(struct mtd_info *mtd,
-		struct nand_chip *chip, uint8_t *buf, int page)
+static int atmel_nand_read_page(struct mtd_info *mtd, struct nand_chip *chip,
+				uint8_t *buf, int oob_required, int page)
 {
 	int eccsize = chip->ecc.size;
 	int eccbytes = chip->ecc.bytes;
diff --git a/drivers/mtd/nand/bcm_umi_bch.c b/drivers/mtd/nand/bcm_umi_bch.c
index a930666..ee6669d 100644
--- a/drivers/mtd/nand/bcm_umi_bch.c
+++ b/drivers/mtd/nand/bcm_umi_bch.c
@@ -22,9 +22,9 @@
 
 /* ---- Private Function Prototypes -------------------------------------- */
 static int bcm_umi_bch_read_page_hwecc(struct mtd_info *mtd,
-	struct nand_chip *chip, uint8_t *buf, int page);
+	struct nand_chip *chip, uint8_t *buf, int oob_required, int page);
 static void bcm_umi_bch_write_page_hwecc(struct mtd_info *mtd,
-	struct nand_chip *chip, const uint8_t *buf);
+	struct nand_chip *chip, const uint8_t *buf, int oob_required);
 
 /* ---- Private Variables ------------------------------------------------ */
 
@@ -103,11 +103,12 @@ static struct nand_ecclayout nand_hw_eccoob_4096 = {
 *  @mtd:	mtd info structure
 *  @chip:	nand chip info structure
 *  @buf:	buffer to store read data
+*  @oob_required:	caller expects OOB data read to chip->oob_poi
 *
 ***************************************************************************/
 static int bcm_umi_bch_read_page_hwecc(struct mtd_info *mtd,
 				       struct nand_chip *chip, uint8_t * buf,
-						 int page)
+				       int oob_required, int page)
 {
 	int sectorIdx = 0;
 	int eccsize = chip->ecc.size;
@@ -188,10 +189,11 @@ static int bcm_umi_bch_read_page_hwecc(struct mtd_info *mtd,
 *  @mtd:	mtd info structure
 *  @chip:	nand chip info structure
 *  @buf:	data buffer
+*  @oob_required:	must write chip->oob_poi to OOB
 *
 ***************************************************************************/
 static void bcm_umi_bch_write_page_hwecc(struct mtd_info *mtd,
-	struct nand_chip *chip, const uint8_t *buf)
+	struct nand_chip *chip, const uint8_t *buf, int oob_required)
 {
 	int sectorIdx = 0;
 	int eccsize = chip->ecc.size;
diff --git a/drivers/mtd/nand/bcm_umi_nand.c b/drivers/mtd/nand/bcm_umi_nand.c
index 6908cdd..27d11e8 100644
--- a/drivers/mtd/nand/bcm_umi_nand.c
+++ b/drivers/mtd/nand/bcm_umi_nand.c
@@ -341,7 +341,7 @@ static int bcm_umi_nand_verify_buf(struct mtd_info *mtd, const u_char * buf,
 	 * for MLC parts which may have permanently stuck bits.
 	 */
 	struct nand_chip *chip = mtd->priv;
-	int ret = chip->ecc.read_page(mtd, chip, readbackbuf, 0);
+	int ret = chip->ecc.read_page(mtd, chip, readbackbuf, false, 0);
 	if (ret < 0)
 		return -EFAULT;
 	else {
diff --git a/drivers/mtd/nand/bf5xx_nand.c b/drivers/mtd/nand/bf5xx_nand.c
index d7b86b9..3f1c185 100644
--- a/drivers/mtd/nand/bf5xx_nand.c
+++ b/drivers/mtd/nand/bf5xx_nand.c
@@ -558,7 +558,7 @@ static void bf5xx_nand_dma_write_buf(struct mtd_info *mtd,
 }
 
 static int bf5xx_nand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
-		uint8_t *buf, int page)
+		uint8_t *buf, int oob_required, int page)
 {
 	bf5xx_nand_read_buf(mtd, buf, mtd->writesize);
 	bf5xx_nand_read_buf(mtd, chip->oob_poi, mtd->oobsize);
@@ -567,7 +567,7 @@ static int bf5xx_nand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip
 }
 
 static void bf5xx_nand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
-		const uint8_t *buf)
+		const uint8_t *buf, int oob_required)
 {
 	bf5xx_nand_write_buf(mtd, buf, mtd->writesize);
 	bf5xx_nand_write_buf(mtd, chip->oob_poi, mtd->oobsize);
diff --git a/drivers/mtd/nand/cafe_nand.c b/drivers/mtd/nand/cafe_nand.c
index 2973d97..738aafa 100644
--- a/drivers/mtd/nand/cafe_nand.c
+++ b/drivers/mtd/nand/cafe_nand.c
@@ -375,12 +375,13 @@ static int cafe_nand_read_oob(struct mtd_info *mtd, struct nand_chip *chip,
  * @mtd:	mtd info structure
  * @chip:	nand chip info structure
  * @buf:	buffer to store read data
+ * @oob_required:	caller expects OOB data read to chip->oob_poi
  *
  * The hw generator calculates the error syndrome automatically. Therefor
  * we need a special oob layout and handling.
  */
 static int cafe_nand_read_page(struct mtd_info *mtd, struct nand_chip *chip,
-			       uint8_t *buf, int page)
+			       uint8_t *buf, int oob_required, int page)
 {
 	struct cafe_priv *cafe = mtd->priv;
 
@@ -518,7 +519,8 @@ static struct nand_bbt_descr cafe_bbt_mirror_descr_512 = {
 
 
 static void cafe_nand_write_page_lowlevel(struct mtd_info *mtd,
-					  struct nand_chip *chip, const uint8_t *buf)
+					  struct nand_chip *chip,
+					  const uint8_t *buf, int oob_required)
 {
 	struct cafe_priv *cafe = mtd->priv;
 
@@ -530,16 +532,17 @@ static void cafe_nand_write_page_lowlevel(struct mtd_info *mtd,
 }
 
 static int cafe_nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
-				const uint8_t *buf, int page, int cached, int raw)
+				const uint8_t *buf, int oob_required, int page,
+				int cached, int raw)
 {
 	int status;
 
 	chip->cmdfunc(mtd, NAND_CMD_SEQIN, 0x00, page);
 
 	if (unlikely(raw))
-		chip->ecc.write_page_raw(mtd, chip, buf);
+		chip->ecc.write_page_raw(mtd, chip, buf, oob_required);
 	else
-		chip->ecc.write_page(mtd, chip, buf);
+		chip->ecc.write_page(mtd, chip, buf, oob_required);
 
 	/*
 	 * Cached progamming disabled for now, Not sure if its worth the
diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
index a1048c7..436ea83 100644
--- a/drivers/mtd/nand/denali.c
+++ b/drivers/mtd/nand/denali.c
@@ -1084,7 +1084,7 @@ static void write_page(struct mtd_info *mtd, struct nand_chip *chip,
  * by write_page above.
  * */
 static void denali_write_page(struct mtd_info *mtd, struct nand_chip *chip,
-				const uint8_t *buf)
+				const uint8_t *buf, int oob_required)
 {
 	/* for regular page writes, we let HW handle all the ECC
 	 * data written to the device. */
@@ -1096,7 +1096,7 @@ static void denali_write_page(struct mtd_info *mtd, struct nand_chip *chip,
  * write_page() function above.
  */
 static void denali_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
-					const uint8_t *buf)
+					const uint8_t *buf, int oob_required)
 {
 	/* for raw page writes, we want to disable ECC and simply write
 	   whatever data is in the buffer. */
@@ -1119,7 +1119,7 @@ static int denali_read_oob(struct mtd_info *mtd, struct nand_chip *chip,
 }
 
 static int denali_read_page(struct mtd_info *mtd, struct nand_chip *chip,
-			    uint8_t *buf, int page)
+			    uint8_t *buf, int oob_required, int page)
 {
 	struct denali_nand_info *denali = mtd_to_denali(mtd);
 
@@ -1171,7 +1171,7 @@ static int denali_read_page(struct mtd_info *mtd, struct nand_chip *chip,
 }
 
 static int denali_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
-				uint8_t *buf, int page)
+				uint8_t *buf, int oob_required, int page)
 {
 	struct denali_nand_info *denali = mtd_to_denali(mtd);
 
diff --git a/drivers/mtd/nand/docg4.c b/drivers/mtd/nand/docg4.c
index b082026..b90f315 100644
--- a/drivers/mtd/nand/docg4.c
+++ b/drivers/mtd/nand/docg4.c
@@ -786,13 +786,13 @@ static int read_page(struct mtd_info *mtd, struct nand_chip *nand,
 
 
 static int docg4_read_page_raw(struct mtd_info *mtd, struct nand_chip *nand,
-			       uint8_t *buf, int page)
+			       uint8_t *buf, int oob_required, int page)
 {
 	return read_page(mtd, nand, buf, page, false);
 }
 
 static int docg4_read_page(struct mtd_info *mtd, struct nand_chip *nand,
-			   uint8_t *buf, int page)
+			   uint8_t *buf, int oob_required, int page)
 {
 	return read_page(mtd, nand, buf, page, true);
 }
@@ -952,13 +952,13 @@ static void write_page(struct mtd_info *mtd, struct nand_chip *nand,
 }
 
 static void docg4_write_page_raw(struct mtd_info *mtd, struct nand_chip *nand,
-				 const uint8_t *buf)
+				 const uint8_t *buf, int oob_required)
 {
 	return write_page(mtd, nand, buf, false);
 }
 
 static void docg4_write_page(struct mtd_info *mtd, struct nand_chip *nand,
-			     const uint8_t *buf)
+			     const uint8_t *buf, int oob_required)
 {
 	return write_page(mtd, nand, buf, true);
 }
@@ -1002,7 +1002,7 @@ static int __init read_factory_bbt(struct mtd_info *mtd)
 		return -ENOMEM;
 
 	read_page_prologue(mtd, g4_addr);
-	status = docg4_read_page(mtd, nand, buf, DOCG4_FACTORY_BBT_PAGE);
+	status = docg4_read_page(mtd, nand, buf, false, DOCG4_FACTORY_BBT_PAGE);
 	if (status)
 		goto exit;
 
@@ -1079,7 +1079,7 @@ static int docg4_block_markbad(struct mtd_info *mtd, loff_t ofs)
 
 	/* write first page of block */
 	write_page_prologue(mtd, g4_addr);
-	docg4_write_page(mtd, nand, buf);
+	docg4_write_page(mtd, nand, buf, true);
 	ret = pageprog(mtd);
 	if (!ret)
 		mtd->ecc_stats.badblocks++;
diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c
index 80b5264..5cddd65 100644
--- a/drivers/mtd/nand/fsl_elbc_nand.c
+++ b/drivers/mtd/nand/fsl_elbc_nand.c
@@ -738,10 +738,8 @@ static int fsl_elbc_chip_init_tail(struct mtd_info *mtd)
 	return 0;
 }
 
-static int fsl_elbc_read_page(struct mtd_info *mtd,
-                              struct nand_chip *chip,
-			      uint8_t *buf,
-			      int page)
+static int fsl_elbc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
+			      uint8_t *buf, int oob_required, int page)
 {
 	fsl_elbc_read_buf(mtd, buf, mtd->writesize);
 	fsl_elbc_read_buf(mtd, chip->oob_poi, mtd->oobsize);
@@ -755,9 +753,8 @@ static int fsl_elbc_read_page(struct mtd_info *mtd,
 /* ECC will be calculated automatically, and errors will be detected in
  * waitfunc.
  */
-static void fsl_elbc_write_page(struct mtd_info *mtd,
-                                struct nand_chip *chip,
-                                const uint8_t *buf)
+static void fsl_elbc_write_page(struct mtd_info *mtd, struct nand_chip *chip,
+				const uint8_t *buf, int oob_required)
 {
 	fsl_elbc_write_buf(mtd, buf, mtd->writesize);
 	fsl_elbc_write_buf(mtd, chip->oob_poi, mtd->oobsize);
diff --git a/drivers/mtd/nand/fsl_ifc_nand.c b/drivers/mtd/nand/fsl_ifc_nand.c
index 5387cec..a8d1e87 100644
--- a/drivers/mtd/nand/fsl_ifc_nand.c
+++ b/drivers/mtd/nand/fsl_ifc_nand.c
@@ -692,9 +692,8 @@ static int fsl_ifc_wait(struct mtd_info *mtd, struct nand_chip *chip)
 	return nand_fsr | NAND_STATUS_WP;
 }
 
-static int fsl_ifc_read_page(struct mtd_info *mtd,
-			      struct nand_chip *chip,
-			      uint8_t *buf, int page)
+static int fsl_ifc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
+			     uint8_t *buf, int oob_required, int page)
 {
 	struct fsl_ifc_mtd *priv = chip->priv;
 	struct fsl_ifc_ctrl *ctrl = priv->ctrl;
@@ -714,9 +713,8 @@ static int fsl_ifc_read_page(struct mtd_info *mtd,
 /* ECC will be calculated automatically, and errors will be detected in
  * waitfunc.
  */
-static void fsl_ifc_write_page(struct mtd_info *mtd,
-				struct nand_chip *chip,
-				const uint8_t *buf)
+static void fsl_ifc_write_page(struct mtd_info *mtd, struct nand_chip *chip,
+			       const uint8_t *buf, int oob_required)
 {
 	fsl_ifc_write_buf(mtd, buf, mtd->writesize);
 	fsl_ifc_write_buf(mtd, chip->oob_poi, mtd->oobsize);
diff --git a/drivers/mtd/nand/fsmc_nand.c b/drivers/mtd/nand/fsmc_nand.c
index 9d7f417..2756259 100644
--- a/drivers/mtd/nand/fsmc_nand.c
+++ b/drivers/mtd/nand/fsmc_nand.c
@@ -692,6 +692,7 @@ static void fsmc_write_buf_dma(struct mtd_info *mtd, const uint8_t *buf,
  * @mtd:	mtd info structure
  * @chip:	nand chip info structure
  * @buf:	buffer to store read data
+ * @oob_required:	caller expects OOB data read to chip->oob_poi
  * @page:	page number to read
  *
  * This routine is needed for fsmc version 8 as reading from NAND chip has to be
@@ -701,7 +702,7 @@ static void fsmc_write_buf_dma(struct mtd_info *mtd, const uint8_t *buf,
  * max of 8 bits)
  */
 static int fsmc_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
-				 uint8_t *buf, int page)
+				 uint8_t *buf, int oob_required, int page)
 {
 	struct fsmc_nand_data *host = container_of(mtd,
 					struct fsmc_nand_data, mtd);
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index 75b1dde..ec16f2e 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -841,7 +841,7 @@ static void block_mark_swapping(struct gpmi_nand_data *this,
 }
 
 static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
-				uint8_t *buf, int page)
+				uint8_t *buf, int oob_required, int page)
 {
 	struct gpmi_nand_data *this = chip->priv;
 	struct bch_geometry *nfc_geo = &this->bch_geometry;
@@ -927,8 +927,8 @@ exit_nfc:
 	return ret;
 }
 
-static void gpmi_ecc_write_page(struct mtd_info *mtd,
-				struct nand_chip *chip, const uint8_t *buf)
+static void gpmi_ecc_write_page(struct mtd_info *mtd, struct nand_chip *chip,
+				const uint8_t *buf, int oob_required)
 {
 	struct gpmi_nand_data *this = chip->priv;
 	struct bch_geometry *nfc_geo = &this->bch_geometry;
@@ -1308,7 +1308,7 @@ static int mx23_write_transcription_stamp(struct gpmi_nand_data *this)
 		/* Write the first page of the current stride. */
 		dev_dbg(dev, "Writing an NCB fingerprint in page 0x%x\n", page);
 		chip->cmdfunc(mtd, NAND_CMD_SEQIN, 0x00, page);
-		chip->ecc.write_page_raw(mtd, chip, buffer);
+		chip->ecc.write_page_raw(mtd, chip, buffer, false);
 		chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1);
 
 		/* Wait for the write to finish. */
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index eb88d8b..96d950e 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1066,12 +1066,13 @@ EXPORT_SYMBOL(nand_lock);
  * @mtd: mtd info structure
  * @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
  *
  * Not for syndrome calculating ECC controllers, which use a special oob layout.
  */
 static int nand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
-			      uint8_t *buf, int page)
+			      uint8_t *buf, int oob_required, int page)
 {
 	chip->read_buf(mtd, buf, mtd->writesize);
 	chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
@@ -1083,13 +1084,14 @@ static int nand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
  * @mtd: mtd info structure
  * @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
  *
  * We need a special oob layout and handling even when OOB isn't used.
  */
 static int nand_read_page_raw_syndrome(struct mtd_info *mtd,
-					struct nand_chip *chip,
-					uint8_t *buf, int page)
+				       struct nand_chip *chip, uint8_t *buf,
+				       int oob_required, int page)
 {
 	int eccsize = chip->ecc.size;
 	int eccbytes = chip->ecc.bytes;
@@ -1126,10 +1128,11 @@ static int nand_read_page_raw_syndrome(struct mtd_info *mtd,
  * @mtd: mtd info structure
  * @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
  */
 static int nand_read_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,
-				uint8_t *buf, int page)
+				uint8_t *buf, int oob_required, int page)
 {
 	int i, eccsize = chip->ecc.size;
 	int eccbytes = chip->ecc.bytes;
@@ -1139,7 +1142,7 @@ static int nand_read_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,
 	uint8_t *ecc_code = chip->buffers->ecccode;
 	uint32_t *eccpos = chip->ecc.layout->eccpos;
 
-	chip->ecc.read_page_raw(mtd, chip, buf, page);
+	chip->ecc.read_page_raw(mtd, chip, buf, 1, page);
 
 	for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize)
 		chip->ecc.calculate(mtd, p, &ecc_calc[i]);
@@ -1257,12 +1260,13 @@ static int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip,
  * @mtd: mtd info structure
  * @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
  *
  * Not for syndrome calculating ECC controllers which need a special oob layout.
  */
 static int nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
-				uint8_t *buf, int page)
+				uint8_t *buf, int oob_required, int page)
 {
 	int i, eccsize = chip->ecc.size;
 	int eccbytes = chip->ecc.bytes;
@@ -1302,6 +1306,7 @@ static int nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
  * @mtd: mtd info structure
  * @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
  *
  * Hardware ECC for large page chips, require OOB to be read first. For this
@@ -1311,7 +1316,7 @@ static int nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
  * the data area, by overwriting the NAND manufacturer bad block markings.
  */
 static int nand_read_page_hwecc_oob_first(struct mtd_info *mtd,
-	struct nand_chip *chip, uint8_t *buf, int page)
+	struct nand_chip *chip, uint8_t *buf, int oob_required, int page)
 {
 	int i, eccsize = chip->ecc.size;
 	int eccbytes = chip->ecc.bytes;
@@ -1350,13 +1355,14 @@ static int nand_read_page_hwecc_oob_first(struct mtd_info *mtd,
  * @mtd: mtd info structure
  * @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
  *
  * The hw generator calculates the error syndrome automatically. Therefore we
  * need a special oob layout and handling.
  */
 static int nand_read_page_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
-				   uint8_t *buf, int page)
+				   uint8_t *buf, int oob_required, int page)
 {
 	int i, eccsize = chip->ecc.size;
 	int eccbytes = chip->ecc.bytes;
@@ -1500,14 +1506,14 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
 
 			/* Now read the page into the buffer */
 			if (unlikely(ops->mode == MTD_OPS_RAW))
-				ret = chip->ecc.read_page_raw(mtd, chip,
-							      bufpoi, page);
+				ret = chip->ecc.read_page_raw(mtd, chip, bufpoi,
+							      1, page);
 			else if (!aligned && NAND_SUBPAGE_READ(chip) && !oob)
 				ret = chip->ecc.read_subpage(mtd, chip,
 							col, bytes, bufpoi);
 			else
 				ret = chip->ecc.read_page(mtd, chip, bufpoi,
-							  page);
+							  1, page);
 			if (ret < 0) {
 				if (!aligned)
 					/* Invalidate page cache */
@@ -1919,11 +1925,12 @@ out:
  * @mtd: mtd info structure
  * @chip: nand chip info structure
  * @buf: data buffer
+ * @oob_required: must write chip->oob_poi to OOB
  *
  * Not for syndrome calculating ECC controllers, which use a special oob layout.
  */
 static void nand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
-				const uint8_t *buf)
+				const uint8_t *buf, int oob_required)
 {
 	chip->write_buf(mtd, buf, mtd->writesize);
 	chip->write_buf(mtd, chip->oob_poi, mtd->oobsize);
@@ -1934,12 +1941,13 @@ static void nand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
  * @mtd: mtd info structure
  * @chip: nand chip info structure
  * @buf: data buffer
+ * @oob_required: must write chip->oob_poi to OOB
  *
  * We need a special oob layout and handling even when ECC isn't checked.
  */
 static void nand_write_page_raw_syndrome(struct mtd_info *mtd,
 					struct nand_chip *chip,
-					const uint8_t *buf)
+					const uint8_t *buf, int oob_required)
 {
 	int eccsize = chip->ecc.size;
 	int eccbytes = chip->ecc.bytes;
@@ -1973,9 +1981,10 @@ static void nand_write_page_raw_syndrome(struct mtd_info *mtd,
  * @mtd: mtd info structure
  * @chip: nand chip info structure
  * @buf: data buffer
+ * @oob_required: must write chip->oob_poi to OOB
  */
 static void nand_write_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,
-				  const uint8_t *buf)
+				  const uint8_t *buf, int oob_required)
 {
 	int i, eccsize = chip->ecc.size;
 	int eccbytes = chip->ecc.bytes;
@@ -1991,7 +2000,7 @@ static void nand_write_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,
 	for (i = 0; i < chip->ecc.total; i++)
 		chip->oob_poi[eccpos[i]] = ecc_calc[i];
 
-	chip->ecc.write_page_raw(mtd, chip, buf);
+	chip->ecc.write_page_raw(mtd, chip, buf, 1);
 }
 
 /**
@@ -1999,9 +2008,10 @@ static void nand_write_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,
  * @mtd: mtd info structure
  * @chip: nand chip info structure
  * @buf: data buffer
+ * @oob_required: must write chip->oob_poi to OOB
  */
 static void nand_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
-				  const uint8_t *buf)
+				  const uint8_t *buf, int oob_required)
 {
 	int i, eccsize = chip->ecc.size;
 	int eccbytes = chip->ecc.bytes;
@@ -2027,12 +2037,14 @@ static void nand_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
  * @mtd: mtd info structure
  * @chip: nand chip info structure
  * @buf: data buffer
+ * @oob_required: must write chip->oob_poi to OOB
  *
  * The hw generator calculates the error syndrome automatically. Therefore we
  * need a special oob layout and handling.
  */
 static void nand_write_page_syndrome(struct mtd_info *mtd,
-				    struct nand_chip *chip, const uint8_t *buf)
+				    struct nand_chip *chip,
+				    const uint8_t *buf, int oob_required)
 {
 	int i, eccsize = chip->ecc.size;
 	int eccbytes = chip->ecc.bytes;
@@ -2071,21 +2083,23 @@ static void nand_write_page_syndrome(struct mtd_info *mtd,
  * @mtd: MTD device structure
  * @chip: NAND chip descriptor
  * @buf: the data to write
+ * @oob_required: must write chip->oob_poi to OOB
  * @page: page number to write
  * @cached: cached programming
  * @raw: use _raw version of write_page
  */
 static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
-			   const uint8_t *buf, int page, int cached, int raw)
+			   const uint8_t *buf, int oob_required, int page,
+			   int cached, int raw)
 {
 	int status;
 
 	chip->cmdfunc(mtd, NAND_CMD_SEQIN, 0x00, page);
 
 	if (unlikely(raw))
-		chip->ecc.write_page_raw(mtd, chip, buf);
+		chip->ecc.write_page_raw(mtd, chip, buf, oob_required);
 	else
-		chip->ecc.write_page(mtd, chip, buf);
+		chip->ecc.write_page(mtd, chip, buf, oob_required);
 
 	/*
 	 * Cached progamming disabled for now. Not sure if it's worth the
@@ -2264,7 +2278,7 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
 			memset(chip->oob_poi, 0xff, mtd->oobsize);
 		}
 
-		ret = chip->write_page(mtd, chip, wbuf, page, cached,
+		ret = chip->write_page(mtd, chip, wbuf, 1, page, cached,
 				       (ops->mode == MTD_OPS_RAW));
 		if (ret)
 			break;
diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
index def50ca..82ef968 100644
--- a/drivers/mtd/nand/pxa3xx_nand.c
+++ b/drivers/mtd/nand/pxa3xx_nand.c
@@ -682,14 +682,15 @@ static void pxa3xx_nand_cmdfunc(struct mtd_info *mtd, unsigned command,
 }
 
 static void pxa3xx_nand_write_page_hwecc(struct mtd_info *mtd,
-		struct nand_chip *chip, const uint8_t *buf)
+		struct nand_chip *chip, const uint8_t *buf, int oob_required)
 {
 	chip->write_buf(mtd, buf, mtd->writesize);
 	chip->write_buf(mtd, chip->oob_poi, mtd->oobsize);
 }
 
 static int pxa3xx_nand_read_page_hwecc(struct mtd_info *mtd,
-		struct nand_chip *chip, uint8_t *buf, int page)
+		struct nand_chip *chip, uint8_t *buf, int oob_required,
+		int page)
 {
 	struct pxa3xx_nand_host *host = mtd->priv;
 	struct pxa3xx_nand_info *info = host->info_data;
diff --git a/drivers/mtd/nand/sh_flctl.c b/drivers/mtd/nand/sh_flctl.c
index e9b2b26..115d2e7 100644
--- a/drivers/mtd/nand/sh_flctl.c
+++ b/drivers/mtd/nand/sh_flctl.c
@@ -344,7 +344,7 @@ static void set_cmd_regs(struct mtd_info *mtd, uint32_t cmd, uint32_t flcmcdr_va
 }
 
 static int flctl_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
-				uint8_t *buf, int page)
+				uint8_t *buf, int oob_required, int page)
 {
 	int i, eccsize = chip->ecc.size;
 	int eccbytes = chip->ecc.bytes;
@@ -366,7 +366,7 @@ static int flctl_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
 }
 
 static void flctl_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
-				   const uint8_t *buf)
+				   const uint8_t *buf, int oob_required)
 {
 	int i, eccsize = chip->ecc.size;
 	int eccbytes = chip->ecc.bytes;
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 1482340..9e9cdca 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -363,15 +363,15 @@ struct nand_ecc_ctrl {
 	int (*correct)(struct mtd_info *mtd, uint8_t *dat, uint8_t *read_ecc,
 			uint8_t *calc_ecc);
 	int (*read_page_raw)(struct mtd_info *mtd, struct nand_chip *chip,
-			uint8_t *buf, int page);
+			uint8_t *buf, int oob_required, int page);
 	void (*write_page_raw)(struct mtd_info *mtd, struct nand_chip *chip,
-			const uint8_t *buf);
+			const uint8_t *buf, int oob_required);
 	int (*read_page)(struct mtd_info *mtd, struct nand_chip *chip,
-			uint8_t *buf, int page);
+			uint8_t *buf, int oob_required, int page);
 	int (*read_subpage)(struct mtd_info *mtd, struct nand_chip *chip,
 			uint32_t offs, uint32_t len, uint8_t *buf);
 	void (*write_page)(struct mtd_info *mtd, struct nand_chip *chip,
-			const uint8_t *buf);
+			const uint8_t *buf, int oob_required);
 	int (*write_oob_raw)(struct mtd_info *mtd, struct nand_chip *chip,
 			int page);
 	int (*read_oob_raw)(struct mtd_info *mtd, struct nand_chip *chip,
@@ -505,7 +505,8 @@ struct nand_chip {
 	int (*errstat)(struct mtd_info *mtd, struct nand_chip *this, int state,
 			int status, int page);
 	int (*write_page)(struct mtd_info *mtd, struct nand_chip *chip,
-			const uint8_t *buf, int page, int cached, int raw);
+			const uint8_t *buf, int oob_required, int page,
+			int cached, int raw);
 
 	int chip_delay;
 	unsigned int options;
-- 
1.7.5.4.2.g519b1

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

* [PATCH v3 02/10] mtd: nand: pass proper 'oob_required' parameter
  2012-04-28  1:29 [PATCH v3 00/10] mtd: nand: rework nand_ecc_ctrl interface for OOB Brian Norris
  2012-04-28  1:29 ` [PATCH v3 01/10] mtd: nand: add 'oob_required' argument to NAND {read, write}_page interfaces Brian Norris
@ 2012-04-28  1:29 ` Brian Norris
  2012-04-29 11:41   ` Shmulik Ladkani
  2012-04-28  1:29 ` [PATCH v3 03/10] mtd: Blackfin NFC: utilize oob_required parameter Brian Norris
                   ` (8 subsequent siblings)
  10 siblings, 1 reply; 30+ messages in thread
From: Brian Norris @ 2012-04-28  1:29 UTC (permalink / raw)
  To: linux-mtd
  Cc: Li Yang, Mike Dunn, Prabhakar Kushwaha, Artem Bityutskiy,
	Lei Wen, Jean-Christophe PLAGNIOL-VILLARD, Kevin Cernekee,
	Wolfram Sang, Matthieu CASTET, Huang Shijie, Shmulik Ladkani,
	Florian Fainelli, Scott Wood, Jamie Iles, Thomas Gleixner,
	Brian Norris, David Woodhouse, Axel Lin, Bastian Hecht

We now have an interface for notifying the nand_ecc_ctrl functions when OOB
data must be returned to the upper layers and when it may be left untouched.
This patch fills in the 'oob_required' parameter properly from
nand_do_{read,write}_ops. When utilized properly in the lower layers, this
parameter can improve performance for NAND HW and SW that can simply avoid
transferring the OOB data.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 drivers/mtd/nand/nand_base.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 96d950e..13a6355 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1469,7 +1469,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
 	struct nand_chip *chip = mtd->priv;
 	struct mtd_ecc_stats stats;
 	int blkcheck = (1 << (chip->phys_erase_shift - chip->page_shift)) - 1;
-	int sndcmd = 1;
+	int sndcmd = 1, oob_required;
 	int ret = 0;
 	uint32_t readlen = ops->len;
 	uint32_t oobreadlen = ops->ooblen;
@@ -1490,6 +1490,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
 
 	buf = ops->datbuf;
 	oob = ops->oobbuf;
+	oob_required = oob ? 1 : 0;
 
 	while (1) {
 		bytes = min(mtd->writesize - col, readlen);
@@ -1507,13 +1508,14 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
 			/* Now read the page into the buffer */
 			if (unlikely(ops->mode == MTD_OPS_RAW))
 				ret = chip->ecc.read_page_raw(mtd, chip, bufpoi,
-							      1, page);
+							      oob_required,
+							      page);
 			else if (!aligned && NAND_SUBPAGE_READ(chip) && !oob)
 				ret = chip->ecc.read_subpage(mtd, chip,
 							col, bytes, bufpoi);
 			else
 				ret = chip->ecc.read_page(mtd, chip, bufpoi,
-							  1, page);
+							  oob_required, page);
 			if (ret < 0) {
 				if (!aligned)
 					/* Invalidate page cache */
@@ -1536,7 +1538,6 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
 			buf += bytes;
 
 			if (unlikely(oob)) {
-
 				int toread = min(oobreadlen, max_oobsize);
 
 				if (toread) {
@@ -2216,6 +2217,7 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
 	uint8_t *oob = ops->oobbuf;
 	uint8_t *buf = ops->datbuf;
 	int ret, subpage;
+	int oob_required = oob ? 1 : 0;
 
 	ops->retlen = 0;
 	if (!writelen)
@@ -2278,8 +2280,8 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
 			memset(chip->oob_poi, 0xff, mtd->oobsize);
 		}
 
-		ret = chip->write_page(mtd, chip, wbuf, 1, page, cached,
-				       (ops->mode == MTD_OPS_RAW));
+		ret = chip->write_page(mtd, chip, wbuf, oob_required, page,
+				       cached, (ops->mode == MTD_OPS_RAW));
 		if (ret)
 			break;
 
-- 
1.7.5.4.2.g519b1

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

* [PATCH v3 03/10] mtd: Blackfin NFC: utilize oob_required parameter
  2012-04-28  1:29 [PATCH v3 00/10] mtd: nand: rework nand_ecc_ctrl interface for OOB Brian Norris
  2012-04-28  1:29 ` [PATCH v3 01/10] mtd: nand: add 'oob_required' argument to NAND {read, write}_page interfaces Brian Norris
  2012-04-28  1:29 ` [PATCH v3 02/10] mtd: nand: pass proper 'oob_required' parameter Brian Norris
@ 2012-04-28  1:29 ` Brian Norris
  2012-04-28  1:29 ` [PATCH v3 04/10] mtd: cafe_nand: " Brian Norris
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 30+ messages in thread
From: Brian Norris @ 2012-04-28  1:29 UTC (permalink / raw)
  To: linux-mtd
  Cc: Mike Dunn, Brian Norris, David Woodhouse, Jamie Iles, Artem Bityutskiy

Don't read/write OOB if the caller doesn't require it.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 drivers/mtd/nand/bf5xx_nand.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/bf5xx_nand.c b/drivers/mtd/nand/bf5xx_nand.c
index 3f1c185..8188416 100644
--- a/drivers/mtd/nand/bf5xx_nand.c
+++ b/drivers/mtd/nand/bf5xx_nand.c
@@ -561,7 +561,8 @@ static int bf5xx_nand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip
 		uint8_t *buf, int oob_required, int page)
 {
 	bf5xx_nand_read_buf(mtd, buf, mtd->writesize);
-	bf5xx_nand_read_buf(mtd, chip->oob_poi, mtd->oobsize);
+	if (oob_required)
+		bf5xx_nand_read_buf(mtd, chip->oob_poi, mtd->oobsize);
 
 	return 0;
 }
@@ -570,7 +571,8 @@ static void bf5xx_nand_write_page_raw(struct mtd_info *mtd, struct nand_chip *ch
 		const uint8_t *buf, int oob_required)
 {
 	bf5xx_nand_write_buf(mtd, buf, mtd->writesize);
-	bf5xx_nand_write_buf(mtd, chip->oob_poi, mtd->oobsize);
+	if (oob_required)
+		bf5xx_nand_write_buf(mtd, chip->oob_poi, mtd->oobsize);
 }
 
 /*
-- 
1.7.5.4.2.g519b1

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

* [PATCH v3 04/10] mtd: cafe_nand: utilize oob_required parameter
  2012-04-28  1:29 [PATCH v3 00/10] mtd: nand: rework nand_ecc_ctrl interface for OOB Brian Norris
                   ` (2 preceding siblings ...)
  2012-04-28  1:29 ` [PATCH v3 03/10] mtd: Blackfin NFC: utilize oob_required parameter Brian Norris
@ 2012-04-28  1:29 ` Brian Norris
  2012-04-28  1:29 ` [PATCH v3 05/10] mtd: denali: " Brian Norris
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 30+ messages in thread
From: Brian Norris @ 2012-04-28  1:29 UTC (permalink / raw)
  To: linux-mtd; +Cc: Brian Norris, David Woodhouse, Artem Bityutskiy

Don't write OOB if the caller doesn't require it.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 drivers/mtd/nand/cafe_nand.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/nand/cafe_nand.c b/drivers/mtd/nand/cafe_nand.c
index 738aafa..4c9714b 100644
--- a/drivers/mtd/nand/cafe_nand.c
+++ b/drivers/mtd/nand/cafe_nand.c
@@ -525,7 +525,8 @@ static void cafe_nand_write_page_lowlevel(struct mtd_info *mtd,
 	struct cafe_priv *cafe = mtd->priv;
 
 	chip->write_buf(mtd, buf, mtd->writesize);
-	chip->write_buf(mtd, chip->oob_poi, mtd->oobsize);
+	if (oob_required)
+		chip->write_buf(mtd, chip->oob_poi, mtd->oobsize);
 
 	/* Set up ECC autogeneration */
 	cafe->ctl2 |= (1<<30);
-- 
1.7.5.4.2.g519b1

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

* [PATCH v3 05/10] mtd: denali: utilize oob_required parameter
  2012-04-28  1:29 [PATCH v3 00/10] mtd: nand: rework nand_ecc_ctrl interface for OOB Brian Norris
                   ` (3 preceding siblings ...)
  2012-04-28  1:29 ` [PATCH v3 04/10] mtd: cafe_nand: " Brian Norris
@ 2012-04-28  1:29 ` Brian Norris
  2012-04-28  1:29 ` [PATCH v3 06/10] mtd: eLBD NAND: " Brian Norris
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 30+ messages in thread
From: Brian Norris @ 2012-04-28  1:29 UTC (permalink / raw)
  To: linux-mtd
  Cc: Jamie Iles, Axel Lin, Brian Norris, David Woodhouse, Artem Bityutskiy

Don't return OOB if the caller doesn't require it.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 drivers/mtd/nand/denali.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
index 436ea83..c56757f 100644
--- a/drivers/mtd/nand/denali.c
+++ b/drivers/mtd/nand/denali.c
@@ -1204,7 +1204,9 @@ static int denali_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
 	denali_enable_dma(denali, false);
 
 	memcpy(buf, denali->buf.buf, mtd->writesize);
-	memcpy(chip->oob_poi, denali->buf.buf + mtd->writesize, mtd->oobsize);
+	if (oob_required)
+		memcpy(chip->oob_poi, denali->buf.buf + mtd->writesize,
+				mtd->oobsize);
 
 	return 0;
 }
-- 
1.7.5.4.2.g519b1

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

* [PATCH v3 06/10] mtd: eLBD NAND: utilize oob_required parameter
  2012-04-28  1:29 [PATCH v3 00/10] mtd: nand: rework nand_ecc_ctrl interface for OOB Brian Norris
                   ` (4 preceding siblings ...)
  2012-04-28  1:29 ` [PATCH v3 05/10] mtd: denali: " Brian Norris
@ 2012-04-28  1:29 ` Brian Norris
  2012-04-28  1:29 ` [PATCH v3 07/10] mtd: IFC " Brian Norris
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 30+ messages in thread
From: Brian Norris @ 2012-04-28  1:29 UTC (permalink / raw)
  To: linux-mtd; +Cc: Brian Norris, David Woodhouse, Li Yang, Artem Bityutskiy

Don't read/write OOB if the caller doesn't require it.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 drivers/mtd/nand/fsl_elbc_nand.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c
index 5cddd65..ab22985 100644
--- a/drivers/mtd/nand/fsl_elbc_nand.c
+++ b/drivers/mtd/nand/fsl_elbc_nand.c
@@ -742,7 +742,8 @@ static int fsl_elbc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
 			      uint8_t *buf, int oob_required, int page)
 {
 	fsl_elbc_read_buf(mtd, buf, mtd->writesize);
-	fsl_elbc_read_buf(mtd, chip->oob_poi, mtd->oobsize);
+	if (oob_required)
+		fsl_elbc_read_buf(mtd, chip->oob_poi, mtd->oobsize);
 
 	if (fsl_elbc_wait(mtd, chip) & NAND_STATUS_FAIL)
 		mtd->ecc_stats.failed++;
@@ -757,7 +758,8 @@ static void fsl_elbc_write_page(struct mtd_info *mtd, struct nand_chip *chip,
 				const uint8_t *buf, int oob_required)
 {
 	fsl_elbc_write_buf(mtd, buf, mtd->writesize);
-	fsl_elbc_write_buf(mtd, chip->oob_poi, mtd->oobsize);
+	if (oob_required)
+		fsl_elbc_write_buf(mtd, chip->oob_poi, mtd->oobsize);
 }
 
 static int fsl_elbc_chip_init(struct fsl_elbc_mtd *priv)
-- 
1.7.5.4.2.g519b1

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

* [PATCH v3 07/10] mtd: IFC NAND: utilize oob_required parameter
  2012-04-28  1:29 [PATCH v3 00/10] mtd: nand: rework nand_ecc_ctrl interface for OOB Brian Norris
                   ` (5 preceding siblings ...)
  2012-04-28  1:29 ` [PATCH v3 06/10] mtd: eLBD NAND: " Brian Norris
@ 2012-04-28  1:29 ` Brian Norris
  2012-04-30 16:43   ` Scott Wood
  2012-04-28  1:29 ` [PATCH v3 08/10] mtd: gpmi-nand: utilize oob_requested parameter Brian Norris
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 30+ messages in thread
From: Brian Norris @ 2012-04-28  1:29 UTC (permalink / raw)
  To: linux-mtd
  Cc: Li Yang, Artem Bityutskiy, Scott Wood, Brian Norris,
	David Woodhouse, Prabhakar Kushwaha

Don't read/write OOB if the caller doesn't requre it.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 drivers/mtd/nand/fsl_ifc_nand.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/fsl_ifc_nand.c b/drivers/mtd/nand/fsl_ifc_nand.c
index a8d1e87..2bbb9d5 100644
--- a/drivers/mtd/nand/fsl_ifc_nand.c
+++ b/drivers/mtd/nand/fsl_ifc_nand.c
@@ -699,7 +699,8 @@ static int fsl_ifc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
 	struct fsl_ifc_ctrl *ctrl = priv->ctrl;
 
 	fsl_ifc_read_buf(mtd, buf, mtd->writesize);
-	fsl_ifc_read_buf(mtd, chip->oob_poi, mtd->oobsize);
+	if (oob_required)
+		fsl_ifc_read_buf(mtd, chip->oob_poi, mtd->oobsize);
 
 	if (ctrl->nand_stat & IFC_NAND_EVTER_STAT_ECCER)
 		dev_err(priv->dev, "NAND Flash ECC Uncorrectable Error\n");
@@ -717,7 +718,8 @@ static void fsl_ifc_write_page(struct mtd_info *mtd, struct nand_chip *chip,
 			       const uint8_t *buf, int oob_required)
 {
 	fsl_ifc_write_buf(mtd, buf, mtd->writesize);
-	fsl_ifc_write_buf(mtd, chip->oob_poi, mtd->oobsize);
+	if (oob_required)
+		fsl_ifc_write_buf(mtd, chip->oob_poi, mtd->oobsize);
 }
 
 static int fsl_ifc_chip_init_tail(struct mtd_info *mtd)
-- 
1.7.5.4.2.g519b1

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

* [PATCH v3 08/10] mtd: gpmi-nand: utilize oob_requested parameter
  2012-04-28  1:29 [PATCH v3 00/10] mtd: nand: rework nand_ecc_ctrl interface for OOB Brian Norris
                   ` (6 preceding siblings ...)
  2012-04-28  1:29 ` [PATCH v3 07/10] mtd: IFC " Brian Norris
@ 2012-04-28  1:29 ` Brian Norris
  2012-04-28  2:32   ` Huang Shijie
  2012-04-28  1:29 ` [PATCH v3 09/10] mtd: nand: utilize oob_required parameter Brian Norris
                   ` (2 subsequent siblings)
  10 siblings, 1 reply; 30+ messages in thread
From: Brian Norris @ 2012-04-28  1:29 UTC (permalink / raw)
  To: linux-mtd
  Cc: Huang Shijie, Brian Norris, David Woodhouse, Wolfram Sang,
	Artem Bityutskiy

Don't read OOB if the caller didn't request it.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c |   35 +++++++++++++++++--------------
 1 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index ec16f2e..805bcf3 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -907,22 +907,25 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
 		mtd->ecc_stats.corrected += corrected;
 	}
 
-	/*
-	 * It's time to deliver the OOB bytes. See gpmi_ecc_read_oob() for
-	 * details about our policy for delivering the OOB.
-	 *
-	 * We fill the caller's buffer with set bits, and then copy the block
-	 * mark to th caller's buffer. Note that, if block mark swapping was
-	 * necessary, it has already been done, so we can rely on the first
-	 * byte of the auxiliary buffer to contain the block mark.
-	 */
-	memset(chip->oob_poi, ~0, mtd->oobsize);
-	chip->oob_poi[0] = ((uint8_t *) auxiliary_virt)[0];
+	if (oob_required) {
+		/*
+		 * It's time to deliver the OOB bytes. See gpmi_ecc_read_oob()
+		 * for details about our policy for delivering the OOB.
+		 *
+		 * We fill the caller's buffer with set bits, and then copy the
+		 * block mark to th caller's buffer. Note that, if block mark
+		 * swapping was necessary, it has already been done, so we can
+		 * rely on the first byte of the auxiliary buffer to contain
+		 * the block mark.
+		 */
+		memset(chip->oob_poi, ~0, mtd->oobsize);
+		chip->oob_poi[0] = ((uint8_t *) auxiliary_virt)[0];
 
-	read_page_swap_end(this, buf, mtd->writesize,
-			this->payload_virt, this->payload_phys,
-			nfc_geo->payload_size,
-			payload_virt, payload_phys);
+		read_page_swap_end(this, buf, mtd->writesize,
+				this->payload_virt, this->payload_phys,
+				nfc_geo->payload_size,
+				payload_virt, payload_phys);
+	}
 exit_nfc:
 	return ret;
 }
-- 
1.7.5.4.2.g519b1

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

* [PATCH v3 09/10] mtd: nand: utilize oob_required parameter
  2012-04-28  1:29 [PATCH v3 00/10] mtd: nand: rework nand_ecc_ctrl interface for OOB Brian Norris
                   ` (7 preceding siblings ...)
  2012-04-28  1:29 ` [PATCH v3 08/10] mtd: gpmi-nand: utilize oob_requested parameter Brian Norris
@ 2012-04-28  1:29 ` Brian Norris
  2012-04-29 12:47   ` Shmulik Ladkani
  2012-04-28  1:29 ` [PATCH v3 10/10] mtd: pxa3xx_nand: " Brian Norris
  2012-04-30  7:10 ` [PATCH v3 00/10] mtd: nand: rework nand_ecc_ctrl interface for OOB Artem Bityutskiy
  10 siblings, 1 reply; 30+ messages in thread
From: Brian Norris @ 2012-04-28  1:29 UTC (permalink / raw)
  To: linux-mtd; +Cc: Brian Norris, David Woodhouse, Artem Bityutskiy

Don't read/write OOB if the caller doesn't requre it.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 drivers/mtd/nand/nand_base.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 13a6355..5b390ae 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1075,7 +1075,8 @@ static int nand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
 			      uint8_t *buf, int oob_required, int page)
 {
 	chip->read_buf(mtd, buf, mtd->writesize);
-	chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
+	if (oob_required)
+		chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
 	return 0;
 }
 
@@ -1934,7 +1935,8 @@ static void nand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
 				const uint8_t *buf, int oob_required)
 {
 	chip->write_buf(mtd, buf, mtd->writesize);
-	chip->write_buf(mtd, chip->oob_poi, mtd->oobsize);
+	if (oob_required)
+		chip->write_buf(mtd, chip->oob_poi, mtd->oobsize);
 }
 
 /**
-- 
1.7.5.4.2.g519b1

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

* [PATCH v3 10/10] mtd: pxa3xx_nand: utilize oob_required parameter
  2012-04-28  1:29 [PATCH v3 00/10] mtd: nand: rework nand_ecc_ctrl interface for OOB Brian Norris
                   ` (8 preceding siblings ...)
  2012-04-28  1:29 ` [PATCH v3 09/10] mtd: nand: utilize oob_required parameter Brian Norris
@ 2012-04-28  1:29 ` Brian Norris
  2012-04-30  7:10 ` [PATCH v3 00/10] mtd: nand: rework nand_ecc_ctrl interface for OOB Artem Bityutskiy
  10 siblings, 0 replies; 30+ messages in thread
From: Brian Norris @ 2012-04-28  1:29 UTC (permalink / raw)
  To: linux-mtd
  Cc: Artem Bityutskiy, Lei Wen, Dmitry Eremin-Solenikov, Axel Lin,
	Brian Norris, David Woodhouse

Don't read/write OOB if the caller doesn't require it.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 drivers/mtd/nand/pxa3xx_nand.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
index 82ef968..372bc47 100644
--- a/drivers/mtd/nand/pxa3xx_nand.c
+++ b/drivers/mtd/nand/pxa3xx_nand.c
@@ -685,7 +685,8 @@ static void pxa3xx_nand_write_page_hwecc(struct mtd_info *mtd,
 		struct nand_chip *chip, const uint8_t *buf, int oob_required)
 {
 	chip->write_buf(mtd, buf, mtd->writesize);
-	chip->write_buf(mtd, chip->oob_poi, mtd->oobsize);
+	if (oob_required)
+		chip->write_buf(mtd, chip->oob_poi, mtd->oobsize);
 }
 
 static int pxa3xx_nand_read_page_hwecc(struct mtd_info *mtd,
@@ -696,7 +697,8 @@ static int pxa3xx_nand_read_page_hwecc(struct mtd_info *mtd,
 	struct pxa3xx_nand_info *info = host->info_data;
 
 	chip->read_buf(mtd, buf, mtd->writesize);
-	chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
+	if (oob_required)
+		chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
 
 	if (info->retcode == ERR_SBERR) {
 		switch (info->use_ecc) {
-- 
1.7.5.4.2.g519b1

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

* Re: [PATCH v3 08/10] mtd: gpmi-nand: utilize oob_requested parameter
  2012-04-28  1:29 ` [PATCH v3 08/10] mtd: gpmi-nand: utilize oob_requested parameter Brian Norris
@ 2012-04-28  2:32   ` Huang Shijie
  0 siblings, 0 replies; 30+ messages in thread
From: Huang Shijie @ 2012-04-28  2:32 UTC (permalink / raw)
  To: Brian Norris; +Cc: David Woodhouse, linux-mtd, Wolfram Sang, Artem Bityutskiy

于 2012年04月28日 09:29, Brian Norris 写道:
> Don't read OOB if the caller didn't request it.
>
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> ---
>  drivers/mtd/nand/gpmi-nand/gpmi-nand.c |   35 +++++++++++++++++--------------
>  1 files changed, 19 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> index ec16f2e..805bcf3 100644
> --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> @@ -907,22 +907,25 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
>  		mtd->ecc_stats.corrected += corrected;
>  	}
>  
> -	/*
> -	 * It's time to deliver the OOB bytes. See gpmi_ecc_read_oob() for
> -	 * details about our policy for delivering the OOB.
> -	 *
> -	 * We fill the caller's buffer with set bits, and then copy the block
> -	 * mark to th caller's buffer. Note that, if block mark swapping was
> -	 * necessary, it has already been done, so we can rely on the first
> -	 * byte of the auxiliary buffer to contain the block mark.
> -	 */
> -	memset(chip->oob_poi, ~0, mtd->oobsize);
> -	chip->oob_poi[0] = ((uint8_t *) auxiliary_virt)[0];
> +	if (oob_required) {
> +		/*
> +		 * It's time to deliver the OOB bytes. See gpmi_ecc_read_oob()
> +		 * for details about our policy for delivering the OOB.
> +		 *
> +		 * We fill the caller's buffer with set bits, and then copy the
> +		 * block mark to th caller's buffer. Note that, if block mark
> +		 * swapping was necessary, it has already been done, so we can
> +		 * rely on the first byte of the auxiliary buffer to contain
> +		 * the block mark.
> +		 */
> +		memset(chip->oob_poi, ~0, mtd->oobsize);
> +		chip->oob_poi[0] = ((uint8_t *) auxiliary_virt)[0];
>  
> -	read_page_swap_end(this, buf, mtd->writesize,
> -			this->payload_virt, this->payload_phys,
> -			nfc_geo->payload_size,
> -			payload_virt, payload_phys);
> +		read_page_swap_end(this, buf, mtd->writesize,
> +				this->payload_virt, this->payload_phys,
> +				nfc_geo->payload_size,
> +				payload_virt, payload_phys);
> +	}
>  exit_nfc:
>  	return ret;
>  }
it's ok to me.

Acked-by: Huang Shijie <b32955@freescale.com>

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

* Re: [PATCH v3 01/10] mtd: nand: add 'oob_required' argument to NAND {read,write}_page interfaces
  2012-04-28  1:29 ` [PATCH v3 01/10] mtd: nand: add 'oob_required' argument to NAND {read, write}_page interfaces Brian Norris
@ 2012-04-29 11:36   ` Shmulik Ladkani
  2012-04-29 13:25     ` Artem Bityutskiy
  0 siblings, 1 reply; 30+ messages in thread
From: Shmulik Ladkani @ 2012-04-29 11:36 UTC (permalink / raw)
  To: Brian Norris
  Cc: Mike Dunn, Artem Bityutskiy, Lei Wen,
	Jean-Christophe PLAGNIOL-VILLARD, Kevin Cernekee, Wolfram Sang,
	Matthieu CASTET, Huang Shijie, linux-mtd, Prabhakar Kushwaha,
	Florian Fainelli, Scott Wood, Jamie Iles, Thomas Gleixner,
	Li Yang, David Woodhouse, Axel Lin, Bastian Hecht

On Fri, 27 Apr 2012 18:29:45 -0700 Brian Norris <computersforpeace@gmail.com> wrote:
> New NAND controllers can perform read/write via HW engines which don't expose
> OOB data in their DMA mode. To reflect this, we should rework the nand_chip /
> nand_ecc_ctrl interfaces that assume that drivers will always read/write OOB
> data in the nand_chip.oob_poi buffer. A better interface includes a boolean
> argument that explicitly tells the callee when OOB data is requested by the
> calling layer (for reading/writing to/from nand_chip.oob_poi).
> 
> This patch adds the 'oob_required' parameter to each relevant {read,write}_page
> interface; all 'oob_required' parameters are left unused for now. The next
> patch will set the parameter properly in the nand_base.c callers, and follow-up
> patches will make use of 'oob_required' in some of the callee functions.
> 
> Note that currently, there is no harm in ignoring the 'oob_required' parameter
> and *always* utilizing nand_chip.oob_poi, but there can be
> performance/complexity/design benefits from avoiding filling oob_poi in the
> common case. I will try to implement this for some drivers which can be ported
> easily.
> 
> Note: I couldn't compile-test all of these easily, as some had ARCH
> dependencies.
> 
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>

Reviewed-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>

Regards,
Shmulik

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

* Re: [PATCH v3 02/10] mtd: nand: pass proper 'oob_required' parameter
  2012-04-28  1:29 ` [PATCH v3 02/10] mtd: nand: pass proper 'oob_required' parameter Brian Norris
@ 2012-04-29 11:41   ` Shmulik Ladkani
  0 siblings, 0 replies; 30+ messages in thread
From: Shmulik Ladkani @ 2012-04-29 11:41 UTC (permalink / raw)
  To: Brian Norris
  Cc: Mike Dunn, Artem Bityutskiy, Lei Wen,
	Jean-Christophe PLAGNIOL-VILLARD, Kevin Cernekee, Wolfram Sang,
	Matthieu CASTET, Huang Shijie, linux-mtd, Prabhakar Kushwaha,
	Florian Fainelli, Scott Wood, Jamie Iles, Thomas Gleixner,
	Li Yang, David Woodhouse, Axel Lin, Bastian Hecht

On Fri, 27 Apr 2012 18:29:46 -0700 Brian Norris <computersforpeace@gmail.com> wrote:
> We now have an interface for notifying the nand_ecc_ctrl functions when OOB
> data must be returned to the upper layers and when it may be left untouched.
> This patch fills in the 'oob_required' parameter properly from
> nand_do_{read,write}_ops. When utilized properly in the lower layers, this
> parameter can improve performance for NAND HW and SW that can simply avoid
> transferring the OOB data.
> 
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>

Reviewed-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>

Regards,
Shmulik

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

* Re: [PATCH v3 09/10] mtd: nand: utilize oob_required parameter
  2012-04-28  1:29 ` [PATCH v3 09/10] mtd: nand: utilize oob_required parameter Brian Norris
@ 2012-04-29 12:47   ` Shmulik Ladkani
  2012-04-30 19:59     ` Brian Norris
  0 siblings, 1 reply; 30+ messages in thread
From: Shmulik Ladkani @ 2012-04-29 12:47 UTC (permalink / raw)
  To: Brian Norris; +Cc: David Woodhouse, linux-mtd, Artem Bityutskiy

Hi Brian,

On Fri, 27 Apr 2012 18:29:53 -0700 Brian Norris <computersforpeace@gmail.com> wrote:
> Don't read/write OOB if the caller doesn't requre it.
> 
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> ---
>  drivers/mtd/nand/nand_base.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index 13a6355..5b390ae 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -1075,7 +1075,8 @@ static int nand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
>  			      uint8_t *buf, int oob_required, int page)
>  {
>  	chip->read_buf(mtd, buf, mtd->writesize);
> -	chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
> +	if (oob_required)
> +		chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
>  	return 0;
>  }

Re-thinking this, I think this might be incorrect.
Sorry I havn't noticed this earlier.

Suppose the nand chip is working in "sequential" (aka "incremental")
mode.
Meaning, a NAND_CMD_READ0 command is issued, and then adjacent pages are
read sequencially, without having to re-issue NAND_CMD_READ0.

(see for example the loop within 'nand_do_read_ops', especially the
'sndcmd' variable).

In that case, we MUST read the 'oob', because the OOB bytes will always
arrive on the bus following the inband data.
(on bus, data will appear as: page, spare, page, spare, and so on...)

If we do not read into 'oob_poi', then the OOB bytes arriving on the bus
will be set by the software into next page's 'buf'...

I have no idea if this issue is also relevant for 'read_page' implementors
other than of nand_base.c; should carefully review.

There are 2 options for fixing the issue in nand_base.c:

- Disregard the 'oob_required' parameter in all nand_base's
  'read_page' implementations (not future proof, someone might miss the
  nuance; also bug might still exist in the non-default implementations)

- Fix your 02/10 patch, in away that the passed 'oob_required' argument
  will be somehow set according to the 'snd_cmd'

Regards,
Shmulik

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

* Re: [PATCH v3 01/10] mtd: nand: add 'oob_required' argument to NAND {read,write}_page interfaces
  2012-04-29 11:36   ` [PATCH v3 01/10] mtd: nand: add 'oob_required' argument to NAND {read,write}_page interfaces Shmulik Ladkani
@ 2012-04-29 13:25     ` Artem Bityutskiy
  2012-04-30 19:16       ` Brian Norris
  0 siblings, 1 reply; 30+ messages in thread
From: Artem Bityutskiy @ 2012-04-29 13:25 UTC (permalink / raw)
  To: Shmulik Ladkani
  Cc: Li Yang, Mike Dunn, Lei Wen, Jean-Christophe PLAGNIOL-VILLARD,
	Kevin Cernekee, Wolfram Sang, Matthieu CASTET, Huang Shijie,
	linux-mtd, Prabhakar Kushwaha, Florian Fainelli, Scott Wood,
	Jamie Iles, Thomas Gleixner, Brian Norris, David Woodhouse,
	Axel Lin, Bastian Hecht

[-- Attachment #1: Type: text/plain, Size: 679 bytes --]

On Sun, 2012-04-29 at 14:36 +0300, Shmulik Ladkani wrote:
> > Note: I couldn't compile-test all of these easily, as some had ARCH
> > dependencies.
> > 
> > Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> 
> Reviewed-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>

Brian, probably you take care of this, but just in case I would like to
ask to put tags like this to your patches when re-sending. I am trying
to be careful about this for several reasons: it shows that the patch
was reviewed, it saves the reviewers name in the git history which and
makes persons' contribution visible, so it is kind of a credit.

-- 
Best Regards,
Artem Bityutskiy

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH v3 00/10] mtd: nand: rework nand_ecc_ctrl interface for OOB
  2012-04-28  1:29 [PATCH v3 00/10] mtd: nand: rework nand_ecc_ctrl interface for OOB Brian Norris
                   ` (9 preceding siblings ...)
  2012-04-28  1:29 ` [PATCH v3 10/10] mtd: pxa3xx_nand: " Brian Norris
@ 2012-04-30  7:10 ` Artem Bityutskiy
  10 siblings, 0 replies; 30+ messages in thread
From: Artem Bityutskiy @ 2012-04-30  7:10 UTC (permalink / raw)
  To: Brian Norris
  Cc: Lei Wen, Mike Dunn, Prabhakar Kushwaha, Dmitry Eremin-Solenikov,
	Jean-Christophe PLAGNIOL-VILLARD, Kevin Cernekee, Wolfram Sang,
	Matthieu CASTET, Huang Shijie, linux-mtd, Shmulik Ladkani,
	Florian Fainelli, Scott Wood, Jamie Iles, Thomas Gleixner,
	Li Yang, David Woodhouse, Axel Lin, Bastian Hecht

[-- Attachment #1: Type: text/plain, Size: 546 bytes --]

On Fri, 2012-04-27 at 18:29 -0700, Brian Norris wrote:
> Hello again,
> 
> This is the third (final?) version of my patches to change the nand_chip and
> nand_ecc_ctrl interfaces so that the nand_ecc_ctrl functions have information
> about whether the higher layers actually need OOB data to be read/written
> from/to the NAND device.

Brian, now your patches do not apply to l2-mtd tree because of Mike's
changes I guess. Would you please make sure v4 is rebased against the
latest l2-mtd.git?

-- 
Best Regards,
Artem Bityutskiy

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH v3 07/10] mtd: IFC NAND: utilize oob_required parameter
  2012-04-28  1:29 ` [PATCH v3 07/10] mtd: IFC " Brian Norris
@ 2012-04-30 16:43   ` Scott Wood
  2012-04-30 19:08     ` Brian Norris
  0 siblings, 1 reply; 30+ messages in thread
From: Scott Wood @ 2012-04-30 16:43 UTC (permalink / raw)
  To: Brian Norris
  Cc: David Woodhouse, Li Yang, linux-mtd, Prabhakar Kushwaha,
	Artem Bityutskiy

On 04/27/2012 08:29 PM, Brian Norris wrote:
> @@ -717,7 +718,8 @@ static void fsl_ifc_write_page(struct mtd_info *mtd, struct nand_chip *chip,
>  			       const uint8_t *buf, int oob_required)
>  {
>  	fsl_ifc_write_buf(mtd, buf, mtd->writesize);
> -	fsl_ifc_write_buf(mtd, chip->oob_poi, mtd->oobsize);
> +	if (oob_required)
> +		fsl_ifc_write_buf(mtd, chip->oob_poi, mtd->oobsize);
>  }

This will result in writing junk to the non-ECC OOB bytes as opposed to
leaving it alone.

-Scott

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

* Re: [PATCH v3 07/10] mtd: IFC NAND: utilize oob_required parameter
  2012-04-30 16:43   ` Scott Wood
@ 2012-04-30 19:08     ` Brian Norris
  2012-04-30 19:13       ` Scott Wood
  0 siblings, 1 reply; 30+ messages in thread
From: Brian Norris @ 2012-04-30 19:08 UTC (permalink / raw)
  To: Scott Wood
  Cc: David Woodhouse, Li Yang, linux-mtd, Prabhakar Kushwaha,
	Artem Bityutskiy

On Mon, Apr 30, 2012 at 9:43 AM, Scott Wood <scottwood@freescale.com> wrote:
> On 04/27/2012 08:29 PM, Brian Norris wrote:
>> @@ -717,7 +718,8 @@ static void fsl_ifc_write_page(struct mtd_info *mtd, struct nand_chip *chip,
>>                              const uint8_t *buf, int oob_required)
>>  {
>>       fsl_ifc_write_buf(mtd, buf, mtd->writesize);
>> -     fsl_ifc_write_buf(mtd, chip->oob_poi, mtd->oobsize);
>> +     if (oob_required)
>> +             fsl_ifc_write_buf(mtd, chip->oob_poi, mtd->oobsize);
>>  }
>
> This will result in writing junk to the non-ECC OOB bytes as opposed to
> leaving it alone.

Then I'll drop the write_page change from this patch.

Is the read_page change sane?

Did you review the (misspelled) eLBC patch? (patch 06/10)

Thanks.

Brian

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

* Re: [PATCH v3 07/10] mtd: IFC NAND: utilize oob_required parameter
  2012-04-30 19:08     ` Brian Norris
@ 2012-04-30 19:13       ` Scott Wood
  2012-04-30 19:23         ` Brian Norris
  0 siblings, 1 reply; 30+ messages in thread
From: Scott Wood @ 2012-04-30 19:13 UTC (permalink / raw)
  To: Brian Norris
  Cc: David Woodhouse, Li Yang, linux-mtd, Prabhakar Kushwaha,
	Artem Bityutskiy

On 04/30/2012 02:08 PM, Brian Norris wrote:
> On Mon, Apr 30, 2012 at 9:43 AM, Scott Wood <scottwood@freescale.com> wrote:
>> On 04/27/2012 08:29 PM, Brian Norris wrote:
>>> @@ -717,7 +718,8 @@ static void fsl_ifc_write_page(struct mtd_info *mtd, struct nand_chip *chip,
>>>                              const uint8_t *buf, int oob_required)
>>>  {
>>>       fsl_ifc_write_buf(mtd, buf, mtd->writesize);
>>> -     fsl_ifc_write_buf(mtd, chip->oob_poi, mtd->oobsize);
>>> +     if (oob_required)
>>> +             fsl_ifc_write_buf(mtd, chip->oob_poi, mtd->oobsize);
>>>  }
>>
>> This will result in writing junk to the non-ECC OOB bytes as opposed to
>> leaving it alone.
> 
> Then I'll drop the write_page change from this patch.
> 
> Is the read_page change sane?

It should be harmless.

> Did you review the (misspelled) eLBC patch? (patch 06/10)

No, that one wasn't CCed to me (I should probably get around to
subscribing to linux-mtd...).  It looks like the same situation as IFC.

-Scott

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

* Re: [PATCH v3 01/10] mtd: nand: add 'oob_required' argument to NAND {read,write}_page interfaces
  2012-04-29 13:25     ` Artem Bityutskiy
@ 2012-04-30 19:16       ` Brian Norris
  2012-04-30 19:21         ` Scott Wood
  0 siblings, 1 reply; 30+ messages in thread
From: Brian Norris @ 2012-04-30 19:16 UTC (permalink / raw)
  To: Artem Bityutskiy
  Cc: Mike Dunn, Prabhakar Kushwaha, Lei Wen,
	Jean-Christophe PLAGNIOL-VILLARD, Kevin Cernekee, Wolfram Sang,
	Matthieu CASTET, Huang Shijie, linux-mtd, Shmulik Ladkani,
	Florian Fainelli, Scott Wood, Jamie Iles, Thomas Gleixner,
	Li Yang, David Woodhouse, Axel Lin, Bastian Hecht

On Sun, Apr 29, 2012 at 6:25 AM, Artem Bityutskiy <dedekind1@gmail.com> wrote:
> On Sun, 2012-04-29 at 14:36 +0300, Shmulik Ladkani wrote:
>> > Note: I couldn't compile-test all of these easily, as some had ARCH
>> > dependencies.
>> >
>> > Signed-off-by: Brian Norris <computersforpeace@gmail.com>
>>
>> Reviewed-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
>
> Brian, probably you take care of this, but just in case I would like to
> ask to put tags like this to your patches when re-sending. I am trying
> to be careful about this for several reasons: it shows that the patch
> was reviewed, it saves the reviewers name in the git history which and
> makes persons' contribution visible, so it is kind of a credit.

Sure, I'll do this as appropriate. Should I apply these tags when the
review is made w/o an explicit "Reviewed-by" (e.g., Scott Wood's
comments on patch 7)? There's also the issue of placing "reviewed-by"
before the reviewer actually sees my change.

So I'll be sure to place Shmulik's and Huang's tags. Not quite as sure
on Scott's review, but I will include it as "Reviewed-by" for now.

Brian

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

* Re: [PATCH v3 01/10] mtd: nand: add 'oob_required' argument to NAND {read,write}_page interfaces
  2012-04-30 19:16       ` Brian Norris
@ 2012-04-30 19:21         ` Scott Wood
  0 siblings, 0 replies; 30+ messages in thread
From: Scott Wood @ 2012-04-30 19:21 UTC (permalink / raw)
  To: Brian Norris
  Cc: Mike Dunn, Prabhakar Kushwaha, Artem Bityutskiy, Lei Wen,
	Jean-Christophe PLAGNIOL-VILLARD, Kevin Cernekee, Wolfram Sang,
	Matthieu CASTET, Huang Shijie, linux-mtd, Shmulik Ladkani,
	Florian Fainelli, Jamie Iles, Thomas Gleixner, Li Yang,
	David Woodhouse, Axel Lin, Bastian Hecht

On 04/30/2012 02:16 PM, Brian Norris wrote:
> On Sun, Apr 29, 2012 at 6:25 AM, Artem Bityutskiy <dedekind1@gmail.com> wrote:
>> On Sun, 2012-04-29 at 14:36 +0300, Shmulik Ladkani wrote:
>>>> Note: I couldn't compile-test all of these easily, as some had ARCH
>>>> dependencies.
>>>>
>>>> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
>>>
>>> Reviewed-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
>>
>> Brian, probably you take care of this, but just in case I would like to
>> ask to put tags like this to your patches when re-sending. I am trying
>> to be careful about this for several reasons: it shows that the patch
>> was reviewed, it saves the reviewers name in the git history which and
>> makes persons' contribution visible, so it is kind of a credit.
> 
> Sure, I'll do this as appropriate. Should I apply these tags when the
> review is made w/o an explicit "Reviewed-by" (e.g., Scott Wood's
> comments on patch 7)? There's also the issue of placing "reviewed-by"
> before the reviewer actually sees my change.

You can put mine on if you want in this case, provided the write-side
change is removed as discussed -- but in general, I'd say that making a
comment on one part of a patch doesn't indicate that the whole thing has
been reviewed.

-Scott

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

* Re: [PATCH v3 07/10] mtd: IFC NAND: utilize oob_required parameter
  2012-04-30 19:13       ` Scott Wood
@ 2012-04-30 19:23         ` Brian Norris
  2012-04-30 19:32           ` Scott Wood
  0 siblings, 1 reply; 30+ messages in thread
From: Brian Norris @ 2012-04-30 19:23 UTC (permalink / raw)
  To: Scott Wood
  Cc: Artem Bityutskiy, linux-mtd, Shmulik Ladkani, Li Yang,
	David Woodhouse, Prabhakar Kushwaha

On Mon, Apr 30, 2012 at 12:13 PM, Scott Wood <scottwood@freescale.com> wrote:
> On 04/30/2012 02:08 PM, Brian Norris wrote:
>> Is the read_page change sane?
>
> It should be harmless.

Right, but I am now handling Shmulik's comments about auto-incremented
NAND. It seems like there are few/no users of auto-incrementing page
reads, but if any driver relied on reading page,oob,page,oob,etc.
without a READ command in between, then we might cause problems by
skipping the OOB buffer read. Of course, with various NAND
controllers/drivers, this issue is hard for me to sort through.

>> Did you review the (misspelled) eLBC patch? (patch 06/10)
>
> No, that one wasn't CCed to me (I should probably get around to
> subscribing to linux-mtd...).

scripts/get_maintainers.pl only goes so far. It's hard to track down
the *real* experts here...

> It looks like the same situation as IFC.

OK, I'll fix it too then.

Thanks.

Brian

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

* Re: [PATCH v3 07/10] mtd: IFC NAND: utilize oob_required parameter
  2012-04-30 19:23         ` Brian Norris
@ 2012-04-30 19:32           ` Scott Wood
  0 siblings, 0 replies; 30+ messages in thread
From: Scott Wood @ 2012-04-30 19:32 UTC (permalink / raw)
  To: Brian Norris
  Cc: Artem Bityutskiy, linux-mtd, Shmulik Ladkani, Li Yang,
	David Woodhouse, Prabhakar Kushwaha

On 04/30/2012 02:23 PM, Brian Norris wrote:
> On Mon, Apr 30, 2012 at 12:13 PM, Scott Wood <scottwood@freescale.com> wrote:
>> On 04/30/2012 02:08 PM, Brian Norris wrote:
>>> Is the read_page change sane?
>>
>> It should be harmless.
> 
> Right, but I am now handling Shmulik's comments about auto-incremented
> NAND. It seems like there are few/no users of auto-incrementing page
> reads, but if any driver relied on reading page,oob,page,oob,etc.
> without a READ command in between, then we might cause problems by
> skipping the OOB buffer read. Of course, with various NAND
> controllers/drivers, this issue is hard for me to sort through.

This isn't an issue with eLBC/IFC -- besides not currently supporting
autoincrement, the OOB is still read.  We just wouldn't pull it out of
the controller buffer.  Not sure if the time saved is significant.

-Scott

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

* Re: [PATCH v3 09/10] mtd: nand: utilize oob_required parameter
  2012-04-29 12:47   ` Shmulik Ladkani
@ 2012-04-30 19:59     ` Brian Norris
  2012-04-30 20:12       ` Brian Norris
                         ` (2 more replies)
  0 siblings, 3 replies; 30+ messages in thread
From: Brian Norris @ 2012-04-30 19:59 UTC (permalink / raw)
  To: Shmulik Ladkani; +Cc: David Woodhouse, linux-mtd, Artem Bityutskiy

On Sun, Apr 29, 2012 at 5:47 AM, Shmulik Ladkani
<shmulik.ladkani@gmail.com> wrote:
> On Fri, 27 Apr 2012 18:29:53 -0700 Brian Norris <computersforpeace@gmail.com> wrote:
>> Don't read/write OOB if the caller doesn't requre it.
>
> Re-thinking this, I think this might be incorrect.
> Sorry I havn't noticed this earlier.
>
> Suppose the nand chip is working in "sequential" (aka "incremental")
> mode.
> Meaning, a NAND_CMD_READ0 command is issued, and then adjacent pages are
> read sequencially, without having to re-issue NAND_CMD_READ0.
>
> (see for example the loop within 'nand_do_read_ops', especially the
> 'sndcmd' variable).
>
> In that case, we MUST read the 'oob', because the OOB bytes will always
> arrive on the bus following the inband data.
...

I see. This is the kind of issue I was alluding to back in v2:

"For instance, is there any sort of hardware that expects the whole
page + OOB to be read via chip->read_buf() for all reads..."

This situation comes up if NAND_NO_AUTOINCR is not set. But really, it
looks like we *always* have NAND_NO_AUTOINCR enabled, and so we
*always* send a new READ cmd. I know that it's possible for some board
driver to override this, but I don't see that anywhere...

> I have no idea if this issue is also relevant for 'read_page' implementors
> other than of nand_base.c; should carefully review.
>
> There are 2 options for fixing the issue in nand_base.c:
>
> - Disregard the 'oob_required' parameter in all nand_base's
>  'read_page' implementations (not future proof, someone might miss the
>  nuance; also bug might still exist in the non-default implementations)
>
> - Fix your 02/10 patch, in away that the passed 'oob_required' argument
>  will be somehow set according to the 'snd_cmd'

I'm fine with adding an 'else' to the 'if (likely(sndcmd))', so that
we get something like this in patch 2:

               if (likely(sndcmd)) {
                       chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page);
                       sndcmd = 0;
+              } else {
+                      /* force driver to read OOB, for sequential read */
+                      oob_required = 1;
               }

I think that would take care of the corner case where we use autoincrement.

Brian

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

* Re: [PATCH v3 09/10] mtd: nand: utilize oob_required parameter
  2012-04-30 19:59     ` Brian Norris
@ 2012-04-30 20:12       ` Brian Norris
  2012-04-30 20:21       ` Scott Wood
  2012-05-01  8:29       ` Shmulik Ladkani
  2 siblings, 0 replies; 30+ messages in thread
From: Brian Norris @ 2012-04-30 20:12 UTC (permalink / raw)
  To: Shmulik Ladkani; +Cc: David Woodhouse, linux-mtd, Artem Bityutskiy

On Mon, Apr 30, 2012 at 12:59 PM, Brian Norris
<computersforpeace@gmail.com> wrote:
> On Sun, Apr 29, 2012 at 5:47 AM, Shmulik Ladkani
> <shmulik.ladkani@gmail.com> wrote:
>> - Fix your 02/10 patch, in away that the passed 'oob_required' argument
>>  will be somehow set according to the 'snd_cmd'
>
> I'm fine with adding an 'else' to the 'if (likely(sndcmd))', so that
> we get something like this in patch 2:
>
>               if (likely(sndcmd)) {
>                       chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page);
>                       sndcmd = 0;
> +              } else {
> +                      /* force driver to read OOB, for sequential read */
> +                      oob_required = 1;
>               }
>
> I think that would take care of the corner case where we use autoincrement.

On second thought, this is not good enough. I need to actually check
for CANAUTOINCR(chip). This is a better candidate:

+ /* force read OOB, for auto-incremented read */
+ if (unlikely(NAND_CANAUTOINCR(chip)))
+         oob_required = 1;

Brian

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

* Re: [PATCH v3 09/10] mtd: nand: utilize oob_required parameter
  2012-04-30 19:59     ` Brian Norris
  2012-04-30 20:12       ` Brian Norris
@ 2012-04-30 20:21       ` Scott Wood
  2012-04-30 21:49         ` Brian Norris
  2012-05-01  8:29       ` Shmulik Ladkani
  2 siblings, 1 reply; 30+ messages in thread
From: Scott Wood @ 2012-04-30 20:21 UTC (permalink / raw)
  To: Brian Norris
  Cc: linux-mtd, David Woodhouse, Shmulik Ladkani, Artem Bityutskiy

On 04/30/2012 02:59 PM, Brian Norris wrote:
> I see. This is the kind of issue I was alluding to back in v2:
> 
> "For instance, is there any sort of hardware that expects the whole
> page + OOB to be read via chip->read_buf() for all reads..."
> 
> This situation comes up if NAND_NO_AUTOINCR is not set. But really, it
> looks like we *always* have NAND_NO_AUTOINCR enabled, and so we
> *always* send a new READ cmd. I know that it's possible for some board
> driver to override this, but I don't see that anywhere...

If it's never used, maybe just remove autoincrement support altogether
and simplify the code?

-Scott

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

* Re: [PATCH v3 09/10] mtd: nand: utilize oob_required parameter
  2012-04-30 20:21       ` Scott Wood
@ 2012-04-30 21:49         ` Brian Norris
  2012-05-01 12:12           ` Artem Bityutskiy
  0 siblings, 1 reply; 30+ messages in thread
From: Brian Norris @ 2012-04-30 21:49 UTC (permalink / raw)
  To: Scott Wood; +Cc: linux-mtd, David Woodhouse, Shmulik Ladkani, Artem Bityutskiy

On Mon, Apr 30, 2012 at 1:21 PM, Scott Wood <scottwood@freescale.com> wrote:
> On 04/30/2012 02:59 PM, Brian Norris wrote:
>> I see. This is the kind of issue I was alluding to back in v2:
>>
>> "For instance, is there any sort of hardware that expects the whole
>> page + OOB to be read via chip->read_buf() for all reads..."
>>
>> This situation comes up if NAND_NO_AUTOINCR is not set. But really, it
>> looks like we *always* have NAND_NO_AUTOINCR enabled, and so we
>> *always* send a new READ cmd. I know that it's possible for some board
>> driver to override this, but I don't see that anywhere...
>
> If it's never used, maybe just remove autoincrement support altogether
> and simplify the code?

Fine with me. I'd like some word from a Artem or David though.

I've started a patch for this and will send it before I send a v4 if
killing autoincrement is acceptable. Otherwise, I'll just work around
autoincrement for this series with the previously-posted snippet.

Brian

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

* Re: [PATCH v3 09/10] mtd: nand: utilize oob_required parameter
  2012-04-30 19:59     ` Brian Norris
  2012-04-30 20:12       ` Brian Norris
  2012-04-30 20:21       ` Scott Wood
@ 2012-05-01  8:29       ` Shmulik Ladkani
  2 siblings, 0 replies; 30+ messages in thread
From: Shmulik Ladkani @ 2012-05-01  8:29 UTC (permalink / raw)
  To: Brian Norris; +Cc: David Woodhouse, linux-mtd, Artem Bityutskiy

Hi Brian,

On Mon, 30 Apr 2012 12:59:52 -0700 Brian Norris <computersforpeace@gmail.com> wrote:
> On Sun, Apr 29, 2012 at 5:47 AM, Shmulik Ladkani
> <shmulik.ladkani@gmail.com> wrote:
> > On Fri, 27 Apr 2012 18:29:53 -0700 Brian Norris <computersforpeace@gmail.com> wrote:
> >> Don't read/write OOB if the caller doesn't requre it.
> >
> > Re-thinking this, I think this might be incorrect.
> > Sorry I havn't noticed this earlier.
> >
> > Suppose the nand chip is working in "sequential" (aka "incremental")
> > mode.
> > Meaning, a NAND_CMD_READ0 command is issued, and then adjacent pages are
> > read sequencially, without having to re-issue NAND_CMD_READ0.
> >
> > (see for example the loop within 'nand_do_read_ops', especially the
> > 'sndcmd' variable).
> >
> > In that case, we MUST read the 'oob', because the OOB bytes will always
> > arrive on the bus following the inband data.
> ...
> 
> I see. This is the kind of issue I was alluding to back in v2:
> 
> "For instance, is there any sort of hardware that expects the whole
> page + OOB to be read via chip->read_buf() for all reads..."

Yep. Charmed by the 'oob_required' idea, I sensed this potential trouble
too late :)

This is more delicate than I originally thought.

I completely agree with your statement "please do NOT accept any of
the patches 3-10 without an explicit ACK from someone who knows the driver".

I was querying regarging the adaptation of existing drivers since the
patchset looked "incomplete".

However if this attempt gets too complicated, I guess the compromise of
submitting just the infrastructure changes (patches 1 and 2) is probably
reasonable. Let the maintainers decide.

Regards,
Shmulik

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

* Re: [PATCH v3 09/10] mtd: nand: utilize oob_required parameter
  2012-04-30 21:49         ` Brian Norris
@ 2012-05-01 12:12           ` Artem Bityutskiy
  0 siblings, 0 replies; 30+ messages in thread
From: Artem Bityutskiy @ 2012-05-01 12:12 UTC (permalink / raw)
  To: Brian Norris; +Cc: Scott Wood, linux-mtd, David Woodhouse, Shmulik Ladkani

[-- Attachment #1: Type: text/plain, Size: 996 bytes --]

On Mon, 2012-04-30 at 14:49 -0700, Brian Norris wrote:
> On Mon, Apr 30, 2012 at 1:21 PM, Scott Wood <scottwood@freescale.com> wrote:
> > On 04/30/2012 02:59 PM, Brian Norris wrote:
> >> I see. This is the kind of issue I was alluding to back in v2:
> >>
> >> "For instance, is there any sort of hardware that expects the whole
> >> page + OOB to be read via chip->read_buf() for all reads..."
> >>
> >> This situation comes up if NAND_NO_AUTOINCR is not set. But really, it
> >> looks like we *always* have NAND_NO_AUTOINCR enabled, and so we
> >> *always* send a new READ cmd. I know that it's possible for some board
> >> driver to override this, but I don't see that anywhere...
> >
> > If it's never used, maybe just remove autoincrement support altogether
> > and simplify the code?
> 
> Fine with me. I'd like some word from a Artem or David though.

My opinion is that we have too much cruft and killing unused feature is
fine.

-- 
Best Regards,
Artem Bityutskiy

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2012-05-01 12:12 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-28  1:29 [PATCH v3 00/10] mtd: nand: rework nand_ecc_ctrl interface for OOB Brian Norris
2012-04-28  1:29 ` [PATCH v3 01/10] mtd: nand: add 'oob_required' argument to NAND {read, write}_page interfaces Brian Norris
2012-04-29 11:36   ` [PATCH v3 01/10] mtd: nand: add 'oob_required' argument to NAND {read,write}_page interfaces Shmulik Ladkani
2012-04-29 13:25     ` Artem Bityutskiy
2012-04-30 19:16       ` Brian Norris
2012-04-30 19:21         ` Scott Wood
2012-04-28  1:29 ` [PATCH v3 02/10] mtd: nand: pass proper 'oob_required' parameter Brian Norris
2012-04-29 11:41   ` Shmulik Ladkani
2012-04-28  1:29 ` [PATCH v3 03/10] mtd: Blackfin NFC: utilize oob_required parameter Brian Norris
2012-04-28  1:29 ` [PATCH v3 04/10] mtd: cafe_nand: " Brian Norris
2012-04-28  1:29 ` [PATCH v3 05/10] mtd: denali: " Brian Norris
2012-04-28  1:29 ` [PATCH v3 06/10] mtd: eLBD NAND: " Brian Norris
2012-04-28  1:29 ` [PATCH v3 07/10] mtd: IFC " Brian Norris
2012-04-30 16:43   ` Scott Wood
2012-04-30 19:08     ` Brian Norris
2012-04-30 19:13       ` Scott Wood
2012-04-30 19:23         ` Brian Norris
2012-04-30 19:32           ` Scott Wood
2012-04-28  1:29 ` [PATCH v3 08/10] mtd: gpmi-nand: utilize oob_requested parameter Brian Norris
2012-04-28  2:32   ` Huang Shijie
2012-04-28  1:29 ` [PATCH v3 09/10] mtd: nand: utilize oob_required parameter Brian Norris
2012-04-29 12:47   ` Shmulik Ladkani
2012-04-30 19:59     ` Brian Norris
2012-04-30 20:12       ` Brian Norris
2012-04-30 20:21       ` Scott Wood
2012-04-30 21:49         ` Brian Norris
2012-05-01 12:12           ` Artem Bityutskiy
2012-05-01  8:29       ` Shmulik Ladkani
2012-04-28  1:29 ` [PATCH v3 10/10] mtd: pxa3xx_nand: " Brian Norris
2012-04-30  7:10 ` [PATCH v3 00/10] mtd: nand: rework nand_ecc_ctrl interface for OOB Artem Bityutskiy

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.