public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* Re: [PATCH] mtd: cfi: Wait for Block Erase operation to finish
@ 2012-03-01 17:22 Paul Parsons
  2012-03-01 17:38 ` Paul Parsons
  0 siblings, 1 reply; 26+ messages in thread
From: Paul Parsons @ 2012-03-01 17:22 UTC (permalink / raw)
  To: Joakim Tjernlund; +Cc: dwmw2, linux-mtd, philipp.zabel

--- On Thu, 1/3/12, Joakim Tjernlund <joakim.tjernlund@transmode.se> wrote:
> > OK, I think I've made some progress here.
> >
> > The status transitions around the Erase Resume are as
> follows:
> >
> > [   58.702774] 108: PUTC: 0:
> status=0x00c000c0 // Before CMD(0xd0)
> > [   58.702792] 108: PUTC: 1:
> status=0x00400040 // After CMD(0xd0),CMD(0x70)
> > [   58.702808] 108: PUTC: 2:
> status=0x00000000 // + cfi_udelay(1)
> 
> hmm, this is not ideal. The status bits are only valid if
> SR.7 is set if I remember correctly?
> Maybe SR.6 is an exception?
> So reading SR.6 and waiting for it to clear may not work on
> other chips?
> Is there some resume to erase time in the specs?

Yes the spec I have (Intel StrataFlash, 253854-003) says SR[6:1] are valid
only if SR.7=1. It also says (section 13.4) "The Erase Resume command
instructs the corresponding segment to continue erasing, and automatically
clears status register bits SR[7:6]". The flowchart makes no mention of
needing to poll the status register after issuing an Erase Resume command.
The spec makes no mention of Erase Resume time.

It seems to me that waiting for SR[7:6]=00 instead of just SR.6=0 would:
1. Have the same outcome.
2. Be strictly within spec; SR[7:6] have been cleared therefore the Erase
Resume command has been accepted.

^ permalink raw reply	[flat|nested] 26+ messages in thread
* [PATCH] mtd: cfi: Wait for Block Erase operation to finish
@ 2012-02-28 15:32 Paul Parsons
  2012-02-28 21:25 ` Joakim Tjernlund
  0 siblings, 1 reply; 26+ messages in thread
From: Paul Parsons @ 2012-02-28 15:32 UTC (permalink / raw)
  To: linux-mtd; +Cc: dwmw2, philipp.zabel

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


^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2012-03-13 13:33 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-01 17:22 [PATCH] mtd: cfi: Wait for Block Erase operation to finish 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
  -- strict thread matches above, loose matches on Subject: below --
2012-02-28 15:32 Paul Parsons
2012-02-28 21:25 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox