From patchwork Tue Feb 28 15:32:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Parsons X-Patchwork-Id: 143476 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A249FB6FB4 for ; Wed, 29 Feb 2012 02:34:19 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1S2P2O-0007Aa-PI; Tue, 28 Feb 2012 15:32:24 +0000 Received: from nm5-vm1.bullet.mail.ird.yahoo.com ([77.238.189.202]) by merlin.infradead.org with smtp (Exim 4.76 #1 (Red Hat Linux)) id 1S2P2H-0007A4-Md for linux-mtd@lists.infradead.org; Tue, 28 Feb 2012 15:32:18 +0000 Received: from [77.238.189.56] by nm5.bullet.mail.ird.yahoo.com with NNFMP; 28 Feb 2012 15:32:15 -0000 Received: from [212.82.108.254] by tm9.bullet.mail.ird.yahoo.com with NNFMP; 28 Feb 2012 15:32:15 -0000 Received: from [127.0.0.1] by omp1019.mail.ird.yahoo.com with NNFMP; 28 Feb 2012 15:32:15 -0000 X-Yahoo-Newman-Property: ymail-5 X-Yahoo-Newman-Id: 838210.87720.bm@omp1019.mail.ird.yahoo.com Received: (qmail 76592 invoked by uid 60001); 28 Feb 2012 15:32:15 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1330443135; bh=lFx/tVKGYScNGvoighQTCpM2dmeTJo0IOAfx53xTSsk=; h=X-YMail-OSG:Received:X-Mailer:Message-ID:Date:From:Subject:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding; b=PRMq7vWBsiFHjy6Xof3JEgUlkXi6cMT/HrzqUv6b37MgwxFwKHuqAJCkBjMe1P9lXPi1T1mfNmVmzuAQ98IoM/JX8jsP4dW02BHjeDcAZzhDwcU5/VQZyAcdzTy2d8yPdaAqZ9+UhDXdE/Wd2ErFi3VPLogEaQylH25SSdt/gpc= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Message-ID:Date:From:Subject:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding; b=lCSLPh1G5M7bejHfYEHU3Dqq0zmJMLL+GUi8pBV5hHyrwAbNmc5i54KBl+vBzhmraAn42IwKn7/9S7ivj0dDjNzOjlU/FSkyoRxes8Tg7ZU33vQVp6/s8jNYwAhYgfMiPa7FRVmrXKIK1LXoR436eKNNTpW/OHQQ+17BuJyjNOc=; X-YMail-OSG: tZjqepYVM1nA3IwoU.5cL0RmpQmrB._Hh3Tlw5fnQvfWxmM gIfhMxbd4sTM9NIpvS0A0YffH8DskkmpiAq36a6SndB0lTehKbc_5ZRfuAca bjUWbdOjxeXa_kZFFfhhIY_SJupKdYC3OpHk6jH0eTP0wKasfQZn1VaSG2K0 2tzyBropTobc8l_WUivR2JrHP9Q56k8WUIzkRIkZdAjd9QZysku9V85ylc4O lX_SD9woLDGsWZJxU4wpojR6dofj6aeNR2EJOSNO8KoyYXse9mRjcuyAf1Hq V0rZJGVZdZRmILEv05e0kl.dtH9.A_PHTcUAHKMaSQIRpc1xobAUnp5zE__J Mtvy9TM4_X7iwTC.OdNLhmwovSYnnnNIcqwXHeGVjakwM_H_R2EAdaZxzdpP abvHavDKmXGJv8R0UhpNweiinninHFCmRH2O6128WGeh5sGt8jTIhADrS1.R tGybWq_gt Received: from [91.125.251.122] by web29019.mail.ird.yahoo.com via HTTP; Tue, 28 Feb 2012 15:32:15 GMT X-Mailer: YahooMailClassic/15.0.4 YahooMailWebService/0.8.116.338427 Message-ID: <1330443135.75072.YahooMailClassic@web29019.mail.ird.yahoo.com> Date: Tue, 28 Feb 2012 15:32:15 +0000 (GMT) From: Paul Parsons Subject: [PATCH] mtd: cfi: Wait for Block Erase operation to finish To: linux-mtd@lists.infradead.org MIME-Version: 1.0 X-Spam-Note: CRM114 invocation failed 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 (lost.distance[at]yahoo.com) -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [77.238.189.202 listed in list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -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: dwmw2@infradead.org, philipp.zabel@gmail.com X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org If an Erase Suspend Command (0xb0) is issued while a Block Erase operation (0x20, 0xd0) is in progress, Status Register bit 6 (SR.6) will be set to 1. After an Erase Resume Command (0xd0) is issued, SR.6 will be set back to 0. Unfortunately when inval_cache_and_wait_for_operation() is called to wait for a Block Erase operation to finish, it never checks that SR.6 = 0 before returning. Consequently it can (and does) return while a Block Erase operation is still suspended, resulting in random breakage. This patch ensures that when inval_cache_and_wait_for_operation() is called to wait for a Block Erase operation to finish (chip->state == FL_ERASING), it does not return until both SR.7 = 1 (as before) and SR.6 = 0. Signed-off-by: Paul Parsons --- I found this after switching my HP iPAQ hx4700 from using jffs2 to ubifs. It then consistently reported "block erase error: (bad VPP)" errors. Intriguingly, the bootloader never reporting erase or programming failures; it turned out that the bootloader never issued Erase Suspend Commands. Should SR.6 = 0 also be checked after an Erase Suspend Command (0xb0) is issued? This should preclude an unnecessary (and perhaps unpredictable) subsequent Erase Resume Command (0xd0). --- clean-3.3-rc5/drivers/mtd/chips/cfi_cmdset_0001.c 2012-02-25 20:18:16.000000000 +0000 +++ linux-3.3-rc5/drivers/mtd/chips/cfi_cmdset_0001.c 2012-02-28 03:13:30.521537614 +0000 @@ -1211,6 +1211,7 @@ static int inval_cache_and_wait_for_oper { struct cfi_private *cfi = map->fldrv_priv; map_word status, status_OK = CMD(0x80); + map_word status_76 = (chip->state == FL_ERASING) ? CMD(0xc0) : CMD(0x80); int chip_state = chip->state; unsigned int timeo, sleep_time, reset_timeo; @@ -1239,7 +1240,7 @@ static int inval_cache_and_wait_for_oper } status = map_read(map, cmd_adr); - if (map_word_andequal(map, status, status_OK, status_OK)) + if (map_word_andequal(map, status, status_76, status_OK)) break; if (chip->erase_suspended && chip_state == FL_ERASING) {