]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mtd: spinand: Prevent continuous reads on some controllers
authorMiquel Raynal <miquel.raynal@bootlin.com>
Thu, 26 Mar 2026 16:47:17 +0000 (17:47 +0100)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Mon, 4 May 2026 13:27:03 +0000 (15:27 +0200)
Some controllers do not have full control over the CS line state and may
deassert it under certain conditions in the middle of a (long)
transfer.

Continuous reads are stopped with a CS deassert, hence both features
cannot live together.

Whenever a controller flags that it cannot maintain the CS state
reliably, disable continuous reads entirely.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
drivers/mtd/nand/spi/core.c

index 1d631054bb24eb81168630ed83610397b58f0435..f1084d5e04b9797702a3a35d1a735ee18e05abcd 100644 (file)
@@ -965,6 +965,7 @@ static void spinand_cont_read_init(struct spinand_device *spinand)
 {
        struct nand_device *nand = spinand_to_nand(spinand);
        enum nand_ecc_engine_type engine_type = nand->ecc.ctx.conf.engine_type;
+       struct spi_controller *ctlr = spinand->spimem->spi->controller;
 
        /* OOBs cannot be retrieved so external/on-host ECC engine won't work */
        if (spinand->set_cont_read) {
@@ -976,8 +977,9 @@ static void spinand_cont_read_init(struct spinand_device *spinand)
                 */
                spinand_cont_read_enable(spinand, false);
 
-               if (engine_type == NAND_ECC_ENGINE_TYPE_ON_DIE ||
-                   engine_type == NAND_ECC_ENGINE_TYPE_NONE)
+               if ((engine_type == NAND_ECC_ENGINE_TYPE_ON_DIE ||
+                    engine_type == NAND_ECC_ENGINE_TYPE_NONE) &&
+                   !spi_mem_controller_is_capable(ctlr, no_cs_assertion))
                        spinand->cont_read_possible = true;
        }
 }