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 2/4] drivers: mtd: spi-nand: try a regular dirmap if creating a dirmap for continuous reading fails
Date: Tue, 5 Aug 2025 18:35:32 +0300	[thread overview]
Message-ID: <74646064-0c8c-46b9-8ec3-653c4f80b70f@iopsys.eu> (raw)
In-Reply-To: <87jz3hhjlj.fsf@bootlin.com>


On 05.08.2025 18:30, Miquel Raynal wrote:
> On 04/08/2025 at 22:21:30 +03, Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu> wrote:
>
>> Continuous reading may result in multiple flash pages reading in one
>> operation. Typically only one flash page has read/written (a little bit
>> more than 2-4 Kb), but continuous reading requires the spi-controller
>> to read up to 512 Kb in one operation without togling CS in beetween.
>>
>> Roughly speaking spi-controllers can be divided on 2 categories:
>>  * spi-controllers without dirmap acceleration support
>>  * spi-controllers with dirmap acceleration support
>>
>> Usually, first of them have no issues with large reading support.
>> Second group often supports acceleration of single page only reading.
>> Thus enabling of continuous reading can break flash reading.
> I would be more conservative, I believe it is very implementation
> dependent; many controller drivers do not even advertise a max size.
>
> I agree though that controllers with dirmap support may express
> limitations such as the mapped size which may lead to splitting
> operations into smaller chunks, possibly leading to CS changes which
> would break the continuous read mode on the chip's side.
>
>> This patch tries to create dirmap for continuous reading first and
>> fallback to regular reading if spi-controller refuses to create it.
> no '-'                              ^
>
>> Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
>> ---
>>  drivers/mtd/nand/spi/core.c | 29 +++++++++++++++++++++++++----
>>  1 file changed, 25 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
>> index b42c42ec58a4..ff6a1e2fcfdc 100644
>> --- a/drivers/mtd/nand/spi/core.c
>> +++ b/drivers/mtd/nand/spi/core.c
>> @@ -1114,11 +1114,32 @@ static int spinand_create_dirmap(struct spinand_device *spinand,
>>  
>>  	spinand->dirmaps[plane].wdesc = desc;
>>  
>> -	if (spinand->cont_read_possible)
>> +	desc = NULL;
>> +	if (spinand->cont_read_possible) {
>> +		/*
>> +		 * spi-controllers may return an error if info.length is
>> +		 * too large
>> +		 */
>>  		info.length = nanddev_eraseblock_size(nand);
>> -	info.op_tmpl = *spinand->op_templates.read_cache;
>> -	desc = devm_spi_mem_dirmap_create(&spinand->spimem->spi->dev,
>> -					  spinand->spimem, &info);
>> +		info.op_tmpl = *spinand->op_templates.read_cache;
>> +		desc = devm_spi_mem_dirmap_create(&spinand->spimem->spi->dev,
>> +						  spinand->spimem, &info);
>> +	}
>> +
>> +	if (IS_ERR_OR_NULL(desc)) {
> Here if the problem is continuous reading, I expect an error and not a
> NULL pointer.
NULL is possible if flash does not supports continuous reading
>
>> +		/*
>> +		 * continuous reading is not supported by flash or
> Not by the flash, here if we get an error, it is the spi controller
> (still without '-' ;) ) that fails (please fix the comment).

we can go here in 2 cases:
1) spinand->cont_read_possible is false (flash does not supports
continuous reading)

2) spi controller returns an error (spi controller does not like
continuous reading)

>
>> +		 * its spi-controller, try regular reading
>> +		 */
>> +		spinand->cont_read_possible = false;
>> +
>> +		info.length = nanddev_page_size(nand) +
>> +			      nanddev_per_page_oobsize(nand);
>> +		info.op_tmpl = *spinand->op_templates.read_cache;
>> +		desc = devm_spi_mem_dirmap_create(&spinand->spimem->spi->dev,
>> +						  spinand->spimem, &info);
>> +	}
>> +
>>  	if (IS_ERR(desc))
>>  		return PTR_ERR(desc);

  reply	other threads:[~2025-08-05 15:37 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 [this message]
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
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=74646064-0c8c-46b9-8ec3-653c4f80b70f@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).