SPI DMA maximum message size

Moderators: mdrjr, odroid

SPI DMA maximum message size

Unread postby ban » Tue Jun 12, 2018 5:26 am

Hello.

I want to transfer a data with a size of >256KB in a single SPI message with DMA.
I'm using ODROID-XU4 with Ubuntu 18.04 LTS (GNU/Linux 4.14.43-138 armv7l).
I'm testing this with slightly modified spidev_test.c.
The DMA coherent_pool is 1MB by default:
Code: Select all
[    0.218410] DMA: preallocated 1024 KiB pool for atomic coherent allocations

I've set the spidev bufsiz to 512KB:
Code: Select all
rmmod spidev
modprobe spidev bufsiz=524288

When I try to send the SPI message with the size of 256KB then everything works fine.
But when I try to send the message with the size of >256KB then I'm getting an error:
Code: Select all
can't send spi message: Input/output error


Is it a hardware restriction of Exynos 5422 DMA or is there some other parameters that I need to change?
ban
 
Posts: 10
Joined: Thu Feb 08, 2018 1:28 am
languages_spoken: english
ODROIDs: XU3 Lite, XU4

Re: SPI DMA maximum message size

Unread postby odroid » Tue Jun 19, 2018 7:19 pm

DMA size in the Rx buffer is limited at 64KByte.
If you don't use the Rx input, you can send 512KB via Tx buffer.
We are checking if we can break the Rx limitation or not.

BTW, which device do you connect on the SPI bus?
User avatar
odroid
Site Admin
 
Posts: 28698
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: SPI DMA maximum message size

Unread postby ban » Tue Jun 19, 2018 8:23 pm

I want to periodically transfer 2MB data chunk from FPGA to ODROID with SPI. It would be easier if It was possible to do it in a single message as I could just start the transfer in FPGA on CS from the beginning of the buffer to the end without dividing the message and implementing additional transfer control.
ban
 
Posts: 10
Joined: Thu Feb 08, 2018 1:28 am
languages_spoken: english
ODROIDs: XU3 Lite, XU4

Re: SPI DMA maximum message size

Unread postby odroid » Wed Jun 20, 2018 2:46 pm

The SPI driver has an over-flow issue in calculating time-out value when the packet size is bigger than ~200KB.
https://github.com/hardkernel/linux/blo ... 4xx.c#L475

Therefore, you need to modify the SPI kernel driver for your specific case.
I think 2MB at 20Mhz takes roughly 5~6 seconds.
So you have to modify this line to ms=6000.
https://github.com/hardkernel/linux/blo ... 4xx.c#L476

You need to set spidev bufsiz to "2097152" when you load the SPI driver.

The rx buffer size in your application software must be always zero.

Note that coherent_pool size parameter doesn't affect to the SPI driver.
User avatar
odroid
Site Admin
 
Posts: 28698
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: SPI DMA maximum message size

Unread postby ban » Sat Jun 23, 2018 8:38 pm

It shouldn't be related to the timeout issue, because it works fine for the same 256KB transfer with much slower speed:
Code: Select all
Data sent in bytes: 262144
max speed: 25000 Hz (25 KHz)
Time spent in nanoseconds: 10738467543

Data sent in bytes: 262144
max speed: 25000000 Hz (25000 KHz)
Time spent in nanoseconds: 112033958

But if I try to send data with the size more than 256KB it'll give me an error.
Code: Select all
can't send spi message: I/O error

I've tried to increase the timeout value by 1s:
Code: Select all
ms += 10; /* some tolerance */
to
Code: Select all
ms += 1000; /* some tolerance */

It should be more than enough timeout to send 320KB (test buf size >256KB) with 25MHz speed as it should take ~110ms to send the data.
But it didn't change anything and it still give me the same error.
Also, what about the 64KB DMA Rx buffer size limit? It seems to work fine with the 256KB transfers.
ban
 
Posts: 10
Joined: Thu Feb 08, 2018 1:28 am
languages_spoken: english
ODROIDs: XU3 Lite, XU4

Re: SPI DMA maximum message size

Unread postby odroid » Sun Jun 24, 2018 5:03 pm

We tested 512KB on Tx and it worked only if the Rx size is zero in the test code.
When we tried to send 2MB, we had to modify the Kernel source to make it work.

Don't forget to set the Rx size to zero in your test code.
User avatar
odroid
Site Admin
 
Posts: 28698
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID


Return to Hardware and peripherals

Who is online

Users browsing this forum: No registered users and 3 guests