Jump to content

SPI with DMA TX only doesn't work


robert@axium.co.nz

Recommended Posts

In my spi protocol driver I send large buffers of data to be transferred.  I am not interested in the data received so I leave the rx_buf as NULL. 

 

In the controller driver they have code to implement this use case:

https://github.com/allwinner-zh/linux-3.4-sunxi/blob/6964d467510849e3e262518cb87bff7ef92e01f5/drivers/spi/spi-sunxi.c#L1003

However the transfer never completes and the kernel logs a time out for each transfer after 120 seconds.

 

I have tried modifying the driver with various options like disabling the SPI_GC_TP_EN, which pauses transmit when the receive fifo is full, but it has no effect.  Finally after hours of futile tinkering I decided to change my protocol driver to use what I figured was the better tested code path for both transmit and receive.  After adding a dummy receive buffer to my spi transfers, the transmits finally succeed.

 

I don't mind having to do this, but it was very misleading with the code seemingly supporting the options I was using and silently failing.  The controller driver should instead log an error message that half-duplex transmit is not supported.  This would have saved me a lot of time.

 

 

 

Additionally there is the issue that either the bits_per_word or speed_hz fields of the spi_transfer struct must be set in the  in order for the protocol driver settings to actually be setup.  In the driver, the function that does this is sunxi_spi_xfer_setup, but it's only called if the transfer has those set.  That required functionality should also be performed in the sunxi_spi_setup function which occurs when the protocol driver initialises.

 

 

I'll attach my revised version of the driver soon, in case it might be of benefit to someone.

I realise that this is technically a legacy driver, but seeing as the mainline kernel isn't quite ready on a few things, I believe this driver is still most likely to be used for a while yet.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines