From: PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
To: boris.brezillon@free-electrons.com, dwmw2@infradead.org,
computersforpeace@gmail.com, marek.vasut@gmail.com,
cyrille.pitchen@wedev4u.fr, linux-mtd@lists.infradead.org,
linux-kernel@vger.kernel.org
Cc: Lars-Peter Clausen <lars@metafoo.de>,
PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
Subject: [RFC] NAND: Optimize NAND_ECC_HW_OOB_FIRST read
Date: Sat, 28 Oct 2017 13:13:51 +0530 [thread overview]
Message-ID: <20171028074351.13118-1-prasannatsmkumar@gmail.com> (raw)
From: Lars-Peter Clausen <lars@metafoo.de>
Avoid sending unnecessary READ commands to the chip.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: PrasannaKumar Muralidharan <prasannatsmkumar@gmail.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
next reply other threads:[~2017-10-28 7:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-28 7:43 PrasannaKumar Muralidharan [this message]
2017-10-30 8:34 ` [RFC] NAND: Optimize NAND_ECC_HW_OOB_FIRST read Boris Brezillon
2017-10-30 12:47 ` PrasannaKumar Muralidharan
2017-10-30 13:03 ` Boris Brezillon
2017-10-30 13:34 ` PrasannaKumar Muralidharan
2017-10-31 16:20 ` PrasannaKumar Muralidharan
2018-01-27 7:42 ` PrasannaKumar Muralidharan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171028074351.13118-1-prasannatsmkumar@gmail.com \
--to=prasannatsmkumar@gmail.com \
--cc=boris.brezillon@free-electrons.com \
--cc=computersforpeace@gmail.com \
--cc=cyrille.pitchen@wedev4u.fr \
--cc=dwmw2@infradead.org \
--cc=lars@metafoo.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).