diff options
| author | Richard Genoud <richard.genoud@gmail.com> | 2012-08-20 12:00:15 -0400 |
|---|---|---|
| committer | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2012-09-04 02:39:01 -0400 |
| commit | db7e21c21f293d52f5363fe8d9ee91d6bd0a503a (patch) | |
| tree | 8d2ac3f6988dabc4cd418f3ff08385972204a753 | |
| parent | edac493dfb48fe46d43fe6afabb8cfb2d1d4c048 (diff) | |
UBI: add max_beb_per1024 to attach ioctl
This patch provides a possibility to set the "maximum expected number of
bad blocks per 1024 blocks" (max_beb_per1024) for each mtd device using
the UBI_IOCATT ioctl.
Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
| -rw-r--r-- | drivers/mtd/ubi/Kconfig | 3 | ||||
| -rw-r--r-- | drivers/mtd/ubi/cdev.c | 2 | ||||
| -rw-r--r-- | include/mtd/ubi-user.h | 16 |
3 files changed, 18 insertions, 3 deletions
diff --git a/drivers/mtd/ubi/Kconfig b/drivers/mtd/ubi/Kconfig index 3e185e46cf6c..271a842f8c39 100644 --- a/drivers/mtd/ubi/Kconfig +++ b/drivers/mtd/ubi/Kconfig | |||
| @@ -51,7 +51,8 @@ config MTD_UBI_BEB_LIMIT | |||
| 51 | MTD partitions of the same size, UBI will reserve 40 eraseblocks when | 51 | MTD partitions of the same size, UBI will reserve 40 eraseblocks when |
| 52 | attaching a partition. | 52 | attaching a partition. |
| 53 | 53 | ||
| 54 | This option can be overridden by the "mtd=" UBI module parameter. | 54 | This option can be overridden by the "mtd=" UBI module parameter or |
| 55 | by the "attach" ioctl. | ||
| 55 | 56 | ||
| 56 | Leave the default value if unsure. | 57 | Leave the default value if unsure. |
| 57 | 58 | ||
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c index 619f9144f990..7885dc0934ce 100644 --- a/drivers/mtd/ubi/cdev.c +++ b/drivers/mtd/ubi/cdev.c | |||
| @@ -1011,7 +1011,7 @@ static long ctrl_cdev_ioctl(struct file *file, unsigned int cmd, | |||
| 1011 | */ | 1011 | */ |
| 1012 | mutex_lock(&ubi_devices_mutex); | 1012 | mutex_lock(&ubi_devices_mutex); |
| 1013 | err = ubi_attach_mtd_dev(mtd, req.ubi_num, req.vid_hdr_offset, | 1013 | err = ubi_attach_mtd_dev(mtd, req.ubi_num, req.vid_hdr_offset, |
| 1014 | CONFIG_MTD_UBI_BEB_LIMIT); | 1014 | req.max_beb_per1024); |
| 1015 | mutex_unlock(&ubi_devices_mutex); | 1015 | mutex_unlock(&ubi_devices_mutex); |
| 1016 | if (err < 0) | 1016 | if (err < 0) |
| 1017 | put_mtd_device(mtd); | 1017 | put_mtd_device(mtd); |
diff --git a/include/mtd/ubi-user.h b/include/mtd/ubi-user.h index 8787349fbafe..53cae1e11e57 100644 --- a/include/mtd/ubi-user.h +++ b/include/mtd/ubi-user.h | |||
| @@ -222,6 +222,7 @@ enum { | |||
| 222 | * @ubi_num: UBI device number to create | 222 | * @ubi_num: UBI device number to create |
| 223 | * @mtd_num: MTD device number to attach | 223 | * @mtd_num: MTD device number to attach |
| 224 | * @vid_hdr_offset: VID header offset (use defaults if %0) | 224 | * @vid_hdr_offset: VID header offset (use defaults if %0) |
| 225 | * @max_beb_per1024: maximum expected number of bad PEB per 1024 PEBs | ||
| 225 | * @padding: reserved for future, not used, has to be zeroed | 226 | * @padding: reserved for future, not used, has to be zeroed |
| 226 | * | 227 | * |
| 227 | * This data structure is used to specify MTD device UBI has to attach and the | 228 | * This data structure is used to specify MTD device UBI has to attach and the |
| @@ -245,12 +246,25 @@ enum { | |||
| 245 | * be 2KiB-64 bytes = 1984. Note, that this position is not even 512-bytes | 246 | * be 2KiB-64 bytes = 1984. Note, that this position is not even 512-bytes |
| 246 | * aligned, which is OK, as UBI is clever enough to realize this is 4th | 247 | * aligned, which is OK, as UBI is clever enough to realize this is 4th |
| 247 | * sub-page of the first page and add needed padding. | 248 | * sub-page of the first page and add needed padding. |
| 249 | * | ||
| 250 | * The @max_beb_per1024 is the maximum amount of bad PEBs UBI expects on the | ||
| 251 | * UBI device per 1024 eraseblocks. This value is often given in an other form | ||
| 252 | * in the NAND datasheet (min NVB i.e. minimal number of valid blocks). The | ||
| 253 | * maximum expected bad eraseblocks per 1024 is then: | ||
| 254 | * 1024 * (1 - MinNVB / MaxNVB) | ||
| 255 | * Which gives 20 for most NAND devices. This limit is used in order to derive | ||
| 256 | * amount of eraseblock UBI reserves for handling new bad blocks. If the device | ||
| 257 | * has more bad eraseblocks than this limit, UBI does not reserve any physical | ||
| 258 | * eraseblocks for new bad eraseblocks, but attempts to use available | ||
| 259 | * eraseblocks (if any). The accepted range is 0-768. If 0 is given, the | ||
| 260 | * default kernel value of %CONFIG_MTD_UBI_BEB_LIMIT will be used. | ||
| 248 | */ | 261 | */ |
| 249 | struct ubi_attach_req { | 262 | struct ubi_attach_req { |
| 250 | __s32 ubi_num; | 263 | __s32 ubi_num; |
| 251 | __s32 mtd_num; | 264 | __s32 mtd_num; |
| 252 | __s32 vid_hdr_offset; | 265 | __s32 vid_hdr_offset; |
| 253 | __s8 padding[12]; | 266 | __s16 max_beb_per1024; |
| 267 | __s8 padding[10]; | ||
| 254 | }; | 268 | }; |
| 255 | 269 | ||
| 256 | /** | 270 | /** |
