diff options
author | Shmulik Ladkani <shmulik.ladkani@gmail.com> | 2012-07-04 04:06:00 -0400 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2012-09-04 02:38:58 -0400 |
commit | 8beeb3bb9df8caba36ad3e4f226255dff9c92556 (patch) | |
tree | 4758809d39183d7aaccaa8178c5d5150c2bf1a9d /drivers/mtd | |
parent | afe7d12b6d997ff8ceff02e405eae9ba54aa8350 (diff) |
UBI: introduce new bad PEB limit
Introduce 'ubi->bad_peb_limit', which specifies an upper limit of PEBs
UBI expects to go bad. Currently, it is initialized to a fixed percentage
of total PEBs in the UBI device (configurable via CONFIG_MTD_UBI_BEB_LIMIT).
The 'bad_peb_limit' is intended to be used for calculating the amount of PEBs
UBI needs to reserve for bad eraseblock handling.
Artem: minor amendments.
Signed-off-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/ubi/Kconfig | 26 | ||||
-rw-r--r-- | drivers/mtd/ubi/build.c | 12 | ||||
-rw-r--r-- | drivers/mtd/ubi/ubi.h | 2 |
3 files changed, 32 insertions, 8 deletions
diff --git a/drivers/mtd/ubi/Kconfig b/drivers/mtd/ubi/Kconfig index ea4b95b5451c..76195ac90e51 100644 --- a/drivers/mtd/ubi/Kconfig +++ b/drivers/mtd/ubi/Kconfig | |||
@@ -34,13 +34,25 @@ config MTD_UBI_BEB_RESERVE | |||
34 | help | 34 | help |
35 | If the MTD device admits of bad eraseblocks (e.g. NAND flash), UBI | 35 | If the MTD device admits of bad eraseblocks (e.g. NAND flash), UBI |
36 | reserves some amount of physical eraseblocks to handle new bad | 36 | reserves some amount of physical eraseblocks to handle new bad |
37 | eraseblocks. For example, if a flash physical eraseblock becomes bad, | 37 | eraseblocks. When a physical eraseblock becomes bad, UBI uses these |
38 | UBI uses these reserved physical eraseblocks to relocate the bad one. | 38 | reserved physical eraseblocks to relocate the bad one. This |
39 | This option specifies how many physical eraseblocks will be reserved | 39 | configuration option specifies how many physical eraseblocks will be |
40 | for bad eraseblock handling (percents of total number of good flash | 40 | reserved for bad eraseblock handling (percents of total number of |
41 | eraseblocks). If the underlying flash does not admit of bad | 41 | good physical eraseblocks on this MTD partition). If the underlying |
42 | eraseblocks (e.g. NOR flash), this value is ignored and nothing is | 42 | flash does not admit of bad eraseblocks (e.g. NOR flash), this value |
43 | reserved. Leave the default value if unsure. | 43 | is ignored and nothing is reserved. Leave the default value if |
44 | unsure. | ||
45 | |||
46 | config MTD_UBI_BEB_LIMIT | ||
47 | int "Percentage of maximum expected bad eraseblocks" | ||
48 | default 2 | ||
49 | range 0 25 | ||
50 | help | ||
51 | This option specifies the maximum bad physical eraseblocks UBI | ||
52 | expects on the UBI device (percents of total number of physical | ||
53 | eraseblocks on this MTD partition). If the underlying flash does not | ||
54 | admit of bad eraseblocks (e.g. NOR flash), this value is ignored. | ||
55 | Leave the default value if unsure. | ||
44 | 56 | ||
45 | config MTD_UBI_GLUEBI | 57 | config MTD_UBI_GLUEBI |
46 | tristate "MTD devices emulation driver (gluebi)" | 58 | tristate "MTD devices emulation driver (gluebi)" |
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 3174dd40095d..ce311aa75a75 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c | |||
@@ -607,8 +607,18 @@ static int io_init(struct ubi_device *ubi) | |||
607 | ubi->peb_count = mtd_div_by_eb(ubi->mtd->size, ubi->mtd); | 607 | ubi->peb_count = mtd_div_by_eb(ubi->mtd->size, ubi->mtd); |
608 | ubi->flash_size = ubi->mtd->size; | 608 | ubi->flash_size = ubi->mtd->size; |
609 | 609 | ||
610 | if (mtd_can_have_bb(ubi->mtd)) | 610 | if (mtd_can_have_bb(ubi->mtd)) { |
611 | ubi->bad_allowed = 1; | 611 | ubi->bad_allowed = 1; |
612 | if (CONFIG_MTD_UBI_BEB_LIMIT > 0) { | ||
613 | int percent = CONFIG_MTD_UBI_BEB_LIMIT; | ||
614 | int limit = mult_frac(ubi->peb_count, percent, 100); | ||
615 | |||
616 | /* Round it up */ | ||
617 | if (mult_frac(limit, 100, percent) < ubi->peb_count) | ||
618 | limit += 1; | ||
619 | ubi->bad_peb_limit = limit; | ||
620 | } | ||
621 | } | ||
612 | 622 | ||
613 | if (ubi->mtd->type == MTD_NORFLASH) { | 623 | if (ubi->mtd->type == MTD_NORFLASH) { |
614 | ubi_assert(ubi->mtd->writesize == 1); | 624 | ubi_assert(ubi->mtd->writesize == 1); |
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h index 84f66e3fa05d..aeb459eb7e42 100644 --- a/drivers/mtd/ubi/ubi.h +++ b/drivers/mtd/ubi/ubi.h | |||
@@ -363,6 +363,7 @@ struct ubi_wl_entry; | |||
363 | * @flash_size: underlying MTD device size (in bytes) | 363 | * @flash_size: underlying MTD device size (in bytes) |
364 | * @peb_count: count of physical eraseblocks on the MTD device | 364 | * @peb_count: count of physical eraseblocks on the MTD device |
365 | * @peb_size: physical eraseblock size | 365 | * @peb_size: physical eraseblock size |
366 | * @bad_peb_limit: top limit of expected bad physical eraseblocks | ||
366 | * @bad_peb_count: count of bad physical eraseblocks | 367 | * @bad_peb_count: count of bad physical eraseblocks |
367 | * @good_peb_count: count of good physical eraseblocks | 368 | * @good_peb_count: count of good physical eraseblocks |
368 | * @corr_peb_count: count of corrupted physical eraseblocks (preserved and not | 369 | * @corr_peb_count: count of corrupted physical eraseblocks (preserved and not |
@@ -410,6 +411,7 @@ struct ubi_device { | |||
410 | int avail_pebs; | 411 | int avail_pebs; |
411 | int beb_rsvd_pebs; | 412 | int beb_rsvd_pebs; |
412 | int beb_rsvd_level; | 413 | int beb_rsvd_level; |
414 | int bad_peb_limit; | ||
413 | 415 | ||
414 | int autoresize_vol_id; | 416 | int autoresize_vol_id; |
415 | int vtbl_slots; | 417 | int vtbl_slots; |