Date:2011-02-26 18:40:02 (8 years 4 months ago)
Author:Lars C.
Commit:5629baf0c48035b927276374a6e7c13fe6b16de6
Message:[xburst] Improve mounttime.

This patchset optimizes nand read access and reduces the ubi attach time by ~2/3
Credits go to dvdk for having the idea.
Files: target/linux/xburst/patches-2.6.32/901-ubi-Read-only-the-vid-header-instead-of-the-whole-pa.patch (1 diff)
target/linux/xburst/patches-2.6.32/902-NAND-Optimize-NAND_ECC_HW_OOB_FIRST-read.patch (1 diff)
target/linux/xburst/patches-2.6.32/903-NAND-Add-support-for-subpage-reads-for-NAND_ECC_HW_O.patch (1 diff)
target/linux/xburst/patches-2.6.32/904-NAND-Optimize-reading-the-eec-data-for-the-JZ4740-ev.patch (1 diff)

Change Details

target/linux/xburst/patches-2.6.32/901-ubi-Read-only-the-vid-header-instead-of-the-whole-pa.patch
1From 2b0db7309cf386899741b355efb12ab2742f178c Mon Sep 17 00:00:00 2001
2From: Lars-Peter Clausen <lars@metafoo.de>
3Date: Sat, 26 Feb 2011 15:19:11 +0100
4Subject: [PATCH 1/4] ubi: Read only the vid header instead of the whole page
5
6Improves ubi attach time by ~1/2
7---
8 drivers/mtd/ubi/io.c | 2 +-
9 1 files changed, 1 insertions(+), 1 deletions(-)
10
11--- a/drivers/mtd/ubi/io.c
12@@ -979,7 +979,7 @@ int ubi_io_read_vid_hdr(struct ubi_devic
13
14     p = (char *)vid_hdr - ubi->vid_hdr_shift;
15     err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset,
16- ubi->vid_hdr_alsize);
17+ UBI_VID_HDR_SIZE + ubi->vid_hdr_shift);
18     if (err) {
19         if (err != UBI_IO_BITFLIPS && err != -EBADMSG)
20             return err;
target/linux/xburst/patches-2.6.32/902-NAND-Optimize-NAND_ECC_HW_OOB_FIRST-read.patch
1From 93ad1a19872dfa2f4b9aa7b8d20581bda3057622 Mon Sep 17 00:00:00 2001
2From: Lars-Peter Clausen <lars@metafoo.de>
3Date: Sat, 26 Feb 2011 15:30:07 +0100
4Subject: [PATCH 2/4] NAND: Optimize NAND_ECC_HW_OOB_FIRST read
5
6Avoid sending unnecessary READ commands to the chip.
7---
8 drivers/mtd/nand/nand_base.c | 15 +++++++++++----
9 1 files changed, 11 insertions(+), 4 deletions(-)
10
11--- a/drivers/mtd/nand/nand_base.c
12@@ -1008,9 +1008,16 @@ static int nand_read_page_hwecc_oob_firs
13     uint8_t *ecc_calc = chip->buffers->ecccalc;
14
15     /* Read the OOB area first */
16- chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);
17- chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
18- chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page);
19+ /* Read the OOB area first */
20+ if (mtd->writesize > 512) {
21+ chip->cmdfunc(mtd, NAND_CMD_READ0, mtd->writesize, page);
22+ chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
23+ chip->cmdfunc(mtd, NAND_CMD_RNDOUT, 0, -1);
24+ } else {
25+ chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);
26+ chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
27+ chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page);
28+ }
29
30     for (i = 0; i < chip->ecc.total; i++)
31         ecc_code[i] = chip->oob_poi[eccpos[i]];
32@@ -1177,7 +1184,7 @@ static int nand_do_read_ops(struct mtd_i
33         if (realpage != chip->pagebuf || oob) {
34             bufpoi = aligned ? buf : chip->buffers->databuf;
35
36- if (likely(sndcmd)) {
37+ if (likely(sndcmd) && chip->ecc.mode != NAND_ECC_HW_OOB_FIRST) {
38                 chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page);
39                 sndcmd = 0;
40             }
target/linux/xburst/patches-2.6.32/903-NAND-Add-support-for-subpage-reads-for-NAND_ECC_HW_O.patch
1From 117f87de607a65e8e1cd155acd12a7cd201de7d0 Mon Sep 17 00:00:00 2001
2From: Lars-Peter Clausen <lars@metafoo.de>
3Date: Sat, 26 Feb 2011 15:26:55 +0100
4Subject: [PATCH 3/4] NAND: Add support for subpage reads for NAND_ECC_HW_OOB_FIRST
5
6---
7 drivers/mtd/nand/nand_base.c | 84 ++++++++++++++++++++++++++++++++++++++++--
8 include/linux/mtd/nand.h | 8 ++--
9 2 files changed, 84 insertions(+), 8 deletions(-)
10
11--- a/drivers/mtd/nand/nand_base.c
12@@ -864,7 +864,8 @@ static int nand_read_page_swecc(struct m
13  * @readlen: data length
14  * @bufpoi: buffer to store read data
15  */
16-static int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip, uint32_t data_offs, uint32_t readlen, uint8_t *bufpoi)
17+static int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip,
18+ uint32_t data_offs, uint32_t readlen, uint8_t *bufpoi, int page)
19 {
20     int start_step, end_step, num_steps;
21     uint32_t *eccpos = chip->ecc.layout->eccpos;
22@@ -1039,6 +1040,76 @@ static int nand_read_page_hwecc_oob_firs
23 }
24
25 /**
26+ * nand_read_subpage_hwecc_oob_first - [REPLACABLE] hw ecc based sub-page read function
27+ * @mtd: mtd info structure
28+ * @chip: nand chip info structure
29+ * @data_offs: offset of requested data within the page
30+ * @readlen: data length
31+ * @bufpoi: buffer to store read data
32+ * @page: page number to read
33+ *
34+ * Hardware ECC for large page chips, require OOB to be read first.
35+ * For this ECC mode, the write_page method is re-used from ECC_HW.
36+ * These methods read/write ECC from the OOB area, unlike the
37+ * ECC_HW_SYNDROME support with multiple ECC steps, follows the
38+ * "infix ECC" scheme and reads/writes ECC from the data area, by
39+ * overwriting the NAND manufacturer bad block markings.
40+ */
41+static int nand_read_subpage_hwecc_oob_first(struct mtd_info *mtd, struct nand_chip *chip,
42+ uint32_t data_offs, uint32_t readlen, uint8_t *bufpoi, int page)
43+{
44+ int start_step, end_step, num_steps;
45+ uint32_t *eccpos = chip->ecc.layout->eccpos;
46+ uint8_t *p;
47+ int data_col_addr;
48+ int eccsize = chip->ecc.size;
49+ int eccbytes = chip->ecc.bytes;
50+ uint8_t *ecc_code = chip->buffers->ecccode;
51+ uint8_t *ecc_calc = chip->buffers->ecccalc;
52+ int i;
53+
54+ /* Column address wihin the page aligned to ECC size */
55+ start_step = data_offs / chip->ecc.size;
56+ end_step = (data_offs + readlen - 1) / chip->ecc.size;
57+ num_steps = end_step - start_step + 1;
58+
59+ data_col_addr = start_step * chip->ecc.size;
60+
61+ /* Read the OOB area first */
62+ if (mtd->writesize > 512) {
63+ chip->cmdfunc(mtd, NAND_CMD_READ0, mtd->writesize, page);
64+ chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
65+ chip->cmdfunc(mtd, NAND_CMD_RNDOUT, data_col_addr, -1);
66+ } else {
67+ chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);
68+ chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
69+ chip->cmdfunc(mtd, NAND_CMD_READ0, data_col_addr, page);
70+ }
71+
72+ for (i = 0; i < chip->ecc.total; i++)
73+ ecc_code[i] = chip->oob_poi[eccpos[i]];
74+
75+ p = bufpoi + data_col_addr;
76+
77+ for (i = eccbytes * start_step; num_steps; num_steps--, i += eccbytes, p += eccsize) {
78+ int stat;
79+
80+ chip->ecc.hwctl(mtd, NAND_ECC_READ);
81+ chip->read_buf(mtd, p, eccsize);
82+ chip->ecc.calculate(mtd, p, &ecc_calc[i]);
83+
84+ stat = chip->ecc.correct(mtd, p, &ecc_code[i], NULL);
85+ if (stat < 0)
86+ mtd->ecc_stats.failed++;
87+ else
88+ mtd->ecc_stats.corrected += stat;
89+ }
90+
91+ return 0;
92+}
93+
94+
95+/**
96  * nand_read_page_syndrome - [REPLACABLE] hardware ecc syndrom based page read
97  * @mtd: mtd info structure
98  * @chip: nand chip info structure
99@@ -1194,7 +1265,7 @@ static int nand_do_read_ops(struct mtd_i
100                 ret = chip->ecc.read_page_raw(mtd, chip,
101                                   bufpoi, page);
102             else if (!aligned && NAND_SUBPAGE_READ(chip) && !oob)
103- ret = chip->ecc.read_subpage(mtd, chip, col, bytes, bufpoi);
104+ ret = chip->ecc.read_subpage(mtd, chip, col, bytes, bufpoi, page);
105             else
106                 ret = chip->ecc.read_page(mtd, chip, bufpoi,
107                               page);
108@@ -2742,8 +2813,11 @@ int nand_scan_tail(struct mtd_info *mtd)
109                    "Hardware ECC not possible\n");
110             BUG();
111         }
112- if (!chip->ecc.read_page)
113+ if (!chip->ecc.read_page) {
114             chip->ecc.read_page = nand_read_page_hwecc_oob_first;
115+ if (!chip->ecc.read_subpage)
116+ chip->ecc.read_subpage = nand_read_subpage_hwecc_oob_first;
117+ }
118
119     case NAND_ECC_HW:
120         /* Use standard hwecc read page function ? */
121--- a/include/linux/mtd/nand.h
122@@ -178,9 +178,9 @@ typedef enum {
123 #define NAND_MUST_PAD(chip) (!(chip->options & NAND_NO_PADDING))
124 #define NAND_HAS_CACHEPROG(chip) ((chip->options & NAND_CACHEPRG))
125 #define NAND_HAS_COPYBACK(chip) ((chip->options & NAND_COPYBACK))
126-/* Large page NAND with SOFT_ECC should support subpage reads */
127-#define NAND_SUBPAGE_READ(chip) ((chip->ecc.mode == NAND_ECC_SOFT) \
128- && (chip->page_shift > 9))
129+/* Large page NAND with read_subpage set should support subpage reads */
130+#define NAND_SUBPAGE_READ(chip) (((chip)->ecc.read_subpage) \
131+ && ((chip)->page_shift > 9))
132
133 /* Mask to zero out the chip options, which come from the id table */
134 #define NAND_CHIPOPTIONS_MSK (0x0000ffff & ~NAND_NO_AUTOINCR)
135@@ -282,7 +282,7 @@ struct nand_ecc_ctrl {
136     int (*read_subpage)(struct mtd_info *mtd,
137                          struct nand_chip *chip,
138                          uint32_t offs, uint32_t len,
139- uint8_t *buf);
140+ uint8_t *buf, int page);
141     void (*write_page)(struct mtd_info *mtd,
142                           struct nand_chip *chip,
143                           const uint8_t *buf);
target/linux/xburst/patches-2.6.32/904-NAND-Optimize-reading-the-eec-data-for-the-JZ4740-ev.patch
1From 3eeeee7302a9b25de1eeabd901d3bb678d9983d9 Mon Sep 17 00:00:00 2001
2From: Lars-Peter Clausen <lars@metafoo.de>
3Date: Sat, 26 Feb 2011 15:32:30 +0100
4Subject: [PATCH 4/4] NAND: Optimize reading the eec data for the JZ4740 (evil hack)
5
6We know that the ecc data is continuous, this allows us to only read the ecc
7data instead of the whole oob section, which slightly improves performance.
8
9Note that this is an evil hack, which will break platforms where the ecc data is
10non-continuous.
11---
12 drivers/mtd/nand/nand_base.c | 16 +++++-----------
13 1 files changed, 5 insertions(+), 11 deletions(-)
14
15--- a/drivers/mtd/nand/nand_base.c
16@@ -1011,8 +1011,8 @@ static int nand_read_page_hwecc_oob_firs
17     /* Read the OOB area first */
18     /* Read the OOB area first */
19     if (mtd->writesize > 512) {
20- chip->cmdfunc(mtd, NAND_CMD_READ0, mtd->writesize, page);
21- chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
22+ chip->cmdfunc(mtd, NAND_CMD_READ0, mtd->writesize + eccpos[0], page);
23+ chip->read_buf(mtd, ecc_code, chip->ecc.total);
24         chip->cmdfunc(mtd, NAND_CMD_RNDOUT, 0, -1);
25     } else {
26         chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);
27@@ -1020,9 +1020,6 @@ static int nand_read_page_hwecc_oob_firs
28         chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page);
29     }
30
31- for (i = 0; i < chip->ecc.total; i++)
32- ecc_code[i] = chip->oob_poi[eccpos[i]];
33-
34     for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
35         int stat;
36
37@@ -1077,8 +1074,8 @@ static int nand_read_subpage_hwecc_oob_f
38
39     /* Read the OOB area first */
40     if (mtd->writesize > 512) {
41- chip->cmdfunc(mtd, NAND_CMD_READ0, mtd->writesize, page);
42- chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
43+ chip->cmdfunc(mtd, NAND_CMD_READ0, mtd->writesize + eccpos[0], page);
44+ chip->read_buf(mtd, ecc_code, chip->ecc.total);
45         chip->cmdfunc(mtd, NAND_CMD_RNDOUT, data_col_addr, -1);
46     } else {
47         chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);
48@@ -1086,9 +1083,6 @@ static int nand_read_subpage_hwecc_oob_f
49         chip->cmdfunc(mtd, NAND_CMD_READ0, data_col_addr, page);
50     }
51
52- for (i = 0; i < chip->ecc.total; i++)
53- ecc_code[i] = chip->oob_poi[eccpos[i]];
54-
55     p = bufpoi + data_col_addr;
56
57     for (i = eccbytes * start_step; num_steps; num_steps--, i += eccbytes, p += eccsize) {

Archive Download the corresponding diff file



interactive