Prevent erase command invocation on suspended chip
PATCH 1/1 Prevent erase command invocation on suspended chip
Hello,
while running stress tests we have met cfi_cmdset_0001.c driver issue. Working on multipartitional devices with erase suspend on write feature enabled it is possible to get erase operation invoked on chip with suspended erase. get_chip() looses information about earlier suspended erase and new erase operation gets issued. New erase operations report successful completion, but blocks remain dirty causing, for example, JFFS2 error messages like:
...
Newly-erased block contained word 0x20031985 at offset 0x00200000 Newly-erased block contained word 0x20031985 at offset 0x00280000 Newly-erased block contained word 0x20031985 at offset 0x00240000
...
The patch below fixes that issue.
diff -uNr a/drivers/mtd/chips/cfi_cmdset_0001.cb/drivers/mtd/chips/cfi_cmdset_0001.c
drivers/mtd/chips/cfi_cmdset_0001.c +0 -0
@@ -795,6 +795,7 @@ static int get_chip(struct map_info *map, struct flchip *chip,
unsigned long adr, int mode)
{
int ret;
+ DECLARE_WAITQUEUE(wait, current);
retry:
if (chip->priv && (mode == FL_WRITING || mode == FL_ERASING
@@ -851,6 +852,20 @@
spin_unlock(contender->mutex);
}
+ /* Check if we already have suspended erase
+ * on this chip. Sleep. */
+ if (mode == FL_ERASING && shared->erasing
+ && shared->erasing->oldstate == FL_ERASING) {
+ spin_unlock(&shared->lock);
+ set_current_state(TASK_UNINTERRUPTIBLE);
+ add_wait_queue(&chip->wq, &wait);
+ spin_unlock(chip->mutex);
+ schedule();
+ remove_wait_queue(&chip->wq, &wait);
+ spin_lock(chip->mutex);
+ goto retry;
+ }
+
/* We now own it */
shared->writing = chip;
if (mode == FL_ERASING)
Quoted 17 lines · Alexander Belyakov
Hello,
while running stress tests we have met
cfi_cmdset_0001.cdriver issue. Working on multipartitional devices with erase suspend on write feature enabled it is possible to get erase operation invoked on chip with suspended erase.get_chip()looses information about earlier suspended erase and new erase operation gets issued. New erase operations report successful completion, but blocks remain dirty causing, for example, JFFS2 error messages like:...
Newly-erased block contained word0x20031985at offset0x00200000Newly-erased block contained word0x20031985at offset0x00280000Newly-erased block contained word0x20031985at offset0x00240000
...
Quoted 3 lines
The patch below fixes that issue.
Signed-off-by Alexander Belyakov <[email protected]>
Quoted 26 lines
diff -uNr
a/drivers/mtd/chips/cfi_cmdset_0001.cb/drivers/mtd/chips/cfi_cmdset_0001.cdrivers/mtd/chips/cfi_cmdset_0001.c +1
-0@@ -795,6 +795,7 @@static int get_chip (struct map_info *map,struct flchip *chip,unsigned long adr,int mode) {int ret; +DECLARE_WAITQUEUE (wait, current); retry:drivers/mtd/chips/cfi_cmdset_0001.c +7
-0if (chip->priv && (mode == FL_WRITING || mode == FL_ERASING@@ -851,6 +852,20 @@spin_unlock (contender->mutex); } +/* Check if we already have suspended erase +* on this chip. Sleep. */ +if (mode ==FL_ERASING && shared->erasing + && shared->erasing->oldstate ==FL_ERASING ) { +spin_unlock (&shared->lock); +set_current_state (TASK_UNINTERRUPTIBLE ); +add_wait_queue (&chip->wq, &wait);
drivers/mtd/chips/cfi_cmdset_0001.c line 871
Quoted 10 lines
drivers/mtd/chips/cfi_cmdset_0001.c +7
-0+spin_unlock (chip->mutex); +schedule (); +remove_wait_queue (&chip->wq, &wait); +spin_lock (chip->mutex); + goto retry; + } +/* We now own it */ shared->writing = chip;if (mode ==FL_ERASING )
Nicolas
Quoted 8 lines · Nicolas Pitre
Quoted 4 lines · Alexander Belyakov
The patch below fixes that issue.
Signed-off-by Alexander Belyakov <[email protected]>Acked-by Nicolas Pitre <[email protected]>
Hello David,
Please apply this patch.
Thanks,
Alexander
Quoted 5 lines · Alexander Belyakov
Quoted 4 lines · Nicolas Pitre
Quoted 3 lines · Alexander Belyakov
The patch below fixes that issue.
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Alexander Belyakov <[email protected]>Acked-by Nicolas Pitre <[email protected]>Hello David,
Please apply this patch.
Just a remainder about patch pending. Please apply.
-a
Quoted 1 line · Alexander Belyakov
Just a remainder about patch pending. Please apply.
Try applying it yourself. Make sure you use the copy you received in your email.
Signature · 1 line
dwmw2
Quoted 7 lines · David Woodhouse
Quoted 1 line · Alexander Belyakov
Just a remainder about patch pending. Please apply.
Try applying it yourself. Make sure you use the copy you received in your email.
Please excuse me for gmail-corrupted patch and thanks for committing it. I'll try to avoid such a corruption next time.
-a