Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 255088
b: refs/heads/master
c: cd6d856
h: refs/heads/master
v: v3
  • Loading branch information
Artem Bityutskiy authored and Artem Bityutskiy committed Jun 1, 2011
1 parent db543cd commit aacee52
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 29 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 18073733247dc0c31e07f3a87f3267fe8d7e7022
refs/heads/master: cd6d8567a42907d4e7add0b08f9a2d846690fc65
40 changes: 33 additions & 7 deletions trunk/drivers/mtd/ubi/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@
#include <linux/debugfs.h>
#include <linux/uaccess.h>
#include <linux/module.h>
#include <linux/moduleparam.h>

unsigned int ubi_tst_flags;

module_param_named(debug_tsts, ubi_tst_flags, uint, S_IRUGO | S_IWUSR);

MODULE_PARM_DESC(debug_tsts, "Debug special test flags");

/**
* ubi_dbg_dump_ec_hdr - dump an erase counter header.
Expand Down Expand Up @@ -318,6 +311,12 @@ static ssize_t dfs_file_read(struct file *file, char __user *user_buf,
val = d->chk_gen;
else if (dent == d->dfs_chk_io)
val = d->chk_io;
else if (dent == d->dfs_disable_bgt)
val = d->disable_bgt;
else if (dent == d->dfs_emulate_bitflips)
val = d->emulate_bitflips;
else if (dent == d->dfs_emulate_io_failures)
val = d->emulate_io_failures;
else {
count = -EINVAL;
goto out;
Expand Down Expand Up @@ -373,6 +372,12 @@ static ssize_t dfs_file_write(struct file *file, const char __user *user_buf,
d->chk_gen = val;
else if (dent == d->dfs_chk_io)
d->chk_io = val;
else if (dent == d->dfs_disable_bgt)
d->disable_bgt = val;
else if (dent == d->dfs_emulate_bitflips)
d->emulate_bitflips = val;
else if (dent == d->dfs_emulate_io_failures)
d->emulate_io_failures = val;
else
count = -EINVAL;

Expand Down Expand Up @@ -442,6 +447,27 @@ int ubi_debugfs_init_dev(struct ubi_device *ubi)
goto out_remove;
d->dfs_chk_io = dent;

fname = "tst_disable_bgt";
dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, (void *)ubi_num,
&dfs_fops);
if (IS_ERR_OR_NULL(dent))
goto out_remove;
d->dfs_disable_bgt = dent;

fname = "tst_emulate_bitflips";
dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, (void *)ubi_num,
&dfs_fops);
if (IS_ERR_OR_NULL(dent))
goto out_remove;
d->dfs_emulate_bitflips = dent;

fname = "tst_emulate_io_failures";
dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, (void *)ubi_num,
&dfs_fops);
if (IS_ERR_OR_NULL(dent))
goto out_remove;
d->dfs_emulate_io_failures = dent;

return 0;

out_remove:
Expand Down
37 changes: 16 additions & 21 deletions trunk/drivers/mtd/ubi/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,35 +85,30 @@ void ubi_debugfs_exit_dev(struct ubi_device *ubi);
*
* @chk_gen: if UBI general extra checks are enabled
* @chk_io: if UBI I/O extra checks are enabled
* @disable_bgt: disable the background task for testing purposes
* @emulate_bitflips: emulate bit-flips for testing purposes
* @emulate_io_failures: emulate write/erase failures for testing purposes
* @dfs_dir_name: name of debugfs directory containing files of this UBI device
* @dfs_dir: direntry object of the UBI device debugfs directory
* @dfs_chk_gen: debugfs knob to enable UBI general extra checks
* @dfs_chk_io: debugfs knob to enable UBI I/O extra checks
* @dfs_disable_bgt: debugfs knob to disable the background task
* @dfs_emulate_bitflips: debugfs knob to emulate bit-flips
* @dfs_emulate_io_failures: debugfs knob to emulate write/erase failures
*/
struct ubi_debug_info {
unsigned int chk_gen:1;
unsigned int chk_io:1;
unsigned int disable_bgt:1;
unsigned int emulate_bitflips:1;
unsigned int emulate_io_failures:1;
char dfs_dir_name[UBI_DFS_DIR_LEN + 1];
struct dentry *dfs_dir;
struct dentry *dfs_chk_gen;
struct dentry *dfs_chk_io;
};

extern unsigned int ubi_tst_flags;

/*
* Special testing flags.
*
* UBIFS_TST_DISABLE_BGT: disable the background thread
* UBI_TST_EMULATE_BITFLIPS: emulate bit-flips
* UBI_TST_EMULATE_WRITE_FAILURES: emulate write failures
* UBI_TST_EMULATE_ERASE_FAILURES: emulate erase failures
*/
enum {
UBI_TST_DISABLE_BGT = 0x1,
UBI_TST_EMULATE_BITFLIPS = 0x2,
UBI_TST_EMULATE_WRITE_FAILURES = 0x4,
UBI_TST_EMULATE_ERASE_FAILURES = 0x8,
struct dentry *dfs_disable_bgt;
struct dentry *dfs_emulate_bitflips;
struct dentry *dfs_emulate_io_failures;
};

/**
Expand All @@ -125,7 +120,7 @@ enum {
*/
static inline int ubi_dbg_is_bgt_disabled(const struct ubi_device *ubi)
{
return ubi_tst_flags & UBI_TST_DISABLE_BGT;
return ubi->dbg->disable_bgt;
}

/**
Expand All @@ -136,7 +131,7 @@ static inline int ubi_dbg_is_bgt_disabled(const struct ubi_device *ubi)
*/
static inline int ubi_dbg_is_bitflip(const struct ubi_device *ubi)
{
if (ubi_tst_flags & UBI_TST_EMULATE_BITFLIPS)
if (ubi->dbg->emulate_bitflips)
return !(random32() % 200);
return 0;
}
Expand All @@ -150,7 +145,7 @@ static inline int ubi_dbg_is_bitflip(const struct ubi_device *ubi)
*/
static inline int ubi_dbg_is_write_failure(const struct ubi_device *ubi)
{
if (ubi_tst_flags & UBI_TST_EMULATE_WRITE_FAILURES)
if (ubi->dbg->emulate_io_failures)
return !(random32() % 500);
return 0;
}
Expand All @@ -164,7 +159,7 @@ static inline int ubi_dbg_is_write_failure(const struct ubi_device *ubi)
*/
static inline int ubi_dbg_is_erase_failure(const struct ubi_device *ubi)
{
if (ubi_tst_flags & UBI_TST_EMULATE_ERASE_FAILURES)
if (ubi->dbg->emulate_io_failures)
return !(random32() % 400);
return 0;
}
Expand Down

0 comments on commit aacee52

Please sign in to comment.