Message ID | 1326140612-26323-4-git-send-email-computersforpeace@gmail.com |
---|---|
State | New, archived |
Headers | show |
On Mon, 2012-01-09 at 12:23 -0800, Brian Norris wrote: > Many NAND flash systems (especially those with MLC NAND) cannot be > reliably written twice in a row. For instance, when marking a bad block, > the block may already have data written to it, and so we should attempt > to erase the block before writing a bad block marker to its OOB region. > > We can ignore erase failures, since the block may be bad such that it > cannot be erased properly; we still attempt to write zeros to its spare > area. > > Note that the erase must be performed before the BBT is updated, since > otherwise, nand_erase_nand() would not allow us to erase our "bad > block." > > Signed-off-by: Brian Norris <computersforpeace@gmail.com> This looks like an independent patch to me, is that right? If yes, you can send it separately. Artem.
On Fri, Jan 13, 2012 at 2:42 PM, Artem Bityutskiy <dedekind1@gmail.com> wrote: > This looks like an independent patch to me, is that right? If yes, you > can send it separately. It's mostly independent, but its exact code placement will be dependent on the previous two patches. If you'd prefer, I'll resubmit this separately. Then, assuming it's applied, I'll fix and resend the controversial stuff (BBT + OOB) as a separate series, on top of it. Brian
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index ead2a12..d5dbe0a 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -397,6 +397,16 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) BUG_ON((chip->options & NAND_NO_WRITE_OOB) && !(chip->bbt_options & NAND_BBT_USE_FLASH)); + /* Erase before writing to OOB and before BBT is updated */ + if (!(chip->options & NAND_NO_WRITE_OOB)) { + struct erase_info einfo; + memset(&einfo, 0, sizeof(einfo)); + einfo.mtd = mtd; + einfo.addr = ofs; + einfo.len = 1 << chip->phys_erase_shift; + nand_erase_nand(mtd, &einfo, 0); + } + if (chip->bbt_options & NAND_BBT_SCANLASTPAGE) ofs += mtd->erasesize - mtd->writesize;
Many NAND flash systems (especially those with MLC NAND) cannot be reliably written twice in a row. For instance, when marking a bad block, the block may already have data written to it, and so we should attempt to erase the block before writing a bad block marker to its OOB region. We can ignore erase failures, since the block may be bad such that it cannot be erased properly; we still attempt to write zeros to its spare area. Note that the erase must be performed before the BBT is updated, since otherwise, nand_erase_nand() would not allow us to erase our "bad block." Signed-off-by: Brian Norris <computersforpeace@gmail.com> --- drivers/mtd/nand/nand_base.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)