[PATCH] spi-nor: fix spi_nor_probe

Pascal Fabreges pascal.fabreges at nokia.com
Mon Apr 25 06:58:05 PDT 2022


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;
+
 	nor = devm_kzalloc(&spi->dev, sizeof(*nor), GFP_KERNEL);
 	if (!nor)
 		return -ENOMEM;
-- 
2.32.0




More information about the linux-mtd mailing list