From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Mikhail Kshevetskiy <mikhail.kshevetskiy@oktetlabs.ru>
Cc: richard@nod.at, linux-mtd@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] mtd: spinand: wait for erase completion before writing bad block maker
Date: Wed, 11 Mar 2020 11:13:12 +0100 [thread overview]
Message-ID: <20200311111312.5c175916@xps13> (raw)
In-Reply-To: <20200310203224.410198-1-mikhail.kshevetskiy@oktetlabs.ru>
Hi Mikhail,
Mikhail Kshevetskiy <mikhail.kshevetskiy@oktetlabs.ru> wrote on Tue, 10
Mar 2020 23:32:23 +0300:
> SPI flash will discard any write operation while it is busy with block
> erasing. As result bad block marker will not be writed to a flash.
> To fix it just wait for completion of erase operation.
>
> The erasing code is almost the same as in spinand_erase(). The only
> difference is: we ignore ERASE_FAILED status.
>
> This patch also improve error handling a bit.
>
> Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@oktetlabs.ru>
Thanks a lot for sharing this!
Actually Frieder sent a fix for that I already added to nand/next,
please have a look at:
https://lore.kernel.org/linux-mtd/20200218100432.32433-1-frieder.schrempf@kontron.de/
If you think I'm missing something else, please tell me!
> ---
> drivers/mtd/nand/spi/core.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
> index 89f6beefb01c..bb4eac400b0f 100644
> --- a/drivers/mtd/nand/spi/core.c
> +++ b/drivers/mtd/nand/spi/core.c
> @@ -610,6 +610,7 @@ static int spinand_markbad(struct nand_device *nand, const struct nand_pos *pos)
> .oobbuf.out = spinand->oobbuf,
> };
> int ret;
> + u8 status;
>
> /* Erase block before marking it bad. */
> ret = spinand_select_target(spinand, pos->target);
> @@ -620,7 +621,14 @@ static int spinand_markbad(struct nand_device *nand, const struct nand_pos *pos)
> if (ret)
> return ret;
>
> - spinand_erase_op(spinand, pos);
> + ret = spinand_erase_op(spinand, pos);
> + if (ret)
> + return ret;
> +
> + /* ignore status as erase may fail for bad blocks */
> + spinand_wait(spinand, &status);
> + if (ret)
> + return ret;
>
> memset(spinand->oobbuf, 0, 2);
> return spinand_write_page(spinand, &req);
Thanks,
Miquèl
prev parent reply other threads:[~2020-03-11 10:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-10 20:32 [PATCH 1/2] mtd: spinand: wait for erase completion before writing bad block maker Mikhail Kshevetskiy
2020-03-10 20:32 ` [PATCH 2/2] mtd: spinand: fix bad block marker writing Mikhail Kshevetskiy
2020-03-11 10:13 ` Miquel Raynal [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200311111312.5c175916@xps13 \
--to=miquel.raynal@bootlin.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=mikhail.kshevetskiy@oktetlabs.ru \
--cc=richard@nod.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox