From patchwork Tue Jun 4 01:46:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 248448 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 05C0E2C00A7 for ; Tue, 4 Jun 2013 11:48:08 +1000 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UjgLY-00060c-5k; Tue, 04 Jun 2013 01:47:36 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UjgLV-0007WH-Ne; Tue, 04 Jun 2013 01:47:33 +0000 Received: from mail-pd0-f170.google.com ([209.85.192.170]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UjgLM-0007Ud-R6 for linux-mtd@lists.infradead.org; Tue, 04 Jun 2013 01:47:25 +0000 Received: by mail-pd0-f170.google.com with SMTP id x10so6485995pdj.1 for ; Mon, 03 Jun 2013 18:47:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=WE2C5d9Yqf6IciDrqvTMyqOSXANP1fbnSPfPaSodLNE=; b=FNwSJtB/lvpGOltjnJy4qC8NR4/wVnrm4qZoZzxPqP9afR7GjQyL4bT0XbsHy8UzrL SnMnmOCqtBo/b4xib/H6NU/PzjI8cw41jIJvUtHFPorKqNSJIMbTltJ7r+0o9D1peutN N2MaIj4BbnrnmcL1ZGAaTe5TXjf0WSIbra7LIucyK7ov7djVX8XzNpgVnNF0TKIPcqed lidT1PxnmvICdchzxu+NGkZ4hoDWLMQ3hZPXP81laxpGCxRP0cgygwA8yQWBUaVTZ2KV QudAFOSwBrnSMR84Lyym66GFSiQOJY9xwGyjyyM0HDvFvHW4BXjnbreHsxtugKLm+oGo UyMw== X-Received: by 10.68.176.37 with SMTP id cf5mr26149138pbc.173.1370310423462; Mon, 03 Jun 2013 18:47:03 -0700 (PDT) Received: from ld-irv-0074.broadcom.com (5520-maca-inet1-outside.broadcom.com. [216.31.211.11]) by mx.google.com with ESMTPSA id cq1sm61054021pbc.13.2013.06.03.18.47.02 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 03 Jun 2013 18:47:02 -0700 (PDT) From: Brian Norris To: Artem Bityutskiy Subject: [PATCH 3/3] mtd: cfi_cmdset_0002: increase do_write_buffer() timeout Date: Mon, 3 Jun 2013 18:46:46 -0700 Message-Id: <1370310406-413-3-git-send-email-computersforpeace@gmail.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1370310406-413-1-git-send-email-computersforpeace@gmail.com> References: <1370310406-413-1-git-send-email-computersforpeace@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130603_214725_050802_5693DE95 X-CRM114-Status: GOOD ( 15.56 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (computersforpeace[at]gmail.com) -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.192.170 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Huang Shijie , Brian Norris , linux-mtd@lists.infradead.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.15 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" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org I have seen various failures like this while doing a simple reboot + mount UBIFS test: UBIFS: recovery needed MTD do_write_buffer(): software timeout UBI error: ubi_io_write: error -5 while writing 512 bytes to PEB 365:43648, written 192 bytes (This message doens't exactly match the message in the current head of tree, as Huang edited the timeout message.) I'm using a 64Mbyte Spansion S29GL512 NOR flash. I've also seen reports of the same failure on Micron 128Mbyte NOR flash AM29EWLD. After various tests, it seems simply that the timeout is not long enough for my system; increasing it by a few jiffies prevented all failures (testing for 12+ hours). There is no harm in increasing the timeout, but there is harm in having it too short, as evidenced here. This patch increases the timeout value in 3 locations, as they all are referencing the do_write_oneword function. I have only ever seen the timeout in do_write_buffer(). Signed-off-by: Brian Norris --- drivers/mtd/chips/cfi_cmdset_0002.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index 4e28081..45de025 100644 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -1228,14 +1228,11 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, struct cfi_private *cfi = map->fldrv_priv; unsigned long timeo; /* - * We use a 1ms generic timeout for writes (most devices have a max - * write time of a few hundreds usec). However, we should use the - * maximum timeout value given by the chip at probe time instead. - * Unfortunately, struct flchip does have a field for maximum timeout, - * only for typical which can be far too short depending of the - * conditions. + * We use a 10ms generic timeout for writes. Most devices have a max + * write time of a few hundreds usec, but timeouts have been seen with + * too few jiffies. */ - unsigned long uWriteTimeout = msecs_to_jiffies(1); + unsigned long uWriteTimeout = msecs_to_jiffies(10); int ret = 0; map_word oldd; int retry_cnt = 0; @@ -1465,7 +1462,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, struct cfi_private *cfi = map->fldrv_priv; unsigned long timeo; /* see comments in do_write_oneword() regarding uWriteTimeout */ - unsigned long uWriteTimeout = msecs_to_jiffies(1); + unsigned long uWriteTimeout = msecs_to_jiffies(10); int ret = -EIO; unsigned long cmd_adr; int z, words; @@ -1716,7 +1713,7 @@ static int cfi_amdstd_panic_wait(struct map_info *map, struct flchip *chip, static int do_panic_write_oneword(struct map_info *map, struct flchip *chip, unsigned long adr, map_word datum) { - const unsigned long uWriteTimeout = msecs_to_jiffies(1); + const unsigned long uWriteTimeout = msecs_to_jiffies(10); struct cfi_private *cfi = map->fldrv_priv; int retry_cnt = 0; map_word oldd;