]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
UBI: make tests modes dynamic
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Tue, 15 Mar 2011 08:30:40 +0000 (10:30 +0200)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Wed, 16 Mar 2011 11:50:17 +0000 (13:50 +0200)
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>
drivers/mtd/ubi/Kconfig
drivers/mtd/ubi/Kconfig.debug [deleted file]
drivers/mtd/ubi/build.c
drivers/mtd/ubi/debug.c
drivers/mtd/ubi/debug.h
drivers/mtd/ubi/wl.c

index 3cf193fb5e00c722b864f194939c525c9cd73f23..6abeb4f1340372796e81f0e7ad920182f5734aa8 100644 (file)
@@ -52,6 +52,12 @@ config MTD_UBI_GLUEBI
           work on top of UBI. Do not enable this unless you use legacy
           software.
 
-source "drivers/mtd/ubi/Kconfig.debug"
+config MTD_UBI_DEBUG
+       bool "UBI debugging"
+       depends on SYSFS
+       select DEBUG_FS
+       select KALLSYMS_ALL if KALLSYMS && DEBUG_KERNEL
+       help
+         This option enables UBI debugging.
 
 endif # MTD_UBI
diff --git a/drivers/mtd/ubi/Kconfig.debug b/drivers/mtd/ubi/Kconfig.debug
deleted file mode 100644 (file)
index d8d33dd..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-comment "UBI debugging options"
-
-config MTD_UBI_DEBUG
-       bool "UBI debugging"
-       depends on SYSFS
-       select DEBUG_FS
-       select KALLSYMS_ALL if KALLSYMS && DEBUG_KERNEL
-       help
-         This option enables UBI debugging.
-
-if MTD_UBI_DEBUG
-
-config MTD_UBI_DEBUG_DISABLE_BGT
-       bool "Do not enable the UBI background thread"
-       help
-         This option switches the background thread off by default. The thread
-         may be also be enabled/disabled via UBI sysfs.
-
-config MTD_UBI_DEBUG_EMULATE_BITFLIPS
-       bool "Emulate flash bit-flips"
-       help
-         This option emulates bit-flips with probability 1/50, which in turn
-         causes scrubbing. Useful for debugging and stressing UBI.
-
-config MTD_UBI_DEBUG_EMULATE_WRITE_FAILURES
-       bool "Emulate flash write failures"
-       help
-         This option emulates write failures with probability 1/100. Useful for
-         debugging and testing how UBI handlines errors.
-
-config MTD_UBI_DEBUG_EMULATE_ERASE_FAILURES
-       bool "Emulate flash erase failures"
-       help
-         This option emulates erase failures with probability 1/100. Useful for
-         debugging and testing how UBI handlines errors.
-
-endif # MTD_UBI_DEBUG
index 3a047199a105f3ae41b6b36faec069d26f090395..a801ea6b8b6d5cff1fb0208a2dd1c20e28c0ebf3 100644 (file)
@@ -986,8 +986,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
         * checks @ubi->thread_enabled. Otherwise we may fail to wake it up.
         */
        spin_lock(&ubi->wl_lock);
-       if (!DBG_DISABLE_BGT)
-               ubi->thread_enabled = 1;
+       ubi->thread_enabled = 1;
        wake_up_process(ubi->bgt_thread);
        spin_unlock(&ubi->wl_lock);
 
index 4c7a3f67156b0f039b00da286c0c0e40702e0c01..d4d07e5f138f2ccdd4267d5166ee93647a71873f 100644 (file)
 
 unsigned int ubi_msg_flags;
 unsigned int ubi_chk_flags;
+unsigned int ubi_tst_flags;
 
 module_param_named(debug_msgs, ubi_msg_flags, uint, S_IRUGO | S_IWUSR);
 module_param_named(debug_chks, ubi_chk_flags, uint, S_IRUGO | S_IWUSR);
+module_param_named(debug_tsts, ubi_chk_flags, uint, S_IRUGO | S_IWUSR);
 
 MODULE_PARM_DESC(debug_msgs, "Debug message type flags");
 MODULE_PARM_DESC(debug_chks, "Debug check flags");
+MODULE_PARM_DESC(debug_tsts, "Debug special test flags");
 
 /**
  * ubi_dbg_dump_ec_hdr - dump an erase counter header.
index 2511b586490a155937a382c39beaa037f285e8e6..0b0c2888c65694e4ca2782340c41da7c1f91cc5d 100644 (file)
@@ -116,13 +116,34 @@ int ubi_dbg_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len);
 int ubi_dbg_check_write(struct ubi_device *ubi, const void *buf, int pnum,
                        int offset, int len);
 
-#ifdef CONFIG_MTD_UBI_DEBUG_DISABLE_BGT
-#define DBG_DISABLE_BGT 1
-#else
-#define DBG_DISABLE_BGT 0
-#endif
+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,
+};
+
+/**
+ * ubi_dbg_is_bgt_disabled - if the background thread is disabled.
+ *
+ * Returns non-zero if the UBI background thread is disabled for testing
+ * purposes.
+ */
+static inline int ubi_dbg_is_bgt_disabled(void)
+{
+       return ubi_tst_flags & UBI_TST_DISABLE_BGT;
+}
 
-#ifdef CONFIG_MTD_UBI_DEBUG_EMULATE_BITFLIPS
 /**
  * ubi_dbg_is_bitflip - if it is time to emulate a bit-flip.
  *
@@ -130,13 +151,11 @@ int ubi_dbg_check_write(struct ubi_device *ubi, const void *buf, int pnum,
  */
 static inline int ubi_dbg_is_bitflip(void)
 {
-       return !(random32() % 200);
+       if (ubi_tst_flags & UBI_TST_EMULATE_BITFLIPS)
+               return !(random32() % 200);
+       return 0;
 }
-#else
-#define ubi_dbg_is_bitflip() 0
-#endif
 
-#ifdef CONFIG_MTD_UBI_DEBUG_EMULATE_WRITE_FAILURES
 /**
  * ubi_dbg_is_write_failure - if it is time to emulate a write failure.
  *
@@ -145,13 +164,11 @@ static inline int ubi_dbg_is_bitflip(void)
  */
 static inline int ubi_dbg_is_write_failure(void)
 {
-       return !(random32() % 500);
+       if (ubi_tst_flags & UBI_TST_EMULATE_WRITE_FAILURES)
+               return !(random32() % 500);
+       return 0;
 }
-#else
-#define ubi_dbg_is_write_failure() 0
-#endif
 
-#ifdef CONFIG_MTD_UBI_DEBUG_EMULATE_ERASE_FAILURES
 /**
  * ubi_dbg_is_erase_failure - if its time to emulate an erase failure.
  *
@@ -160,11 +177,10 @@ static inline int ubi_dbg_is_write_failure(void)
  */
 static inline int ubi_dbg_is_erase_failure(void)
 {
+       if (ubi_tst_flags & UBI_TST_EMULATE_ERASE_FAILURES)
                return !(random32() % 400);
+       return 0;
 }
-#else
-#define ubi_dbg_is_erase_failure() 0
-#endif
 
 #else
 
@@ -187,7 +203,7 @@ static inline int ubi_dbg_is_erase_failure(void)
 #define ubi_dbg_dump_flash(ubi, pnum, offset, len) ({})
 #define ubi_dbg_print_hex_dump(l, ps, pt, r, g, b, len, a)  ({})
 
-#define DBG_DISABLE_BGT            0
+#define ubi_dbg_is_bgt_disabled()  0
 #define ubi_dbg_is_bitflip()       0
 #define ubi_dbg_is_write_failure() 0
 #define ubi_dbg_is_erase_failure() 0
index 4e5529014c9be6501565f2e22308b16d7a31096b..b4cf57db25561c8323ba97dbccdbc53a50d51306 100644 (file)
@@ -613,7 +613,7 @@ static void schedule_ubi_work(struct ubi_device *ubi, struct ubi_work *wrk)
        list_add_tail(&wrk->list, &ubi->works);
        ubi_assert(ubi->works_count >= 0);
        ubi->works_count += 1;
-       if (ubi->thread_enabled)
+       if (ubi->thread_enabled && !ubi_dbg_is_bgt_disabled())
                wake_up_process(ubi->bgt_thread);
        spin_unlock(&ubi->wl_lock);
 }
@@ -1364,7 +1364,7 @@ int ubi_thread(void *u)
 
                spin_lock(&ubi->wl_lock);
                if (list_empty(&ubi->works) || ubi->ro_mode ||
-                              !ubi->thread_enabled) {
+                   !ubi->thread_enabled || ubi_dbg_is_bgt_disabled()) {
                        set_current_state(TASK_INTERRUPTIBLE);
                        spin_unlock(&ubi->wl_lock);
                        schedule();