Loading drivers/mtd/Kconfig +11 −0 Original line number Diff line number Diff line Loading @@ -326,6 +326,17 @@ config MTD_PARTITIONED_MASTER the parent of the partition device be the master device, rather than what lies behind the master. config MTD_LAZYECCSTATS bool "MTD Lazy ECC Stats collection support" default y help Normally bad block counts for ECC stats are collected at boot time. This option delays the badblock stats collection until ECCGETSTATS ioctl is invoked on the partition. This can significantly decrease boot times depending on the size of the partition. If unsure, say 'N'. source "drivers/mtd/chips/Kconfig" source "drivers/mtd/maps/Kconfig" Loading drivers/mtd/mtdchar.c +4 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ #include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h> #include <linux/mtd/map.h> #include <linux/mtd/partitions.h> #include <linux/uaccess.h> Loading Loading @@ -1003,6 +1004,9 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg) case ECCGETSTATS: { #ifdef CONFIG_MTD_LAZYECCSTATS part_fill_badblockstats(mtd); #endif if (copy_to_user(argp, &mtd->ecc_stats, sizeof(struct mtd_ecc_stats))) return -EFAULT; Loading drivers/mtd/mtdpart.c +32 −11 Original line number Diff line number Diff line Loading @@ -51,6 +51,12 @@ struct mtd_part { struct list_head list; }; /* * Given a pointer to the MTD object in the mtd_part structure, we can retrieve * the pointer to that structure with this macro. */ #define PART(x) ((struct mtd_part *)(x)) /* * Given a pointer to the MTD object in the mtd_part structure, we can retrieve * the pointer to that structure. Loading Loading @@ -369,6 +375,29 @@ static inline void free_partition(struct mtd_part *p) kfree(p); } void part_fill_badblockstats(struct mtd_info *mtd) { uint64_t offs = 0; struct mtd_info *parent; struct mtd_part *part; part = PART(mtd); parent = part->parent; if (parent->_block_isbad) { mtd->ecc_stats.badblocks = 0; mtd->ecc_stats.bbtblocks = 0; while (offs < mtd->size) { if (mtd_block_isreserved(parent, offs + part->offset)) mtd->ecc_stats.bbtblocks++; else if (mtd_block_isbad(parent, offs + part->offset)) mtd->ecc_stats.badblocks++; offs += mtd->erasesize; } } } /** * mtd_parse_part - parse MTD partition looking for subpartitions * Loading Loading @@ -613,17 +642,9 @@ static struct mtd_part *allocate_partition(struct mtd_info *parent, slave->mtd.ecc_strength = parent->ecc_strength; slave->mtd.bitflip_threshold = parent->bitflip_threshold; if (parent->_block_isbad) { uint64_t offs = 0; while (offs < slave->mtd.size) { if (mtd_block_isreserved(parent, offs + slave->offset)) slave->mtd.ecc_stats.bbtblocks++; else if (mtd_block_isbad(parent, offs + slave->offset)) slave->mtd.ecc_stats.badblocks++; offs += slave->mtd.erasesize; } } #ifndef CONFIG_MTD_LAZYECCSTATS part_fill_badblockstats(&(slave->mtd)); #endif out_register: return slave; Loading include/linux/mtd/partitions.h +2 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,8 @@ struct mtd_part_parser_data { }; void part_fill_badblockstats(struct mtd_info *mtd); /* * Functions dealing with the various ways of partitioning the space */ Loading Loading
drivers/mtd/Kconfig +11 −0 Original line number Diff line number Diff line Loading @@ -326,6 +326,17 @@ config MTD_PARTITIONED_MASTER the parent of the partition device be the master device, rather than what lies behind the master. config MTD_LAZYECCSTATS bool "MTD Lazy ECC Stats collection support" default y help Normally bad block counts for ECC stats are collected at boot time. This option delays the badblock stats collection until ECCGETSTATS ioctl is invoked on the partition. This can significantly decrease boot times depending on the size of the partition. If unsure, say 'N'. source "drivers/mtd/chips/Kconfig" source "drivers/mtd/maps/Kconfig" Loading
drivers/mtd/mtdchar.c +4 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ #include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h> #include <linux/mtd/map.h> #include <linux/mtd/partitions.h> #include <linux/uaccess.h> Loading Loading @@ -1003,6 +1004,9 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg) case ECCGETSTATS: { #ifdef CONFIG_MTD_LAZYECCSTATS part_fill_badblockstats(mtd); #endif if (copy_to_user(argp, &mtd->ecc_stats, sizeof(struct mtd_ecc_stats))) return -EFAULT; Loading
drivers/mtd/mtdpart.c +32 −11 Original line number Diff line number Diff line Loading @@ -51,6 +51,12 @@ struct mtd_part { struct list_head list; }; /* * Given a pointer to the MTD object in the mtd_part structure, we can retrieve * the pointer to that structure with this macro. */ #define PART(x) ((struct mtd_part *)(x)) /* * Given a pointer to the MTD object in the mtd_part structure, we can retrieve * the pointer to that structure. Loading Loading @@ -369,6 +375,29 @@ static inline void free_partition(struct mtd_part *p) kfree(p); } void part_fill_badblockstats(struct mtd_info *mtd) { uint64_t offs = 0; struct mtd_info *parent; struct mtd_part *part; part = PART(mtd); parent = part->parent; if (parent->_block_isbad) { mtd->ecc_stats.badblocks = 0; mtd->ecc_stats.bbtblocks = 0; while (offs < mtd->size) { if (mtd_block_isreserved(parent, offs + part->offset)) mtd->ecc_stats.bbtblocks++; else if (mtd_block_isbad(parent, offs + part->offset)) mtd->ecc_stats.badblocks++; offs += mtd->erasesize; } } } /** * mtd_parse_part - parse MTD partition looking for subpartitions * Loading Loading @@ -613,17 +642,9 @@ static struct mtd_part *allocate_partition(struct mtd_info *parent, slave->mtd.ecc_strength = parent->ecc_strength; slave->mtd.bitflip_threshold = parent->bitflip_threshold; if (parent->_block_isbad) { uint64_t offs = 0; while (offs < slave->mtd.size) { if (mtd_block_isreserved(parent, offs + slave->offset)) slave->mtd.ecc_stats.bbtblocks++; else if (mtd_block_isbad(parent, offs + slave->offset)) slave->mtd.ecc_stats.badblocks++; offs += slave->mtd.erasesize; } } #ifndef CONFIG_MTD_LAZYECCSTATS part_fill_badblockstats(&(slave->mtd)); #endif out_register: return slave; Loading
include/linux/mtd/partitions.h +2 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,8 @@ struct mtd_part_parser_data { }; void part_fill_badblockstats(struct mtd_info *mtd); /* * Functions dealing with the various ways of partitioning the space */ Loading