kernel: update 4.1 to 4.1.5
[openwrt/svn-archive/archive.git] / target / linux / sunxi / patches-4.1 / 114-mtd-randomizer-into-nand-framework.patch
index 7d1bdbd9aa5bbd27601ae0312d255437e241370a..173bd1eb49e365d49d7c158d68e3d79223769496 100644 (file)
@@ -34,11 +34,9 @@ Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  include/linux/mtd/nand.h     |  98 +++++++++++++++
  2 files changed, 321 insertions(+), 55 deletions(-)
 
-diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
-index 8a5d12e..577cb9e 100644
 --- a/drivers/mtd/nand/nand_base.c
 +++ b/drivers/mtd/nand/nand_base.c
-@@ -1102,6 +1102,62 @@ int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
+@@ -1102,6 +1102,62 @@ out:
  EXPORT_SYMBOL(nand_lock);
  
  /**
@@ -119,7 +117,7 @@ index 8a5d12e..577cb9e 100644
        return 0;
  }
  
-@@ -1270,28 +1331,40 @@ static int nand_read_page_raw_syndrome(struct mtd_info *mtd,
+@@ -1270,28 +1331,40 @@ static int nand_read_page_raw_syndrome(s
        int eccbytes = chip->cur_ecc->bytes;
        uint8_t *oob = chip->oob_poi;
        int steps, size;
@@ -166,7 +164,7 @@ index 8a5d12e..577cb9e 100644
  
        return 0;
  }
-@@ -1380,7 +1453,8 @@ static int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip,
+@@ -1380,7 +1453,8 @@ static int nand_read_subpage(struct mtd_
                chip->cmdfunc(mtd, NAND_CMD_RNDOUT, data_col_addr, -1);
  
        p = bufpoi + data_col_addr;
@@ -176,7 +174,7 @@ index 8a5d12e..577cb9e 100644
  
        /* Calculate ECC */
        for (i = 0; i < eccfrag_len;
-@@ -1399,7 +1473,8 @@ static int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip,
+@@ -1399,7 +1473,8 @@ static int nand_read_subpage(struct mtd_
        }
        if (gaps) {
                chip->cmdfunc(mtd, NAND_CMD_RNDOUT, mtd->writesize, -1);
@@ -186,7 +184,7 @@ index 8a5d12e..577cb9e 100644
        } else {
                /*
                 * Send the command to read the particular ECC bytes take care
-@@ -1415,7 +1490,8 @@ static int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip,
+@@ -1415,7 +1490,8 @@ static int nand_read_subpage(struct mtd_
  
                chip->cmdfunc(mtd, NAND_CMD_RNDOUT,
                                        mtd->writesize + aligned_pos, -1);
@@ -196,7 +194,7 @@ index 8a5d12e..577cb9e 100644
        }
  
        for (i = 0; i < eccfrag_len; i++)
-@@ -1436,6 +1512,7 @@ static int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip,
+@@ -1436,6 +1512,7 @@ static int nand_read_subpage(struct mtd_
                        max_bitflips = max_t(unsigned int, max_bitflips, stat);
                }
        }
@@ -204,7 +202,7 @@ index 8a5d12e..577cb9e 100644
        return max_bitflips;
  }
  
-@@ -1460,13 +1537,17 @@ static int nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
+@@ -1460,13 +1537,17 @@ static int nand_read_page_hwecc(struct m
        uint8_t *ecc_code = chip->buffers->ecccode;
        uint32_t *eccpos = chip->cur_ecc->layout->eccpos;
        unsigned int max_bitflips = 0;
@@ -224,7 +222,7 @@ index 8a5d12e..577cb9e 100644
  
        for (i = 0; i < chip->cur_ecc->total; i++)
                ecc_code[i] = chip->oob_poi[eccpos[i]];
-@@ -1486,6 +1567,7 @@ static int nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
+@@ -1486,6 +1567,7 @@ static int nand_read_page_hwecc(struct m
                        max_bitflips = max_t(unsigned int, max_bitflips, stat);
                }
        }
@@ -232,7 +230,7 @@ index 8a5d12e..577cb9e 100644
        return max_bitflips;
  }
  
-@@ -1514,11 +1596,14 @@ static int nand_read_page_hwecc_oob_first(struct mtd_info *mtd,
+@@ -1514,11 +1596,14 @@ static int nand_read_page_hwecc_oob_firs
        uint32_t *eccpos = chip->cur_ecc->layout->eccpos;
        uint8_t *ecc_calc = chip->buffers->ecccalc;
        unsigned int max_bitflips = 0;
@@ -248,7 +246,7 @@ index 8a5d12e..577cb9e 100644
  
        for (i = 0; i < chip->cur_ecc->total; i++)
                ecc_code[i] = chip->oob_poi[eccpos[i]];
-@@ -1527,7 +1612,8 @@ static int nand_read_page_hwecc_oob_first(struct mtd_info *mtd,
+@@ -1527,7 +1612,8 @@ static int nand_read_page_hwecc_oob_firs
                int stat;
  
                chip->cur_ecc->hwctl(mtd, NAND_ECC_READ);
@@ -258,7 +256,7 @@ index 8a5d12e..577cb9e 100644
                chip->cur_ecc->calculate(mtd, p, &ecc_calc[i]);
  
                stat = chip->cur_ecc->correct(mtd, p, &ecc_code[i], NULL);
-@@ -1538,6 +1624,7 @@ static int nand_read_page_hwecc_oob_first(struct mtd_info *mtd,
+@@ -1538,6 +1624,7 @@ static int nand_read_page_hwecc_oob_firs
                        max_bitflips = max_t(unsigned int, max_bitflips, stat);
                }
        }
@@ -266,7 +264,7 @@ index 8a5d12e..577cb9e 100644
        return max_bitflips;
  }
  
-@@ -1561,20 +1648,27 @@ static int nand_read_page_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
+@@ -1561,20 +1648,27 @@ static int nand_read_page_syndrome(struc
        uint8_t *p = buf;
        uint8_t *oob = chip->oob_poi;
        unsigned int max_bitflips = 0;
@@ -297,7 +295,7 @@ index 8a5d12e..577cb9e 100644
                stat = chip->cur_ecc->correct(mtd, p, oob, NULL);
  
                if (stat < 0) {
-@@ -1587,29 +1681,36 @@ static int nand_read_page_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
+@@ -1587,29 +1681,36 @@ static int nand_read_page_syndrome(struc
                oob += eccbytes;
  
                if (chip->cur_ecc->postpad) {
@@ -339,7 +337,7 @@ index 8a5d12e..577cb9e 100644
        switch (ops->mode) {
  
        case MTD_OPS_PLACE_OOB:
-@@ -1737,6 +1838,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
+@@ -1737,6 +1838,7 @@ read_retry:
                         * Now read the page into the buffer.  Absent an error,
                         * the read methods return max bitflips per ecc step.
                         */
@@ -347,7 +345,7 @@ index 8a5d12e..577cb9e 100644
                        if (unlikely(ops->mode == MTD_OPS_RAW))
                                ret = chip->cur_ecc->read_page_raw(mtd, chip,
                                                                bufpoi,
-@@ -1753,6 +1855,8 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
+@@ -1753,6 +1855,8 @@ read_retry:
                                                               bufpoi,
                                                               oob_required,
                                                               page);
@@ -356,7 +354,7 @@ index 8a5d12e..577cb9e 100644
                        if (ret < 0) {
                                if (use_bufpoi)
                                        /* Invalidate page cache */
-@@ -1780,8 +1884,8 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
+@@ -1780,8 +1884,8 @@ read_retry:
                                int toread = min(oobreadlen, max_oobsize);
  
                                if (toread) {
@@ -367,7 +365,7 @@ index 8a5d12e..577cb9e 100644
                                        oobreadlen -= toread;
                                }
                        }
-@@ -1909,12 +2013,15 @@ static int nand_part_read(struct mtd_info *mtd, loff_t from, size_t len,
+@@ -1909,12 +2013,15 @@ static int nand_part_read(struct mtd_inf
        nand_get_device(part->master, FL_READING);
        if (part->ecc)
                chip->cur_ecc = part->ecc;
@@ -383,7 +381,7 @@ index 8a5d12e..577cb9e 100644
        chip->cur_ecc = &chip->ecc;
        nand_release_device(part->master);
        return ret;
-@@ -1930,7 +2037,9 @@ static int nand_read_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
+@@ -1930,7 +2037,9 @@ static int nand_read_oob_std(struct mtd_
                             int page)
  {
        chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);
@@ -394,7 +392,7 @@ index 8a5d12e..577cb9e 100644
        return 0;
  }
  
-@@ -1949,7 +2058,7 @@ static int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
+@@ -1949,7 +2058,7 @@ static int nand_read_oob_syndrome(struct
                    chip->cur_ecc->postpad;
        int eccsize = chip->cur_ecc->size;
        uint8_t *bufpoi = chip->oob_poi;
@@ -403,7 +401,7 @@ index 8a5d12e..577cb9e 100644
  
        chip->cmdfunc(mtd, NAND_CMD_READ0, chip->cur_ecc->size, page);
        for (i = 0; i < chip->cur_ecc->steps; i++) {
-@@ -1962,12 +2071,17 @@ static int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
+@@ -1962,12 +2071,17 @@ static int nand_read_oob_syndrome(struct
                } else
                        sndrnd = 1;
                toread = min_t(int, length, chunk);
@@ -424,7 +422,7 @@ index 8a5d12e..577cb9e 100644
  
        return 0;
  }
-@@ -1986,7 +2100,9 @@ static int nand_write_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
+@@ -1986,7 +2100,9 @@ static int nand_write_oob_std(struct mtd
        int length = mtd->oobsize;
  
        chip->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->writesize, page);
@@ -435,7 +433,7 @@ index 8a5d12e..577cb9e 100644
        /* Send command to program the OOB data */
        chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1);
  
-@@ -2042,12 +2158,18 @@ static int nand_write_oob_syndrome(struct mtd_info *mtd,
+@@ -2042,12 +2158,18 @@ static int nand_write_oob_syndrome(struc
                } else
                        sndcmd = 1;
                len = min_t(int, length, chunk);
@@ -457,7 +455,7 @@ index 8a5d12e..577cb9e 100644
  
        chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1);
        status = chip->waitfunc(mtd, chip);
-@@ -2116,7 +2238,7 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
+@@ -2116,7 +2238,7 @@ static int nand_do_read_oob(struct mtd_i
                        break;
  
                len = min(len, readlen);
@@ -466,7 +464,7 @@ index 8a5d12e..577cb9e 100644
  
                if (chip->options & NAND_NEED_READRDY) {
                        /* Apply delay or wait for ready/busy pin */
-@@ -2226,6 +2348,8 @@ static int nand_part_read_oob(struct mtd_info *mtd, loff_t from,
+@@ -2226,6 +2348,8 @@ static int nand_part_read_oob(struct mtd
        nand_get_device(part->master, FL_READING);
        if (part->ecc)
                chip->cur_ecc = part->ecc;
@@ -475,7 +473,7 @@ index 8a5d12e..577cb9e 100644
  
        switch (ops->mode) {
        case MTD_OPS_PLACE_OOB:
-@@ -2243,6 +2367,7 @@ static int nand_part_read_oob(struct mtd_info *mtd, loff_t from,
+@@ -2243,6 +2367,7 @@ static int nand_part_read_oob(struct mtd
                ret = nand_do_read_ops(part->master, from, ops);
  
  out:
@@ -483,7 +481,7 @@ index 8a5d12e..577cb9e 100644
        chip->cur_ecc = &chip->ecc;
        nand_release_device(part->master);
        return ret;
-@@ -2261,9 +2386,11 @@ static int nand_part_read_oob(struct mtd_info *mtd, loff_t from,
+@@ -2261,9 +2386,11 @@ out:
  static int nand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
                                const uint8_t *buf, int oob_required)
  {
@@ -498,7 +496,7 @@ index 8a5d12e..577cb9e 100644
  
        return 0;
  }
-@@ -2285,28 +2412,39 @@ static int nand_write_page_raw_syndrome(struct mtd_info *mtd,
+@@ -2285,28 +2412,39 @@ static int nand_write_page_raw_syndrome(
        int eccbytes = chip->cur_ecc->bytes;
        uint8_t *oob = chip->oob_poi;
        int steps, size;
@@ -544,7 +542,7 @@ index 8a5d12e..577cb9e 100644
  
        return 0;
  }
-@@ -2353,17 +2491,21 @@ static int nand_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
+@@ -2353,17 +2491,21 @@ static int nand_write_page_hwecc(struct
        uint8_t *ecc_calc = chip->buffers->ecccalc;
        const uint8_t *p = buf;
        uint32_t *eccpos = chip->cur_ecc->layout->eccpos;
@@ -568,7 +566,7 @@ index 8a5d12e..577cb9e 100644
  
        return 0;
  }
-@@ -2399,7 +2541,9 @@ static int nand_write_subpage_hwecc(struct mtd_info *mtd,
+@@ -2399,7 +2541,9 @@ static int nand_write_subpage_hwecc(stru
                chip->cur_ecc->hwctl(mtd, NAND_ECC_WRITE);
  
                /* write data (untouched subpages already masked by 0xFF) */
@@ -579,7 +577,7 @@ index 8a5d12e..577cb9e 100644
  
                /* mask ECC of un-touched subpages by padding 0xFF */
                if ((step < start_step) || (step > end_step))
-@@ -2424,7 +2568,8 @@ static int nand_write_subpage_hwecc(struct mtd_info *mtd,
+@@ -2424,7 +2568,8 @@ static int nand_write_subpage_hwecc(stru
                chip->oob_poi[eccpos[i]] = ecc_calc[i];
  
        /* write OOB buffer to NAND device */
@@ -589,7 +587,7 @@ index 8a5d12e..577cb9e 100644
  
        return 0;
  }
-@@ -2449,31 +2594,42 @@ static int nand_write_page_syndrome(struct mtd_info *mtd,
+@@ -2449,31 +2594,42 @@ static int nand_write_page_syndrome(stru
        int eccsteps = chip->cur_ecc->steps;
        const uint8_t *p = buf;
        uint8_t *oob = chip->oob_poi;
@@ -638,7 +636,7 @@ index 8a5d12e..577cb9e 100644
  
        return 0;
  }
-@@ -2504,6 +2660,7 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
+@@ -2504,6 +2660,7 @@ static int nand_write_page(struct mtd_in
  
        chip->cmdfunc(mtd, NAND_CMD_SEQIN, 0x00, page);
  
@@ -646,7 +644,7 @@ index 8a5d12e..577cb9e 100644
        if (unlikely(raw))
                status = chip->cur_ecc->write_page_raw(mtd, chip, buf,
                                                       oob_required);
-@@ -2514,6 +2671,7 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
+@@ -2514,6 +2671,7 @@ static int nand_write_page(struct mtd_in
        else
                status = chip->cur_ecc->write_page(mtd, chip, buf,
                                                   oob_required);
@@ -654,7 +652,7 @@ index 8a5d12e..577cb9e 100644
  
        if (status < 0)
                return status;
-@@ -2803,6 +2961,8 @@ static int panic_nand_part_write(struct mtd_info *mtd, loff_t to, size_t len,
+@@ -2803,6 +2961,8 @@ static int panic_nand_part_write(struct
        panic_nand_get_device(chip, part->master, FL_WRITING);
        if (part->ecc)
                chip->cur_ecc = part->ecc;
@@ -663,7 +661,7 @@ index 8a5d12e..577cb9e 100644
  
        ops.len = len;
        ops.datbuf = (uint8_t *)buf;
-@@ -2811,6 +2971,7 @@ static int panic_nand_part_write(struct mtd_info *mtd, loff_t to, size_t len,
+@@ -2811,6 +2971,7 @@ static int panic_nand_part_write(struct
  
        ret = nand_do_write_ops(part->master, to, &ops);
  
@@ -671,7 +669,7 @@ index 8a5d12e..577cb9e 100644
        chip->cur_ecc = &chip->ecc;
        *retlen = ops.retlen;
        return ret;
-@@ -2865,12 +3026,15 @@ static int nand_part_write(struct mtd_info *mtd, loff_t to, size_t len,
+@@ -2865,12 +3026,15 @@ static int nand_part_write(struct mtd_in
        nand_get_device(part->master, FL_WRITING);
        if (part->ecc)
                chip->cur_ecc = part->ecc;
@@ -687,7 +685,7 @@ index 8a5d12e..577cb9e 100644
        chip->cur_ecc = &chip->ecc;
        nand_release_device(part->master);
        return ret;
-@@ -3032,6 +3196,8 @@ static int nand_part_write_oob(struct mtd_info *mtd, loff_t to,
+@@ -3032,6 +3196,8 @@ static int nand_part_write_oob(struct mt
        nand_get_device(part->master, FL_WRITING);
        if (part->ecc)
                chip->cur_ecc = part->ecc;
@@ -696,7 +694,7 @@ index 8a5d12e..577cb9e 100644
  
        switch (ops->mode) {
        case MTD_OPS_PLACE_OOB:
-@@ -3049,6 +3215,7 @@ static int nand_part_write_oob(struct mtd_info *mtd, loff_t to,
+@@ -3049,6 +3215,7 @@ static int nand_part_write_oob(struct mt
                ret = nand_do_write_ops(part->master, to, ops);
  
  out:
@@ -712,11 +710,9 @@ index 8a5d12e..577cb9e 100644
  
        /* Allow subpage writes up to ecc.steps. Not possible for MLC flash */
        if (!(chip->options & NAND_NO_SUBPAGE_WRITE) && nand_is_slc(chip)) {
-diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
-index 4f7ca8d..6cbd06a3 100644
 --- a/include/linux/mtd/nand.h
 +++ b/include/linux/mtd/nand.h
-@@ -539,6 +539,64 @@ void nand_page_set_status(struct mtd_info *mtd, int page,
+@@ -539,6 +539,64 @@ void nand_page_set_status(struct mtd_inf
  
  int nand_pst_create(struct mtd_info *mtd);
  
@@ -807,7 +803,7 @@ index 4f7ca8d..6cbd06a3 100644
        void (*release)(struct nand_part *part);
  };
  
-@@ -902,6 +965,41 @@ extern int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
+@@ -902,6 +965,41 @@ extern int nand_erase_nand(struct mtd_in
  extern int nand_do_read(struct mtd_info *mtd, loff_t from, size_t len,
                        size_t *retlen, uint8_t *buf);