Date:2011-04-26 05:16:09 (8 years 7 months ago)
Author:Xiangfu Liu
Commit:06082c3b5af85beb8b070be7897cebbb49e41ba1
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.37/901-ubi-Read-only-the-vid-header-instead-of-the-whole-pa.patch (1 diff)
target/linux/xburst/patches-2.6.37/902-NAND-Optimize-NAND_ECC_HW_OOB_FIRST-read.patch (1 diff)
target/linux/xburst/patches-2.6.37/903-NAND-Add-support-for-subpage-reads-for-NAND_ECC_HW_O.patch (1 diff)
target/linux/xburst/patches-2.6.37/904-NAND-Optimize-reading-the-eec-data-for-the-JZ4740-ev.patch (1 diff)

Change Details

target/linux/xburst/patches-2.6.37/901-ubi-Read-only-the-vid-header-instead-of-the-whole-pa.patch
1--- a/drivers/mtd/ubi/io.c
2@@ -995,7 +995,7 @@ int ubi_io_read_vid_hdr(struct ubi_devic
3
4     p = (char *)vid_hdr - ubi->vid_hdr_shift;
5     read_err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset,
6- ubi->vid_hdr_alsize);
7+ UBI_VID_HDR_SIZE + ubi->vid_hdr_shift);
8     if (read_err && read_err != UBI_IO_BITFLIPS && read_err != -EBADMSG)
9         return read_err;
10
target/linux/xburst/patches-2.6.37/902-NAND-Optimize-NAND_ECC_HW_OOB_FIRST-read.patch
1--- a/drivers/mtd/nand/nand_base.c
2@@ -1313,9 +1313,15 @@ static int nand_read_page_hwecc_oob_firs
3     uint8_t *ecc_calc = chip->buffers->ecccalc;
4
5     /* Read the OOB area first */
6- chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);
7- chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
8- chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page);
9+ if (mtd->writesize > 512) {
10+ chip->cmdfunc(mtd, NAND_CMD_READ0, mtd->writesize, page);
11+ chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
12+ chip->cmdfunc(mtd, NAND_CMD_RNDOUT, 0, -1);
13+ } else {
14+ chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);
15+ chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
16+ chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page);
17+ }
18
19     for (i = 0; i < chip->ecc.total; i++)
20         ecc_code[i] = chip->oob_poi[eccpos[i]];
21@@ -1485,7 +1491,7 @@ static int nand_do_read_ops(struct mtd_i
22         if (realpage != chip->pagebuf || oob) {
23             bufpoi = aligned ? buf : chip->buffers->databuf;
24
25- if (likely(sndcmd)) {
26+ if (likely(sndcmd) && chip->ecc.mode != NAND_ECC_HW_OOB_FIRST) {
27                 chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page);
28                 sndcmd = 0;
29             }
target/linux/xburst/patches-2.6.37/903-NAND-Add-support-for-subpage-reads-for-NAND_ECC_HW_O.patch
1--- a/drivers/mtd/nand/nand_base.c
2@@ -1164,7 +1164,7 @@ static int nand_read_page_swecc(struct m
3  * @bufpoi: buffer to store read data
4  */
5 static int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip,
6- uint32_t data_offs, uint32_t readlen, uint8_t *bufpoi)
7+ uint32_t data_offs, uint32_t readlen, uint8_t *bufpoi, int page)
8 {
9     int start_step, end_step, num_steps;
10     uint32_t *eccpos = chip->ecc.layout->eccpos;
11@@ -1342,6 +1342,75 @@ static int nand_read_page_hwecc_oob_firs
12     return 0;
13 }
14
15+ /**
16+ * nand_read_subpage_hwecc_oob_first - [REPLACABLE] hw ecc based sub-page read function
17+ * @mtd: mtd info structure
18+ * @chip: nand chip info structure
19+ * @data_offs: offset of requested data within the page
20+ * @readlen: data length
21+ * @bufpoi: buffer to store read data
22+ * @page: page number to read
23+ *
24+ * Hardware ECC for large page chips, require OOB to be read first.
25+ * For this ECC mode, the write_page method is re-used from ECC_HW.
26+ * These methods read/write ECC from the OOB area, unlike the
27+ * ECC_HW_SYNDROME support with multiple ECC steps, follows the
28+ * "infix ECC" scheme and reads/writes ECC from the data area, by
29+ * overwriting the NAND manufacturer bad block markings.
30+ */
31+static int nand_read_subpage_hwecc_oob_first(struct mtd_info *mtd, struct nand_chip *chip,
32+ uint32_t data_offs, uint32_t readlen, uint8_t *bufpoi, int page)
33+{
34+ int start_step, end_step, num_steps;
35+ uint32_t *eccpos = chip->ecc.layout->eccpos;
36+ uint8_t *p;
37+ int data_col_addr;
38+ int eccsize = chip->ecc.size;
39+ int eccbytes = chip->ecc.bytes;
40+ uint8_t *ecc_code = chip->buffers->ecccode;
41+ uint8_t *ecc_calc = chip->buffers->ecccalc;
42+ int i;
43+
44+ /* Column address wihin the page aligned to ECC size */
45+ start_step = data_offs / chip->ecc.size;
46+ end_step = (data_offs + readlen - 1) / chip->ecc.size;
47+ num_steps = end_step - start_step + 1;
48+
49+ data_col_addr = start_step * chip->ecc.size;
50+
51+ /* Read the OOB area first */
52+ if (mtd->writesize > 512) {
53+ chip->cmdfunc(mtd, NAND_CMD_READ0, mtd->writesize, page);
54+ chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
55+ chip->cmdfunc(mtd, NAND_CMD_RNDOUT, data_col_addr, -1);
56+ } else {
57+ chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);
58+ chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
59+ chip->cmdfunc(mtd, NAND_CMD_READ0, data_col_addr, page);
60+ }
61+
62+ for (i = 0; i < chip->ecc.total; i++)
63+ ecc_code[i] = chip->oob_poi[eccpos[i]];
64+
65+ p = bufpoi + data_col_addr;
66+
67+ for (i = eccbytes * start_step; num_steps; num_steps--, i += eccbytes, p += eccsize) {
68+ int stat;
69+
70+ chip->ecc.hwctl(mtd, NAND_ECC_READ);
71+ chip->read_buf(mtd, p, eccsize);
72+ chip->ecc.calculate(mtd, p, &ecc_calc[i]);
73+
74+ stat = chip->ecc.correct(mtd, p, &ecc_code[i], NULL);
75+ if (stat < 0)
76+ mtd->ecc_stats.failed++;
77+ else
78+ mtd->ecc_stats.corrected += stat;
79+ }
80+
81+ return 0;
82+}
83+
84 /**
85  * nand_read_page_syndrome - [REPLACABLE] hardware ecc syndrom based page read
86  * @mtd: mtd info structure
87@@ -1502,7 +1571,7 @@ static int nand_do_read_ops(struct mtd_i
88                                   bufpoi, page);
89             else if (!aligned && NAND_SUBPAGE_READ(chip) && !oob)
90                 ret = chip->ecc.read_subpage(mtd, chip,
91- col, bytes, bufpoi);
92+ col, bytes, bufpoi, page);
93             else
94                 ret = chip->ecc.read_page(mtd, chip, bufpoi,
95                               page);
96@@ -3288,8 +3357,11 @@ int nand_scan_tail(struct mtd_info *mtd)
97                    "Hardware ECC not possible\n");
98             BUG();
99         }
100- if (!chip->ecc.read_page)
101+ if (!chip->ecc.read_page) {
102             chip->ecc.read_page = nand_read_page_hwecc_oob_first;
103+ if (!chip->ecc.read_subpage)
104+ chip->ecc.read_subpage = nand_read_subpage_hwecc_oob_first;
105+ }
106
107     case NAND_ECC_HW:
108         /* Use standard hwecc read page function ? */
109--- a/include/linux/mtd/nand.h
110@@ -210,9 +210,9 @@ typedef enum {
111 #define NAND_MUST_PAD(chip) (!(chip->options & NAND_NO_PADDING))
112 #define NAND_HAS_CACHEPROG(chip) ((chip->options & NAND_CACHEPRG))
113 #define NAND_HAS_COPYBACK(chip) ((chip->options & NAND_COPYBACK))
114-/* Large page NAND with SOFT_ECC should support subpage reads */
115-#define NAND_SUBPAGE_READ(chip) ((chip->ecc.mode == NAND_ECC_SOFT) \
116- && (chip->page_shift > 9))
117+/* Large page NAND with read_subpage should support subpage reads */
118+#define NAND_SUBPAGE_READ(chip) (((chip)->ecc.read_subpage) \
119+ && ((chip)->page_shift > 9))
120
121 /* Mask to zero out the chip options, which come from the id table */
122 #define NAND_CHIPOPTIONS_MSK (0x0000ffff & ~NAND_NO_AUTOINCR)
123@@ -374,7 +374,7 @@ struct nand_ecc_ctrl {
124     int (*read_page)(struct mtd_info *mtd, struct nand_chip *chip,
125             uint8_t *buf, int page);
126     int (*read_subpage)(struct mtd_info *mtd, struct nand_chip *chip,
127- uint32_t offs, uint32_t len, uint8_t *buf);
128+ uint32_t offs, uint32_t len, uint8_t *buf, int page);
129     void (*write_page)(struct mtd_info *mtd, struct nand_chip *chip,
130             const uint8_t *buf);
131     int (*read_oob)(struct mtd_info *mtd, struct nand_chip *chip, int page,
target/linux/xburst/patches-2.6.37/904-NAND-Optimize-reading-the-eec-data-for-the-JZ4740-ev.patch
1--- a/drivers/mtd/nand/nand_base.c
2@@ -1314,8 +1314,8 @@ static int nand_read_page_hwecc_oob_firs
3
4     /* Read the OOB area first */
5     if (mtd->writesize > 512) {
6- chip->cmdfunc(mtd, NAND_CMD_READ0, mtd->writesize, page);
7- chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
8+ chip->cmdfunc(mtd, NAND_CMD_READ0, mtd->writesize + eccpos[0], page);
9+ chip->read_buf(mtd, ecc_code, chip->ecc.total);
10         chip->cmdfunc(mtd, NAND_CMD_RNDOUT, 0, -1);
11     } else {
12         chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);
13@@ -1323,9 +1323,6 @@ static int nand_read_page_hwecc_oob_firs
14         chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page);
15     }
16
17- for (i = 0; i < chip->ecc.total; i++)
18- ecc_code[i] = chip->oob_poi[eccpos[i]];
19-
20     for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
21         int stat;
22
23@@ -1380,8 +1377,8 @@ static int nand_read_subpage_hwecc_oob_f
24
25     /* Read the OOB area first */
26     if (mtd->writesize > 512) {
27- chip->cmdfunc(mtd, NAND_CMD_READ0, mtd->writesize, page);
28- chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
29+ chip->cmdfunc(mtd, NAND_CMD_READ0, mtd->writesize + eccpos[0], page);
30+ chip->read_buf(mtd, ecc_code, chip->ecc.total);
31         chip->cmdfunc(mtd, NAND_CMD_RNDOUT, data_col_addr, -1);
32     } else {
33         chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);
34@@ -1389,9 +1386,6 @@ static int nand_read_subpage_hwecc_oob_f
35         chip->cmdfunc(mtd, NAND_CMD_READ0, data_col_addr, page);
36     }
37
38- for (i = 0; i < chip->ecc.total; i++)
39- ecc_code[i] = chip->oob_poi[eccpos[i]];
40-
41     p = bufpoi + data_col_addr;
42
43     for (i = eccbytes * start_step; num_steps; num_steps--, i += eccbytes, p += eccsize) {

Archive Download the corresponding diff file



interactive