[PATCH] mtd: spinand: macronix: use scratch buffer for DMA operation

Dhruva Gole d-gole at ti.com
Thu Jan 19 20:30:09 PST 2023


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 at makrotopia.org>
> ---

Reviewed-by: Dhruva Gole <d-gole at 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



More information about the linux-mtd mailing list