From: arvid.brodin@enea.com (Arvid Brodin)
To: kernelnewbies@lists.kernelnewbies.org
Subject: (struct spi_transfer)->rx_buf == (struct spi_transfer)->tx_buf?
Date: Fri, 26 Aug 2011 23:35:31 +0200 [thread overview]
Message-ID: <4E5811A3.9040403@enea.com> (raw)
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
reply other threads:[~2011-08-26 21:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E5811A3.9040403@enea.com \
--to=arvid.brodin@enea.com \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.