linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
To: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Lorenzo Bianconi <lorenzo@kernel.org>,
	Ray Liu <ray.liu@airoha.com>, Mark Brown <broonie@kernel.org>,
	Tudor Ambarus <tudor.ambarus@linaro.org>,
	Martin Kurbanov <mmkurbanov@salutedevices.com>,
	Takahiro Kuwano <Takahiro.Kuwano@infineon.com>,
	Cheng Ming Lin <chengminglin@mxic.com.tw>,
	linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org
Subject: Re: [PATCH 3/4] drivers: mtd: spi-nand: repeat reading in regular mode if continuous reading fails
Date: Mon, 18 Aug 2025 15:05:11 +0300	[thread overview]
Message-ID: <e01d40c2-cf1d-42f3-8589-da998b23901f@iopsys.eu> (raw)
In-Reply-To: <875xf1hjb8.fsf@bootlin.com>

Hello Miquèl, is there any comments to my v2 series? Mikhail

On 05.08.2025 18:36, Miquel Raynal wrote:
> On 04/08/2025 at 22:21:31 +03, Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu> wrote:
>
>> Continuous reading may result in multiple flash pages reading in one
>> operation. Unfortunately, not all spi-nand 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.
>>
>> Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
>> ---
>>  drivers/mtd/nand/spi/core.c | 19 +++++++++++++++----
>>  1 file changed, 15 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
>> index ff6a1e2fcfdc..88e4c00cccc4 100644
>> --- a/drivers/mtd/nand/spi/core.c
>> +++ b/drivers/mtd/nand/spi/core.c
>> @@ -431,7 +431,7 @@ static int spinand_read_from_cache_op(struct spinand_device *spinand,
>>  		 * Toggling the CS during a continuous read is forbidden.
>>  		 */
>>  		if (nbytes && req->continuous)
>> -			return -EIO;
>> +			return -E2BIG;
>>  	}
>>  
>>  	if (req->datalen)
>> @@ -893,15 +893,26 @@ static int spinand_mtd_read(struct mtd_info *mtd, loff_t from,
>>  	struct spinand_device *spinand = mtd_to_spinand(mtd);
>>  	struct mtd_ecc_stats old_stats;
>>  	unsigned int max_bitflips = 0;
>> -	int ret;
>> +	int ret = -E2BIG;
>>  
>>  	mutex_lock(&spinand->lock);
>>  
>>  	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 == -E2BIG) {
>> +			/*
>> +			 * Some spi controllers may not support reading up to
>> +			 * erase block size. They will read less data than
>> +			 * expected. If this happen disable continuous mode
>                                              happens,
>
>> +			 * and repeat reading in normal mode.
>> +			 */
>> +			spinand->cont_read_possible = false;
>> +		}
>> +	}
>> +
>> +	if (ret == -E2BIG)
> While I agree with the overall logic, I find pretty unreadable to
> perform the regular read upon a return value that is an error code set
> in the init sequence. Can you please propose an alternate implementation?
>
>>  		ret = spinand_mtd_regular_page_read(mtd, from, ops, &max_bitflips);
>>  
>>  	if (ops->stats) {
> Thanks!
> Miquèl

  reply	other threads:[~2025-08-18 12:05 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-04 19:21 [PATCH 0/4] drivers: mtd: spi-nand: fix continuous reading mode Mikhail Kshevetskiy
2025-08-04 19:21 ` [PATCH 1/4] drivers: mtd: spi-nand: fix direct mapping creation sizes Mikhail Kshevetskiy
2025-08-05 15:24   ` Miquel Raynal
2025-08-04 19:21 ` [PATCH 2/4] drivers: mtd: spi-nand: try a regular dirmap if creating a dirmap for continuous reading fails Mikhail Kshevetskiy
2025-08-05 15:30   ` Miquel Raynal
2025-08-05 15:35     ` Mikhail Kshevetskiy
2025-08-06  9:03       ` Miquel Raynal
2025-08-08 21:01         ` [PATCH v2 0/4] mtd: spinand: fix continuous reading mode support Mikhail Kshevetskiy
2025-08-08 21:01           ` [PATCH v2 1/4] mtd: spinand: fix direct mapping creation sizes Mikhail Kshevetskiy
2025-08-08 21:01           ` [PATCH v2 2/4] mtd: spinand: try a regular dirmap if creating a dirmap for continuous reading fails Mikhail Kshevetskiy
2025-08-08 21:01           ` [PATCH v2 3/4] mtd: spinand: repeat reading in regular mode if " Mikhail Kshevetskiy
2025-08-08 21:01           ` [PATCH v2 4/4] spi: spi-airoha-snfi: return an error for continuous mode dirmap creation cases Mikhail Kshevetskiy
2025-08-04 19:21 ` [PATCH 3/4] drivers: mtd: spi-nand: repeat reading in regular mode if continuous reading fails Mikhail Kshevetskiy
2025-08-05 15:36   ` Miquel Raynal
2025-08-18 12:05     ` Mikhail Kshevetskiy [this message]
2025-08-04 19:21 ` [PATCH 4/4] drivers: spi: spi-airoha-snfi: return an error for continuous mode dirmap creation cases Mikhail Kshevetskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e01d40c2-cf1d-42f3-8589-da998b23901f@iopsys.eu \
    --to=mikhail.kshevetskiy@iopsys.eu \
    --cc=Takahiro.Kuwano@infineon.com \
    --cc=broonie@kernel.org \
    --cc=chengminglin@mxic.com.tw \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=mmkurbanov@salutedevices.com \
    --cc=ray.liu@airoha.com \
    --cc=richard@nod.at \
    --cc=tudor.ambarus@linaro.org \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).