public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* Deadlock in cfi_cmdset_0001.c on simultaneous write operations.
@ 2005-11-23 16:26 Korolev, Alexey
  2005-11-23 17:13 ` Nicolas Pitre
  2005-11-23 22:02 ` Nicolas Pitre
  0 siblings, 2 replies; 6+ messages in thread
From: Korolev, Alexey @ 2005-11-23 16:26 UTC (permalink / raw)
  To: linux-mtd

Hi All,
 
I faced a halting issue on multi partitioned chip when I tried to
execute simultaneous write operations.
Platform has halted, on execution of this sequence:
dd if=random of=/dev/mtd4 bs=4k count=1k&
dd if=random of=/dev/mtd5 bs=4k count=1k&
dd if=random of=/dev/mtd6 bs=4k count=1k

Halt didn't happens on two simultaneous write operations
Execution of 
dd if=random of=/dev/mtd5 bs=4k count=1k&
dd if=random of=/dev/mtd6 bs=4k count=1k
was ok.
 
I made small investigation. Platform falls to deadlock in get_chip
function.
I was unable to definetly locate the place of the halt. But I gues it
happened here.
 
  struct flchip_shared *shared = chip->priv;
  struct flchip *contender;
  spin_lock(&shared->lock);
  contender = shared->writing;
  if (contender && contender != chip) {
   int ret = spin_trylock(contender->mutex);
   spin_unlock(&shared->lock);
   if (!ret)
    goto retry;
   spin_unlock(chip->mutex);
   ret = get_chip(map, contender, contender->start, mode);
   spin_lock(chip->mutex);
   if (ret) {
    spin_unlock(contender->mutex);
    return ret;
   }
   timeo = jiffies + HZ;
   spin_lock(&shared->lock);
  }
  shared->writing = chip;
  if (mode == FL_ERASING)
   shared->erasing = chip;
  if (contender && contender != chip)
   spin_unlock(contender->mutex);
  spin_unlock(&shared->lock);

I slightly simplified functionality of the code and it helped, the
following code doesn't halt
  struct flchip_shared *shared = chip->priv;
  struct flchip *contender;
 
  contender = shared->writing;
  if (contender && contender != chip) {
      yield(); 
       timeo = jiffies + HZ;
      goto retry;
  }
  /* We now own it */
  spin_lock(&shared->lock);     
  shared->writing = chip;
  if (mode == FL_ERASING)
   shared->erasing = chip;
  if (contender && contender != chip)
   spin_unlock(contender->mutex);
  spin_unlock(&shared->lock);

I know that it can not be solution because it reduces functionality. 
I would be very much appreciate if someone advice me solution for
deadlock issue on simultaneous write operations.
 
Thanks,
Alexey

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

end of thread, other threads:[~2005-11-25 13:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-23 16:26 Deadlock in cfi_cmdset_0001.c on simultaneous write operations Korolev, Alexey
2005-11-23 17:13 ` Nicolas Pitre
2005-11-23 22:02 ` Nicolas Pitre
2005-11-24 15:57   ` Alexey, Korolev
2005-11-24 16:39     ` Nicolas Pitre
2005-11-25 13:27       ` Alexey, Korolev

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