提交 a9c465f0 编写于 作者: I Ivan Djelic 提交者: David Woodhouse

mtd: nand: omap: fix race condition in omap_wait()

If a context switch occurs in function omap_wait() just before the
while loop is entered, then upon return from context switch the
timeout may already have elapsed: in that case, status is never
read from NAND device, and omap_wait() returns an error.
This failure has been experimentally observed during stress tests.

This patch ensures a NAND status read is always performed before
returning, as in the generic nand_wait() function.
Signed-off-by: NIvan Djelic <ivan.djelic@parrot.com>
Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
上级 e25da1c0
...@@ -881,7 +881,7 @@ static int omap_wait(struct mtd_info *mtd, struct nand_chip *chip) ...@@ -881,7 +881,7 @@ static int omap_wait(struct mtd_info *mtd, struct nand_chip *chip)
struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, struct omap_nand_info *info = container_of(mtd, struct omap_nand_info,
mtd); mtd);
unsigned long timeo = jiffies; unsigned long timeo = jiffies;
int status = NAND_STATUS_FAIL, state = this->state; int status, state = this->state;
if (state == FL_ERASING) if (state == FL_ERASING)
timeo += (HZ * 400) / 1000; timeo += (HZ * 400) / 1000;
...@@ -896,6 +896,8 @@ static int omap_wait(struct mtd_info *mtd, struct nand_chip *chip) ...@@ -896,6 +896,8 @@ static int omap_wait(struct mtd_info *mtd, struct nand_chip *chip)
break; break;
cond_resched(); cond_resched();
} }
status = gpmc_nand_read(info->gpmc_cs, GPMC_NAND_DATA);
return status; return status;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册