[PATCH 1/4] drivers: mtd: spi-nand: fix direct mapping creation sizes.

Miquel Raynal miquel.raynal at bootlin.com
Tue Aug 5 08:24:50 PDT 2025


Hello Mikhail,

Thanks a lot for this series!

On 04/08/2025 at 22:21:29 +03, Mikhail Kshevetskiy <mikhail.kshevetskiy at iopsys.eu> wrote:

> Continuous mode is only supported for non-raw data reads, thus raw I/O
> or non-raw writing requires only single flash page mapping.
>
> Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy at iopsys.eu>
> ---
>  drivers/mtd/nand/spi/core.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
> index b0898990b2a5..b42c42ec58a4 100644
> --- a/drivers/mtd/nand/spi/core.c
> +++ b/drivers/mtd/nand/spi/core.c
> @@ -1103,9 +1103,6 @@ static int spinand_create_dirmap(struct spinand_device *spinand,
>  	};
>  	struct spi_mem_dirmap_desc *desc;
>  
> -	if (spinand->cont_read_possible)
> -		info.length = nanddev_eraseblock_size(nand);
> -
>  	/* The plane number is passed in MSB just above the column address */
>  	info.offset = plane << fls(nand->memorg.pagesize);
>  
> @@ -1117,6 +1114,8 @@ static int spinand_create_dirmap(struct spinand_device *spinand,
>  
>  	spinand->dirmaps[plane].wdesc = desc;
>  
> +	if (spinand->cont_read_possible)
> +		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);
> @@ -1132,6 +1131,9 @@ static int spinand_create_dirmap(struct spinand_device *spinand,
>  		return 0;
>  	}
>  
> +	// ECC reading/writing always happen in non-continuous mode

This comment does not sound helpful, at least I do not understand it?
(and the comment style should be /* */)

> +	info.length = nanddev_page_size(nand) + nanddev_per_page_oobsize(nand);
> +
>  	info.op_tmpl = *spinand->op_templates.update_cache;
>  	info.op_tmpl.data.ecc = true;
>  	desc = devm_spi_mem_dirmap_create(&spinand->spimem->spi->dev,

May I suggest to use two different dirmap infos? One with a large size
(for reads) and a page-sized one for other cases (including the fallback
you're introducing in PATCH 2).

Thanks,
Miquèl



More information about the linux-arm-kernel mailing list