diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2011-05-18 09:21:43 -0400 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2011-06-01 04:23:12 -0400 |
commit | cd6d8567a42907d4e7add0b08f9a2d846690fc65 (patch) | |
tree | c86567ce86f98b01c0c150d8fe6625321c8de93c /drivers/mtd | |
parent | 18073733247dc0c31e07f3a87f3267fe8d7e7022 (diff) |
UBI: switch debugging tests knobs to debugfs
Kill the UBI 'debug_tsts' module parameter and switch to debugfs. Create
per-test mode files there. E.g., to enable bit-flips emulation you may just do:
echo 1 > /sys/kernel/debug/ubi/ubi0/tst_emulate_bitflips
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/ubi/debug.c | 40 | ||||
-rw-r--r-- | drivers/mtd/ubi/debug.h | 37 |
2 files changed, 49 insertions, 28 deletions
diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c index dce1227929f1..ab80c0debac8 100644 --- a/drivers/mtd/ubi/debug.c +++ b/drivers/mtd/ubi/debug.c | |||
@@ -30,13 +30,6 @@ | |||
30 | #include <linux/debugfs.h> | 30 | #include <linux/debugfs.h> |
31 | #include <linux/uaccess.h> | 31 | #include <linux/uaccess.h> |
32 | #include <linux/module.h> | 32 | #include <linux/module.h> |
33 | #include <linux/moduleparam.h> | ||
34 | |||
35 | unsigned int ubi_tst_flags; | ||
36 | |||
37 | module_param_named(debug_tsts, ubi_tst_flags, uint, S_IRUGO | S_IWUSR); | ||
38 | |||
39 | MODULE_PARM_DESC(debug_tsts, "Debug special test flags"); | ||
40 | 33 | ||
41 | /** | 34 | /** |
42 | * ubi_dbg_dump_ec_hdr - dump an erase counter header. | 35 | * ubi_dbg_dump_ec_hdr - dump an erase counter header. |
@@ -318,6 +311,12 @@ static ssize_t dfs_file_read(struct file *file, char __user *user_buf, | |||
318 | val = d->chk_gen; | 311 | val = d->chk_gen; |
319 | else if (dent == d->dfs_chk_io) | 312 | else if (dent == d->dfs_chk_io) |
320 | val = d->chk_io; | 313 | val = d->chk_io; |
314 | else if (dent == d->dfs_disable_bgt) | ||
315 | val = d->disable_bgt; | ||
316 | else if (dent == d->dfs_emulate_bitflips) | ||
317 | val = d->emulate_bitflips; | ||
318 | else if (dent == d->dfs_emulate_io_failures) | ||
319 | val = d->emulate_io_failures; | ||
321 | else { | 320 | else { |
322 | count = -EINVAL; | 321 | count = -EINVAL; |
323 | goto out; | 322 | goto out; |
@@ -373,6 +372,12 @@ static ssize_t dfs_file_write(struct file *file, const char __user *user_buf, | |||
373 | d->chk_gen = val; | 372 | d->chk_gen = val; |
374 | else if (dent == d->dfs_chk_io) | 373 | else if (dent == d->dfs_chk_io) |
375 | d->chk_io = val; | 374 | d->chk_io = val; |
375 | else if (dent == d->dfs_disable_bgt) | ||
376 | d->disable_bgt = val; | ||
377 | else if (dent == d->dfs_emulate_bitflips) | ||
378 | d->emulate_bitflips = val; | ||
379 | else if (dent == d->dfs_emulate_io_failures) | ||
380 | d->emulate_io_failures = val; | ||
376 | else | 381 | else |
377 | count = -EINVAL; | 382 | count = -EINVAL; |
378 | 383 | ||
@@ -442,6 +447,27 @@ int ubi_debugfs_init_dev(struct ubi_device *ubi) | |||
442 | goto out_remove; | 447 | goto out_remove; |
443 | d->dfs_chk_io = dent; | 448 | d->dfs_chk_io = dent; |
444 | 449 | ||
450 | fname = "tst_disable_bgt"; | ||
451 | dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, (void *)ubi_num, | ||
452 | &dfs_fops); | ||
453 | if (IS_ERR_OR_NULL(dent)) | ||
454 | goto out_remove; | ||
455 | d->dfs_disable_bgt = dent; | ||
456 | |||
457 | fname = "tst_emulate_bitflips"; | ||
458 | dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, (void *)ubi_num, | ||
459 | &dfs_fops); | ||
460 | if (IS_ERR_OR_NULL(dent)) | ||
461 | goto out_remove; | ||
462 | d->dfs_emulate_bitflips = dent; | ||
463 | |||
464 | fname = "tst_emulate_io_failures"; | ||
465 | dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, (void *)ubi_num, | ||
466 | &dfs_fops); | ||
467 | if (IS_ERR_OR_NULL(dent)) | ||
468 | goto out_remove; | ||
469 | d->dfs_emulate_io_failures = dent; | ||
470 | |||
445 | return 0; | 471 | return 0; |
446 | 472 | ||
447 | out_remove: | 473 | out_remove: |
diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h index ef97c12fe9b8..65b5b76cc379 100644 --- a/drivers/mtd/ubi/debug.h +++ b/drivers/mtd/ubi/debug.h | |||
@@ -85,35 +85,30 @@ void ubi_debugfs_exit_dev(struct ubi_device *ubi); | |||
85 | * | 85 | * |
86 | * @chk_gen: if UBI general extra checks are enabled | 86 | * @chk_gen: if UBI general extra checks are enabled |
87 | * @chk_io: if UBI I/O extra checks are enabled | 87 | * @chk_io: if UBI I/O extra checks are enabled |
88 | * @disable_bgt: disable the background task for testing purposes | ||
89 | * @emulate_bitflips: emulate bit-flips for testing purposes | ||
90 | * @emulate_io_failures: emulate write/erase failures for testing purposes | ||
88 | * @dfs_dir_name: name of debugfs directory containing files of this UBI device | 91 | * @dfs_dir_name: name of debugfs directory containing files of this UBI device |
89 | * @dfs_dir: direntry object of the UBI device debugfs directory | 92 | * @dfs_dir: direntry object of the UBI device debugfs directory |
90 | * @dfs_chk_gen: debugfs knob to enable UBI general extra checks | 93 | * @dfs_chk_gen: debugfs knob to enable UBI general extra checks |
91 | * @dfs_chk_io: debugfs knob to enable UBI I/O extra checks | 94 | * @dfs_chk_io: debugfs knob to enable UBI I/O extra checks |
95 | * @dfs_disable_bgt: debugfs knob to disable the background task | ||
96 | * @dfs_emulate_bitflips: debugfs knob to emulate bit-flips | ||
97 | * @dfs_emulate_io_failures: debugfs knob to emulate write/erase failures | ||
92 | */ | 98 | */ |
93 | struct ubi_debug_info { | 99 | struct ubi_debug_info { |
94 | unsigned int chk_gen:1; | 100 | unsigned int chk_gen:1; |
95 | unsigned int chk_io:1; | 101 | unsigned int chk_io:1; |
102 | unsigned int disable_bgt:1; | ||
103 | unsigned int emulate_bitflips:1; | ||
104 | unsigned int emulate_io_failures:1; | ||
96 | char dfs_dir_name[UBI_DFS_DIR_LEN + 1]; | 105 | char dfs_dir_name[UBI_DFS_DIR_LEN + 1]; |
97 | struct dentry *dfs_dir; | 106 | struct dentry *dfs_dir; |
98 | struct dentry *dfs_chk_gen; | 107 | struct dentry *dfs_chk_gen; |
99 | struct dentry *dfs_chk_io; | 108 | struct dentry *dfs_chk_io; |
100 | }; | 109 | struct dentry *dfs_disable_bgt; |
101 | 110 | struct dentry *dfs_emulate_bitflips; | |
102 | extern unsigned int ubi_tst_flags; | 111 | struct dentry *dfs_emulate_io_failures; |
103 | |||
104 | /* | ||
105 | * Special testing flags. | ||
106 | * | ||
107 | * UBIFS_TST_DISABLE_BGT: disable the background thread | ||
108 | * UBI_TST_EMULATE_BITFLIPS: emulate bit-flips | ||
109 | * UBI_TST_EMULATE_WRITE_FAILURES: emulate write failures | ||
110 | * UBI_TST_EMULATE_ERASE_FAILURES: emulate erase failures | ||
111 | */ | ||
112 | enum { | ||
113 | UBI_TST_DISABLE_BGT = 0x1, | ||
114 | UBI_TST_EMULATE_BITFLIPS = 0x2, | ||
115 | UBI_TST_EMULATE_WRITE_FAILURES = 0x4, | ||
116 | UBI_TST_EMULATE_ERASE_FAILURES = 0x8, | ||
117 | }; | 112 | }; |
118 | 113 | ||
119 | /** | 114 | /** |
@@ -125,7 +120,7 @@ enum { | |||
125 | */ | 120 | */ |
126 | static inline int ubi_dbg_is_bgt_disabled(const struct ubi_device *ubi) | 121 | static inline int ubi_dbg_is_bgt_disabled(const struct ubi_device *ubi) |
127 | { | 122 | { |
128 | return ubi_tst_flags & UBI_TST_DISABLE_BGT; | 123 | return ubi->dbg->disable_bgt; |
129 | } | 124 | } |
130 | 125 | ||
131 | /** | 126 | /** |
@@ -136,7 +131,7 @@ static inline int ubi_dbg_is_bgt_disabled(const struct ubi_device *ubi) | |||
136 | */ | 131 | */ |
137 | static inline int ubi_dbg_is_bitflip(const struct ubi_device *ubi) | 132 | static inline int ubi_dbg_is_bitflip(const struct ubi_device *ubi) |
138 | { | 133 | { |
139 | if (ubi_tst_flags & UBI_TST_EMULATE_BITFLIPS) | 134 | if (ubi->dbg->emulate_bitflips) |
140 | return !(random32() % 200); | 135 | return !(random32() % 200); |
141 | return 0; | 136 | return 0; |
142 | } | 137 | } |
@@ -150,7 +145,7 @@ static inline int ubi_dbg_is_bitflip(const struct ubi_device *ubi) | |||
150 | */ | 145 | */ |
151 | static inline int ubi_dbg_is_write_failure(const struct ubi_device *ubi) | 146 | static inline int ubi_dbg_is_write_failure(const struct ubi_device *ubi) |
152 | { | 147 | { |
153 | if (ubi_tst_flags & UBI_TST_EMULATE_WRITE_FAILURES) | 148 | if (ubi->dbg->emulate_io_failures) |
154 | return !(random32() % 500); | 149 | return !(random32() % 500); |
155 | return 0; | 150 | return 0; |
156 | } | 151 | } |
@@ -164,7 +159,7 @@ static inline int ubi_dbg_is_write_failure(const struct ubi_device *ubi) | |||
164 | */ | 159 | */ |
165 | static inline int ubi_dbg_is_erase_failure(const struct ubi_device *ubi) | 160 | static inline int ubi_dbg_is_erase_failure(const struct ubi_device *ubi) |
166 | { | 161 | { |
167 | if (ubi_tst_flags & UBI_TST_EMULATE_ERASE_FAILURES) | 162 | if (ubi->dbg->emulate_io_failures) |
168 | return !(random32() % 400); | 163 | return !(random32() % 400); |
169 | return 0; | 164 | return 0; |
170 | } | 165 | } |