From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5793B385D7B; Thu, 30 Jul 2026 16:16:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785428183; cv=none; b=YKNoR+2sY/6ee25zdZcGqXHVTJYHuwC4OAv4L60bxDXN86vjxEai6Fhi5N1Dsjuc4NPfNFAihVHDivwHG2ujxuXFNJ9PWKU7v0DMUJH9rw3e1FYApbyUGhmqkFBmDsNwLI41kVtUD2HW2DUWONDQ82RTX6fG8q2hgYmmVEKaaTE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785428183; c=relaxed/simple; bh=hBshRUOaiWAI7edCSDxYXXBRVAAQwqIPgIIZjgaejEw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HyLy4+rubgf9YlIE6viloPxXnOpjoQg37D2a/1lz5Wl3rjdRXxpHoFcYjfg9EUzT3kAiCkal7vezzkqfK94uhvK1u7LoOK/9yl8HMRDTBFI3XYYSA0xI7Mw6P06GYYC3hglX/hNM5N9S3WeMoT5weRruWWLQ7W6f3tn762wiWis= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=WxLKcBYn; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="WxLKcBYn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 623EE1F00AC4; Thu, 30 Jul 2026 16:16:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1785428167; bh=a5RKtGRa9ZtnDIU+s2S34NC76DNSwO4GyfwrA66TZ3c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WxLKcBYnFlaB5xEwWEF3NwIRMjfuZJ2J9hof4SQshW0P656QNkcp69T0s3CSvNZOr ykEw2oUXQTdtkUUH5F8cm7mmf/hoH0quOohjqTBzs3fgFUg/xG8vFgz8Z/7BTR9v96 yC6PjGPPQPfFWySnW4X1TZ745X6fAXRQzhoQjfzw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Miquel Raynal , Sasha Levin Subject: [PATCH 6.6 428/484] mtd: rawnand: Pause continuous reads at block boundaries Date: Thu, 30 Jul 2026 16:15:25 +0200 Message-ID: <20260730141432.779152521@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260730141423.392222816@linuxfoundation.org> References: <20260730141423.392222816@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Miquel Raynal [ Upstream commit 8e4531667d718e2e9b193928cf9b2497fa0d01ef ] 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 Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/nand/raw/nand_base.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -1212,32 +1212,32 @@ static int nand_lp_exec_read_page_op(str 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; - - /* 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); + 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 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)