Skip to content

Commit 5fa7fa5

Browse files
UBI: Add initial support for fastmap self checks
Using this debugfs knob fastmap self checks can be controlled. Signed-off-by: Richard Weinberger <richard@nod.at> Reviewed-by: Tanya Brokhman <tlinder@codeaurora.org>
1 parent 5ca97ad commit 5fa7fa5

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

‎drivers/mtd/ubi/debug.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ static ssize_t dfs_file_read(struct file *file, char __user *user_buf,
275275
val = d->chk_gen;
276276
else if (dent == d->dfs_chk_io)
277277
val = d->chk_io;
278+
else if (dent == d->dfs_chk_fastmap)
279+
val = d->chk_fastmap;
278280
else if (dent == d->dfs_disable_bgt)
279281
val = d->disable_bgt;
280282
else if (dent == d->dfs_emulate_bitflips)
@@ -336,6 +338,8 @@ static ssize_t dfs_file_write(struct file *file, const char __user *user_buf,
336338
d->chk_gen = val;
337339
else if (dent == d->dfs_chk_io)
338340
d->chk_io = val;
341+
else if (dent == d->dfs_chk_fastmap)
342+
d->chk_fastmap = val;
339343
else if (dent == d->dfs_disable_bgt)
340344
d->disable_bgt = val;
341345
else if (dent == d->dfs_emulate_bitflips)
@@ -406,6 +410,13 @@ int ubi_debugfs_init_dev(struct ubi_device *ubi)
406410
goto out_remove;
407411
d->dfs_chk_io = dent;
408412

413+
fname = "chk_fastmap";
414+
dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, (void *)ubi_num,
415+
&dfs_fops);
416+
if (IS_ERR_OR_NULL(dent))
417+
goto out_remove;
418+
d->dfs_chk_fastmap = dent;
419+
409420
fname = "tst_disable_bgt";
410421
dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, (void *)ubi_num,
411422
&dfs_fops);

‎drivers/mtd/ubi/debug.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,9 @@ static inline int ubi_dbg_chk_gen(const struct ubi_device *ubi)
127127
{
128128
return ubi->dbg.chk_gen;
129129
}
130+
131+
static inline int ubi_dbg_chk_fastmap(const struct ubi_device *ubi)
132+
{
133+
return ubi->dbg.chk_fastmap;
134+
}
130135
#endif /* !__UBI_DEBUG_H__ */

‎drivers/mtd/ubi/ubi.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,27 +356,31 @@ struct ubi_wl_entry;
356356
*
357357
* @chk_gen: if UBI general extra checks are enabled
358358
* @chk_io: if UBI I/O extra checks are enabled
359+
* @chk_fastmap: if UBI fastmap extra checks are enabled
359360
* @disable_bgt: disable the background task for testing purposes
360361
* @emulate_bitflips: emulate bit-flips for testing purposes
361362
* @emulate_io_failures: emulate write/erase failures for testing purposes
362363
* @dfs_dir_name: name of debugfs directory containing files of this UBI device
363364
* @dfs_dir: direntry object of the UBI device debugfs directory
364365
* @dfs_chk_gen: debugfs knob to enable UBI general extra checks
365366
* @dfs_chk_io: debugfs knob to enable UBI I/O extra checks
367+
* @dfs_chk_fastmap: debugfs knob to enable UBI fastmap extra checks
366368
* @dfs_disable_bgt: debugfs knob to disable the background task
367369
* @dfs_emulate_bitflips: debugfs knob to emulate bit-flips
368370
* @dfs_emulate_io_failures: debugfs knob to emulate write/erase failures
369371
*/
370372
struct ubi_debug_info {
371373
unsigned int chk_gen:1;
372374
unsigned int chk_io:1;
375+
unsigned int chk_fastmap:1;
373376
unsigned int disable_bgt:1;
374377
unsigned int emulate_bitflips:1;
375378
unsigned int emulate_io_failures:1;
376379
char dfs_dir_name[UBI_DFS_DIR_LEN + 1];
377380
struct dentry *dfs_dir;
378381
struct dentry *dfs_chk_gen;
379382
struct dentry *dfs_chk_io;
383+
struct dentry *dfs_chk_fastmap;
380384
struct dentry *dfs_disable_bgt;
381385
struct dentry *dfs_emulate_bitflips;
382386
struct dentry *dfs_emulate_io_failures;

0 commit comments

Comments
 (0)