xburst: Add 3.10 support
[openwrt/svn-archive/archive.git] / target / linux / xburst / patches-3.10 / 002-NAND-Optimize-NAND_ECC_HW_OOB_FIRST-read.patch
1 From f2b7099d3986e59aab5792cecc052e440caf2cdd Mon Sep 17 00:00:00 2001
2 From: Lars-Peter Clausen <lars@metafoo.de>
3 Date: Sat, 26 Feb 2011 15:30:07 +0100
4 Subject: [PATCH 02/16] NAND: Optimize NAND_ECC_HW_OOB_FIRST read
5
6 Avoid sending unnecessary READ commands to the chip.
7
8 Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
9 ---
10 drivers/mtd/nand/nand_base.c | 17 +++++++++++++----
11 1 file changed, 13 insertions(+), 4 deletions(-)
12
13 diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
14 index dfcd0a5..287c433 100644
15 --- a/drivers/mtd/nand/nand_base.c
16 +++ b/drivers/mtd/nand/nand_base.c
17 @@ -1278,9 +1278,16 @@ static int nand_read_page_hwecc_oob_first(struct mtd_info *mtd,
18 unsigned int max_bitflips = 0;
19
20 /* Read the OOB area first */
21 - chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);
22 - chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
23 - chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page);
24 + /* Read the OOB area first */
25 + if (mtd->writesize > 512) {
26 + chip->cmdfunc(mtd, NAND_CMD_READ0, mtd->writesize, page);
27 + chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
28 + chip->cmdfunc(mtd, NAND_CMD_RNDOUT, 0, -1);
29 + } else {
30 + chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);
31 + chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
32 + chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page);
33 + }
34
35 for (i = 0; i < chip->ecc.total; i++)
36 ecc_code[i] = chip->oob_poi[eccpos[i]];
37 @@ -1455,7 +1462,9 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
38 if (realpage != chip->pagebuf || oob) {
39 bufpoi = aligned ? buf : chip->buffers->databuf;
40
41 - chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page);
42 + if (chip->ecc.mode != NAND_ECC_HW_OOB_FIRST) {
43 + chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page);
44 + }
45
46 /*
47 * Now read the page into the buffer. Absent an error,
48 --
49 1.7.10.4
50