All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Parsons <lost.distance@yahoo.com>
To: linux-mtd@lists.infradead.org
Cc: dwmw2@infradead.org, philipp.zabel@gmail.com
Subject: [PATCH] mtd: cfi: Wait for Block Erase operation to finish
Date: Tue, 28 Feb 2012 15:32:15 +0000 (GMT)	[thread overview]
Message-ID: <1330443135.75072.YahooMailClassic@web29019.mail.ird.yahoo.com> (raw)

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 <lost.distance@yahoo.com>
---

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)  {


             reply	other threads:[~2012-02-28 15:32 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-28 15:32 Paul Parsons [this message]
2012-02-28 21:25 ` [PATCH] mtd: cfi: Wait for Block Erase operation to finish Joakim Tjernlund
2012-02-29  0:23   ` Paul Parsons
2012-02-29  8:58     ` Joakim Tjernlund
2012-02-29 17:22       ` Paul Parsons
2012-02-29 18:03         ` Artem Bityutskiy
2012-02-29 22:26           ` Paul Parsons
2012-03-09 10:39             ` Artem Bityutskiy
2012-02-29 23:35         ` Joakim Tjernlund
2012-03-01 14:57           ` Paul Parsons
2012-03-01 15:59             ` Joakim Tjernlund
  -- strict thread matches above, loose matches on Subject: below --
2012-03-01 17:22 Paul Parsons
2012-03-01 17:38 ` Paul Parsons
2012-03-01 17:53   ` Paul Parsons
2012-03-01 18:03     ` Joakim Tjernlund
2012-03-01 18:50       ` Paul Parsons
2012-03-02 12:39         ` Joakim Tjernlund
2012-03-02 14:06           ` Paul Parsons
2012-03-02 14:30             ` Joakim Tjernlund
2012-03-02 15:15               ` Paul Parsons
2012-03-09 10:45               ` Artem Bityutskiy
2012-03-13  8:27                 ` Joakim Tjernlund
2012-03-13 12:48                   ` Artem Bityutskiy
2012-03-13 12:55                     ` Joakim Tjernlund
2012-03-13 13:09                       ` Artem Bityutskiy
2012-03-13 13:33                         ` Joakim Tjernlund

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=1330443135.75072.YahooMailClassic@web29019.mail.ird.yahoo.com \
    --to=lost.distance@yahoo.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=philipp.zabel@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.