From b5b5f5dfa64519120369c5f5d26ba922c9fbcd4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Fri, 27 Jul 2018 21:54:08 +0200 Subject: kernel: backport mtd support for subpartitions in DT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a new & warm feature that allows nesting partiitons in DT and mixing their types (e.g. static vs. dynamic). It's very useful for boards that have most partitions static but some of them require extra parsing (e.g. a "firmware" partition). It's required to successfully backport support for new devices using that new syntax in their DT files. Since brcm63xx has a custom alternative patch the upstream one is being reverted for it. The plan is to make brcm63xx use the upstream implementation. Signed-off-by: Rafał Miłecki (cherry picked from commit 2a598bbaa3f75b7051c2453a6ccf706191cf2153) --- .../161-mtd-part-add-generic-parsing-of-linux-part-probe.patch | 8 ++++---- .../generic/pending-4.9/400-mtd-add-rootfs-split-support.patch | 10 +++++----- ...-mtd-add-support-for-different-partition-parser-types.patch | 2 +- ...d-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch | 6 +++--- .../pending-4.9/404-mtd-add-more-helper-functions.patch | 4 ++-- .../generic/pending-4.9/411-mtd-partial_eraseblock_write.patch | 2 +- ...-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch | 4 ++-- .../432-mtd-bcm47xxpart-detect-T_Meter-partition.patch | 4 ++-- 8 files changed, 20 insertions(+), 20 deletions(-) (limited to 'target/linux/generic/pending-4.9') diff --git a/target/linux/generic/pending-4.9/161-mtd-part-add-generic-parsing-of-linux-part-probe.patch b/target/linux/generic/pending-4.9/161-mtd-part-add-generic-parsing-of-linux-part-probe.patch index e2a0e4887d..1b6290fca2 100644 --- a/target/linux/generic/pending-4.9/161-mtd-part-add-generic-parsing-of-linux-part-probe.patch +++ b/target/linux/generic/pending-4.9/161-mtd-part-add-generic-parsing-of-linux-part-probe.patch @@ -114,7 +114,7 @@ Signed-off-by: Hauke Mehrtens #include #include -@@ -843,6 +844,42 @@ void deregister_mtd_parser(struct mtd_pa +@@ -827,6 +828,42 @@ void deregister_mtd_parser(struct mtd_pa EXPORT_SYMBOL_GPL(deregister_mtd_parser); /* @@ -157,7 +157,7 @@ Signed-off-by: Hauke Mehrtens * Do not forget to update 'parse_mtd_partitions()' kerneldoc comment if you * are changing this array! */ -@@ -983,6 +1020,13 @@ int parse_mtd_partitions(struct mtd_info +@@ -975,6 +1012,13 @@ int parse_mtd_partitions(struct mtd_info struct mtd_partitions pparts = { }; struct mtd_part_parser *parser; int ret, err = 0; @@ -170,8 +170,8 @@ Signed-off-by: Hauke Mehrtens + } if (!types) - types = default_mtd_part_types; -@@ -1023,6 +1067,7 @@ int parse_mtd_partitions(struct mtd_info + types = mtd_is_partition(master) ? default_subpartition_types : +@@ -1016,6 +1060,7 @@ int parse_mtd_partitions(struct mtd_info if (ret < 0 && !err) err = ret; } diff --git a/target/linux/generic/pending-4.9/400-mtd-add-rootfs-split-support.patch b/target/linux/generic/pending-4.9/400-mtd-add-rootfs-split-support.patch index 10be7a16ab..b0cb273141 100644 --- a/target/linux/generic/pending-4.9/400-mtd-add-rootfs-split-support.patch +++ b/target/linux/generic/pending-4.9/400-mtd-add-rootfs-split-support.patch @@ -60,7 +60,7 @@ Signed-off-by: Felix Fietkau /* * Given a pointer to the MTD object in the mtd_part structure, we can retrieve * the pointer to that structure. -@@ -666,6 +670,7 @@ int mtd_add_partition(struct mtd_info *p +@@ -650,6 +654,7 @@ int mtd_add_partition(struct mtd_info *p mutex_unlock(&mtd_partitions_mutex); add_mtd_device(&new->mtd); @@ -68,7 +68,7 @@ Signed-off-by: Felix Fietkau mtd_add_partition_attrs(new); -@@ -744,6 +749,35 @@ int mtd_del_partition(struct mtd_info *m +@@ -728,6 +733,35 @@ int mtd_del_partition(struct mtd_info *m } EXPORT_SYMBOL_GPL(mtd_del_partition); @@ -104,14 +104,14 @@ Signed-off-by: Felix Fietkau /* * This function, given a master MTD object and a partition table, creates * and registers slave MTD objects which are bound to the master according to -@@ -775,6 +809,7 @@ int add_mtd_partitions(struct mtd_info * +@@ -759,6 +793,7 @@ int add_mtd_partitions(struct mtd_info * mutex_unlock(&mtd_partitions_mutex); add_mtd_device(&slave->mtd); + mtd_partition_split(master, slave); mtd_add_partition_attrs(slave); - if (parts[i].types) - mtd_parse_part(slave, parts[i].types); + /* Look for subpartitions */ + parse_mtd_partitions(&slave->mtd, parts[i].types, NULL); --- a/include/linux/mtd/partitions.h +++ b/include/linux/mtd/partitions.h @@ -110,5 +110,7 @@ int mtd_add_partition(struct mtd_info *m diff --git a/target/linux/generic/pending-4.9/401-mtd-add-support-for-different-partition-parser-types.patch b/target/linux/generic/pending-4.9/401-mtd-add-support-for-different-partition-parser-types.patch index 63affd7eed..1188cc656f 100644 --- a/target/linux/generic/pending-4.9/401-mtd-add-support-for-different-partition-parser-types.patch +++ b/target/linux/generic/pending-4.9/401-mtd-add-support-for-different-partition-parser-types.patch @@ -9,7 +9,7 @@ Signed-off-by: Gabor Juhos --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c -@@ -1122,6 +1122,62 @@ void mtd_part_parser_cleanup(struct mtd_ +@@ -1115,6 +1115,62 @@ void mtd_part_parser_cleanup(struct mtd_ } } diff --git a/target/linux/generic/pending-4.9/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch b/target/linux/generic/pending-4.9/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch index 10d8551482..9c2650b45f 100644 --- a/target/linux/generic/pending-4.9/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch +++ b/target/linux/generic/pending-4.9/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch @@ -10,7 +10,7 @@ Signed-off-by: Gabor Juhos --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c -@@ -749,6 +749,36 @@ int mtd_del_partition(struct mtd_info *m +@@ -733,6 +733,36 @@ int mtd_del_partition(struct mtd_info *m } EXPORT_SYMBOL_GPL(mtd_del_partition); @@ -47,7 +47,7 @@ Signed-off-by: Gabor Juhos #ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME #define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME #else -@@ -757,6 +787,7 @@ EXPORT_SYMBOL_GPL(mtd_del_partition); +@@ -741,6 +771,7 @@ EXPORT_SYMBOL_GPL(mtd_del_partition); static void split_firmware(struct mtd_info *master, struct mtd_part *part) { @@ -55,7 +55,7 @@ Signed-off-by: Gabor Juhos } void __weak arch_split_mtd_part(struct mtd_info *master, const char *name, -@@ -771,6 +802,12 @@ static void mtd_partition_split(struct m +@@ -755,6 +786,12 @@ static void mtd_partition_split(struct m if (rootfs_found) return; diff --git a/target/linux/generic/pending-4.9/404-mtd-add-more-helper-functions.patch b/target/linux/generic/pending-4.9/404-mtd-add-more-helper-functions.patch index 076ec314b2..886dece4f7 100644 --- a/target/linux/generic/pending-4.9/404-mtd-add-more-helper-functions.patch +++ b/target/linux/generic/pending-4.9/404-mtd-add-more-helper-functions.patch @@ -11,7 +11,7 @@ Signed-off-by: Gabor Juhos --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c -@@ -779,6 +779,17 @@ run_parsers_by_type(struct mtd_part *sla +@@ -763,6 +763,17 @@ run_parsers_by_type(struct mtd_part *sla return nr_parts; } @@ -29,7 +29,7 @@ Signed-off-by: Gabor Juhos #ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME #define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME #else -@@ -1232,6 +1243,24 @@ int mtd_is_partition(const struct mtd_in +@@ -1225,6 +1236,24 @@ int mtd_is_partition(const struct mtd_in } EXPORT_SYMBOL_GPL(mtd_is_partition); diff --git a/target/linux/generic/pending-4.9/411-mtd-partial_eraseblock_write.patch b/target/linux/generic/pending-4.9/411-mtd-partial_eraseblock_write.patch index e925983b30..4e66272bb6 100644 --- a/target/linux/generic/pending-4.9/411-mtd-partial_eraseblock_write.patch +++ b/target/linux/generic/pending-4.9/411-mtd-partial_eraseblock_write.patch @@ -107,7 +107,7 @@ Signed-off-by: Felix Fietkau if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN) instr->fail_addr -= part->offset; -@@ -578,19 +647,22 @@ static struct mtd_part *allocate_partiti +@@ -562,19 +631,22 @@ static struct mtd_part *allocate_partiti remainder = do_div(tmp, wr_alignment); if ((slave->mtd.flags & MTD_WRITEABLE) && remainder) { /* Doesn't start on a boundary of major erase size */ diff --git a/target/linux/generic/pending-4.9/431-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch b/target/linux/generic/pending-4.9/431-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch index d54c284c34..cbd185e0ae 100644 --- a/target/linux/generic/pending-4.9/431-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch +++ b/target/linux/generic/pending-4.9/431-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch @@ -6,7 +6,7 @@ Signed-off-by: Rafał Miłecki --- a/drivers/mtd/parsers/parser_trx.c +++ b/drivers/mtd/parsers/parser_trx.c -@@ -29,6 +29,33 @@ struct trx_header { +@@ -30,6 +30,33 @@ struct trx_header { uint32_t offset[3]; } __packed; @@ -40,7 +40,7 @@ Signed-off-by: Rafał Miłecki static const char *parser_trx_data_part_name(struct mtd_info *master, size_t offset) { -@@ -83,21 +110,21 @@ static int parser_trx_parse(struct mtd_i +@@ -84,21 +111,21 @@ static int parser_trx_parse(struct mtd_i if (trx.offset[2]) { part = &parts[curr_part++]; part->name = "loader"; diff --git a/target/linux/generic/pending-4.9/432-mtd-bcm47xxpart-detect-T_Meter-partition.patch b/target/linux/generic/pending-4.9/432-mtd-bcm47xxpart-detect-T_Meter-partition.patch index a6d0828b99..3970641555 100644 --- a/target/linux/generic/pending-4.9/432-mtd-bcm47xxpart-detect-T_Meter-partition.patch +++ b/target/linux/generic/pending-4.9/432-mtd-bcm47xxpart-detect-T_Meter-partition.patch @@ -11,7 +11,7 @@ Signed-off-by: Rafał Miłecki --- a/drivers/mtd/bcm47xxpart.c +++ b/drivers/mtd/bcm47xxpart.c -@@ -39,6 +39,7 @@ +@@ -40,6 +40,7 @@ #define NVRAM_HEADER 0x48534C46 /* FLSH */ #define POT_MAGIC1 0x54544f50 /* POTT */ #define POT_MAGIC2 0x504f /* OP */ @@ -19,7 +19,7 @@ Signed-off-by: Rafał Miłecki #define ML_MAGIC1 0x39685a42 #define ML_MAGIC2 0x26594131 #define TRX_MAGIC 0x30524448 -@@ -182,6 +183,15 @@ static int bcm47xxpart_parse(struct mtd_ +@@ -183,6 +184,15 @@ static int bcm47xxpart_parse(struct mtd_ MTD_WRITEABLE); continue; } -- cgit v1.2.3