[PATCH v4 01/13] spi: airoha: return an error for continuous mode dirmap creation cases

Mikhail Kshevetskiy posted 13 patches 1 month, 1 week ago
There is a newer version of this series
[PATCH v4 01/13] spi: airoha: return an error for continuous mode dirmap creation cases
Posted by Mikhail Kshevetskiy 1 month, 1 week ago
This driver can accelerate single page operations only, thus
continuous reading mode should not be used.

Continuous reading will use sizes up to the size of one erase block.
This size is much larger than the size of single flash page. Use this
difference to identify continuous reading and return an error.

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
---
 drivers/spi/spi-airoha-snfi.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/spi/spi-airoha-snfi.c b/drivers/spi/spi-airoha-snfi.c
index dbe640986825..043a03cd90a1 100644
--- a/drivers/spi/spi-airoha-snfi.c
+++ b/drivers/spi/spi-airoha-snfi.c
@@ -618,6 +618,10 @@ static int airoha_snand_dirmap_create(struct spi_mem_dirmap_desc *desc)
 	if (desc->info.offset + desc->info.length > U32_MAX)
 		return -EINVAL;
 
+	/* continuous reading is not supported */
+	if (desc->info.length > SPI_NAND_CACHE_SIZE)
+		return -E2BIG;
+
 	if (!airoha_snand_supports_op(desc->mem, &desc->info.op_tmpl))
 		return -EOPNOTSUPP;
 
-- 
2.50.1
Re: [PATCH v4 01/13] spi: airoha: return an error for continuous mode dirmap creation cases
Posted by Lorenzo Bianconi 1 month, 1 week ago
> This driver can accelerate single page operations only, thus
> continuous reading mode should not be used.
> 
> Continuous reading will use sizes up to the size of one erase block.
> This size is much larger than the size of single flash page. Use this
> difference to identify continuous reading and return an error.
> 
> Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
> Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>

I guess here we need to add the proper Fixes tag:

Fixes: a403997c12019 ("spi: airoha: add SPI-NAND Flash controller driver")

> ---
>  drivers/spi/spi-airoha-snfi.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/spi/spi-airoha-snfi.c b/drivers/spi/spi-airoha-snfi.c
> index dbe640986825..043a03cd90a1 100644
> --- a/drivers/spi/spi-airoha-snfi.c
> +++ b/drivers/spi/spi-airoha-snfi.c
> @@ -618,6 +618,10 @@ static int airoha_snand_dirmap_create(struct spi_mem_dirmap_desc *desc)
>  	if (desc->info.offset + desc->info.length > U32_MAX)
>  		return -EINVAL;
>  
> +	/* continuous reading is not supported */
> +	if (desc->info.length > SPI_NAND_CACHE_SIZE)
> +		return -E2BIG;
> +
>  	if (!airoha_snand_supports_op(desc->mem, &desc->info.op_tmpl))
>  		return -EOPNOTSUPP;
>  
> -- 
> 2.50.1
> 
Re: [PATCH v4 01/13] spi: airoha: return an error for continuous mode dirmap creation cases
Posted by Mikhail Kshevetskiy 1 month, 1 week ago
On 23.08.2025 11:04, Lorenzo Bianconi wrote:
>> This driver can accelerate single page operations only, thus
>> continuous reading mode should not be used.
>>
>> Continuous reading will use sizes up to the size of one erase block.
>> This size is much larger than the size of single flash page. Use this
>> difference to identify continuous reading and return an error.
>>
>> Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
>> Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
> I guess here we need to add the proper Fixes tag:

Airoha spi driver was introduced in linux-6.10. Continuous reading mode
was introduced later in linux-6.12 (see: commit
631cfdd0520d19b7f4fc13b834fd9c8b46c6dbac). Continuous mode needs to be
agreed with spi controller driver because some spi drivers (like airoha
one) does not support it.

 So I don't know what should be specified in Fixes tag.

Mikhail

> Fixes: a403997c12019 ("spi: airoha: add SPI-NAND Flash controller driver")
>
>> ---
>>  drivers/spi/spi-airoha-snfi.c | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/drivers/spi/spi-airoha-snfi.c b/drivers/spi/spi-airoha-snfi.c
>> index dbe640986825..043a03cd90a1 100644
>> --- a/drivers/spi/spi-airoha-snfi.c
>> +++ b/drivers/spi/spi-airoha-snfi.c
>> @@ -618,6 +618,10 @@ static int airoha_snand_dirmap_create(struct spi_mem_dirmap_desc *desc)
>>  	if (desc->info.offset + desc->info.length > U32_MAX)
>>  		return -EINVAL;
>>  
>> +	/* continuous reading is not supported */
>> +	if (desc->info.length > SPI_NAND_CACHE_SIZE)
>> +		return -E2BIG;
>> +
>>  	if (!airoha_snand_supports_op(desc->mem, &desc->info.op_tmpl))
>>  		return -EOPNOTSUPP;
>>  
>> -- 
>> 2.50.1
>>