]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
spi: cadence-quadspi: Flush posted register writes before DAC access
authorPratyush Yadav <pratyush@kernel.org>
Fri, 5 Sep 2025 18:59:56 +0000 (00:29 +0530)
committerMark Brown <broonie@kernel.org>
Tue, 9 Sep 2025 13:17:33 +0000 (14:17 +0100)
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: 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-3-s-k6@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-cadence-quadspi.c

index eaf9a0f522d50cf245b08e74ae7ef6b5aa2dad6f..447a32a08a934ba28e51cd662841da9a2480db81 100644 (file)
@@ -719,6 +719,7 @@ static int cqspi_read_setup(struct cqspi_flash_pdata *f_pdata,
        reg &= ~CQSPI_REG_SIZE_ADDRESS_MASK;
        reg |= (op->addr.nbytes - 1);
        writel(reg, reg_base + CQSPI_REG_SIZE);
+       readl(reg_base + CQSPI_REG_SIZE); /* Flush posted write. */
        return 0;
 }
 
@@ -1063,6 +1064,7 @@ static int cqspi_write_setup(struct cqspi_flash_pdata *f_pdata,
        reg &= ~CQSPI_REG_SIZE_ADDRESS_MASK;
        reg |= (op->addr.nbytes - 1);
        writel(reg, reg_base + CQSPI_REG_SIZE);
+       readl(reg_base + CQSPI_REG_SIZE); /* Flush posted write. */
        return 0;
 }