[REGRESSION] spi: cadence-quadspi: STIG mode results in timeouts for Micron MT25QL01 flash

From: Stefan Kerkmann
Date: Mon Oct 14 2024 - 08:44:07 EST


Hello,

I have run into the same regression when probing a Micron MT25QL01 SPI-NOR flash
on a Intel CycloneV platform (socfpga) as Yoshitaka Ikeda[1]. The regression
manifests in read timeouts. Bisecting the issue tracked it down to commit
"d403fb6e76bf8 spi: cadence-quadspi: use STIG mode for small reads". Reverting
the commit resolves the issue on v6.12-rc3. There are no custom patches applied,
except for the debugging output mentioned in the linked thread.

The good case is as follows:

```
[ 1.063171] **********spi_mem_op dump**************
[ 1.063183] addr: nbytes:0x0 , buswidth 0x0, dtr 0x0, val 0x0
[ 1.068093] cmd: nbytes:0x1 , buswidth 0x1, dtr 0x0, opcode 0x9F
[ 1.073837] data: nbytes:0x6 , buswidth 0x1, dtr 0x0, data dir 0x1
[ 1.079823] ***************************************
[ 1.086068] **********spi_mem_op dump**************
[ 1.090931] addr: nbytes:0x3 , buswidth 0x1, dtr 0x0, val 0x0
[ 1.095815] cmd: nbytes:0x1 , buswidth 0x1, dtr 0x0, opcode 0x5A
[ 1.101543] data: nbytes:0x10 , buswidth 0x1, dtr 0x0, data dir 0x1
[ 1.107547] ***************************************
[ 1.113835] **********spi_mem_op dump**************
[ 1.118695] addr: nbytes:0x3 , buswidth 0x1, dtr 0x0, val 0x10
[ 1.123573] cmd: nbytes:0x1 , buswidth 0x1, dtr 0x0, opcode 0x5A
[ 1.129395] data: nbytes:0x8 , buswidth 0x1, dtr 0x0, data dir 0x1
[ 1.135392] ***************************************
[ 1.141592] **********spi_mem_op dump**************
[ 1.146471] addr: nbytes:0x3 , buswidth 0x1, dtr 0x0, val 0x0
[ 1.151335] cmd: nbytes:0x1 , buswidth 0x1, dtr 0x0, opcode 0x5A
[ 1.157072] data: nbytes:0x88 , buswidth 0x1, dtr 0x0, data dir 0x1
[ 1.163058] ***************************************
[ 1.169341] **********spi_mem_op dump**************
[ 1.174219] addr: nbytes:0x3 , buswidth 0x1, dtr 0x0, val 0x30
[ 1.179082] cmd: nbytes:0x1 , buswidth 0x1, dtr 0x0, opcode 0x5A
[ 1.184904] data: nbytes:0x40 , buswidth 0x1, dtr 0x0, data dir 0x1
[ 1.190890] ***************************************
[ 1.197183] **********spi_mem_op dump**************
[ 1.202045] addr: nbytes:0x3 , buswidth 0x1, dtr 0x0, val 0x80
[ 1.206925] cmd: nbytes:0x1 , buswidth 0x1, dtr 0x0, opcode 0x5A
[ 1.212740] data: nbytes:0x8 , buswidth 0x1, dtr 0x0, data dir 0x1
[ 1.218736] ***************************************
[ 1.224916] **********spi_mem_op dump**************
[ 1.229776] addr: nbytes:0x0 , buswidth 0x0, dtr 0x0, val 0x0
[ 1.234649] cmd: nbytes:0x1 , buswidth 0x1, dtr 0x0, opcode 0x6
[ 1.240376] data: nbytes:0x0 , buswidth 0x0, dtr 0x0, data dir 0x0
[ 1.246283] ***************************************
[ 1.252443] **********spi_mem_op dump**************
[ 1.257314] addr: nbytes:0x0 , buswidth 0x0, dtr 0x0, val 0x0
[ 1.262176] cmd: nbytes:0x1 , buswidth 0x1, dtr 0x0, opcode 0xB7
[ 1.267917] data: nbytes:0x0 , buswidth 0x0, dtr 0x0, data dir 0x0
[ 1.273914] ***************************************
[ 1.280074] **********spi_mem_op dump**************
[ 1.284946] addr: nbytes:0x0 , buswidth 0x0, dtr 0x0, val 0x0
[ 1.289809] cmd: nbytes:0x1 , buswidth 0x1, dtr 0x0, opcode 0x4
[ 1.295544] data: nbytes:0x0 , buswidth 0x0, dtr 0x0, data dir 0x0
[ 1.301444] ***************************************
[ 1.307694] 5 fixed-partitions partitions found on MTD device ff705000.spi.0
[ 1.319593] Creating 5 MTD partitions on "ff705000.spi.0":
[ 1.325080] 0x000000000000-0x000000040000 : "preloader"
[ 1.331825] 0x000000040000-0x0000000c0000 : "bootloader"
[ 1.338645] 0x0000000c0000-0x0000000e0000 : "barebox-environment"
[ 1.346299] 0x0000000e0000-0x000000110000 : "state-storage"
[ 1.353319] 0x000000110000-0x000008000000 : "ubi"
```

With the STIG short read optimization enabled, the read timeouts occur:

```
[ 0.931469] **********spi_mem_op dump**************
[ 0.931482] addr: nbytes:0x0 , buswidth 0x0, dtr 0x0, val 0x0
[ 0.936398] cmd: nbytes:0x1 , buswidth 0x1, dtr 0x0, opcode 0x9F
[ 0.942129] data: nbytes:0x6 , buswidth 0x1, dtr 0x0, data dir 0x1
[ 0.948132] ***************************************
[ 0.954369] **********spi_mem_op dump**************
[ 0.959233] addr: nbytes:0x3 , buswidth 0x1, dtr 0x0, val 0x0
[ 0.964117] cmd: nbytes:0x1 , buswidth 0x1, dtr 0x0, opcode 0x5A
[ 0.969845] data: nbytes:0x10 , buswidth 0x1, dtr 0x0, data dir 0x1
[ 0.975844] ***************************************
[ 1.482104] cadence-qspi ff705000.spi: Flash command execution timed out.
[ 1.493754] **********spi_mem_op dump**************
[ 1.493759] addr: nbytes:0x3 , buswidth 0x1, dtr 0x0, val 0x10
[ 1.498623] cmd: nbytes:0x1 , buswidth 0x1, dtr 0x0, opcode 0x5A
[ 1.504451] data: nbytes:0x8 , buswidth 0x1, dtr 0x0, data dir 0x1
[ 1.510438] ***************************************
[ 1.516611] spi-nor spi0.0: operation failed with -110
[ 2.026639] cadence-qspi ff705000.spi: Flash command execution timed out.
[ 2.033430] **********spi_mem_op dump**************
[ 2.033437] addr: nbytes:0x0 , buswidth 0x0, dtr 0x0, val 0x0
[ 2.038300] cmd: nbytes:0x1 , buswidth 0x1, dtr 0x0, opcode 0x6
[ 2.044041] data: nbytes:0x0 , buswidth 0x0, dtr 0x0, data dir 0x0
[ 2.049942] ***************************************
[ 2.056112] spi-nor spi0.0: operation failed with -110
[ 2.066110] spi-nor spi0.0: probe with driver spi-nor failed with error -110
```

The DT node for the flash is as follows:

```
&qspi {
status = "okay";

flash0: flash@0 {
#address-cells = <1>;
#size-cells = <1>;
/* Micron MT25QL01 */
compatible = "n25q00", "jedec,spi-nor";
reg = <0>; /* chip select */
spi-max-frequency = <100000000>;
m25p,fast-read;
cdns,page-size = <256>;
cdns,block-size = <16>; /* 2^16, 64KB */
cdns,read-delay = <4>; /* delay value in read data capture register */
cdns,tshsl-ns = <50>;
cdns,tsd2d-ns = <50>;
cdns,tchsh-ns = <4>;
cdns,tslch-ns = <4>;
};
};
```

Regards,
Stefan Kerkmann

[1]:
https://lore.kernel.org/lkml/OSZPR01MB70048CE259A3D63C4179199A8B659@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/#t

#regzbot introduced: d403fb6e76bf854ef0f7d84e797e51b9494788e0

--
Pengutronix e.K. | Stefan Kerkmann |
Steuerwalder Str. 21 | https://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-128 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |