* [PATCH] [MTD] NAND: fix race in nand_base
@ 2007-07-23 11:17 Artem Bityutskiy
2007-07-23 11:22 ` Artem Bityutskiy
0 siblings, 1 reply; 2+ messages in thread
From: Artem Bityutskiy @ 2007-07-23 11:17 UTC (permalink / raw)
To: linux-mtd
From: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Date: Mon, 23 Jul 2007 16:06:50 +0300
Subject: [PATCH] [MTD] NAND: fix race in nand_base
When we mark block bad we have to get chip because this involves
writing to the page's OOB. We hit this bug in UBI - we observed
random obscure crashes when it marks block bad from the background
thread and there is some parallel task which utilizes flash.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
---
drivers/mtd/nand/nand_base.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 7e68203..3391b05 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -348,6 +348,8 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
uint8_t buf[2] = { 0, 0 };
int block, ret;
+ nand_get_device(chip, mtd, FL_READING);
+
/* Get block number */
block = (int)(ofs >> chip->bbt_erase_shift);
if (chip->bbt)
@@ -370,6 +372,8 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
}
if (!ret)
mtd->ecc_stats.badblocks++;
+
+ nand_release_device(mtd);
return ret;
}
--
1.5.0.6
--
Best regards,
Artem Bityutskiy (Битюцкий Артём)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] [MTD] NAND: fix race in nand_base
2007-07-23 11:17 [PATCH] [MTD] NAND: fix race in nand_base Artem Bityutskiy
@ 2007-07-23 11:22 ` Artem Bityutskiy
0 siblings, 0 replies; 2+ messages in thread
From: Artem Bityutskiy @ 2007-07-23 11:22 UTC (permalink / raw)
To: linux-mtd
On Mon, 2007-07-23 at 14:17 +0300, Artem Bityutskiy wrote:
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index 7e68203..3391b05 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -348,6 +348,8 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
> uint8_t buf[2] = { 0, 0 };
> int block, ret;
>
> + nand_get_device(chip, mtd, FL_READING);
Err, this should be FL_WRITING I guess.
> +
> /* Get block number */
> block = (int)(ofs >> chip->bbt_erase_shift);
> if (chip->bbt)
> @@ -370,6 +372,8 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
> }
> if (!ret)
> mtd->ecc_stats.badblocks++;
> +
> + nand_release_device(mtd);
> return ret;
> }
There is still the problem with nand_update_bbt() which in turn calls
mtd->read() which will deadlock. I have not found how BBT is protected.
Any suggestions/pointers?
--
Best regards,
Artem Bityutskiy (Битюцкий Артём)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-07-23 11:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-23 11:17 [PATCH] [MTD] NAND: fix race in nand_base Artem Bityutskiy
2007-07-23 11:22 ` Artem Bityutskiy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox