spi-nor: fix spi_nor_probe
Subsystems (2)
PATCH 1/1 spi-nor: fix spi_nor_probe
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
--- drivers/mtd/spi-nor/core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mtd/spi-nor/core.c +3 -0
@@ -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 ; + nor =devm_kzalloc (&spi->dev,sizeof (*nor),GFP_KERNEL );if (!nor)return -ENOMEM ;
Signature · 6 lines
2.32.0 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
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.
Quoted 33 lines · Pascal Fabreges
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_queueprocedure which set the running mode to true after thespi_init_queue(Initialize and start queue).kernel:
spi_masterspi0: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: Callspi_nor_scan
kernel:spi_masterspi0: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 -108Signed-off-by Pascal Fabreges <[email protected]>--- drivers/mtd/spi-nor/core.c | 3 +++ 1 file changed, 3 insertions(+)drivers/mtd/spi-nor/core.c +0
-0
drivers/mtd/spi-nor/core.c static int spi_nor_probe(struct spi_mem *spimem) · line 3623
Quoted 6 lines
drivers/mtd/spi-nor/core.c +3
-0@@ -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.
Quoted 3 lines
drivers/mtd/spi-nor/core.c +0
-0nor =devm_kzalloc (&spi->dev,sizeof (*nor),GFP_KERNEL );if (!nor)return -ENOMEM ;
Signature · 7 lines
Regards, Pratyush Yadav Texas Instruments Inc. ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/