lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20171028074351.13118-1-prasannatsmkumar@gmail.com>
Date:   Sat, 28 Oct 2017 13:13:51 +0530
From:   PrasannaKumar Muralidharan <prasannatsmkumar@...il.com>
To:     boris.brezillon@...e-electrons.com, dwmw2@...radead.org,
        computersforpeace@...il.com, marek.vasut@...il.com,
        cyrille.pitchen@...ev4u.fr, linux-mtd@...ts.infradead.org,
        linux-kernel@...r.kernel.org
Cc:     Lars-Peter Clausen <lars@...afoo.de>,
        PrasannaKumar Muralidharan <prasannatsmkumar@...il.com>
Subject: [RFC] NAND: Optimize NAND_ECC_HW_OOB_FIRST read

From: Lars-Peter Clausen <lars@...afoo.de>

Avoid sending unnecessary READ commands to the chip.

Signed-off-by: Lars-Peter Clausen <lars@...afoo.de>
Signed-off-by: PrasannaKumar Muralidharan <prasannatsmkumar@...il.com>
---
This patch is taken from git://projects.qi-hardware.com/qi-kernel.git
branch jz-3.16. From [1] and [2] it can be seen that the patch author
thinks this can be sent upstream but it never happened so far. This
patch is used in OpenWRT as seen from [3].

I have only compile tested the patch.

1. https://www.mail-archive.com/discussion@lists.en.qi-hardware.com/msg04635.html
2. https://www.mail-archive.com/discussion@lists.en.qi-hardware.com/msg04639.html
3. https://git.lede-project.org/?p=source.git;a=blob;f=target/linux/xburst/patches-3.18/002-NAND-Optimize-NAND_ECC_HW_OOB_FIRST-read.patch;h=046da51912de3cd4444779df5de13d2c1999719a;hb=c03d4317a6bc891cb4a5e89cbdd77f37c23aff86

 drivers/mtd/nand/nand_base.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 12edaae..4bf3bdb 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1680,9 +1680,15 @@ static int nand_read_page_hwecc_oob_first(struct mtd_info *mtd,
 	unsigned int max_bitflips = 0;
 
 	/* Read the OOB area first */
-	chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);
-	chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
-	chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page);
+	if (mtd->writesize > 512) {
+		chip->cmdfunc(mtd, NAND_CMD_READ0, mtd->writesize, page);
+		chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
+		chip->cmdfunc(mtd, NAND_CMD_RNDOUT, 0, -1);
+	} else {
+		chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);
+		chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
+		chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page);
+	}
 
 	ret = mtd_ooblayout_get_eccbytes(mtd, ecc_code, chip->oob_poi, 0,
 					 chip->ecc.total);
@@ -1902,8 +1908,10 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
 						 __func__, buf);
 
 read_retry:
-			if (nand_standard_page_accessors(&chip->ecc))
+			if (nand_standard_page_accessors(&chip->ecc) &&
+			    chip->ecc.mode != NAND_ECC_HW_OOB_FIRST) {
 				chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page);
+			}
 
 			/*
 			 * Now read the page into the buffer.  Absent an error,
-- 
2.10.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ