Skip to content

Commit 6fb075f

Browse files
committed
mtd: rawnand: Ensure all continuous terms are always in sync
While crossing a LUN boundary, it is probably safer (and clearer) to keep all members of the continuous read structure aligned, including the pause page (which is the last page of the lun or the last page of the continuous read). Once these members properly in sync, we can use the rawnand_cap_cont_reads() helper everywhere to "prepare" the next continuous read if there is one. Fixes: bbcd80f ("mtd: rawnand: Prevent crossing LUN boundaries during sequential reads") Cc: [email protected] Signed-off-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected]
1 parent df9803b commit 6fb075f

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

drivers/mtd/nand/raw/nand_base.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,6 +1232,15 @@ static void rawnand_cap_cont_reads(struct nand_chip *chip)
12321232
chip->cont_read.pause_page = rawnand_last_page_of_lun(ppl, first_lun);
12331233
else
12341234
chip->cont_read.pause_page = chip->cont_read.last_page;
1235+
1236+
if (chip->cont_read.first_page == chip->cont_read.pause_page) {
1237+
chip->cont_read.first_page++;
1238+
chip->cont_read.pause_page = min(chip->cont_read.last_page,
1239+
rawnand_last_page_of_lun(ppl, first_lun + 1));
1240+
}
1241+
1242+
if (chip->cont_read.first_page >= chip->cont_read.last_page)
1243+
chip->cont_read.ongoing = false;
12351244
}
12361245

12371246
static int nand_lp_exec_cont_read_page_op(struct nand_chip *chip, unsigned int page,
@@ -1298,12 +1307,11 @@ static int nand_lp_exec_cont_read_page_op(struct nand_chip *chip, unsigned int p
12981307
if (!chip->cont_read.ongoing)
12991308
return 0;
13001309

1301-
if (page == chip->cont_read.pause_page &&
1302-
page != chip->cont_read.last_page) {
1303-
chip->cont_read.first_page = chip->cont_read.pause_page + 1;
1304-
rawnand_cap_cont_reads(chip);
1305-
} else if (page == chip->cont_read.last_page) {
1310+
if (page == chip->cont_read.last_page) {
13061311
chip->cont_read.ongoing = false;
1312+
} else if (page == chip->cont_read.pause_page) {
1313+
chip->cont_read.first_page++;
1314+
rawnand_cap_cont_reads(chip);
13071315
}
13081316

13091317
return 0;
@@ -3510,10 +3518,7 @@ static void rawnand_cont_read_skip_first_page(struct nand_chip *chip, unsigned i
35103518
return;
35113519

35123520
chip->cont_read.first_page++;
3513-
if (chip->cont_read.first_page == chip->cont_read.pause_page)
3514-
chip->cont_read.first_page++;
3515-
if (chip->cont_read.first_page >= chip->cont_read.last_page)
3516-
chip->cont_read.ongoing = false;
3521+
rawnand_cap_cont_reads(chip);
35173522
}
35183523

35193524
/**

0 commit comments

Comments
 (0)