summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPratyush Yadav <pratyush@kernel.org>2025-10-21 14:23:26 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-10-29 14:00:00 +0100
commit4612070e4cb12a9cba83459124f3732fd0df3d72 (patch)
treec85ffd0a4dde75f25eccf14ee660528eb0f509e3
parent5879837bfe46c35f6ef40ceadebf12d094177d27 (diff)
downloadlinux-4612070e4cb12a9cba83459124f3732fd0df3d72.tar.gz
linux-4612070e4cb12a9cba83459124f3732fd0df3d72.tar.bz2
linux-4612070e4cb12a9cba83459124f3732fd0df3d72.zip
spi: cadence-quadspi: Flush posted register writes before INDAC access
[ Upstream commit 29e0b471ccbd674d20d4bbddea1a51e7105212c5 ] cqspi_indirect_read_execute() and cqspi_indirect_write_execute() first set the enable bit on APB region and then start reading/writing to the AHB region. On TI K3 SoCs these regions lie on different endpoints. This means that the order of the two operations is not guaranteed, and they might be reordered at the interconnect level. It is possible for the AHB write to be executed before the APB write to enable the indirect controller, causing the transaction to be invalid and the write erroring out. Read back the APB region write before accessing the AHB region to make sure the write got flushed and the race condition is eliminated. Fixes: 140623410536 ("mtd: spi-nor: Add driver for Cadence Quad SPI Flash Controller") CC: stable@vger.kernel.org Reviewed-by: Pratyush Yadav <pratyush@kernel.org> Signed-off-by: Pratyush Yadav <pratyush@kernel.org> Signed-off-by: Santhosh Kumar K <s-k6@ti.com> Message-ID: <20250905185958.3575037-2-s-k6@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org> [ applied changes to drivers/mtd/spi-nor/cadence-quadspi.c instead of drivers/spi/spi-cadence-quadspi.c ] Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/mtd/spi-nor/cadence-quadspi.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/mtd/spi-nor/cadence-quadspi.c b/drivers/mtd/spi-nor/cadence-quadspi.c
index 7bdc558d8560..2d6f008adb07 100644
--- a/drivers/mtd/spi-nor/cadence-quadspi.c
+++ b/drivers/mtd/spi-nor/cadence-quadspi.c
@@ -523,6 +523,7 @@ static int cqspi_indirect_read_execute(struct spi_nor *nor, u8 *rxbuf,
reinit_completion(&cqspi->transfer_complete);
writel(CQSPI_REG_INDIRECTRD_START_MASK,
reg_base + CQSPI_REG_INDIRECTRD);
+ readl(reg_base + CQSPI_REG_INDIRECTRD); /* Flush posted write. */
while (remaining > 0) {
if (!wait_for_completion_timeout(&cqspi->transfer_complete,
@@ -633,6 +634,8 @@ static int cqspi_indirect_write_execute(struct spi_nor *nor, loff_t to_addr,
reinit_completion(&cqspi->transfer_complete);
writel(CQSPI_REG_INDIRECTWR_START_MASK,
reg_base + CQSPI_REG_INDIRECTWR);
+ readl(reg_base + CQSPI_REG_INDIRECTWR); /* Flush posted write. */
+
/*
* As per 66AK2G02 TRM SPRUHY8F section 11.15.5.3 Indirect Access
* Controller programming sequence, couple of cycles of