]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mtd: rawnand: Pause continuous reads at block boundaries
authorMiquel Raynal <miquel.raynal@bootlin.com>
Fri, 22 May 2026 09:17:39 +0000 (11:17 +0200)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Wed, 27 May 2026 09:10:08 +0000 (11:10 +0200)
Some chips do not support sequential cached reads past block
boundaries, like Winbond. In practice when using UBI, this should very
rarely happen, but let's make sure it never happens.

Cc: stable@vger.kernel.org
Fixes: 003fe4b9545b ("mtd: rawnand: Support for sequential cache reads")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
drivers/mtd/nand/raw/nand_base.c

index e4e1383bd5e1ab8405225479c26ada7cda1b954e..a5b278ab9384fa7cc72339f9b032d39a35a5e026 100644 (file)
@@ -1216,32 +1216,32 @@ static int nand_lp_exec_read_page_op(struct nand_chip *chip, unsigned int page,
        return nand_exec_op(chip, &op);
 }
 
-static unsigned int rawnand_last_page_of_lun(unsigned int pages_per_lun, unsigned int lun)
+static unsigned int rawnand_last_page_of_block(unsigned int ppb, unsigned int block)
 {
-       /* lun is expected to be very small */
-       return (lun * pages_per_lun) + pages_per_lun - 1;
+       /* block is expected to be very small */
+       return (block * ppb) + ppb - 1;
 }
 
 static void rawnand_cap_cont_reads(struct nand_chip *chip)
 {
        struct nand_memory_organization *memorg;
-       unsigned int ppl, first_lun, last_lun;
+       unsigned int ppb, first_block, last_block;
 
        memorg = nanddev_get_memorg(&chip->base);
-       ppl = memorg->pages_per_eraseblock * memorg->eraseblocks_per_lun;
-       first_lun = chip->cont_read.first_page / ppl;
-       last_lun = chip->cont_read.last_page / ppl;
+       ppb = memorg->pages_per_eraseblock;
+       first_block = chip->cont_read.first_page / ppb;
+       last_block = chip->cont_read.last_page / ppb;
 
-       /* Prevent sequential cache reads across LUN boundaries */
-       if (first_lun != last_lun)
-               chip->cont_read.pause_page = rawnand_last_page_of_lun(ppl, first_lun);
+       /* Prevent sequential cache reads across block boundaries */
+       if (first_block != last_block)
+               chip->cont_read.pause_page = rawnand_last_page_of_block(ppb, first_block);
        else
                chip->cont_read.pause_page = chip->cont_read.last_page;
 
        if (chip->cont_read.first_page == chip->cont_read.pause_page) {
                chip->cont_read.first_page++;
                chip->cont_read.pause_page = min(chip->cont_read.last_page,
-                                                rawnand_last_page_of_lun(ppl, first_lun + 1));
+                                                rawnand_last_page_of_block(ppb, first_block + 1));
        }
 
        if (chip->cont_read.first_page >= chip->cont_read.last_page)