[PATCH] spi-nor: fix spi_nor_probe

Pratyush Yadav p.yadav at ti.com
Thu Apr 28 23:33:29 PDT 2022


Hi Pascal,

Thanks for the patch.

Please use the prefix "mtd: spi-nor: core: " for your patch subject. You 
can run git log on a particular file or subsystem to see what prefixes 
they use.

Also please send the patch to _all_ maintainers for the subsystem using 
scripts/get_maintainer.pl.

Anyway, see my review below.

On 25/04/22 01:58PM, Pascal Fabreges wrote:
> In rare cases, 7 on 5000 power off/on, the spi-nor driver is probed
> too soon.
> The controller is not in "running" mode.
> 
> The spi-nor driver take the hand before the end of the
> spi_start_queue procedure which set the running mode to true after
> the spi_init_queue (Initialize and start queue).
> 
> kernel: spi_master spi0: spi_init_queue: ctlr->running = false
> kernel: device: 'spi0.1': device_add
> kernel: bus: 'spi': add device spi0.1
> kernel: bus: 'spi': driver_probe_device: matched device spi0.1 with driver spi-nor
> kernel: bus: 'spi': really_probe: probing driver spi-nor with device spi0.1
> kernel: spi-nor spi0.1: no pinctrl handle
> kernel: spi-nor spi0.1: spi_nor_probe: Caller name: really_probe+0x2b3/0x3e0
> kernel: spi-nor spi0.1: spi_nor_probe: Call spi_nor_scan
> kernel: spi_master spi0: spi_mem_exec_op: Caller name: spi_nor_read_id+0x89/0x190
> kernel: spi-nor spi0.1: spi_sync: Caller name: spi_mem_exec_op+0x2f5/0x460
> kernel: spi-nor spi0.1: __spi_sync:  call __spi_queued_transfer
> kernel: spi-nor spi0.1: __spi_queued_transfer: return -ESHUTDOWN
> kernel: spi-nor spi0.1: error -108 reading JEDEC ID  00 00 00 00 00 00
> kernel: spi-nor: probe of spi0.1 failed with error -108
> 
> Signed-off-by: Pascal Fabreges <pascal.fabreges at nokia.com>
> ---
>  drivers/mtd/spi-nor/core.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> index e6b8b19a68ee..dd82f42c29db 100644
> --- a/drivers/mtd/spi-nor/core.c
> +++ b/drivers/mtd/spi-nor/core.c
> @@ -3618,6 +3618,9 @@ static int spi_nor_probe(struct spi_mem *spimem)
>  	char *flash_name;
>  	int ret;
>  
> +	if (!spi->controller->running)
> +		return -EPROBE_DEFER;
> +

This is not the correct place to do this. SPI or SPI MEM should be 
checking this, and they should not call the peripheral (SPI NOR, SPI 
NAND, etc.) probe at all unless the controller is ready.

>  	nor = devm_kzalloc(&spi->dev, sizeof(*nor), GFP_KERNEL);
>  	if (!nor)
>  		return -ENOMEM;

-- 
Regards,
Pratyush Yadav
Texas Instruments Inc.



More information about the linux-mtd mailing list