From patchwork Sat Apr 4 14:38:48 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Horton X-Patchwork-Id: 25592 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 989F6DDDA9 for ; Sun, 5 Apr 2009 01:41:58 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1Lq72f-0000FX-1w; Sat, 04 Apr 2009 14:40:17 +0000 Received: from bitbox.plus.com ([81.174.226.42] helo=pangolin.localnet) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1Lq72V-0008Dj-Hz for linux-mtd@lists.infradead.org; Sat, 04 Apr 2009 14:40:14 +0000 Received: from turtle.localnet (turtle.localnet [172.16.1.38]) by pangolin.localnet (Postfix) with ESMTP id 8BF57147695; Sat, 4 Apr 2009 15:40:00 +0100 (BST) Received: by turtle.localnet (Postfix, from userid 1002) id 5F473276F4B; Sat, 4 Apr 2009 15:38:48 +0100 (BST) Date: Sat, 4 Apr 2009 15:38:48 +0100 From: Peter Horton To: linux-mtd@lists.infradead.org Subject: [PATCH] Fix erase timeout in M25P80 driver Message-ID: <20090404143848.GA13480@turtle.localnet> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) X-Spam-Score: 0.0 (/) Cc: tbm@cyrius.com X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.11 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 Extend erase timeout in M25P80 SPI Flash driver. The M25P80 drivers fails erasing sectors on a M25P128 because the ready wait timeout is too short. Change the timeout from a simple loop count to a suitable number of seconds. Signed-off-by: Peter Horton Tested-by: Martin Michlmayr Index: linux-2.6.29-git12/drivers/mtd/devices/m25p80.c =================================================================== --- linux-2.6.29-git12.orig/drivers/mtd/devices/m25p80.c 2009-04-04 21:05:44.000000000 +0000 +++ linux-2.6.29-git12/drivers/mtd/devices/m25p80.c 2009-04-04 21:40:06.000000000 +0000 @@ -54,7 +54,7 @@ #define SR_SRWD 0x80 /* SR write protect */ /* Define max times to check status register before we give up. */ -#define MAX_READY_WAIT_COUNT 100000 +#define MAX_READY_WAIT_JIFFIES (10 * HZ) /* eg. M25P128 specs 6s max sector erase */ #define CMD_SIZE 4 #ifdef CONFIG_M25PXX_USE_FAST_READ @@ -145,19 +145,16 @@ */ static int wait_till_ready(struct m25p *flash) { - int count; + unsigned long deadline; int sr; - /* one chip guarantees max 5 msec wait here after page writes, - * but potentially three seconds (!) after page erase. - */ - for (count = 0; count < MAX_READY_WAIT_COUNT; count++) { + for (deadline = jiffies + MAX_READY_WAIT_JIFFIES; !time_after_eq(jiffies, deadline);) { if ((sr = read_sr(flash)) < 0) break; else if (!(sr & SR_WIP)) return 0; - /* REVISIT sometimes sleeping would be best */ + cond_resched(); } return 1;