Skip to content

Commit a3a7b74

Browse files
Pratyush Yadavgregkh
authored andcommitted
spi: cadence-quadspi: Flush posted register writes before DAC access
commit 1ad5576 upstream. cqspi_read_setup() and cqspi_write_setup() program the address width as the last step in the setup. This is likely to be immediately followed by a DAC region read/write. On TI K3 SoCs the DAC region is on a different endpoint from the register region. This means that the order of the two operations is not guaranteed, and they might be reordered at the interconnect level. It is possible that the DAC read/write goes through before the address width update goes through. In this situation if the previous command used a different address width the OSPI command is sent with the wrong number of address bytes, resulting in an invalid command and undefined behavior. Read back the size register to make sure the write gets flushed before accessing the DAC region. 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-3-s-k6@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4497954 commit a3a7b74

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/spi/spi-cadence-quadspi.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,7 @@ static int cqspi_read_setup(struct cqspi_flash_pdata *f_pdata,
712712
reg &= ~CQSPI_REG_SIZE_ADDRESS_MASK;
713713
reg |= (op->addr.nbytes - 1);
714714
writel(reg, reg_base + CQSPI_REG_SIZE);
715+
readl(reg_base + CQSPI_REG_SIZE); /* Flush posted write. */
715716
return 0;
716717
}
717718

@@ -1034,6 +1035,7 @@ static int cqspi_write_setup(struct cqspi_flash_pdata *f_pdata,
10341035
reg &= ~CQSPI_REG_SIZE_ADDRESS_MASK;
10351036
reg |= (op->addr.nbytes - 1);
10361037
writel(reg, reg_base + CQSPI_REG_SIZE);
1038+
readl(reg_base + CQSPI_REG_SIZE); /* Flush posted write. */
10371039
return 0;
10381040
}
10391041

0 commit comments

Comments
 (0)