I was tracing calls to dma_map_single() and noticed that spi drivers call this
function repeatedly on the same buffer address (with no dma_unmap_single()
between). Is this really OK?

Looking into it I saw that the spi drivers' tx_buf and rx_buf were equal (same
address), and these are "dma mapped" simultaneously in many spi drivers (tx_buf
as DMA_TO_DEVICE; rx_buf as DMA_FROM_DEVICE).

If this buffer (tx_buf === rx_buf) is both read from and written to using DMA,
then shouldn't they use DMA_BIDIRECTIONAL? Also, DMA_TO_DEVICE mappings should
be done before starting the transfer to the device, while DMA_FROM_DEVICE
mappings should be done after the device has finished its transfer, if I
understand dma_map_single() correctly (because this is just a cache
synchronization thing, right?)

This whole thing just seemed strange to me and I'm hoping someone can explain 
what's going on!


BTW, the declaration of struct spi_transfer
(http://lxr.linux.no/linux+*/include/linux/spi/spi.h#L430) has this comment:
/* it's ok if tx_buf == rx_buf (right?) */

Since spi is always full duplex, I'm guessing that the idea with using only one
buffer is that incoming bytes overwrites queued bytes?

-- 
Arvid Brodin
Enea Services Stockholm AB

_______________________________________________
Kernelnewbies mailing list
[email protected]
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Reply via email to