Skip to main content
Visitor II
November 19, 2021
Solved

About SPI and dma from Linux user space

  • November 19, 2021
  • 2 replies
  • 2759 views

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.
    Best answer by Eldam

    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!

    2 replies

    EldamAuthor
    Visitor II
    November 24, 2021

    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)

    EldamAuthorAnswer
    Visitor II
    December 2, 2021

    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!

    Graduate
    March 18, 2025

    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