From: Peter Horton <zero@colonel-panic.org>
To: linux-mtd@lists.infradead.org
Cc: tbm@cyrius.com
Subject: [PATCH] Fix erase timeout in M25P80 driver
Date: Sat, 4 Apr 2009 08:31:55 +0100 [thread overview]
Message-ID: <20090404073155.GA12392@turtle.localnet> (raw)
The M25P80 driver erase operations timeout when using a M25P128 part with a
Marvell Kirkwood (ARM) processor. Change the timeout from a simple loop count
to a time based timeout. Also added a conditional schedule() in the loop.
Signed-off-by: Peter Horton <zero@colonel-panic.org>
Tested-by: Martin Michlmayr <tbm@cyrius.com>
--- linux-2.6.29-git8.orig/drivers/mtd/devices/m25p80.c 2009-03-23 23:12:14.000000000 +0000
+++ linux-2.6.29-git8/drivers/mtd/devices/m25p80.c 2009-04-02 20:37:47.000000000 +0100
@@ -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_TIMEOUT 7000 /* ms - M25P128 max is 6s */
#define CMD_SIZE 4
#ifdef CONFIG_M25PXX_USE_FAST_READ
@@ -145,19 +145,25 @@
*/
static int wait_till_ready(struct m25p *flash)
{
- int count;
+# define DIV_U(n,d) (((n)+(d)-1)/(d))
+
+ unsigned long deadline;
int sr;
- /* one chip guarantees max 5 msec wait here after page writes,
- * but potentially three seconds (!) after page erase.
+ deadline = jiffies + DIV_U(MAX_READY_WAIT_TIMEOUT * HZ, 1000);
+
+ /* this can take a long time for sector erase.
+ * we should probably have a separate timeout
+ * for program and erase and we should check
+ * for signals ...
*/
- for (count = 0; count < MAX_READY_WAIT_COUNT; count++) {
+ while (!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;
next reply other threads:[~2009-04-04 7:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-04 7:31 Peter Horton [this message]
2009-04-04 8:10 ` [PATCH] Fix erase timeout in M25P80 driver Mike Frysinger
-- strict thread matches above, loose matches on Subject: below --
2009-04-04 14:38 Peter Horton
2009-04-04 15:34 ` Martin Michlmayr
2009-04-04 18:47 ` Mike Frysinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090404073155.GA12392@turtle.localnet \
--to=zero@colonel-panic.org \
--cc=linux-mtd@lists.infradead.org \
--cc=tbm@cyrius.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox