423-v6.3-mtd-spinand-macronix-use-scratch-buffer-for-DMA-oper.patch 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. From ebed787a0becb9354f0a23620a5130cccd6c730c Mon Sep 17 00:00:00 2001
  2. From: Daniel Golle <[email protected]>
  3. Date: Thu, 19 Jan 2023 03:45:43 +0000
  4. Subject: [PATCH] mtd: spinand: macronix: use scratch buffer for DMA operation
  5. The mx35lf1ge4ab_get_eccsr() function uses an SPI DMA operation to
  6. read the eccsr, hence the buffer should not be on stack. Since commit
  7. 380583227c0c7f ("spi: spi-mem: Add extra sanity checks on the op param")
  8. the kernel emmits a warning and blocks such operations.
  9. Use the scratch buffer to get eccsr instead of trying to directly read
  10. into a stack-allocated variable.
  11. Signed-off-by: Daniel Golle <[email protected]>
  12. Reviewed-by: Dhruva Gole <[email protected]>
  13. Signed-off-by: Miquel Raynal <[email protected]>
  14. Link: https://lore.kernel.org/linux-mtd/[email protected]
  15. ---
  16. drivers/mtd/nand/spi/macronix.c | 3 ++-
  17. 1 file changed, 2 insertions(+), 1 deletion(-)
  18. --- a/drivers/mtd/nand/spi/macronix.c
  19. +++ b/drivers/mtd/nand/spi/macronix.c
  20. @@ -83,9 +83,10 @@ static int mx35lf1ge4ab_ecc_get_status(s
  21. * in order to avoid forcing the wear-leveling layer to move
  22. * data around if it's not necessary.
  23. */
  24. - if (mx35lf1ge4ab_get_eccsr(spinand, &eccsr))
  25. + if (mx35lf1ge4ab_get_eccsr(spinand, spinand->scratchbuf))
  26. return nanddev_get_ecc_conf(nand)->strength;
  27. + eccsr = *spinand->scratchbuf;
  28. if (WARN_ON(eccsr > nanddev_get_ecc_conf(nand)->strength ||
  29. !eccsr))
  30. return nanddev_get_ecc_conf(nand)->strength;