* [PATCH] mtd: spinand: macronix: use scratch buffer for DMA operation
@ 2023-01-19 3:45 ` Daniel Golle
0 siblings, 0 replies; 6+ messages in thread
From: Daniel Golle @ 2023-01-19 3:45 UTC (permalink / raw)
To: linux-mtd, linux-kernel, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra
Cc: Mason Yang, Jianhui Zhao
The mx35lf1ge4ab_get_eccsr() function uses an SPI DMA operation to
read the eccsr, hence the buffer should not be on stack. Since commit
380583227c0c7f ("spi: spi-mem: Add extra sanity checks on the op param")
the kernel emmits a warning and blocks such operations.
Use the scratch buffer to get eccsr instead of trying to directly read
into a stack-allocated variable.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
drivers/mtd/nand/spi/macronix.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/spi/macronix.c b/drivers/mtd/nand/spi/macronix.c
index dce835132a1e2..722a9738ba370 100644
--- a/drivers/mtd/nand/spi/macronix.c
+++ b/drivers/mtd/nand/spi/macronix.c
@@ -83,9 +83,10 @@ static int mx35lf1ge4ab_ecc_get_status(struct spinand_device *spinand,
* in order to avoid forcing the wear-leveling layer to move
* data around if it's not necessary.
*/
- if (mx35lf1ge4ab_get_eccsr(spinand, &eccsr))
+ if (mx35lf1ge4ab_get_eccsr(spinand, spinand->scratchbuf))
return nanddev_get_ecc_conf(nand)->strength;
+ eccsr = *spinand->scratchbuf;
if (WARN_ON(eccsr > nanddev_get_ecc_conf(nand)->strength ||
!eccsr))
return nanddev_get_ecc_conf(nand)->strength;
--
2.39.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] mtd: spinand: macronix: use scratch buffer for DMA operation
@ 2023-01-19 3:45 ` Daniel Golle
0 siblings, 0 replies; 6+ messages in thread
From: Daniel Golle @ 2023-01-19 3:45 UTC (permalink / raw)
To: linux-mtd, linux-kernel, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra
Cc: Mason Yang, Jianhui Zhao
The mx35lf1ge4ab_get_eccsr() function uses an SPI DMA operation to
read the eccsr, hence the buffer should not be on stack. Since commit
380583227c0c7f ("spi: spi-mem: Add extra sanity checks on the op param")
the kernel emmits a warning and blocks such operations.
Use the scratch buffer to get eccsr instead of trying to directly read
into a stack-allocated variable.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
drivers/mtd/nand/spi/macronix.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/spi/macronix.c b/drivers/mtd/nand/spi/macronix.c
index dce835132a1e2..722a9738ba370 100644
--- a/drivers/mtd/nand/spi/macronix.c
+++ b/drivers/mtd/nand/spi/macronix.c
@@ -83,9 +83,10 @@ static int mx35lf1ge4ab_ecc_get_status(struct spinand_device *spinand,
* in order to avoid forcing the wear-leveling layer to move
* data around if it's not necessary.
*/
- if (mx35lf1ge4ab_get_eccsr(spinand, &eccsr))
+ if (mx35lf1ge4ab_get_eccsr(spinand, spinand->scratchbuf))
return nanddev_get_ecc_conf(nand)->strength;
+ eccsr = *spinand->scratchbuf;
if (WARN_ON(eccsr > nanddev_get_ecc_conf(nand)->strength ||
!eccsr))
return nanddev_get_ecc_conf(nand)->strength;
--
2.39.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] mtd: spinand: macronix: use scratch buffer for DMA operation
2023-01-19 3:45 ` Daniel Golle
@ 2023-01-20 4:30 ` Dhruva Gole
-1 siblings, 0 replies; 6+ messages in thread
From: Dhruva Gole @ 2023-01-20 4:30 UTC (permalink / raw)
To: Daniel Golle, linux-mtd, linux-kernel, Miquel Raynal,
Richard Weinberger, Vignesh Raghavendra
Cc: Mason Yang, Jianhui Zhao
Hi Daniel,
On 19/01/23 09:15, Daniel Golle wrote:
> The mx35lf1ge4ab_get_eccsr() function uses an SPI DMA operation to
> read the eccsr, hence the buffer should not be on stack. Since commit
> 380583227c0c7f ("spi: spi-mem: Add extra sanity checks on the op param")
> the kernel emmits a warning and blocks such operations.
Good catch!
>
> Use the scratch buffer to get eccsr instead of trying to directly read
> into a stack-allocated variable.
>
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> ---
Reviewed-by: Dhruva Gole <d-gole@ti.com>
> drivers/mtd/nand/spi/macronix.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/nand/spi/macronix.c b/drivers/mtd/nand/spi/macronix.c
> index dce835132a1e2..722a9738ba370 100644
> --- a/drivers/mtd/nand/spi/macronix.c
> +++ b/drivers/mtd/nand/spi/macronix.c
> @@ -83,9 +83,10 @@ static int mx35lf1ge4ab_ecc_get_status(struct spinand_device *spinand,
> * in order to avoid forcing the wear-leveling layer to move
> * data around if it's not necessary.
> */
> - if (mx35lf1ge4ab_get_eccsr(spinand, &eccsr))
> + if (mx35lf1ge4ab_get_eccsr(spinand, spinand->scratchbuf))
> return nanddev_get_ecc_conf(nand)->strength;
>
> + eccsr = *spinand->scratchbuf;
> if (WARN_ON(eccsr > nanddev_get_ecc_conf(nand)->strength ||
> !eccsr))
> return nanddev_get_ecc_conf(nand)->strength;
--
Thanks and Regards,
Dhruva Gole
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mtd: spinand: macronix: use scratch buffer for DMA operation
@ 2023-01-20 4:30 ` Dhruva Gole
0 siblings, 0 replies; 6+ messages in thread
From: Dhruva Gole @ 2023-01-20 4:30 UTC (permalink / raw)
To: Daniel Golle, linux-mtd, linux-kernel, Miquel Raynal,
Richard Weinberger, Vignesh Raghavendra
Cc: Mason Yang, Jianhui Zhao
Hi Daniel,
On 19/01/23 09:15, Daniel Golle wrote:
> The mx35lf1ge4ab_get_eccsr() function uses an SPI DMA operation to
> read the eccsr, hence the buffer should not be on stack. Since commit
> 380583227c0c7f ("spi: spi-mem: Add extra sanity checks on the op param")
> the kernel emmits a warning and blocks such operations.
Good catch!
>
> Use the scratch buffer to get eccsr instead of trying to directly read
> into a stack-allocated variable.
>
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> ---
Reviewed-by: Dhruva Gole <d-gole@ti.com>
> drivers/mtd/nand/spi/macronix.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/nand/spi/macronix.c b/drivers/mtd/nand/spi/macronix.c
> index dce835132a1e2..722a9738ba370 100644
> --- a/drivers/mtd/nand/spi/macronix.c
> +++ b/drivers/mtd/nand/spi/macronix.c
> @@ -83,9 +83,10 @@ static int mx35lf1ge4ab_ecc_get_status(struct spinand_device *spinand,
> * in order to avoid forcing the wear-leveling layer to move
> * data around if it's not necessary.
> */
> - if (mx35lf1ge4ab_get_eccsr(spinand, &eccsr))
> + if (mx35lf1ge4ab_get_eccsr(spinand, spinand->scratchbuf))
> return nanddev_get_ecc_conf(nand)->strength;
>
> + eccsr = *spinand->scratchbuf;
> if (WARN_ON(eccsr > nanddev_get_ecc_conf(nand)->strength ||
> !eccsr))
> return nanddev_get_ecc_conf(nand)->strength;
--
Thanks and Regards,
Dhruva Gole
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mtd: spinand: macronix: use scratch buffer for DMA operation
2023-01-19 3:45 ` Daniel Golle
@ 2023-01-30 16:05 ` Miquel Raynal
-1 siblings, 0 replies; 6+ messages in thread
From: Miquel Raynal @ 2023-01-30 16:05 UTC (permalink / raw)
To: Daniel Golle
Cc: linux-mtd, linux-kernel, Richard Weinberger, Vignesh Raghavendra,
Mason Yang, Jianhui Zhao
Hi Daniel,
daniel@makrotopia.org wrote on Thu, 19 Jan 2023 03:45:43 +0000:
> The mx35lf1ge4ab_get_eccsr() function uses an SPI DMA operation to
> read the eccsr, hence the buffer should not be on stack. Since commit
> 380583227c0c7f ("spi: spi-mem: Add extra sanity checks on the op param")
> the kernel emmits a warning and blocks such operations.
>
> Use the scratch buffer to get eccsr instead of trying to directly read
> into a stack-allocated variable.
>
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> ---
Looks like my scripts did not properly sent the "applied" e-mail, so
here it is, I applied this patch to nand/next.
> drivers/mtd/nand/spi/macronix.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/nand/spi/macronix.c b/drivers/mtd/nand/spi/macronix.c
> index dce835132a1e2..722a9738ba370 100644
> --- a/drivers/mtd/nand/spi/macronix.c
> +++ b/drivers/mtd/nand/spi/macronix.c
> @@ -83,9 +83,10 @@ static int mx35lf1ge4ab_ecc_get_status(struct spinand_device *spinand,
> * in order to avoid forcing the wear-leveling layer to move
> * data around if it's not necessary.
> */
> - if (mx35lf1ge4ab_get_eccsr(spinand, &eccsr))
> + if (mx35lf1ge4ab_get_eccsr(spinand, spinand->scratchbuf))
> return nanddev_get_ecc_conf(nand)->strength;
>
> + eccsr = *spinand->scratchbuf;
> if (WARN_ON(eccsr > nanddev_get_ecc_conf(nand)->strength ||
> !eccsr))
> return nanddev_get_ecc_conf(nand)->strength;
Thanks,
Miquèl
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mtd: spinand: macronix: use scratch buffer for DMA operation
@ 2023-01-30 16:05 ` Miquel Raynal
0 siblings, 0 replies; 6+ messages in thread
From: Miquel Raynal @ 2023-01-30 16:05 UTC (permalink / raw)
To: Daniel Golle
Cc: linux-mtd, linux-kernel, Richard Weinberger, Vignesh Raghavendra,
Mason Yang, Jianhui Zhao
Hi Daniel,
daniel@makrotopia.org wrote on Thu, 19 Jan 2023 03:45:43 +0000:
> The mx35lf1ge4ab_get_eccsr() function uses an SPI DMA operation to
> read the eccsr, hence the buffer should not be on stack. Since commit
> 380583227c0c7f ("spi: spi-mem: Add extra sanity checks on the op param")
> the kernel emmits a warning and blocks such operations.
>
> Use the scratch buffer to get eccsr instead of trying to directly read
> into a stack-allocated variable.
>
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> ---
Looks like my scripts did not properly sent the "applied" e-mail, so
here it is, I applied this patch to nand/next.
> drivers/mtd/nand/spi/macronix.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/nand/spi/macronix.c b/drivers/mtd/nand/spi/macronix.c
> index dce835132a1e2..722a9738ba370 100644
> --- a/drivers/mtd/nand/spi/macronix.c
> +++ b/drivers/mtd/nand/spi/macronix.c
> @@ -83,9 +83,10 @@ static int mx35lf1ge4ab_ecc_get_status(struct spinand_device *spinand,
> * in order to avoid forcing the wear-leveling layer to move
> * data around if it's not necessary.
> */
> - if (mx35lf1ge4ab_get_eccsr(spinand, &eccsr))
> + if (mx35lf1ge4ab_get_eccsr(spinand, spinand->scratchbuf))
> return nanddev_get_ecc_conf(nand)->strength;
>
> + eccsr = *spinand->scratchbuf;
> if (WARN_ON(eccsr > nanddev_get_ecc_conf(nand)->strength ||
> !eccsr))
> return nanddev_get_ecc_conf(nand)->strength;
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-01-30 16:07 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-19 3:45 [PATCH] mtd: spinand: macronix: use scratch buffer for DMA operation Daniel Golle
2023-01-19 3:45 ` Daniel Golle
2023-01-20 4:30 ` Dhruva Gole
2023-01-20 4:30 ` Dhruva Gole
2023-01-30 16:05 ` Miquel Raynal
2023-01-30 16:05 ` Miquel Raynal
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.