From 9e8bc1c6be751b59e1d782dff3c0cc8703cc18d4 Mon Sep 17 00:00:00 2001 From: Patrice Chotard Date: Tue, 16 Dec 2025 16:31:52 +0100 Subject: spi: stm32-ospi: Increase read throughput in indirect mode Schedule() is called every u8/u16 or u32 read accesses which is overkill. Move schedule() from stm32_ospi_read_fifo() to stm32_ospi_tx_poll() and call schedule() only every 1MB chunk of data. Test performed by reading 64MB on sNOR on stm32mp257f-ev1 board: before after ratio Read : 10.6MB/s 14.2MB/s +34% Reviewed-by: Patrick Delaunay Signed-off-by: Patrice Chotard --- drivers/spi/stm32_ospi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/spi/stm32_ospi.c b/drivers/spi/stm32_ospi.c index 01b8f8e4987..9e143a73559 100644 --- a/drivers/spi/stm32_ospi.c +++ b/drivers/spi/stm32_ospi.c @@ -142,7 +142,6 @@ static void stm32_ospi_read_fifo(void *val, phys_addr_t addr, u8 len) case sizeof(u8): *((u8 *)val) = readb_relaxed(addr); }; - schedule(); } static void stm32_ospi_write_fifo(void *val, phys_addr_t addr, u8 len) @@ -200,6 +199,9 @@ int stm32_ospi_tx_poll(struct udevice *dev, void *buf, u32 len, bool read) fifo(buf, regs_base + OSPI_DR, step); len -= step; buf += step; + + if (!(len % SZ_1M)) + schedule(); } return 0; -- cgit v1.2.3