Re: [PATCH] mtd: spinand: Add support for GigaDevice GD5F1GQ4UC

Stefan Roese
2019-01-24T10:57:47Z

On 24.01.19 10:19, Boris Brezillon wrote:

<snip>

>> So spi_mem_dirmap_read() returns -EINVAL to spinand_write_to_cache_op()
>> which then returns -EIO.
>
> Can you try with the following diff applied?
> --->8---
> diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
> index 52f17fc42daa..67c568f0c47f 100644
> --- a/drivers/mtd/nand/spi/core.c
> +++ b/drivers/mtd/nand/spi/core.c
> @@ -238,7 +238,7 @@ static int spinand_read_from_cache_op(struct spinand_device *spinand,
>
> while (nbytes) {
> ret = spi_mem_dirmap_read(rdesc, column, nbytes, buf);
> - if (!ret || ret > nbytes)
> + if (!ret || (ret > 0 && ret > nbytes))
> ret = -EIO;
>
> if (ret < 0)
> @@ -296,9 +296,9 @@ static int spinand_write_to_cache_op(struct spinand_device *spinand,
> wdesc = spinand->dirmaps[req->pos.plane].wdesc;
>
> while (nbytes) {
> - ret = spi_mem_dirmap_read(wdesc, column, nbytes,
> - spinand->databuf + column);
> - if (!ret || ret > nbytes)
> + ret = spi_mem_dirmap_write(wdesc, column, nbytes,
> + spinand->databuf + column);
> + if (!ret || (ret > 0 && ret > nbytes))
> ret = -EIO;
>
> if (ret < 0)
> @@ -761,21 +761,6 @@ static void spinand_destroy_dirmaps(struct spinand_device *spinand)
> spinand_destroy_dirmap(spinand, i);
> }
>
> -const struct spi_mem_op *
> -spinand_find_supported_op(struct spinand_device *spinand,
> - const struct spi_mem_op *ops,
> - unsigned int nops)
> -{
> - unsigned int i;
> -
> - for (i = 0; i < nops; i++) {
> - if (spi_mem_supports_op(spinand->spimem, &ops[i]))
> - return &ops[i];
> - }
> -
> - return NULL;
> -}
> -
> static const struct nand_ops spinand_ops = {
> .erase = spinand_erase,
> .markbad = spinand_markbad,
>

Sure. Here some logs:

root@mt7688:~# ./nandbiterrs /dev/mtd5 -i
incremental biterrors test
ECC failure, invalid data despite read success
root@mt7688:~# flash_erase /dev/mtd5 0 1
Erasing 128 Kibyte @ 0 -- 100 % complete
root@mt7688:~# nandwrite --input-size=2048 /dev/mtd5 /dev/urandom
Writing data to block 0 at offset 0x0
root@mt7688:~# ./nandbiterrs /dev/mtd5 -o
overwrite biterrors test
ECC failure, invalid data despite read success
Bit error histogram (0 operations total):

Thanks,
Stefan