Skip to contentSkip to conversation

mtd: spi-nor: cadence-quadspi: Fix direct mode write timeouts

PATCH Applied Vignesh R 3 participants 3 messages Jun 30, 2018 – Jul 6, 2018

Subsystems (2)
lore
Share & tools
lore

Vignesh R

author maintainer
#0 lore raw

PATCH 1/1 mtd: spi-nor: cadence-quadspi: Fix direct mode write timeouts

Sometimes when writing large size files to flash in direct/memory mapped mode, it is seen that flash write enable command times out with error:

[  503.146293] cadence-qspi 47040000.ospi: Flash command execution timed out.

This is because, we need to make sure previous direct write operation is complete by polling for IDLE bit in CONFIG_REG before starting the next operation.

Fix this by polling for IDLE bit after memory mapped write.

Fixes a27f2eaf2b27 ("mtd: spi-nor: cadence-quadspi: Add support for direct access mode")
Cc stable at vger.kernel.org
---
 drivers/mtd/spi-nor/cadence-quadspi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mtd/spi-nor/cadence-quadspi.c +4 -2
index c3f7aaa5d18f..d7e10b36a0b9 100644
@@ -926,10 +926,12 @@ static ssize_t cqspi_write(struct spi_nor *nor, loff_t to,
 	if (ret)
 		return ret;
 
-	if (f_pdata->use_direct_mode)
+	if (f_pdata->use_direct_mode) {
 		memcpy_toio(cqspi->ahb_base + to, buf, len);
-	else
+		ret = cqspi_wait_idle(cqspi);
+	} else {
 		ret = cqspi_indirect_write_execute(nor, to, buf, len);
+	}
 	if (ret)
 		return ret;
 
Signature · 1 line
2.18.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Vignesh R

Sometimes when writing large size files to flash in direct/memory mapped mode, it is seen that flash write enable command times out with error:

[  503.146293] cadence-qspi 47040000.ospi: Flash command execution timed out.

This is because, we need to make sure previous direct write operation is complete by polling for IDLE bit in CONFIG_REG before starting the next operation.

Quoted 5 lines

Fix this by polling for IDLE bit after memory mapped write.

Fixes a27f2eaf2b27 ("mtd: spi-nor: cadence-quadspi: Add support for direct access mode")
Cc stable at vger.kernel.org
Quoted 24 lines
---
 drivers/mtd/spi-nor/cadence-quadspi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mtd/spi-nor/cadence-quadspi.c +4 -2
index c3f7aaa5d18f..d7e10b36a0b9 100644
@@ -926,10 +926,12 @@ static ssize_t cqspi_write(struct spi_nor *nor, loff_t to,
 	if (ret)
 		return ret;
 
-	if (f_pdata->use_direct_mode)
+	if (f_pdata->use_direct_mode) {
 		memcpy_toio(cqspi->ahb_base + to, buf, len);
-	else
+		ret = cqspi_wait_idle(cqspi);
+	} else {
 		ret = cqspi_indirect_write_execute(nor, to, buf, len);
+	}
 	if (ret)
 		return ret;
 
Signature · 2 lines
Best regards,
Marek Vasut
#2 lore raw
In reply to Vignesh R
Quoted 8 lines · On Sat, 30 Jun 2018 16:24:21 +0530 Vignesh R <[email protected]> wrote:

Sometimes when writing large size files to flash in direct/memory mapped mode, it is seen that flash write enable command times out with error:

[  503.146293] cadence-qspi 47040000.ospi: Flash command execution timed out.

This is because, we need to make sure previous direct write operation is complete by polling for IDLE bit in CONFIG_REG before starting the next operation.

Quoted 5 lines

Fix this by polling for IDLE bit after memory mapped write.

Fixes a27f2eaf2b27 ("mtd: spi-nor: cadence-quadspi: Add support for direct access mode")
Cc stable at vger.kernel.org

Applied.

Thanks,

Boris

Quoted 23 lines
---
 drivers/mtd/spi-nor/cadence-quadspi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mtd/spi-nor/cadence-quadspi.c +4 -2
index c3f7aaa5d18f..d7e10b36a0b9 100644
@@ -926,10 +926,12 @@ static ssize_t cqspi_write(struct spi_nor *nor, loff_t to,
 	if (ret)
 		return ret;
 
-	if (f_pdata->use_direct_mode)
+	if (f_pdata->use_direct_mode) {
 		memcpy_toio(cqspi->ahb_base + to, buf, len);
-	else
+		ret = cqspi_wait_idle(cqspi);
+	} else {
 		ret = cqspi_indirect_write_execute(nor, to, buf, len);
+	}
 	if (ret)
 		return ret;