All of lore.kernel.org
 help / color / mirror / Atom feed
* omap2 : bug in omap_wait
@ 2011-06-10  8:33 Matthieu CASTET
  0 siblings, 0 replies; only message in thread
From: Matthieu CASTET @ 2011-06-10  8:33 UTC (permalink / raw)
  To: linux-mtd@lists.infradead.org

Hi,

omap nand driver implement the nand.waitfunc[1] but it is buggy and can lead to
 nand write/erase error :
- status = NAND_STATUS_FAIL
- timeo is computed
- thread is preempted
- timeo is expired and we never enter the loop
- we return NAND_STATUS_FAIL, even if the real status is okay.

The correct behavior is to read again the status after the loop like in nand_wait.


BTW why omap2 driver doesn't use nand_wait ?

Matthieu

[1]
static int omap_wait(struct mtd_info *mtd, struct nand_chip *chip)
{
    struct nand_chip *this = mtd->priv;
    struct omap_nand_info *info = container_of(mtd, struct omap_nand_info,
                            mtd);
    unsigned long timeo = jiffies;
    int status = NAND_STATUS_FAIL, state = this->state;

    if (state == FL_ERASING)
        timeo += (HZ * 400) / 1000;
    else
        timeo += (HZ * 20) / 1000;

    gpmc_nand_write(info->gpmc_cs,
            GPMC_NAND_COMMAND, (NAND_CMD_STATUS & 0xFF));
    while (time_before(jiffies, timeo)) {
        status = gpmc_nand_read(info->gpmc_cs, GPMC_NAND_DATA);
        if (status & NAND_STATUS_READY)
            break;
        cond_resched();
    }
    return status;
}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-06-10  8:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-10  8:33 omap2 : bug in omap_wait Matthieu CASTET

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.