diff options
author | Rafał Miłecki <rafal@milecki.pl> | 2018-12-03 15:47:06 +0100 |
---|---|---|
committer | Rafał Miłecki <rafal@milecki.pl> | 2018-12-03 15:50:26 +0100 |
commit | f98fde2db4b3a6953c937e4fa8599da20e875b4b (patch) | |
tree | ef5f7a9cac1d8cc16dec6b3b14d9da03f03a424b | |
parent | e9a9b7d1ed76c88e097d5bc4dabf38735312558b (diff) | |
download | upstream-f98fde2db4b3a6953c937e4fa8599da20e875b4b.tar.gz upstream-f98fde2db4b3a6953c937e4fa8599da20e875b4b.tar.bz2 upstream-f98fde2db4b3a6953c937e4fa8599da20e875b4b.zip |
Revert "kernel: use add_mtd_partitions() helper when using OpenWrt parsers"
This reverts commit 7e88753ace0022bd56f77a7a647894f2936cf17b.
Using subpartitions (hierarchical layout) resulted in calling MTD ops of
parent partition instead of master device ops. That was expected and
should work but testing revealed some bugs.
Apparently the way MTD_ERASE_PARTIAL is implemented in the OpenWrt
breaks something and using parent partition ops triggers using that
code.
On SmartRG SR400ac it was resulting in:
[ 225.487519] jffs2: Erase at 0x01ac0000 failed immediately: errno -22
on the second boot (for some reason erasing was starting over) and it
was breaking flash access in a long term.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
3 files changed, 20 insertions, 12 deletions
diff --git a/target/linux/generic/pending-4.14/401-mtd-add-support-for-different-partition-parser-types.patch b/target/linux/generic/pending-4.14/401-mtd-add-support-for-different-partition-parser-types.patch index 2b8a17b435..359c4c167b 100644 --- a/target/linux/generic/pending-4.14/401-mtd-add-support-for-different-partition-parser-types.patch +++ b/target/linux/generic/pending-4.14/401-mtd-add-support-for-different-partition-parser-types.patch @@ -20,18 +20,18 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org> /* * Given a pointer to the MTD object in the mtd_part structure, we can retrieve -@@ -751,6 +755,28 @@ int mtd_del_partition(struct mtd_info *m +@@ -751,6 +755,36 @@ int mtd_del_partition(struct mtd_info *m } EXPORT_SYMBOL_GPL(mtd_del_partition); -+static int run_parsers_by_type(struct mtd_part *slave, -+ enum mtd_parser_type type) ++static int ++run_parsers_by_type(struct mtd_part *slave, enum mtd_parser_type type) +{ -+ const struct mtd_partition *parts; ++ struct mtd_partition *parts; + int nr_parts; -+ int err; ++ int i; + -+ nr_parts = parse_mtd_partitions_by_type(&slave->mtd, type, &parts, ++ nr_parts = parse_mtd_partitions_by_type(&slave->mtd, type, (const struct mtd_partition **)&parts, + NULL); + if (nr_parts <= 0) + return nr_parts; @@ -39,17 +39,25 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org> + if (WARN_ON(!parts)) + return 0; + -+ err = add_mtd_partitions(&slave->mtd, parts, nr_parts); ++ for (i = 0; i < nr_parts; i++) { ++ /* adjust partition offsets */ ++ parts[i].offset += slave->offset; ++ ++ mtd_add_partition(slave->parent, ++ parts[i].name, ++ parts[i].offset, ++ parts[i].size); ++ } + + kfree(parts); + -+ return err ? err : nr_parts; ++ return nr_parts; +} + #ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME #define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME #else -@@ -1122,6 +1148,61 @@ void mtd_part_parser_cleanup(struct mtd_ +@@ -1122,6 +1156,61 @@ void mtd_part_parser_cleanup(struct mtd_ } } diff --git a/target/linux/generic/pending-4.14/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch b/target/linux/generic/pending-4.14/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch index f8b6266f2d..e870663355 100644 --- a/target/linux/generic/pending-4.14/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch +++ b/target/linux/generic/pending-4.14/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch @@ -10,7 +10,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org> --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c -@@ -785,6 +785,7 @@ static int run_parsers_by_type(struct mt +@@ -793,6 +793,7 @@ run_parsers_by_type(struct mtd_part *sla static void split_firmware(struct mtd_info *master, struct mtd_part *part) { @@ -18,7 +18,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org> } static void mtd_partition_split(struct mtd_info *master, struct mtd_part *part) -@@ -794,6 +795,12 @@ static void mtd_partition_split(struct m +@@ -802,6 +803,12 @@ static void mtd_partition_split(struct m if (rootfs_found) return; diff --git a/target/linux/generic/pending-4.14/404-mtd-add-more-helper-functions.patch b/target/linux/generic/pending-4.14/404-mtd-add-more-helper-functions.patch index 663c9a300f..94c59df01d 100644 --- a/target/linux/generic/pending-4.14/404-mtd-add-more-helper-functions.patch +++ b/target/linux/generic/pending-4.14/404-mtd-add-more-helper-functions.patch @@ -11,7 +11,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org> --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c -@@ -1227,6 +1227,24 @@ int mtd_is_partition(const struct mtd_in +@@ -1235,6 +1235,24 @@ int mtd_is_partition(const struct mtd_in } EXPORT_SYMBOL_GPL(mtd_is_partition); |