From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C96D8C5CFEB for ; Tue, 11 Aug 2026 16:14:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/8R3Y5U48YdWIHcPs2zATHEagcxndCHL55bCPEcloJE=; b=Kp8sfcZ5ApMxpl re3RazrE52ia0zM4xCoDUHIj6wkoOIjronj08soRLRikQyJi5VxwLVkfvjDm4KKp/1I2CIOy27HVH +xd+sRmff495U/OMaPQfDn1SIHYL1xYxe6h0pawqp5s79Z57HS0U6yuQ0LHNt5Ih/xjf0EaK11kEF ajYS1fe9ordhCJlY7kqaD3aC2U4lWL/pmXdDaN/WR82TGmm/lcOuXNxVMzhUGxDVG4jacnqM1NmgP otn061Luog3F43xVk1HldZfIdBPPObX3FWg9oK4IW4pzeig6DkCcvIPbNJPHYHR8xwRzCnLW/JYKV 9Bwy0d8i7HR+GAeaT+gg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wtp76-0000000ESMz-122U; Tue, 11 Aug 2026 16:14:04 +0000 Received: from mail.fris.de ([116.203.77.234]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wtp71-0000000ESJF-3imN for linux-mtd@lists.infradead.org; Tue, 11 Aug 2026 16:14:02 +0000 From: Frieder Schrempf DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fris.de; s=mail; t=1786464836; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FB8jUzAk4vdr/He6IOGom269wrMDPlwN0Q03T1SXJcA=; b=ed+aIs38d2opKY7m9NHGGlutggYTEoU3swZhBgeiVJf8Yeq+ZIlg7GMcikNCzsOyUCqzpe o174B6SglLL+s9lsMCwgXM0GvZ4dJSWS5X5CBmIcLpcc0H+Gf7G5SqS2WuwWOT46o+VCmh q2i8uzqExjk8o/Ta7UYnBZ+uS6xODx/r2Nb5heIUVSMN96VmOMzWcf+lr2xjdVzpZFhpPe vxNOEP730V0Qm/QywRWcLdS2mbjzv6BVTloMrzgREnvwlZ/FNyaQuF2g3a9Q4ttDRGDcx3 iEabvQOTwQNGq5sdjH90JIV6Vv7xD+z1Wn/oBKxyAyxmIwIJxquRZZzK/jBfqg== To: linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: Mikhail Kshevetskiy , stable@vger.kernel.org, Frieder Schrempf , David LaPorte , Gabor Juhos , Pratyush Yadav , Sasha Levin Subject: [PATCH 6.12.y 3/3] mtd: spinand: repeat reading in regular mode if continuous reading fails Date: Tue, 11 Aug 2026 18:13:38 +0200 Message-ID: <20260811161342.533280-4-frieder@fris.de> In-Reply-To: <20260811161342.533280-1-frieder@fris.de> References: <20260811161342.533280-1-frieder@fris.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260811_091400_101332_FBE50113 X-CRM114-Status: GOOD ( 11.19 ) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-mtd" Errors-To: linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org From: Mikhail Kshevetskiy [ Upstream commit 010dc7f2dd6a0078ade3f88f627ed5fbf45ceb94 ] Continuous reading may result in multiple flash pages reading in one operation. Unfortunately, not all spinand controllers support such large reading. They will read less data. Unfortunately, the operation can't be continued. In this case: * disable continuous reading on this (not good enough) spi controller * repeat reading in regular mode. Cc: stable@vger.kernel.org Signed-off-by: Mikhail Kshevetskiy Signed-off-by: Miquel Raynal Signed-off-by: Frieder Schrempf --- drivers/mtd/nand/spi/core.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c index 10339209e7322..bf16901b77b64 100644 --- a/drivers/mtd/nand/spi/core.c +++ b/drivers/mtd/nand/spi/core.c @@ -427,8 +427,16 @@ static int spinand_read_from_cache_op(struct spinand_device *spinand, * Dirmap accesses are allowed to toggle the CS. * Toggling the CS during a continuous read is forbidden. */ - if (nbytes && req->continuous) - return -EIO; + if (nbytes && req->continuous) { + /* + * Spi controller with broken support of continuous + * reading was detected. Disable future use of + * continuous reading and return -EAGAIN to retry + * reading within regular mode. + */ + spinand->cont_read_possible = false; + return -EAGAIN; + } } if (req->datalen) @@ -849,10 +857,19 @@ static int spinand_mtd_read(struct mtd_info *mtd, loff_t from, old_stats = mtd->ecc_stats; - if (spinand_use_cont_read(mtd, from, ops)) + if (spinand_use_cont_read(mtd, from, ops)) { ret = spinand_mtd_continuous_page_read(mtd, from, ops, &max_bitflips); - else + if (ret == -EAGAIN && !spinand->cont_read_possible) { + /* + * Spi controller with broken support of continuous + * reading was detected (see spinand_read_from_cache_op()), + * repeat reading in regular mode. + */ + ret = spinand_mtd_regular_page_read(mtd, from, ops, &max_bitflips); + } + } else { ret = spinand_mtd_regular_page_read(mtd, from, ops, &max_bitflips); + } if (ops->stats) { ops->stats->uncorrectable_errors += -- 2.55.0 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.fris.de (mail.fris.de [116.203.77.234]) (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 A6B1844CAF9; Tue, 11 Aug 2026 16:22:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.77.234 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786465379; cv=none; b=HXMPHOgYhuwprYvhNSO9lM+xxxan1sLYwzS9uPvqFa3a8zP3PNw0LYZ1Umfl+r0DiXWU6WkJywoKQUlKjVGirke42D9KIYBlkopnGK7+QcABhHBpOkr4Fm974M6BPLIhhlLxerjclbuPT1TQUl4hfTUVHrRU2F9dLfe+Xqb7FWA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786465379; c=relaxed/simple; bh=dIklY3UfrxdjUEYYWqpLDVjZe71HM6zRddPIFCZnKhk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aJaR1PAdjB3MmEPh9grprEX08pBKHZb8x2iW3XKtgTiaqjQWqd+G2yUS+R/gelF4yFyea3v1whICBUg13rj6T87jojn+IiQIHpGsEvyOywGoGykV8u1hFNn5fvZStyX7lzg6emELDktwTuKULD+G4v2eJV3wEgCHoqNHiTRJ1n8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fris.de; spf=pass smtp.mailfrom=fris.de; dkim=pass (2048-bit key) header.d=fris.de header.i=@fris.de header.b=ed+aIs38; arc=none smtp.client-ip=116.203.77.234 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fris.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fris.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fris.de header.i=@fris.de header.b="ed+aIs38" From: Frieder Schrempf DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fris.de; s=mail; t=1786464836; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FB8jUzAk4vdr/He6IOGom269wrMDPlwN0Q03T1SXJcA=; b=ed+aIs38d2opKY7m9NHGGlutggYTEoU3swZhBgeiVJf8Yeq+ZIlg7GMcikNCzsOyUCqzpe o174B6SglLL+s9lsMCwgXM0GvZ4dJSWS5X5CBmIcLpcc0H+Gf7G5SqS2WuwWOT46o+VCmh q2i8uzqExjk8o/Ta7UYnBZ+uS6xODx/r2Nb5heIUVSMN96VmOMzWcf+lr2xjdVzpZFhpPe vxNOEP730V0Qm/QywRWcLdS2mbjzv6BVTloMrzgREnvwlZ/FNyaQuF2g3a9Q4ttDRGDcx3 iEabvQOTwQNGq5sdjH90JIV6Vv7xD+z1Wn/oBKxyAyxmIwIJxquRZZzK/jBfqg== To: linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: Mikhail Kshevetskiy , stable@vger.kernel.org, Frieder Schrempf , David LaPorte , Gabor Juhos , Pratyush Yadav , Sasha Levin Subject: [PATCH 6.12.y 3/3] mtd: spinand: repeat reading in regular mode if continuous reading fails Date: Tue, 11 Aug 2026 18:13:38 +0200 Message-ID: <20260811161342.533280-4-frieder@fris.de> In-Reply-To: <20260811161342.533280-1-frieder@fris.de> References: <20260811161342.533280-1-frieder@fris.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Mikhail Kshevetskiy [ Upstream commit 010dc7f2dd6a0078ade3f88f627ed5fbf45ceb94 ] Continuous reading may result in multiple flash pages reading in one operation. Unfortunately, not all spinand controllers support such large reading. They will read less data. Unfortunately, the operation can't be continued. In this case: * disable continuous reading on this (not good enough) spi controller * repeat reading in regular mode. Cc: stable@vger.kernel.org Signed-off-by: Mikhail Kshevetskiy Signed-off-by: Miquel Raynal Signed-off-by: Frieder Schrempf --- drivers/mtd/nand/spi/core.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c index 10339209e7322..bf16901b77b64 100644 --- a/drivers/mtd/nand/spi/core.c +++ b/drivers/mtd/nand/spi/core.c @@ -427,8 +427,16 @@ static int spinand_read_from_cache_op(struct spinand_device *spinand, * Dirmap accesses are allowed to toggle the CS. * Toggling the CS during a continuous read is forbidden. */ - if (nbytes && req->continuous) - return -EIO; + if (nbytes && req->continuous) { + /* + * Spi controller with broken support of continuous + * reading was detected. Disable future use of + * continuous reading and return -EAGAIN to retry + * reading within regular mode. + */ + spinand->cont_read_possible = false; + return -EAGAIN; + } } if (req->datalen) @@ -849,10 +857,19 @@ static int spinand_mtd_read(struct mtd_info *mtd, loff_t from, old_stats = mtd->ecc_stats; - if (spinand_use_cont_read(mtd, from, ops)) + if (spinand_use_cont_read(mtd, from, ops)) { ret = spinand_mtd_continuous_page_read(mtd, from, ops, &max_bitflips); - else + if (ret == -EAGAIN && !spinand->cont_read_possible) { + /* + * Spi controller with broken support of continuous + * reading was detected (see spinand_read_from_cache_op()), + * repeat reading in regular mode. + */ + ret = spinand_mtd_regular_page_read(mtd, from, ops, &max_bitflips); + } + } else { ret = spinand_mtd_regular_page_read(mtd, from, ops, &max_bitflips); + } if (ops->stats) { ops->stats->uncorrectable_errors += -- 2.55.0