Numonyx NOR and chip->mutex bug?

Joakim Tjernlund joakim.tjernlund at transmode.se
Fri Feb 4 11:55:35 EST 2011


Stefan Bigler <stefan.bigler at keymile.com> wrote on 2011/02/04 17:45:17:
>
> Hi Jocke
>
> I tested your proposal to remove the unlock/lock for the
> INVALIDATE_CACHED_RANGE() and without the addtional test
> for unequal states, it worked in my environment.

Great, I have this patch now. Perhaps the both of you can test this
over the weekend?

diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index e89f2d0..b2665ad 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -1245,6 +1245,17 @@ static int inval_cache_and_wait_for_operation(
 	sleep_time = chip_op_time / 2;

 	for (;;) {
+		while (chip->state != chip_state) {
+			/* Someone's suspended the operation: sleep */
+			DECLARE_WAITQUEUE(wait, current);
+			set_current_state(TASK_UNINTERRUPTIBLE);
+			add_wait_queue(&chip->wq, &wait);
+			mutex_unlock(&chip->mutex);
+			schedule();
+			remove_wait_queue(&chip->wq, &wait);
+			mutex_lock(&chip->mutex);
+		}
+
 		status = map_read(map, cmd_adr);
 		if (map_word_andequal(map, status, status_OK, status_OK))
 			break;
@@ -1273,16 +1284,6 @@ static int inval_cache_and_wait_for_operation(
 		}
 		mutex_lock(&chip->mutex);

-		while (chip->state != chip_state) {
-			/* Someone's suspended the operation: sleep */
-			DECLARE_WAITQUEUE(wait, current);
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			add_wait_queue(&chip->wq, &wait);
-			mutex_unlock(&chip->mutex);
-			schedule();
-			remove_wait_queue(&chip->wq, &wait);
-			mutex_lock(&chip->mutex);
-		}
 		if (chip->erase_suspended && chip_state == FL_ERASING)  {
 			/* Erase suspend occured while sleep: reset timeout */
 			timeo = reset_timeo;




More information about the linux-mtd mailing list