This is a note to let you know that I've just added the patch titled mtd: rawnand: Clarify conditions to enable continuous reads to the 6.6-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-rawnand-clarify-conditions-to-enable-continuous-reads.patch and it can be found in the queue-6.6 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 828f6df1bcba7f64729166efc7086ea657070445 Mon Sep 17 00:00:00 2001 From: Miquel Raynal <miquel.raynal@xxxxxxxxxxx> Date: Fri, 15 Dec 2023 13:32:08 +0100 Subject: mtd: rawnand: Clarify conditions to enable continuous reads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Miquel Raynal <miquel.raynal@xxxxxxxxxxx> commit 828f6df1bcba7f64729166efc7086ea657070445 upstream. The current logic is probably fine but is a bit convoluted. Plus, we don't want partial pages to be part of the sequential operation just in case the core would optimize the page read with a subpage read (which would break the sequence). This may happen on the first and last page only, so if the start offset or the end offset is not aligned with a page boundary, better avoid them to prevent any risk. Cc: stable@xxxxxxxxxxxxxxx Fixes: 003fe4b9545b ("mtd: rawnand: Support for sequential cache reads") Signed-off-by: Miquel Raynal <miquel.raynal@xxxxxxxxxxx> Tested-by: Martin Hundebøll <martin@xxxxxxxxxx> Link: https://lore.kernel.org/linux-mtd/20231215123208.516590-5-miquel.raynal@xxxxxxxxxxx Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/mtd/nand/raw/nand_base.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -3461,21 +3461,29 @@ static void rawnand_enable_cont_reads(st u32 readlen, int col) { struct mtd_info *mtd = nand_to_mtd(chip); + unsigned int end_page, end_col; + + chip->cont_read.ongoing = false; if (!chip->controller->supported_op.cont_read) return; - if ((col && col + readlen < (3 * mtd->writesize)) || - (!col && readlen < (2 * mtd->writesize))) { - chip->cont_read.ongoing = false; + end_page = DIV_ROUND_UP(col + readlen, mtd->writesize); + end_col = (col + readlen) % mtd->writesize; + + if (col) + page++; + + if (end_col && end_page) + end_page--; + + if (page + 1 > end_page) return; - } - chip->cont_read.ongoing = true; chip->cont_read.first_page = page; - if (col) - chip->cont_read.first_page++; - chip->cont_read.last_page = page + ((readlen >> chip->page_shift) & chip->pagemask); + chip->cont_read.last_page = end_page; + chip->cont_read.ongoing = true; + rawnand_cap_cont_reads(chip); } Patches currently in stable-queue which might be from miquel.raynal@xxxxxxxxxxx are queue-6.6/mtd-rawnand-prevent-crossing-lun-boundaries-during-sequential-reads.patch queue-6.6/mtd-rawnand-fix-core-interference-with-sequential-reads.patch queue-6.6/mtd-rawnand-clarify-conditions-to-enable-continuous-reads.patch queue-6.6/mtd-rawnand-prevent-sequential-reads-with-on-die-ecc-engines.patch queue-6.6/mtd-maps-vmu-flash-fix-the-mtd-core-switch-to-ref-counters.patch