* [PATCH 6.1.y] mtd: spinand: macronix: use scratch buffer for DMA operation
@ 2026-03-10 17:15 Frieder Schrempf
2026-03-21 14:43 ` Patch "mtd: spinand: macronix: use scratch buffer for DMA operation" has been added to the 6.1-stable tree gregkh
0 siblings, 1 reply; 2+ messages in thread
From: Frieder Schrempf @ 2026-03-10 17:15 UTC (permalink / raw)
To: Greg Kroah-Hartman, Sasha Levin, stable, linux-kernel, linux-mtd,
Miquel Raynal, Richard Weinberger, Vignesh Raghavendra
Cc: Daniel Golle, Dhruva Gole, Frieder Schrempf
From: Daniel Golle <daniel@makrotopia.org>
[ Upstream commit ebed787a0becb9354f0a23620a5130cccd6c730c ]
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>
Reviewed-by: Dhruva Gole <d-gole@ti.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/Y8i85zM0u4XdM46z@makrotopia.org
Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
---
This backport fixes the following error in 6.1:
[ 102.320032] WARNING: CPU: 0 PID: 537 at drivers/spi/spi-mem.c:216 spi_mem_check_op+0x15c/0x168
[ 102.328775] Modules linked in: bluetooth rfkill ipv6 snd_soc_fsl_asrc
[ 102.335289] CPU: 0 PID: 537 Comm: nandtest Not tainted 6.1.158-ktn #1
[ 102.341745] Hardware name: Freescale i.MX6 Ultralite (Device Tree)
[ 102.347943] unwind_backtrace from show_stack+0x10/0x14
[ 102.353203] show_stack from dump_stack_lvl+0x24/0x2c
[ 102.358280] dump_stack_lvl from __warn+0x74/0x120
[ 102.363092] __warn from warn_slowpath_fmt+0x178/0x188
[ 102.368250] warn_slowpath_fmt from spi_mem_check_op+0x15c/0x168
[ 102.374286] spi_mem_check_op from spi_mem_exec_op+0x3c/0x3e0
[ 102.380063] spi_mem_exec_op from mx35lf1ge4ab_ecc_get_status+0x9c/0xf8
[ 102.386712] mx35lf1ge4ab_ecc_get_status from spinand_ondie_ecc_finish_io_req+0x38/0x9c
[ 102.394748] spinand_ondie_ecc_finish_io_req from spinand_mtd_read+0x184/0x350
[ 102.401998] spinand_mtd_read from mtd_read_oob+0x98/0x160
[ 102.407517] mtd_read_oob from mtd_read+0x5c/0x80
[ 102.412247] mtd_read from mtdchar_read+0x108/0x2bc
[ 102.417158] mtdchar_read from vfs_read+0x98/0x24c
[ 102.421977] vfs_read from sys_pread64+0x8c/0xb8
[ 102.426613] sys_pread64 from ret_fast_syscall+0x0/0x54
[ 102.431858] Exception stack(0xe0ce1fa8 to 0xe0ce1ff0)
[ 102.436922] 1fa0: 00200000 00000000 00000003 b6e1f008 00040000 00000000
[ 102.445110] 1fc0: 00200000 00000000 00000001 000000b4 b6ff3220 b6e1f008 b6e1f008 b6ddf008
[ 102.453294] 1fe0: 000000b4 be925b38 b6f3d611 b6ec1b26
[ 102.458414] ---[ end trace 0000000000000000 ]---
---
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.53.0
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 2+ messages in thread* Patch "mtd: spinand: macronix: use scratch buffer for DMA operation" has been added to the 6.1-stable tree
2026-03-10 17:15 [PATCH 6.1.y] mtd: spinand: macronix: use scratch buffer for DMA operation Frieder Schrempf
@ 2026-03-21 14:43 ` gregkh
0 siblings, 0 replies; 2+ messages in thread
From: gregkh @ 2026-03-21 14:43 UTC (permalink / raw)
To: d-gole, daniel, frieder.schrempf, frieder, gregkh, linux-mtd,
miquel.raynal, richard, sashal, vigneshr
Cc: stable-commits
This is a note to let you know that I've just added the patch titled
mtd: spinand: macronix: use scratch buffer for DMA operation
to the 6.1-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
mtd-spinand-macronix-use-scratch-buffer-for-dma-operation.patch
and it can be found in the queue-6.1 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.
From stable+bounces-224526-greg=kroah.com@vger.kernel.org Tue Mar 10 18:16:43 2026
From: Frieder Schrempf <frieder@fris.de>
Date: Tue, 10 Mar 2026 18:15:44 +0100
Subject: mtd: spinand: macronix: use scratch buffer for DMA operation
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Sasha Levin <sashal@kernel.org>, stable@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, Miquel Raynal <miquel.raynal@bootlin.com>, Richard Weinberger <richard@nod.at>, Vignesh Raghavendra <vigneshr@ti.com>
Cc: Daniel Golle <daniel@makrotopia.org>, Dhruva Gole <d-gole@ti.com>, Frieder Schrempf <frieder.schrempf@kontron.de>
Message-ID: <20260310171544.1568499-1-frieder@fris.de>
From: Daniel Golle <daniel@makrotopia.org>
[ Upstream commit ebed787a0becb9354f0a23620a5130cccd6c730c ]
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>
Reviewed-by: Dhruva Gole <d-gole@ti.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/Y8i85zM0u4XdM46z@makrotopia.org
Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/mtd/nand/spi/macronix.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/drivers/mtd/nand/spi/macronix.c
+++ b/drivers/mtd/nand/spi/macronix.c
@@ -83,9 +83,10 @@ static int mx35lf1ge4ab_ecc_get_status(s
* 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;
Patches currently in stable-queue which might be from frieder@fris.de are
queue-6.1/regulator-pca9450-make-irq-optional.patch
queue-6.1/mtd-spinand-macronix-use-scratch-buffer-for-dma-operation.patch
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-21 14:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-10 17:15 [PATCH 6.1.y] mtd: spinand: macronix: use scratch buffer for DMA operation Frieder Schrempf
2026-03-21 14:43 ` Patch "mtd: spinand: macronix: use scratch buffer for DMA operation" has been added to the 6.1-stable tree gregkh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox