UBI: add max_beb_per1024 parameter / ioctl
v2 cover UBI: add max_beb_per1024 parameter / ioctl
Artem,
This patch serie introduce, step by step the kernel module parameter max_beb_per1024, then the ioctl and finally drop the kernel config option CONFIG_MTD_UBI_BEB_LIMIT.
It's based on top of linux-ubi/master (4ebb4b5)
The differences from previous version are:
* The upper bound of max_beb_per1024 is checked and set to 768
* The vid_hdr_offs parameter can now be an empty string in order to have a kernel parameter like that: mtd.ubi=2,,25
* The max_beb_per1024 parameter can also be empty (just for consistency with vid_hdr_offs)
* The comment in ubi-user.h has been adjusted with the new range 0-768 and the term "default kernel value" is used in place of MTD_UBI_DEFAULT_BEB_LIMIT or CONFIG_MTD_UBI_BEB_LIMIT
* As max_beb_per1024 can be safely null, the config range of MTD_UBI_BEB_LIMIT has been updates to 0..768
* For the ioctl, max_beb_per1024 is now an __u16, so that we are not limited to 255 anymore.
* The comment on the default value of max_beb_per1024 has been adjusted before and after the ioctl patch.
I compiled and tested each patch, so every thing should go smoothly. I tested also with a 0 value for CONFIG_MTD_UBI_BEB_LIMIT, it seemed to go well.
Best Regards
Richard.
Richard Genoud (7):
UBI: prepare for max_beb_per1024 module parameter addition
UBI: change CONFIG_MTD_UBI_BEB_LIMIT range
UBI: accept empty string for vid_hdr_offs parameter
UBI: check max_beb_per1024 value in ubi_attach_mtd_dev
UBI: replace MTD_UBI_BEB_LIMIT with module parameter
UBI: add ioctl for max_beb_per1024
UBI: drop CONFIG_MTD_UBI_BEB_LIMIT
arch/arm/configs/sam9_l9260_defconfig | 1 - drivers/mtd/ubi/Kconfig | 26 ------------ drivers/mtd/ubi/build.c | 69 ++++++++++++++++++++++++--------- drivers/mtd/ubi/cdev.c | 3 +- drivers/mtd/ubi/ubi.h | 6 ++- include/mtd/ubi-user.h | 19 +++++++++- 6 files changed, 75 insertions(+), 49 deletions(-)
Signature · 1 line
1.7.2.5
PATCH v2 1/7 UBI: prepare for max_beb_per1024 module parameter addition
This patch prepare the way for the addition of max_beb_per1024 module parameter.
There's no functional change.
--- drivers/mtd/ubi/build.c | 14 ++++++++------ drivers/mtd/ubi/cdev.c | 3 ++- drivers/mtd/ubi/ubi.h | 3 ++- 3 files changed, 12 insertions(+), 8 deletions(-)
drivers/mtd/ubi/build.c +8 -6
@@ -602,6 +602,7 @@ static int get_bad_peb_limit(const struct ubi_device *ubi, int max_beb_per1024)/** * io_init - initialize I/O sub-system for a given UBI device. * @ubi: UBI device description object +* @max_beb_per1024: maximum expected number of bad PEB per 1024 PEB * * If @ubi->vid_hdr_offset or @ubi->leb_start is zero, default offsets are * assumed:
@@ -614,10 +615,8 @@ static int get_bad_peb_limit(const struct ubi_device *ubi, int max_beb_per1024)* This function returns zero in case of success and a negative error code in * case of failure. */ -static int io_init (struct ubi_device *ubi) +static int io_init (struct ubi_device *ubi,int max_beb_per1024) { -const int max_beb_per1024 =CONFIG_MTD_UBI_BEB_LIMIT ; -if (ubi->mtd->numeraseregions !=0 ) {/* * Some flashes have several erase regions. Different regions
@@ -839,6 +838,7 @@ static int autoresize(struct ubi_device *ubi, int vol_id)* @mtd: MTD device description object * @ubi_num: number to assign to the new UBI device * @vid_hdr_offset: VID header offset +* @max_beb_per1024: maximum number of expected bad blocks per 1024 eraseblocks * * This function attaches MTD device @mtd_dev to UBI and assign @ubi_num number * to the newly created UBI device, unless @ubi_num is %UBI_DEV_NUM_AUTO, in
@@ -849,7 +849,8 @@ static int autoresize(struct ubi_device *ubi, int vol_id)* Note, the invocations of this function has to be serialized by the * @ubi_devices_mutex. */ -int ubi_attach_mtd_dev (struct mtd_info *mtd,int ubi_num,int vid_hdr_offset) +int ubi_attach_mtd_dev (struct mtd_info *mtd,int ubi_num, +int vid_hdr_offset,int max_beb_per1024) {struct ubi_device *ubi;int i, err, ref =0 ;
@@ -922,7 +923,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)dbg_msg ("sizeof(struct ubi_ainf_peb) %zu" ,sizeof (struct ubi_ainf_peb ));dbg_msg ("sizeof(struct ubi_wl_entry) %zu" ,sizeof (struct ubi_wl_entry )); - err =io_init (ubi); + err =io_init (ubi, max_beb_per1024);if (err) goto out_free;
@@ -1211,7 +1212,8 @@ static int __init ubi_init(void)mutex_lock (&ubi_devices_mutex); err =ubi_attach_mtd_dev (mtd,UBI_DEV_NUM_AUTO , - p->vid_hdr_offs); + p->vid_hdr_offs, +CONFIG_MTD_UBI_BEB_LIMIT );mutex_unlock (&ubi_devices_mutex);if (err <0 ) {ubi_err ("cannot attach mtd%d" , mtd->index);
drivers/mtd/ubi/cdev.c +2 -1
@@ -1010,7 +1010,8 @@ static long ctrl_cdev_ioctl(struct file *file, unsigned int cmd,* 'ubi_attach_mtd_dev()'. */ mutex_lock (&ubi_devices_mutex); - err =ubi_attach_mtd_dev (mtd, req.ubi_num, req.vid_hdr_offset); + err =ubi_attach_mtd_dev (mtd, req.ubi_num, req.vid_hdr_offset, +CONFIG_MTD_UBI_BEB_LIMIT );mutex_unlock (&ubi_devices_mutex);if (err <0 )put_mtd_device (mtd);
drivers/mtd/ubi/ubi.h +2 -1
@@ -693,7 +693,8 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum, struct ubi_vid_hdr *vid_hdr);/* build.c */ -int ubi_attach_mtd_dev (struct mtd_info *mtd,int ubi_num,int vid_hdr_offset); +int ubi_attach_mtd_dev (struct mtd_info *mtd,int ubi_num, +int vid_hdr_offset,int max_beb_per1024);int ubi_detach_mtd_dev (int ubi_num,int anyway);struct ubi_device *ubi_get_device (int ubi_num);void ubi_put_device (struct ubi_device *ubi);
Signature · 1 line
1.7.2.5
Re: [PATCH v2 1/7] UBI: prepare for max_beb_per1024 module parameter addition
Quoted 5 lines · On Mon, 20 Aug 2012 14:09:15 +0200 Richard Genoud <[email protected]>…
This patch prepare the way for the addition of
max_beb_per1024module parameter.
There's no functional change.Signed-off-by Richard Genoud <[email protected]>
PATCH v2 2/7 UBI: change CONFIG_MTD_UBI_BEB_LIMIT range
In reply to Richard GenoudThere's no reason to limit MTD_UBI_BEB_LIMIT to 256 (25%), let's set it to 768 (75%) this should be enough.
And the lower bound can be 0, no reason to forbid it (even if it will be reserved for test purpose only I guess).
--- drivers/mtd/ubi/Kconfig | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mtd/ubi/Kconfig +1 -1
@@ -30,7 +30,7 @@ config MTD_UBI_WL_THRESHOLD config MTD_UBI_BEB_LIMIT int "Maximum expected bad eraseblock count per 1024 eraseblocks" default 20 - range 1 256 + range 0 768 help This option specifies the maximum bad physical eraseblocks UBI expects on the MTD device (per 1024 eraseblocks). If the underlying
Signature · 1 line
1.7.2.5
PATCH v2 3/7 UBI: accept empty string for vid_hdr_offs parameter
In reply to Richard Genoudas a new parameter (max_beb_per1024) will come in next patches, it's better to accept empty string value so that we can do:
mtd.ubi=2,,25
--- drivers/mtd/ubi/build.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
drivers/mtd/ubi/build.c +5 -1
@@ -1292,7 +1292,11 @@ static int __init bytes_str_to_int(const char *str)unsigned long result; result =simple_strtoul (str, &endp,0 ); -if (str == endp || result >=INT_MAX ) { +if (str == endp) +/* empty string, assume it's 0 */ +return 0 ; + +if (result >=INT_MAX ) {printk (KERN_ERR "UBI error: incorrect bytes count: \"%s\"\n" , str);return -EINVAL ;
Signature · 1 line
1.7.2.5
Re: [PATCH v2 3/7] UBI: accept empty string for vid_hdr_offs parameter
Hi Richard,
drivers/mtd/ubi/build.c static int __init bytes_str_to_int(const char *str) · line 1297
Quoted 8 lines · On Mon, 20 Aug 2012 14:09:17 +0200 Richard Genoud <[email protected]>…
drivers/mtd/ubi/build.c +3
-1@@ -1292,7 +1292,11 @@ static int __init bytes_str_to_int(const char *str)unsigned long result; result =simple_strtoul (str, &endp,0 ); -if (str == endp || result >=INT_MAX ) { +if (str == endp) +/* empty string, assume it's 0 */ +return 0 ;
This will allow "ubi=2,#" (or any non numeric character after the comma), setting a zero vid_hdr_offs instead of erroring.
How about adding:
+ if (!*str)
+ /* empty string, assume it's 0 */
+ return 0;
Before the original (keep it):
result = simple_strtoul(str, &endp, 0);
if (str == endp || result >= INT_MAX) {Can you test this works in all cases?
Regards,
Shmulik
Re: [PATCH v2 3/7] UBI: accept empty string for vid_hdr_offs parameter
Quoted 11 lines · Shmulik Ladkani
Hi Richard,
drivers/mtd/ubi/build.c static int __init bytes_str_to_int(const char *str) · line 1297
Quoted 8 lines · On Mon, 20 Aug 2012 14:09:17 +0200 Richard Genoud <[email protected]>…
drivers/mtd/ubi/build.c +3
-1@@ -1292,7 +1292,11 @@ static int __init bytes_str_to_int(const char *str)unsigned long result; result =simple_strtoul (str, &endp,0 ); -if (str == endp || result >=INT_MAX ) { +if (str == endp) +/* empty string, assume it's 0 */ +return 0 ;
Please, let's not over-engineer this, do not bother with ",,", use ",0," instead. Just do amend the documentation properly.
Signature · 2 lines
Best Regards, Artem Bityutskiy
Re: [PATCH v2 3/7] UBI: accept empty string for vid_hdr_offs parameter
2012/8/20 Artem Bityutskiy <[email protected]>:
Quoted 7 lines · Shmulik Ladkani
Quoted 6 lines
Hi Richard,
Quoted 3 lines · On Mon, 20 Aug 2012 14:09:17 +0200 Richard Genoud <[email protected]>…
drivers/mtd/ubi/build.c +0
-0@@ -1292,7 +1292,11 @@ static int __init bytes_str_to_int(const char *str)unsigned long result;
Quoted 8 lines
Quoted 5 lines
drivers/mtd/ubi/build.c static int __init bytes_str_to_int(const char *str) · line 1297
Quoted 5 lines
drivers/mtd/ubi/build.c +3
-1result =simple_strtoul (str, &endp,0 ); -if (str == endp || result >=INT_MAX ) { +if (str == endp) +/* empty string, assume it's 0 */ +return 0 ;Please, let's not over-engineer this, do not bother with ",,", use ",0," instead. Just do amend the documentation properly.
ok, I'll drop the patch and change the doc.
Re: [PATCH v2 3/7] UBI: accept empty string for vid_hdr_offs parameter
In reply to Artem BityutskiyQuoted 2 lines · On Mon, 20 Aug 2012 16:04:58 +0300 Artem Bityutskiy <[email protected]> wrote:
Please, let's not over-engineer this, do not bother with ",,", use ",0," instead. Just do amend the documentation properly.
Artem, you are probably right, but it was really a one-liner:
drivers/mtd/ubi/build.c +1 -1
@@ -1333,7 +1333,7 @@ static int __init ubi_mtd_param_parse(const char *val, struct kernel_param *kp) p = &mtd_dev_param[mtd_devs];strcpy (&p->name[0 ], tokens[0 ]); -if (tokens[1 ]) +if (tokens[1 ] && *tokens[1 ] !='\0' ) p->vid_hdr_offs =bytes_str_to_int (tokens[1 ]);if (p->vid_hdr_offs <0 )
But either case, I guess the user will probably still need to take a look at the description to understand how to "avoid specifying" the vid_hdr_offs ;-)
So no real benefit supporting ",,"
Bit more intuitive, though.
Anyways, saw you already pushed, thanks.
Shmulik
Re: [PATCH v2 3/7] UBI: accept empty string for vid_hdr_offs parameter
Quoted 4 lines · Shmulik Ladkani
But either case, I guess the user will probably still need to take a look at the description to understand how to "avoid specifying" the
vid_hdr_offs;-)
So no real benefit supporting ",,"
We have 0 as the default value already, no need to have the second way to specify the same.
Signature · 2 lines
Best Regards, Artem Bityutskiy
PATCH v2 4/7 UBI: check max_beb_per1024 value in ubi_attach_mtd_dev
In reply to Richard Genoudmax_beb_per1024 shouldn't be negative, and a 0 value will be treated as the default value.
For the upper bound, 768/1024 should be enough.
--- drivers/mtd/ubi/build.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
drivers/mtd/ubi/build.c +12 -0
@@ -49,6 +49,9 @@/* Maximum number of comma-separated items in the 'mtd=' parameter */ #define MTD_PARAM_MAX_COUNT 2 +/* Maximum value for the number of bad eraseblocks per 1024 limit */ +#define MAX_MTD_UBI_BEB_LIMIT 768 +#ifdef CONFIG_MTD_UBI_MODULE #define ubi_is_module () 1#else
@@ -855,6 +858,15 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,struct ubi_device *ubi;int i, err, ref =0 ; +if ((max_beb_per1024 <0 ) || (max_beb_per1024 >MAX_MTD_UBI_BEB_LIMIT )) +return -EINVAL ; + +/* +* Use the default value if max_beb_per1024 isn't provided. +*/ +if (!max_beb_per1024) + max_beb_per1024 =CONFIG_MTD_UBI_BEB_LIMIT ; +/* * Check if we already have the same MTD device attached. *
Signature · 1 line
1.7.2.5
PATCH v2 5/7 UBI: replace MTD_UBI_BEB_LIMIT with module parameter
In reply to Richard GenoudThis patch provides the possibility to adjust the "maximum expected number of bad blocks per 1024 blocks" (max_beb_per1024) for each mtd device.
The majority of NAND devices have their max_beb_per1024 equal to 20, but sometimes it's more.
Now, we can adjust that via a kernel parameter:
ubi.mtd=<name|num|path>[,<vid_hdr_offs>[,max_beb_per1024]]
--- drivers/mtd/ubi/Kconfig | 2 ++ drivers/mtd/ubi/build.c | 39 +++++++++++++++++++++++++-------------- 2 files changed, 27 insertions(+), 14 deletions(-)
drivers/mtd/ubi/Kconfig +2 -0
@@ -51,6 +51,8 @@ config MTD_UBI_BEB_LIMIT MTD partitions of the same size, UBI will reserve 40 eraseblocks when attaching a partition. + This option can be overridden by the kernel parameter ubi.mtd. + Leave the default value if unsure. config MTD_UBI_GLUEBI
drivers/mtd/ubi/build.c +25 -14
@@ -47,7 +47,7 @@#define MTD_PARAM_LEN_MAX 64/* Maximum number of comma-separated items in the 'mtd=' parameter */ -#define MTD_PARAM_MAX_COUNT 2 +#define MTD_PARAM_MAX_COUNT 3/* Maximum value for the number of bad eraseblocks per 1024 limit */ #define MAX_MTD_UBI_BEB_LIMIT 768
@@ -63,10 +63,12 @@* @name: MTD character device node path, MTD device name, or MTD device number * string * @vid_hdr_offs: VID header offset +* @max_beb_per1024: maximum expected number of bad blocks per 1024 erase blocks */ struct mtd_dev_param {char name[MTD_PARAM_LEN_MAX ];int vid_hdr_offs; +int max_beb_per1024; };/* Numbers of elements set in the @mtd_dev_param array */
@@ -1224,8 +1226,7 @@ static int __init ubi_init(void)mutex_lock (&ubi_devices_mutex); err =ubi_attach_mtd_dev (mtd,UBI_DEV_NUM_AUTO , - p->vid_hdr_offs, -CONFIG_MTD_UBI_BEB_LIMIT ); + p->vid_hdr_offs, p->max_beb_per1024);mutex_unlock (&ubi_devices_mutex);if (err <0 ) {ubi_err ("cannot attach mtd%d" , mtd->index);
@@ -1349,6 +1350,7 @@ static int __init ubi_mtd_param_parse(const char *val, struct kernel_param *kp)char buf[MTD_PARAM_LEN_MAX ];char *pbuf = &buf[0 ];char *tokens[MTD_PARAM_MAX_COUNT ]; +int err;if (!val)return -EINVAL ;
@@ -1396,23 +1398,32 @@ static int __init ubi_mtd_param_parse(const char *val, struct kernel_param *kp)if (p->vid_hdr_offs <0 )return p->vid_hdr_offs; +/* empty string will be treated as default */ +if (tokens[2 ] && (*tokens[2 ] !='\0' )) { + err =kstrtoint (tokens[2 ],10 , &p->max_beb_per1024); +if (err) { +pr_err ("UBI error: bad value for max_beb_per1024 parameter: %s" , + tokens[2 ]); +return -EINVAL ; + } + } + mtd_devs +=1 ;return 0 ; }module_param_call (mtd, ubi_mtd_param_parse,NULL ,NULL ,000 ); -MODULE_PARM_DESC (mtd,"MTD devices to attach. Parameter format: " -"mtd=<name|num|path>[,<vid_hdr_offs>].\n" +MODULE_PARM_DESC(mtd, "MTD devices to attach. Parameter format: mtd=<name|num|path>[,<vid_hdr_offs>[,max_beb_per1024]].\n" "Multiple \"mtd\" parameters may be specified.\n" -"MTD devices may be specified by their number, name, or " -"path to the MTD character device node.\n" -"Optional \"vid_hdr_offs\" parameter specifies UBI VID " -"header position to be used by UBI.\n" -"Example 1: mtd=/dev/mtd0 - attach MTD device " -"/dev/mtd0.\n" -"Example 2: mtd=content,1984 mtd=4 - attach MTD device " -"with name \"content\" using VID header offset 1984, and " -"MTD device number 4 with default VID header offset." ); + "MTD devices may be specified by their number, name, or path to the MTD character device node.\n" + "Optional \"vid_hdr_offs\" parameter specifies UBI VID header position to be used by UBI. (default value if 0 or not set)\n" + "Optional \"max_beb_per1024\" parameter specifies the maximum expected bad eraseblock per 1024 eraseblocks. (default value (" + __stringify(CONFIG_MTD_UBI_BEB_LIMIT) ") if 0 or not set)\n" +"\n" +"Example 1: mtd=/dev/mtd0 - attach MTD device /dev/mtd0.\n" +"Example 2: mtd=content,1984 mtd=4 - attach MTD device with name \"content\" using VID header offset 1984, and MTD device number 4 with default VID header offset.\n" +"Example 3: mtd=/dev/mtd1,0,25 - attach MTD device /dev/mtd1 using default VID header offset and reserve 25*nand_size_in_blocks/1024 erase blocks for bad block handling.\n" +"\t(e.g. if the NAND *chipset* has 4096 PEB, 100 will be reserved for this UBI device)." );MODULE_VERSION (__stringify (UBI_VERSION ));MODULE_DESCRIPTION ("UBI - Unsorted Block Images" );
Signature · 1 line
1.7.2.5
PATCH v2 6/7 UBI: add ioctl for max_beb_per1024
In reply to Richard GenoudThis patch provides the possibility to adjust the "maximum expected number of bad blocks per 1024 blocks" (max_beb_per1024) for each mtd device from UBI_IOCATT ioctl.
The majority of NAND devices have their max_beb_per1024 equal to 20, but sometimes it's more.
We already could adjust that via a kernel parameter, now we can also use UBI_IOCATT ioctl:
struct ubi_attach_req {
__s32 ubi_num;
__s32 mtd_num;
__s32 vid_hdr_offset;
__u16 max_beb_per1024;
__s8 padding[10];
};--- drivers/mtd/ubi/Kconfig | 3 ++- drivers/mtd/ubi/build.c | 2 ++ drivers/mtd/ubi/cdev.c | 2 +- include/mtd/ubi-user.h | 19 ++++++++++++++++++- 4 files changed, 23 insertions(+), 3 deletions(-)
drivers/mtd/ubi/Kconfig +2 -1
@@ -51,7 +51,8 @@ config MTD_UBI_BEB_LIMIT MTD partitions of the same size, UBI will reserve 40 eraseblocks when attaching a partition. - This option can be overridden by the kernel parameter ubi.mtd. + This option can be overridden by the kernel parameter ubi.mtd and the + ioctl UBI_IOCATT. Leave the default value if unsure.
drivers/mtd/ubi/build.c +2 -0
@@ -865,6 +865,8 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,/* * Use the default value if max_beb_per1024 isn't provided. +* This way, we are keeping the same behaviour between the UBI_IOCATT +* ioctl and the module parameter. */ if (!max_beb_per1024) max_beb_per1024 =CONFIG_MTD_UBI_BEB_LIMIT ;
drivers/mtd/ubi/cdev.c +1 -1
@@ -1011,7 +1011,7 @@ static long ctrl_cdev_ioctl(struct file *file, unsigned int cmd,*/ mutex_lock (&ubi_devices_mutex); err =ubi_attach_mtd_dev (mtd, req.ubi_num, req.vid_hdr_offset, -CONFIG_MTD_UBI_BEB_LIMIT ); + req.max_beb_per1024);mutex_unlock (&ubi_devices_mutex);if (err <0 )put_mtd_device (mtd);
include/mtd/ubi-user.h +18 -1
@@ -222,6 +222,7 @@ enum {* @ubi_num: UBI device number to create * @mtd_num: MTD device number to attach * @vid_hdr_offset: VID header offset (use defaults if %0) +* @max_beb_per1024: Maximum expected bad eraseblocks per 1024 eraseblocks * @padding: reserved for future, not used, has to be zeroed * * This data structure is used to specify MTD device UBI has to attach and the
@@ -245,12 +246,28 @@ enum {* be 2KiB-64 bytes = 1984. Note, that this position is not even 512-bytes * aligned, which is OK, as UBI is clever enough to realize this is 4th * sub-page of the first page and add needed padding. +* +* The @max_beb_per1024 is the maximum bad eraseblocks UBI expects on the ubi +* device per 1024 eraseblocks. +* This value is often given in an other form in the NAND datasheet (min NVB +* i.e. minimal number of valid blocks). The maximum expected bad eraseblocks +* per 1024 is then: +* 1024 * (1 - MinNVB / MaxNVB) +* Which gives 20 for most NAND devices. +* This limit is used in order to derive amount of eraseblock UBI reserves for +* handling new bad blocks. +* If the device has more bad eraseblocks than this limit, UBI does not reserve +* any physical eraseblocks for new bad eraseblocks, but attempts to use +* available eraseblocks (if any). +* The accepted range is 0-768. If 0 is given, the default kernel value will be +* used for compatibility. */ struct ubi_attach_req {__s32 ubi_num;__s32 mtd_num;__s32 vid_hdr_offset; -__s8 padding[12 ]; +__u16 max_beb_per1024; +__s8 padding[10 ]; };/**
Signature · 1 line
1.7.2.5
PATCH v2 7/7 UBI: drop CONFIG_MTD_UBI_BEB_LIMIT
In reply to Richard GenoudThis option can be set by a kernel parameter and an ioctl, so we may not need the kernel config option any more.
--- arch/arm/configs/sam9_l9260_defconfig | 1 - drivers/mtd/ubi/Kconfig | 29 ----------------------------- drivers/mtd/ubi/build.c | 4 ++-- drivers/mtd/ubi/ubi.h | 3 +++ 4 files changed, 5 insertions(+), 32 deletions(-)
arch/arm/configs/sam9_l9260_defconfig +0 -1
@@ -39,7 +39,6 @@ CONFIG_MTD_NAND=y CONFIG_MTD_NAND_ATMEL=y CONFIG_MTD_NAND_PLATFORM=y CONFIG_MTD_UBI=y -CONFIG_MTD_UBI_BEB_LIMIT=25 CONFIG_MTD_UBI_GLUEBI=y CONFIG_BLK_DEV_LOOP=y CONFIG_BLK_DEV_RAM=y
drivers/mtd/ubi/Kconfig +0 -29
@@ -27,35 +27,6 @@ config MTD_UBI_WL_THRESHOLD life-cycle less than 10000, the threshold should be lessened (e.g., to 128 or 256, although it does not have to be power of 2). -config MTD_UBI_BEB_LIMIT - int "Maximum expected bad eraseblock count per 1024 eraseblocks" - default 20 - range 0 768 - help - This option specifies the maximum bad physical eraseblocks UBI - expects on the MTD device (per 1024 eraseblocks). If the underlying - flash does not admit of bad eraseblocks (e.g. NOR flash), this value - is ignored. - - NAND datasheets often specify the minimum and maximum NVM (Number of - Valid Blocks) for the flashes' endurance lifetime. The maximum - expected bad eraseblocks per 1024 eraseblocks then can be calculated - as "1024 * (1 - MinNVB / MaxNVB)", which gives 20 for most NANDs - (MaxNVB is basically the total count of eraseblocks on the chip). - - To put it differently, if this value is 20, UBI will try to reserve - about 1.9% of physical eraseblocks for bad blocks handling. And that - will be 1.9% of eraseblocks on the entire NAND chip, not just the MTD - partition UBI attaches. This means that if you have, say, a NAND - flash chip admits maximum 40 bad eraseblocks, and it is split on two - MTD partitions of the same size, UBI will reserve 40 eraseblocks when - attaching a partition. - - This option can be overridden by the kernel parameter ubi.mtd and the - ioctl UBI_IOCATT. - - Leave the default value if unsure. - config MTD_UBI_GLUEBI tristate "MTD devices emulation driver (gluebi)" help
drivers/mtd/ubi/build.c +2 -2
@@ -869,7 +869,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,* ioctl and the module parameter. */ if (!max_beb_per1024) - max_beb_per1024 =CONFIG_MTD_UBI_BEB_LIMIT ; + max_beb_per1024 =MTD_UBI_DEFAULT_BEB_LIMIT ;/* * Check if we already have the same MTD device attached.
@@ -1420,7 +1420,7 @@ MODULE_PARM_DESC(mtd, "MTD devices to attach. Parameter format: mtd=<name|num|pa"MTD devices may be specified by their number, name, or path to the MTD character device node.\n" "Optional \"vid_hdr_offs\" parameter specifies UBI VID header position to be used by UBI. (default value if 0 or not set)\n" "Optional \"max_beb_per1024\" parameter specifies the maximum expected bad eraseblock per 1024 eraseblocks. (default value (" - __stringify(CONFIG_MTD_UBI_BEB_LIMIT) ") if 0 or not set)\n" + __stringify(MTD_UBI_DEFAULT_BEB_LIMIT) ") if 0 or not set)\n""\n" "Example 1: mtd=/dev/mtd0 - attach MTD device /dev/mtd0.\n" "Example 2: mtd=content,1984 mtd=4 - attach MTD device with name \"content\" using VID header offset 1984, and MTD device number 4 with default VID header offset.\n"
drivers/mtd/ubi/ubi.h +3 -0
@@ -50,6 +50,9 @@/* UBI name used for character devices, sysfs, etc */ #define UBI_NAME_STR "ubi" +/* Default number of maximum expected bad blocks per 1024 eraseblocks */ +#define MTD_UBI_DEFAULT_BEB_LIMIT 20 +/* Normal UBI messages */ #define ubi_msg (fmt, ...) printk(KERN_NOTICE "UBI: " fmt "\n", ##__VA_ARGS__)/* UBI warning messages */
Signature · 1 line
1.7.2.5