lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200311111312.5c175916@xps13>
Date:   Wed, 11 Mar 2020 11:13:12 +0100
From:   Miquel Raynal <miquel.raynal@...tlin.com>
To:     Mikhail Kshevetskiy <mikhail.kshevetskiy@...etlabs.ru>
Cc:     richard@....at, linux-mtd@...ts.infradead.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] mtd: spinand: wait for erase completion before
 writing bad block maker

Hi Mikhail,

Mikhail Kshevetskiy <mikhail.kshevetskiy@...etlabs.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@...etlabs.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ