From patchwork Fri Feb 4 16:55:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Numonyx NOR and chip->mutex bug? Date: Fri, 04 Feb 2011 06:55:35 -0000 From: Joakim Tjernlund X-Patchwork-Id: 81918 Message-Id: To: stefan.bigler@keymile.com Cc: linux-mtd@lists.infradead.org, Holger brunck , Michael Cashwell Stefan Bigler 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;