From patchwork Mon Mar 2 08:31:29 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: graff.yang@gmail.com X-Patchwork-Id: 23928 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@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 9D0B4DDF04 for ; Mon, 2 Mar 2009 19:35:14 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1Le3Ys-0002HY-An; Mon, 02 Mar 2009 08:31:42 +0000 Received: from nwd2mail11.analog.com ([137.71.25.57]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1Le3Yo-0002HR-Jv for linux-mtd@lists.infradead.org; Mon, 02 Mar 2009 08:31:41 +0000 X-IronPort-AV: E=Sophos;i="4.38,288,1233550800"; d="scan'208";a="67241923" Received: from nwd2mhb1.analog.com ([137.71.5.12]) by nwd2mail11.analog.com with ESMTP; 02 Mar 2009 03:31:37 -0500 Received: from sdc1.sdcdesign.analog.com ([10.99.22.250]) by nwd2mhb1.analog.com (8.9.3 (PHNE_28810+JAGae91741)/8.9.3) with ESMTP id DAA20307; Mon, 2 Mar 2009 03:31:36 -0500 (EST) From: graff.yang@gmail.com Received: from localhost.localdomain ([10.99.29.106]) by sdc1.sdcdesign.analog.com (8.11.7p1+Sun/8.11.7) with ESMTP id n228VXn08888; Mon, 2 Mar 2009 16:31:34 +0800 (CST) To: dwmw2@infradead.org Subject: [PATCH] [MTD] [CHIPS] cfi_cmdset_0001.c: Fix a bug in inval_cache_and_wait_for_operation(). Date: Mon, 2 Mar 2009 16:31:29 +0800 Message-Id: <12359826893947-git-send-email-graff.yang@gmail.com> X-Mailer: git-send-email 1.5.2.5 X-Spam-Score: 0.0 (/) Cc: Graff Yang , linux-mtd@lists.infradead.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.9 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: Graff Yang If the inval_cache_and_wait_for_operation() is re-entered by write operation when erase operation is in progress, the chip->erase_suspended will be cleared, this cause the erase timeo is not reset and will result time out error for erase. Signed-off-by: Graff Yang --- drivers/mtd/chips/cfi_cmdset_0001.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c index 5157e3c..a254fc3 100644 --- a/drivers/mtd/chips/cfi_cmdset_0001.c +++ b/drivers/mtd/chips/cfi_cmdset_0001.c @@ -1223,10 +1223,14 @@ static int inval_cache_and_wait_for_operation( remove_wait_queue(&chip->wq, &wait); spin_lock(chip->mutex); } - if (chip->erase_suspended || chip->write_suspended) { - /* Suspend has occured while sleep: reset timeout */ + if (chip->erase_suspended && chip_state == FL_ERASING) { + /* Erase suspend occured while sleep: reset timeout */ timeo = reset_timeo; chip->erase_suspended = 0; + } + if (chip->write_suspended && chip_state == FL_WRITING) { + /* Write suspend occured while sleep: reset timeout */ + timeo = reset_timeo; chip->write_suspended = 0; } }