Skip to main content
Eldam
Senior
Nov 19, 2021 11:17 AM UTC
Solved

About SPI and dma from Linux user space

Hello ST People !

I'm looking for information / possiblity to use SPI (via spidev & ioctl) in Linux user space with DMA.

We have to transfert lots of data (4000bytes at one time, very very often) to a fpga, very quickly and we are facing latency issue during transfert.

With the help of a scope, we see dead times between spi transactions during this big packet write.

So we are thinking using spi dma to unload cpu, but we need some infos/direction to look for.

Maybe someone help or points me to right direction?

Bon weekend!

This topic has been closed for replies.
Eldam
EldamBest answer
Senior
Dec 2, 2021 8:52 AM UTC

Well, after a little struggling

With the help of:

https://wiki.st.com/stm32mpu/wiki/SPI_overview

We added kernel debug info and we happy to see:

"dma enabled" in the log file.

so with some modification of calling function (ioctl) we've been able to have a 12Mhz SPI working @ 12Mbits /s

Next phase, modify the clk!

Seeya!

3 replies

Eldam
EldamAuthor
Senior
Nov 24, 2021 1:47 PM UTC

After looking at:

https://github.com/torvalds/linux/blob/master/drivers/spi/spi-stm32.c

If I "lsmod" on my board, I see that "spi_stm32" is in the lsmod list.

So If I understand correctly,

If I made call to ioctl (with /dev/spidev0.0 as parameter)

the ioctl function will use the "spi_stm32" driver mod? Thats it?

How do we know if we already or not using dma?

(we have dts enabled dma for spi tree)

Eldam
EldamAuthorBest answer
Senior
Dec 2, 2021 8:52 AM UTC

Well, after a little struggling

With the help of:

https://wiki.st.com/stm32mpu/wiki/SPI_overview

We added kernel debug info and we happy to see:

"dma enabled" in the log file.

so with some modification of calling function (ioctl) we've been able to have a 12Mhz SPI working @ 12Mbits /s

Next phase, modify the clk!

Seeya!

Associate II
Mar 18, 2025 8:57 AM UTC

Hello @Eldam,

Can you please give more details how did you enable the DMA from the driver and enable the debuggug log.
What did you need to change in the kernel driver to make sure that spi is using the DMA?

Thanks in advance!

Kind regards,

Khaled