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