Skip to content

Commit 5bfbbf0

Browse files
Mateusz Litwinbroonie
authored andcommitted
spi: cadence-quadspi: Improve CQSPI_SLOW_SRAM quirk if flash is slow
CQSPI_SLOW_SRAM quirk on the Stratix10 platform causes fewer interrupts, but also causes timeouts if a small block is used or if flash devices are slower than or equal in speed to SRAM's read operations. Adding the CQSPI_REG_IRQ_IND_COMP interrupt would resolve the problem for small reads, and removing the disabling of interrupts would resolve the issue with lost interrupts. This marginally increases IRQ count. Tests show that this will cause only a few percent more interrupts. Test: $ dd if=/dev/mtd0 of=/dev/null bs=1M count=64 Results from the Stratix10 platform with mt25qu02g flash. FIFO size in all tests: 128 Serviced interrupt call counts: Without CQSPI_SLOW_SRAM quirk: 16 668 850 With CQSPI_SLOW_SRAM quirk: 204 176 With CQSPI_SLOW_SRAM and this commit: 224 528 Signed-off-by: Mateusz Litwin <mateusz.litwin@nokia.com> Link: https://patch.msgid.link/20251218-cqspi_indirect_read_improve-v2-2-396079972f2a@nokia.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent d67396c commit 5bfbbf0

1 file changed

Lines changed: 5 additions & 14 deletions

File tree

drivers/spi/spi-cadence-quadspi.c

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,9 @@ struct cqspi_driver_platdata {
300300
CQSPI_REG_IRQ_IND_SRAM_FULL | \
301301
CQSPI_REG_IRQ_IND_COMP)
302302

303+
#define CQSPI_IRQ_MASK_RD_SLOW_SRAM (CQSPI_REG_IRQ_WATERMARK | \
304+
CQSPI_REG_IRQ_IND_COMP)
305+
303306
#define CQSPI_IRQ_MASK_WR (CQSPI_REG_IRQ_IND_COMP | \
304307
CQSPI_REG_IRQ_WATERMARK | \
305308
CQSPI_REG_IRQ_UNDERFLOW)
@@ -381,7 +384,7 @@ static irqreturn_t cqspi_irq_handler(int this_irq, void *dev)
381384
else if (!cqspi->slow_sram)
382385
irq_status &= CQSPI_IRQ_MASK_RD | CQSPI_IRQ_MASK_WR;
383386
else
384-
irq_status &= CQSPI_REG_IRQ_WATERMARK | CQSPI_IRQ_MASK_WR;
387+
irq_status &= CQSPI_IRQ_MASK_RD_SLOW_SRAM | CQSPI_IRQ_MASK_WR;
385388

386389
if (irq_status)
387390
complete(&cqspi->transfer_complete);
@@ -757,7 +760,7 @@ static int cqspi_indirect_read_execute(struct cqspi_flash_pdata *f_pdata,
757760
*/
758761

759762
if (use_irq && cqspi->slow_sram)
760-
writel(CQSPI_REG_IRQ_WATERMARK, reg_base + CQSPI_REG_IRQMASK);
763+
writel(CQSPI_IRQ_MASK_RD_SLOW_SRAM, reg_base + CQSPI_REG_IRQMASK);
761764
else if (use_irq)
762765
writel(CQSPI_IRQ_MASK_RD, reg_base + CQSPI_REG_IRQMASK);
763766
else
@@ -775,13 +778,6 @@ static int cqspi_indirect_read_execute(struct cqspi_flash_pdata *f_pdata,
775778
msecs_to_jiffies(CQSPI_READ_TIMEOUT_MS)))
776779
ret = -ETIMEDOUT;
777780

778-
/*
779-
* Disable all read interrupts until
780-
* we are out of "bytes to read"
781-
*/
782-
if (cqspi->slow_sram)
783-
writel(0x0, reg_base + CQSPI_REG_IRQMASK);
784-
785781
/*
786782
* Prevent lost interrupt and race condition by reinitializing early.
787783
* A spurious wakeup and another wait cycle can occur here,
@@ -820,11 +816,6 @@ static int cqspi_indirect_read_execute(struct cqspi_flash_pdata *f_pdata,
820816
remaining -= bytes_to_read;
821817
bytes_to_read = cqspi_get_rd_sram_level(cqspi);
822818
}
823-
824-
if (use_irq && remaining > 0) {
825-
if (cqspi->slow_sram)
826-
writel(CQSPI_REG_IRQ_WATERMARK, reg_base + CQSPI_REG_IRQMASK);
827-
}
828819
}
829820

830821
/* Check indirect done status */

0 commit comments

Comments
 (0)