[PATCH RESEND v2 2/4] mtd: spinand: try a regular dirmap if creating a dirmap for continuous reading fails

Miquel Raynal miquel.raynal at bootlin.com
Sun Aug 24 09:26:16 PDT 2025


On 14/08/2025 at 09:54:21 +03, Mikhail Kshevetskiy <mikhail.kshevetskiy at 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 toggling 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.
>
> This patch tries to create dirmap for continuous reading first and
> fallback to regular reading if spi controller refuses to create it.
>
> Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy at iopsys.eu>
> ---
>  drivers/mtd/nand/spi/core.c | 43 ++++++++++++++++++++++++++++++-------
>  1 file changed, 35 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
> index 09dd6e40e308..0f8636047365 100644
> --- a/drivers/mtd/nand/spi/core.c
> +++ b/drivers/mtd/nand/spi/core.c
> @@ -1093,6 +1093,39 @@ static int spinand_mtd_block_isreserved(struct mtd_info *mtd, loff_t offs)
>  	return ret;
>  }
>  
> +static struct spi_mem_dirmap_desc *spinand_create_rdesc_helper(

Can we drop _helper from the name? Just spinand_create_rdesc() sounds
as useful.

> +					struct spinand_device *spinand,
> +					struct spi_mem_dirmap_info *info)
> +{
> +	struct nand_device *nand = spinand_to_nand(spinand);
> +	struct spi_mem_dirmap_desc *desc = NULL;
> +

Looks good otherwise.

Thanks,
Miquèl



More information about the linux-arm-kernel mailing list