kernel: update 3.10 to 3.10.3
[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 --- a/drivers/mtd/nand/nand_base.c
14 +++ b/drivers/mtd/nand/nand_base.c
15 @@ -1278,9 +1278,16 @@ static int nand_read_page_hwecc_oob_firs
16 unsigned int max_bitflips = 0;
17
18 /* Read the OOB area first */
19 - chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);
20 - chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
21 - chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page);
22 + /* Read the OOB area first */
23 + if (mtd->writesize > 512) {
24 + chip->cmdfunc(mtd, NAND_CMD_READ0, mtd->writesize, page);
25 + chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
26 + chip->cmdfunc(mtd, NAND_CMD_RNDOUT, 0, -1);
27 + } else {
28 + chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);
29 + chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
30 + chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page);
31 + }
32
33 for (i = 0; i < chip->ecc.total; i++)
34 ecc_code[i] = chip->oob_poi[eccpos[i]];
35 @@ -1455,7 +1462,9 @@ static int nand_do_read_ops(struct mtd_i
36 if (realpage != chip->pagebuf || oob) {
37 bufpoi = aligned ? buf : chip->buffers->databuf;
38
39 - chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page);
40 + if (chip->ecc.mode != NAND_ECC_HW_OOB_FIRST) {
41 + chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page);
42 + }
43
44 /*
45 * Now read the page into the buffer. Absent an error,