All of lore.kernel.org
 help / color / mirror / Atom feed
* (struct spi_transfer)->rx_buf == (struct spi_transfer)->tx_buf?
@ 2011-08-26 21:35 Arvid Brodin
  0 siblings, 0 replies; only message in thread
From: Arvid Brodin @ 2011-08-26 21:35 UTC (permalink / raw)
  To: kernelnewbies

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-08-26 21:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-26 21:35 (struct spi_transfer)->rx_buf == (struct spi_transfer)->tx_buf? Arvid Brodin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.