mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-09-22 09:34:56 +02:00
mtd: rawnand: Pause continuous reads at block boundaries
[ Upstream commit8e4531667d] 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:003fe4b954("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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
f83ba55179
commit
d26f0b293b
@@ -1212,32 +1212,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)
|
||||
|
||||
Reference in New Issue
Block a user