diff options
author | John Crispin <john@phrozen.org> | 2016-06-17 03:46:25 +0200 |
---|---|---|
committer | John Crispin <john@phrozen.org> | 2016-06-17 04:13:08 +0200 |
commit | e81020c3173a108fb9045af3989a74f51997b44e (patch) | |
tree | 0a32d824e7cbeca650bf590c9e71288caa681691 /target/linux/mediatek/patches-4.4 | |
parent | 16e04fd1b4572ad9f6cf006ff6dc895711d5d6cd (diff) | |
download | upstream-e81020c3173a108fb9045af3989a74f51997b44e.tar.gz upstream-e81020c3173a108fb9045af3989a74f51997b44e.tar.bz2 upstream-e81020c3173a108fb9045af3989a74f51997b44e.zip |
medaitek: convert the NAND target to UBI
Signed-off-by: John Crispin <john@phrozen.org>
Diffstat (limited to 'target/linux/mediatek/patches-4.4')
-rw-r--r-- | target/linux/mediatek/patches-4.4/0072-mtd-backport-v4.7-0day-patches-from-Boris.patch | 177 | ||||
-rw-r--r-- | target/linux/mediatek/patches-4.4/0103-nand_fixes.patch | 22 |
2 files changed, 22 insertions, 177 deletions
diff --git a/target/linux/mediatek/patches-4.4/0072-mtd-backport-v4.7-0day-patches-from-Boris.patch b/target/linux/mediatek/patches-4.4/0072-mtd-backport-v4.7-0day-patches-from-Boris.patch index ccbf8d0fb2..7e7a5de1c8 100644 --- a/target/linux/mediatek/patches-4.4/0072-mtd-backport-v4.7-0day-patches-from-Boris.patch +++ b/target/linux/mediatek/patches-4.4/0072-mtd-backport-v4.7-0day-patches-from-Boris.patch @@ -31,11 +31,6 @@ Signed-off-by: John Crispin <blogic@openwrt.org> drivers/mtd/tests/mtd_nandecctest.c | 2 +- drivers/mtd/tests/oobtest.c | 49 ++- drivers/mtd/tests/pagetest.c | 3 +- - drivers/mtd/ubi/cdev.c | 4 +- - drivers/mtd/ubi/misc.c | 49 +++ - drivers/mtd/ubi/ubi.h | 16 +- - drivers/mtd/ubi/upd.c | 2 +- - drivers/mtd/ubi/wl.c | 21 +- include/linux/mtd/bbm.h | 1 - include/linux/mtd/fsmc.h | 18 -- include/linux/mtd/inftl.h | 1 - @@ -4654,178 +4649,6 @@ Signed-off-by: John Crispin <blogic@openwrt.org> addr0 = 0; for (i = 0; i < ebcnt && bbt[i]; ++i) ---- a/drivers/mtd/ubi/cdev.c -+++ b/drivers/mtd/ubi/cdev.c -@@ -174,9 +174,9 @@ static int vol_cdev_fsync(struct file *f - struct ubi_device *ubi = desc->vol->ubi; - struct inode *inode = file_inode(file); - int err; -- mutex_lock(&inode->i_mutex); -+ inode_lock(inode); - err = ubi_sync(ubi->ubi_num); -- mutex_unlock(&inode->i_mutex); -+ inode_unlock(inode); - return err; - } - ---- a/drivers/mtd/ubi/misc.c -+++ b/drivers/mtd/ubi/misc.c -@@ -153,3 +153,52 @@ int ubi_check_pattern(const void *buf, u - return 0; - return 1; - } -+ -+/* Normal UBI messages */ -+void ubi_msg(const struct ubi_device *ubi, const char *fmt, ...) -+{ -+ struct va_format vaf; -+ va_list args; -+ -+ va_start(args, fmt); -+ -+ vaf.fmt = fmt; -+ vaf.va = &args; -+ -+ pr_notice(UBI_NAME_STR "%d: %pV\n", ubi->ubi_num, &vaf); -+ -+ va_end(args); -+} -+ -+/* UBI warning messages */ -+void ubi_warn(const struct ubi_device *ubi, const char *fmt, ...) -+{ -+ struct va_format vaf; -+ va_list args; -+ -+ va_start(args, fmt); -+ -+ vaf.fmt = fmt; -+ vaf.va = &args; -+ -+ pr_warn(UBI_NAME_STR "%d warning: %ps: %pV\n", -+ ubi->ubi_num, __builtin_return_address(0), &vaf); -+ -+ va_end(args); -+} -+ -+/* UBI error messages */ -+void ubi_err(const struct ubi_device *ubi, const char *fmt, ...) -+{ -+ struct va_format vaf; -+ va_list args; -+ -+ va_start(args, fmt); -+ -+ vaf.fmt = fmt; -+ vaf.va = &args; -+ -+ pr_err(UBI_NAME_STR "%d error: %ps: %pV\n", -+ ubi->ubi_num, __builtin_return_address(0), &vaf); -+ va_end(args); -+} ---- a/drivers/mtd/ubi/ubi.h -+++ b/drivers/mtd/ubi/ubi.h -@@ -49,15 +49,19 @@ - /* UBI name used for character devices, sysfs, etc */ - #define UBI_NAME_STR "ubi" - -+struct ubi_device; -+ - /* Normal UBI messages */ --#define ubi_msg(ubi, fmt, ...) pr_notice(UBI_NAME_STR "%d: " fmt "\n", \ -- ubi->ubi_num, ##__VA_ARGS__) -+__printf(2, 3) -+void ubi_msg(const struct ubi_device *ubi, const char *fmt, ...); -+ - /* UBI warning messages */ --#define ubi_warn(ubi, fmt, ...) pr_warn(UBI_NAME_STR "%d warning: %s: " fmt "\n", \ -- ubi->ubi_num, __func__, ##__VA_ARGS__) -+__printf(2, 3) -+void ubi_warn(const struct ubi_device *ubi, const char *fmt, ...); -+ - /* UBI error messages */ --#define ubi_err(ubi, fmt, ...) pr_err(UBI_NAME_STR "%d error: %s: " fmt "\n", \ -- ubi->ubi_num, __func__, ##__VA_ARGS__) -+__printf(2, 3) -+void ubi_err(const struct ubi_device *ubi, const char *fmt, ...); - - /* Background thread name pattern */ - #define UBI_BGT_NAME_PATTERN "ubi_bgt%dd" ---- a/drivers/mtd/ubi/wl.c -+++ b/drivers/mtd/ubi/wl.c -@@ -628,6 +628,7 @@ static int do_sync_erase(struct ubi_devi - return __erase_worker(ubi, &wl_wrk); - } - -+static int ensure_wear_leveling(struct ubi_device *ubi, int nested); - /** - * wear_leveling_worker - wear-leveling worker function. - * @ubi: UBI device description object -@@ -649,6 +650,7 @@ static int wear_leveling_worker(struct u - #endif - struct ubi_wl_entry *e1, *e2; - struct ubi_vid_hdr *vid_hdr; -+ int dst_leb_clean = 0; - - kfree(wrk); - if (shutdown) -@@ -753,6 +755,7 @@ static int wear_leveling_worker(struct u - - err = ubi_io_read_vid_hdr(ubi, e1->pnum, vid_hdr, 0); - if (err && err != UBI_IO_BITFLIPS) { -+ dst_leb_clean = 1; - if (err == UBI_IO_FF) { - /* - * We are trying to move PEB without a VID header. UBI -@@ -798,10 +801,12 @@ static int wear_leveling_worker(struct u - * protection queue. - */ - protect = 1; -+ dst_leb_clean = 1; - goto out_not_moved; - } - if (err == MOVE_RETRY) { - scrubbing = 1; -+ dst_leb_clean = 1; - goto out_not_moved; - } - if (err == MOVE_TARGET_BITFLIPS || err == MOVE_TARGET_WR_ERR || -@@ -827,6 +832,7 @@ static int wear_leveling_worker(struct u - ubi->erroneous_peb_count); - goto out_error; - } -+ dst_leb_clean = 1; - erroneous = 1; - goto out_not_moved; - } -@@ -897,15 +903,24 @@ out_not_moved: - wl_tree_add(e1, &ubi->scrub); - else - wl_tree_add(e1, &ubi->used); -+ if (dst_leb_clean) { -+ wl_tree_add(e2, &ubi->free); -+ ubi->free_count++; -+ } -+ - ubi_assert(!ubi->move_to_put); - ubi->move_from = ubi->move_to = NULL; - ubi->wl_scheduled = 0; - spin_unlock(&ubi->wl_lock); - - ubi_free_vid_hdr(ubi, vid_hdr); -- err = do_sync_erase(ubi, e2, vol_id, lnum, torture); -- if (err) -- goto out_ro; -+ if (dst_leb_clean) { -+ ensure_wear_leveling(ubi, 1); -+ } else { -+ err = do_sync_erase(ubi, e2, vol_id, lnum, torture); -+ if (err) -+ goto out_ro; -+ } - - mutex_unlock(&ubi->move_mutex); - return 0; --- a/include/linux/mtd/bbm.h +++ b/include/linux/mtd/bbm.h @@ -166,7 +166,6 @@ struct bbm_info { diff --git a/target/linux/mediatek/patches-4.4/0103-nand_fixes.patch b/target/linux/mediatek/patches-4.4/0103-nand_fixes.patch new file mode 100644 index 0000000000..5e18fb4760 --- /dev/null +++ b/target/linux/mediatek/patches-4.4/0103-nand_fixes.patch @@ -0,0 +1,22 @@ +--- a/drivers/mtd/nand/mtk_nand.c ++++ b/drivers/mtd/nand/mtk_nand.c +@@ -1017,8 +1017,8 @@ + if (section >= eccsteps) + return -ERANGE; + +- oob_region->length = fdm->reg_size - fdm->ecc_size; +- oob_region->offset = section * fdm->reg_size + fdm->ecc_size; ++ oob_region->length = fdm->reg_size - 1; ++ oob_region->offset = section * fdm->reg_size + 1; + + return 0; + } +@@ -1058,7 +1058,7 @@ + fdm->reg_size = NFI_FDM_MAX_SIZE; + + /* bad block mark storage */ +- fdm->ecc_size = 1; ++ fdm->ecc_size = fdm->reg_size; + } + + static void mtk_nfc_set_bad_mark_ctl(struct mtk_nfc_bad_mark_ctl *bm_ctl, |