From patchwork Tue Mar 15 09:00:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artem Bityutskiy X-Patchwork-Id: 86895 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 43C66B700D for ; Tue, 15 Mar 2011 19:59:55 +1100 (EST) Received: from canuck.infradead.org ([2001:4978:20e::1]) by bombadil.infradead.org with esmtps (Exim 4.72 #1 (Red Hat Linux)) id 1PzQ5T-0000Wt-1g; Tue, 15 Mar 2011 08:58:43 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1PzQ5P-0007YB-Ib; Tue, 15 Mar 2011 08:58:39 +0000 Received: from smtp.nokia.com ([147.243.128.24] helo=mgw-da01.nokia.com) by canuck.infradead.org with esmtps (Exim 4.72 #1 (Red Hat Linux)) id 1PzQ4n-0007US-8D for linux-mtd@lists.infradead.org; Tue, 15 Mar 2011 08:58:06 +0000 Received: from nokia.com (localhost [127.0.0.1]) by mgw-da01.nokia.com (Switch-3.4.3/Switch-3.4.3) with ESMTP id p2F8vwUc031816 for ; Tue, 15 Mar 2011 10:57:59 +0200 Received: from eru.research.nokia.com ([[172.21.24.59]]) by mgw-da01.nokia.com with ESMTP id p2F8vdmg031449 ; Tue, 15 Mar 2011 10:57:56 +0200 From: Artem Bityutskiy To: MTD list Subject: [PATCH 7/7] UBI: make tests modes dynamic Date: Tue, 15 Mar 2011 11:00:36 +0200 Message-Id: <1300179636-12183-8-git-send-email-dedekind1@gmail.com> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1300179636-12183-1-git-send-email-dedekind1@gmail.com> References: <1300179636-12183-1-git-send-email-dedekind1@gmail.com> X-Nokia-AV: Clean X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110315_045801_692586_B85BF7DF X-CRM114-Status: GOOD ( 19.18 ) X-Spam-Score: 2.7 (++) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [147.243.128.24 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is freemail (dedekind1[at]gmail.com) 0.0 DKIM_ADSP_CUSTOM_MED No valid author signature, adsp_override is CUSTOM_MED 2.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (dedekind1[at]gmail.com) 1.2 NML_ADSP_CUSTOM_MED ADSP custom_med hit, and not from a mailing list Cc: Adrian Hunter X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Artem Bityutskiy 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 --- drivers/mtd/ubi/Kconfig | 8 ++++++- drivers/mtd/ubi/Kconfig.debug | 37 --------------------------------- drivers/mtd/ubi/build.c | 3 +- drivers/mtd/ubi/debug.c | 3 ++ drivers/mtd/ubi/debug.h | 46 +++++++++++++++++++++++++---------------- drivers/mtd/ubi/wl.c | 4 +- 6 files changed, 41 insertions(+), 60 deletions(-) delete mode 100644 drivers/mtd/ubi/Kconfig.debug diff --git a/drivers/mtd/ubi/Kconfig b/drivers/mtd/ubi/Kconfig index 3cf193f..6abeb4f 100644 --- a/drivers/mtd/ubi/Kconfig +++ b/drivers/mtd/ubi/Kconfig @@ -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 index d8d33dd..0000000 --- a/drivers/mtd/ubi/Kconfig.debug +++ /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 diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 3a04719..a801ea6 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) * 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); diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c index 4c7a3f6..d4d07e5 100644 --- a/drivers/mtd/ubi/debug.c +++ b/drivers/mtd/ubi/debug.c @@ -32,12 +32,15 @@ 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. diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h index 2511b58..c713f0b 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); 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. * @@ -132,11 +153,7 @@ static inline int ubi_dbg_is_bitflip(void) { return !(random32() % 200); } -#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. * @@ -147,11 +164,7 @@ static inline int ubi_dbg_is_write_failure(void) { return !(random32() % 500); } -#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. * @@ -162,9 +175,6 @@ static inline int ubi_dbg_is_erase_failure(void) { return !(random32() % 400); } -#else -#define ubi_dbg_is_erase_failure() 0 -#endif #else @@ -187,7 +197,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 diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c index 4e55290..b4cf57d 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) 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();