Skip to content

Commit 4497954

Browse files
Pratyush Yadavgregkh
authored andcommitted
spi: cadence-quadspi: Flush posted register writes before INDAC access
commit 29e0b47 upstream. 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: 1406234 ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1f17a94 commit 4497954

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/spi/spi-cadence-quadspi.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,7 @@ static int cqspi_indirect_read_execute(struct cqspi_flash_pdata *f_pdata,
754754
reinit_completion(&cqspi->transfer_complete);
755755
writel(CQSPI_REG_INDIRECTRD_START_MASK,
756756
reg_base + CQSPI_REG_INDIRECTRD);
757+
readl(reg_base + CQSPI_REG_INDIRECTRD); /* Flush posted write. */
757758

758759
while (remaining > 0) {
759760
if (use_irq &&
@@ -1058,6 +1059,8 @@ static int cqspi_indirect_write_execute(struct cqspi_flash_pdata *f_pdata,
10581059
reinit_completion(&cqspi->transfer_complete);
10591060
writel(CQSPI_REG_INDIRECTWR_START_MASK,
10601061
reg_base + CQSPI_REG_INDIRECTWR);
1062+
readl(reg_base + CQSPI_REG_INDIRECTWR); /* Flush posted write. */
1063+
10611064
/*
10621065
* As per 66AK2G02 TRM SPRUHY8F section 11.15.5.3 Indirect Access
10631066
* Controller programming sequence, couple of cycles of

0 commit comments

Comments
 (0)