Jetson DMA for SPI data

Hi,

We’re trying to receive data over the SPI pins at a very fast data rate. Just reading the data through a system read() call isn’t fast enough (possibly due to OS level task switching). What we’d like to do as a workaround is setup DMA to move data from the SPI rx buffer to a larger memory location. Then use that memory location for our main process to read the SPI data from.

Is this level of DMA and SPI control available on the Jetson through the OS? If so, any level of information for doing that would be greatly appreciated. Thanks

Hi kaco,

Are you using the devkit or custom board for Orin NX?
What’s the Jetpack version in use?

Which SPI interface would you like to use?

What do you mean about “very fast data rate”? What’s the required data rate frequency in your use case?

The current SPI driver should work with PIO mode if packet size less than 256 Bytes and will operate with DMA mode if packet size more than 256 Bytes.

Using SPI slave, dmesg prompts spi-tegra124-slave3210000.spi: Reset control is not found. and Exception occurs when using SPI to transmit data exceeding 256 bytes

Hi @18709295167w,

Are you working with @kaco?

What’s the Jetpack version in use?

Please share the detailed steps how do you reproduce the issue.
And also, the full demsg and device tree for further check.

jetpack is 5.1.5.
i just changed dts content from compatible= “nvidia, tegra186-spi” to compatible=“nvidia, tegra186-spi-slave”, and reboot in dmesg i found that
[ 2.579726] spi-tegra124-slave 3210000.spi: Adding to iommu group 0
[ 2.584494] spi-tegra124-slave 3210000.spi: Reset control is not found

then i use spi slave to transfer 8192 bytes data,
i first transfer date succeed. while i try transfer data second time it occurs in dmesg
i have used devmem2 to check tegra-gpsdma with “sudo devmem2 0x02600000” and value is 0x400000
[12243.268897] tegra-gpcdma 2600000.dma: slave id already in use
[12243.269119] spi-tegra124-slave 3210000.spi: Not able to get desc for Tx
[12243.269334] spi-tegra124-slave 3210000.spi: Starting tx dma failed, err -5
[12243.269513] spi-tegra124-slave 3210000.spi: spi can not start transfer, err -5
[12243.269725] spi_master spi0: failed to transfer one message from queue
is tegra-gpcdma 2600000.dma wrong?
then i used devmem2 to check tegra-gpsdma with “sudo devmem2 0x02600000” and value is 0x400004

Is it because the original reset control configuration does not match the SPI slave?
and i just changed the compatible in dts file, then dtc this file to dtb.

Hi @KevinFFF, thanks for getting back to me. I’m not working with @18709295167w. @18709295167w, it might be helpful to make a separate thread for your issue so we don’t conflate issues. I think it would make it easier for people in the future to parse the thread too.

What do you mean about “very fast data rate”? What’s the required data rate frequency in your use case?

We’re trying to use SPI to transfer data from a microcontroller to the Jetson at 6 bytes every 2 us which equates to ~24Mb/s. We have the Jetson set up as the master, but we’ve found that there’s a delay of 30 us between every system level read() call coming from the Jetson side.

The current SPI driver should work with PIO mode if packet size less than 256 Bytes and will operate with DMA mode if packet size more than 256 Bytes.

Are you saying that the the SPI driver would already handle using DMA mode to buffer data for us if we send more than 256 bytes per read() call? If so, and in case that’s not possible for our system, is there a way to make the SPI driver use DMA to buffer data when each read() call should expect only 6 bytes per call?

Also, this is all with the Jetson operating as the master. We haven’t been able to get the Jetson SPI to operate as the slave. If getting it to work as the slave would allow the Jetson to use DMA as the firehose of data it receives goes beyond 256 bytes, that would be another option. Is that possible, and if so, do you have any pointers on how to get that working?

Finally, we are trying to do this on both an Orin and an Xavier. I made a similar post on the Xavier forums but it was closed.

Please refer to SPI TX Time Variability - #9 by francisco.silverio to check if it could help for your case.

Yes, you can find that there’re dma related properties specified in spi@3210000 node.

It seems you have to customize the SPI driver for this use case.

Do you mean that you want to use SPI as slave instead?
If so, you can simply add -slave in the compatible string of your device tree node.

@KevinFFF Thanks for your help. That’s helpful information for us to try some new things out. I’ll get back to you if we’re still running into issues.