aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2011-03-15 04:30:40 -0400
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2011-03-16 07:50:17 -0400
commit28237e4583604818294dc1ce7881db5f53377b9c (patch)
tree84fc5d22a1f4213824445253cc9702be96069b47 /drivers/mtd
parent92d124f5314913a21f7fa98b22ee457dab171edd (diff)
UBI: make tests modes dynamic
Similarly to the debugging checks and message, make the test modes be dynamically selected via the "debug_tsts" module parameter or via the "/sys/module/ubi/parameters/debug_tsts" sysfs file. This is consistent with UBIFS as well. And now, since all the Kconfig knobs became dynamic, we can remove the Kconfig.debug file completely. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/ubi/Kconfig8
-rw-r--r--drivers/mtd/ubi/Kconfig.debug37
-rw-r--r--drivers/mtd/ubi/build.c3
-rw-r--r--drivers/mtd/ubi/debug.c3
-rw-r--r--drivers/mtd/ubi/debug.h56
-rw-r--r--drivers/mtd/ubi/wl.c4
6 files changed, 49 insertions, 62 deletions
diff --git a/drivers/mtd/ubi/Kconfig b/drivers/mtd/ubi/Kconfig
index 3cf193fb5e00..6abeb4f13403 100644
--- a/drivers/mtd/ubi/Kconfig
+++ b/drivers/mtd/ubi/Kconfig
@@ -52,6 +52,12 @@ config MTD_UBI_GLUEBI
52 work on top of UBI. Do not enable this unless you use legacy 52 work on top of UBI. Do not enable this unless you use legacy
53 software. 53 software.
54 54
55source "drivers/mtd/ubi/Kconfig.debug" 55config MTD_UBI_DEBUG
56 bool "UBI debugging"
57 depends on SYSFS
58 select DEBUG_FS
59 select KALLSYMS_ALL if KALLSYMS && DEBUG_KERNEL
60 help
61 This option enables UBI debugging.
56 62
57endif # MTD_UBI 63endif # MTD_UBI
diff --git a/drivers/mtd/ubi/Kconfig.debug b/drivers/mtd/ubi/Kconfig.debug
deleted file mode 100644
index d8d33ddf567d..000000000000
--- a/drivers/mtd/ubi/Kconfig.debug
+++ /dev/null
@@ -1,37 +0,0 @@
1comment "UBI debugging options"
2
3config MTD_UBI_DEBUG
4 bool "UBI debugging"
5 depends on SYSFS
6 select DEBUG_FS
7 select KALLSYMS_ALL if KALLSYMS && DEBUG_KERNEL
8 help
9 This option enables UBI debugging.
10
11if MTD_UBI_DEBUG
12
13config MTD_UBI_DEBUG_DISABLE_BGT
14 bool "Do not enable the UBI background thread"
15 help
16 This option switches the background thread off by default. The thread
17 may be also be enabled/disabled via UBI sysfs.
18
19config MTD_UBI_DEBUG_EMULATE_BITFLIPS
20 bool "Emulate flash bit-flips"
21 help
22 This option emulates bit-flips with probability 1/50, which in turn
23 causes scrubbing. Useful for debugging and stressing UBI.
24
25config MTD_UBI_DEBUG_EMULATE_WRITE_FAILURES
26 bool "Emulate flash write failures"
27 help
28 This option emulates write failures with probability 1/100. Useful for
29 debugging and testing how UBI handlines errors.
30
31config MTD_UBI_DEBUG_EMULATE_ERASE_FAILURES
32 bool "Emulate flash erase failures"
33 help
34 This option emulates erase failures with probability 1/100. Useful for
35 debugging and testing how UBI handlines errors.
36
37endif # MTD_UBI_DEBUG
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 3a047199a105..a801ea6b8b6d 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -986,8 +986,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
986 * checks @ubi->thread_enabled. Otherwise we may fail to wake it up. 986 * checks @ubi->thread_enabled. Otherwise we may fail to wake it up.
987 */ 987 */
988 spin_lock(&ubi->wl_lock); 988 spin_lock(&ubi->wl_lock);
989 if (!DBG_DISABLE_BGT) 989 ubi->thread_enabled = 1;
990 ubi->thread_enabled = 1;
991 wake_up_process(ubi->bgt_thread); 990 wake_up_process(ubi->bgt_thread);
992 spin_unlock(&ubi->wl_lock); 991 spin_unlock(&ubi->wl_lock);
993 992
diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c
index 4c7a3f67156b..d4d07e5f138f 100644
--- a/drivers/mtd/ubi/debug.c
+++ b/drivers/mtd/ubi/debug.c
@@ -32,12 +32,15 @@
32 32
33unsigned int ubi_msg_flags; 33unsigned int ubi_msg_flags;
34unsigned int ubi_chk_flags; 34unsigned int ubi_chk_flags;
35unsigned int ubi_tst_flags;
35 36
36module_param_named(debug_msgs, ubi_msg_flags, uint, S_IRUGO | S_IWUSR); 37module_param_named(debug_msgs, ubi_msg_flags, uint, S_IRUGO | S_IWUSR);
37module_param_named(debug_chks, ubi_chk_flags, uint, S_IRUGO | S_IWUSR); 38module_param_named(debug_chks, ubi_chk_flags, uint, S_IRUGO | S_IWUSR);
39module_param_named(debug_tsts, ubi_chk_flags, uint, S_IRUGO | S_IWUSR);
38 40
39MODULE_PARM_DESC(debug_msgs, "Debug message type flags"); 41MODULE_PARM_DESC(debug_msgs, "Debug message type flags");
40MODULE_PARM_DESC(debug_chks, "Debug check flags"); 42MODULE_PARM_DESC(debug_chks, "Debug check flags");
43MODULE_PARM_DESC(debug_tsts, "Debug special test flags");
41 44
42/** 45/**
43 * ubi_dbg_dump_ec_hdr - dump an erase counter header. 46 * ubi_dbg_dump_ec_hdr - dump an erase counter header.
diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h
index 2511b586490a..0b0c2888c656 100644
--- a/drivers/mtd/ubi/debug.h
+++ b/drivers/mtd/ubi/debug.h
@@ -116,13 +116,34 @@ int ubi_dbg_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len);
116int ubi_dbg_check_write(struct ubi_device *ubi, const void *buf, int pnum, 116int ubi_dbg_check_write(struct ubi_device *ubi, const void *buf, int pnum,
117 int offset, int len); 117 int offset, int len);
118 118
119#ifdef CONFIG_MTD_UBI_DEBUG_DISABLE_BGT 119extern unsigned int ubi_tst_flags;
120#define DBG_DISABLE_BGT 1 120
121#else 121/*
122#define DBG_DISABLE_BGT 0 122 * Special testing flags.
123#endif 123 *
124 * UBIFS_TST_DISABLE_BGT: disable the background thread
125 * UBI_TST_EMULATE_BITFLIPS: emulate bit-flips
126 * UBI_TST_EMULATE_WRITE_FAILURES: emulate write failures
127 * UBI_TST_EMULATE_ERASE_FAILURES: emulate erase failures
128 */
129enum {
130 UBI_TST_DISABLE_BGT = 0x1,
131 UBI_TST_EMULATE_BITFLIPS = 0x2,
132 UBI_TST_EMULATE_WRITE_FAILURES = 0x4,
133 UBI_TST_EMULATE_ERASE_FAILURES = 0x8,
134};
135
136/**
137 * ubi_dbg_is_bgt_disabled - if the background thread is disabled.
138 *
139 * Returns non-zero if the UBI background thread is disabled for testing
140 * purposes.
141 */
142static inline int ubi_dbg_is_bgt_disabled(void)
143{
144 return ubi_tst_flags & UBI_TST_DISABLE_BGT;
145}
124 146
125#ifdef CONFIG_MTD_UBI_DEBUG_EMULATE_BITFLIPS
126/** 147/**
127 * ubi_dbg_is_bitflip - if it is time to emulate a bit-flip. 148 * ubi_dbg_is_bitflip - if it is time to emulate a bit-flip.
128 * 149 *
@@ -130,13 +151,11 @@ int ubi_dbg_check_write(struct ubi_device *ubi, const void *buf, int pnum,
130 */ 151 */
131static inline int ubi_dbg_is_bitflip(void) 152static inline int ubi_dbg_is_bitflip(void)
132{ 153{
133 return !(random32() % 200); 154 if (ubi_tst_flags & UBI_TST_EMULATE_BITFLIPS)
155 return !(random32() % 200);
156 return 0;
134} 157}
135#else
136#define ubi_dbg_is_bitflip() 0
137#endif
138 158
139#ifdef CONFIG_MTD_UBI_DEBUG_EMULATE_WRITE_FAILURES
140/** 159/**
141 * ubi_dbg_is_write_failure - if it is time to emulate a write failure. 160 * ubi_dbg_is_write_failure - if it is time to emulate a write failure.
142 * 161 *
@@ -145,13 +164,11 @@ static inline int ubi_dbg_is_bitflip(void)
145 */ 164 */
146static inline int ubi_dbg_is_write_failure(void) 165static inline int ubi_dbg_is_write_failure(void)
147{ 166{
148 return !(random32() % 500); 167 if (ubi_tst_flags & UBI_TST_EMULATE_WRITE_FAILURES)
168 return !(random32() % 500);
169 return 0;
149} 170}
150#else
151#define ubi_dbg_is_write_failure() 0
152#endif
153 171
154#ifdef CONFIG_MTD_UBI_DEBUG_EMULATE_ERASE_FAILURES
155/** 172/**
156 * ubi_dbg_is_erase_failure - if its time to emulate an erase failure. 173 * ubi_dbg_is_erase_failure - if its time to emulate an erase failure.
157 * 174 *
@@ -160,11 +177,10 @@ static inline int ubi_dbg_is_write_failure(void)
160 */ 177 */
161static inline int ubi_dbg_is_erase_failure(void) 178static inline int ubi_dbg_is_erase_failure(void)
162{ 179{
180 if (ubi_tst_flags & UBI_TST_EMULATE_ERASE_FAILURES)
163 return !(random32() % 400); 181 return !(random32() % 400);
182 return 0;
164} 183}
165#else
166#define ubi_dbg_is_erase_failure() 0
167#endif
168 184
169#else 185#else
170 186
@@ -187,7 +203,7 @@ static inline int ubi_dbg_is_erase_failure(void)
187#define ubi_dbg_dump_flash(ubi, pnum, offset, len) ({}) 203#define ubi_dbg_dump_flash(ubi, pnum, offset, len) ({})
188#define ubi_dbg_print_hex_dump(l, ps, pt, r, g, b, len, a) ({}) 204#define ubi_dbg_print_hex_dump(l, ps, pt, r, g, b, len, a) ({})
189 205
190#define DBG_DISABLE_BGT 0 206#define ubi_dbg_is_bgt_disabled() 0
191#define ubi_dbg_is_bitflip() 0 207#define ubi_dbg_is_bitflip() 0
192#define ubi_dbg_is_write_failure() 0 208#define ubi_dbg_is_write_failure() 0
193#define ubi_dbg_is_erase_failure() 0 209#define ubi_dbg_is_erase_failure() 0
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 4e5529014c9b..b4cf57db2556 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -613,7 +613,7 @@ static void schedule_ubi_work(struct ubi_device *ubi, struct ubi_work *wrk)
613 list_add_tail(&wrk->list, &ubi->works); 613 list_add_tail(&wrk->list, &ubi->works);
614 ubi_assert(ubi->works_count >= 0); 614 ubi_assert(ubi->works_count >= 0);
615 ubi->works_count += 1; 615 ubi->works_count += 1;
616 if (ubi->thread_enabled) 616 if (ubi->thread_enabled && !ubi_dbg_is_bgt_disabled())
617 wake_up_process(ubi->bgt_thread); 617 wake_up_process(ubi->bgt_thread);
618 spin_unlock(&ubi->wl_lock); 618 spin_unlock(&ubi->wl_lock);
619} 619}
@@ -1364,7 +1364,7 @@ int ubi_thread(void *u)
1364 1364
1365 spin_lock(&ubi->wl_lock); 1365 spin_lock(&ubi->wl_lock);
1366 if (list_empty(&ubi->works) || ubi->ro_mode || 1366 if (list_empty(&ubi->works) || ubi->ro_mode ||
1367 !ubi->thread_enabled) { 1367 !ubi->thread_enabled || ubi_dbg_is_bgt_disabled()) {
1368 set_current_state(TASK_INTERRUPTIBLE); 1368 set_current_state(TASK_INTERRUPTIBLE);
1369 spin_unlock(&ubi->wl_lock); 1369 spin_unlock(&ubi->wl_lock);
1370 schedule(); 1370 schedule();