From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Olivier Maignial <olivier.maignial@hotmail.fr>
Cc: olivier.maignial@somfy.com, Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>,
Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>,
Frieder Schrempf <frieder.schrempf@kontron.de>,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mtd: spinand: winbond|toshiba: Fix ecc_get_status
Date: Thu, 22 Jun 2023 09:47:23 +0200 [thread overview]
Message-ID: <20230622094723.37b70bd3@xps-13> (raw)
In-Reply-To: <DB4P250MB103296BD8C6C8CD514A46E83FE5CA@DB4P250MB1032.EURP250.PROD.OUTLOOK.COM>
Hi Olivier,
olivier.maignial@hotmail.fr wrote on Tue, 20 Jun 2023 23:16:15 +0200:
> Reading ECC status is failing in toshiba & winbond spi-nand drivers.
>
> tx58cxgxsxraix_ecc_get_status() and w25n02kv_ecc_get_status()
> functions are using on-stack buffers which are not suitable
> for DMA needs of spi-mem.
>
> Fix this by using the spi-mem operations dedicated buffer
> spinand->scratchbuf
Missing period .
>
> See
> spinand->scratchbuf:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/mtd/spinand.h?h=v6.3#n418
> spi_mem_check_op():
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/spi/spi-mem.c?h=v6.3#n199
Could you add a Cc: stable and a Fixes tag? It might require to address
both drivers independently (in two different commits), this is not a
problem.
Otherwise LGTM!
Thanks,
Miquèl
> Signed-off-by: Olivier Maignial <olivier.maignial@hotmail.fr>
> ---
> drivers/mtd/nand/spi/toshiba.c | 4 ++--
> drivers/mtd/nand/spi/winbond.c | 4 ++--
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/mtd/nand/spi/toshiba.c b/drivers/mtd/nand/spi/toshiba.c
> index 7380b1ebaccd..a80427c13121 100644
> --- a/drivers/mtd/nand/spi/toshiba.c
> +++ b/drivers/mtd/nand/spi/toshiba.c
> @@ -73,7 +73,7 @@ static int tx58cxgxsxraix_ecc_get_status(struct spinand_device *spinand,
> {
> struct nand_device *nand = spinand_to_nand(spinand);
> u8 mbf = 0;
> - struct spi_mem_op op = SPINAND_GET_FEATURE_OP(0x30, &mbf);
> + struct spi_mem_op op = SPINAND_GET_FEATURE_OP(0x30, spinand->scratchbuf);
>
> switch (status & STATUS_ECC_MASK) {
> case STATUS_ECC_NO_BITFLIPS:
> @@ -92,7 +92,7 @@ static int tx58cxgxsxraix_ecc_get_status(struct spinand_device *spinand,
> if (spi_mem_exec_op(spinand->spimem, &op))
> return nanddev_get_ecc_conf(nand)->strength;
>
> - mbf >>= 4;
> + mbf = *(spinand->scratchbuf) >> 4;
>
> if (WARN_ON(mbf > nanddev_get_ecc_conf(nand)->strength || !mbf))
> return nanddev_get_ecc_conf(nand)->strength;
> diff --git a/drivers/mtd/nand/spi/winbond.c b/drivers/mtd/nand/spi/winbond.c
> index 3ad58cd284d8..f507e3759301 100644
> --- a/drivers/mtd/nand/spi/winbond.c
> +++ b/drivers/mtd/nand/spi/winbond.c
> @@ -108,7 +108,7 @@ static int w25n02kv_ecc_get_status(struct spinand_device *spinand,
> {
> struct nand_device *nand = spinand_to_nand(spinand);
> u8 mbf = 0;
> - struct spi_mem_op op = SPINAND_GET_FEATURE_OP(0x30, &mbf);
> + struct spi_mem_op op = SPINAND_GET_FEATURE_OP(0x30, spinand->scratchbuf);
>
> switch (status & STATUS_ECC_MASK) {
> case STATUS_ECC_NO_BITFLIPS:
> @@ -126,7 +126,7 @@ static int w25n02kv_ecc_get_status(struct spinand_device *spinand,
> if (spi_mem_exec_op(spinand->spimem, &op))
> return nanddev_get_ecc_conf(nand)->strength;
>
> - mbf >>= 4;
> + mbf = *(spinand->scratchbuf) >> 4;
>
> if (WARN_ON(mbf > nanddev_get_ecc_conf(nand)->strength || !mbf))
> return nanddev_get_ecc_conf(nand)->strength;
prev parent reply other threads:[~2023-06-22 7:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-20 21:16 [PATCH] mtd: spinand: winbond|toshiba: Fix ecc_get_status Olivier Maignial
2023-06-22 7:47 ` 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=20230622094723.37b70bd3@xps-13 \
--to=miquel.raynal@bootlin.com \
--cc=frieder.schrempf@kontron.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=mikhail.kshevetskiy@iopsys.eu \
--cc=olivier.maignial@hotmail.fr \
--cc=olivier.maignial@somfy.com \
--cc=richard@nod.at \
--cc=vigneshr@ti.com \
/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