Skip to content

Commit d26f0b2

Browse files
miquelraynalgregkh
authored andcommitted
mtd: rawnand: Pause continuous reads at block boundaries
[ Upstream commit 8e45316 ] 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: 003fe4b ("mtd: rawnand: Support for sequential cache reads") Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f83ba55 commit d26f0b2

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

drivers/mtd/nand/raw/nand_base.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,32 +1212,32 @@ static int nand_lp_exec_read_page_op(struct nand_chip *chip, unsigned int page,
12121212
return nand_exec_op(chip, &op);
12131213
}
12141214

1215-
static unsigned int rawnand_last_page_of_lun(unsigned int pages_per_lun, unsigned int lun)
1215+
static unsigned int rawnand_last_page_of_block(unsigned int ppb, unsigned int block)
12161216
{
1217-
/* lun is expected to be very small */
1218-
return (lun * pages_per_lun) + pages_per_lun - 1;
1217+
/* block is expected to be very small */
1218+
return (block * ppb) + ppb - 1;
12191219
}
12201220

12211221
static void rawnand_cap_cont_reads(struct nand_chip *chip)
12221222
{
12231223
struct nand_memory_organization *memorg;
1224-
unsigned int ppl, first_lun, last_lun;
1224+
unsigned int ppb, first_block, last_block;
12251225

12261226
memorg = nanddev_get_memorg(&chip->base);
1227-
ppl = memorg->pages_per_eraseblock * memorg->eraseblocks_per_lun;
1228-
first_lun = chip->cont_read.first_page / ppl;
1229-
last_lun = chip->cont_read.last_page / ppl;
1227+
ppb = memorg->pages_per_eraseblock;
1228+
first_block = chip->cont_read.first_page / ppb;
1229+
last_block = chip->cont_read.last_page / ppb;
12301230

1231-
/* Prevent sequential cache reads across LUN boundaries */
1232-
if (first_lun != last_lun)
1233-
chip->cont_read.pause_page = rawnand_last_page_of_lun(ppl, first_lun);
1231+
/* Prevent sequential cache reads across block boundaries */
1232+
if (first_block != last_block)
1233+
chip->cont_read.pause_page = rawnand_last_page_of_block(ppb, first_block);
12341234
else
12351235
chip->cont_read.pause_page = chip->cont_read.last_page;
12361236

12371237
if (chip->cont_read.first_page == chip->cont_read.pause_page) {
12381238
chip->cont_read.first_page++;
12391239
chip->cont_read.pause_page = min(chip->cont_read.last_page,
1240-
rawnand_last_page_of_lun(ppl, first_lun + 1));
1240+
rawnand_last_page_of_block(ppb, first_block + 1));
12411241
}
12421242

12431243
if (chip->cont_read.first_page >= chip->cont_read.last_page)

0 commit comments

Comments
 (0)