diff mbox

Numonyx NOR and chip->mutex bug?

Message ID OF9ADE2396.33B1CC34-ONC125782D.005CD31A-C125782D.005CFAD8@transmode.se
State New, archived
Headers show

Commit Message

Joakim Tjernlund Feb. 4, 2011, 4:55 p.m. UTC
Stefan Bigler <stefan.bigler@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 mbox

Patch

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;