On Sun, Jul 05, 2009 at 10:38:39AM +0800, Ming Lei wrote: > 于 Sat, 4 Jul 2009 19:07:00 +0100 > Russell King - ARM Linux <linux@xxxxxxxxxxxxxxxx> 写道: > > > On Sat, Jul 04, 2009 at 11:41:46PM +0800, Ming Lei wrote: > > > dma_map_*() can invalidate cache lines, so dma_unmap_*() may do > > > nothing. But if someone accesses the dma buffer during dma > > > transfer, you may get the inconsistent result. > > > > You missed an important statement: accessing the dma buffer during a > > dma transfer is not permitted without an intervening call to the > > dma_sync_* functions. > > > > DMA buffers have the idea of "ownership" - they initially start off > > being owned by the CPU. Upon dma_map_*(), ownership transfers to the > > DMA agent, and remains there until either a dma_unmap_*() or > > dma_sync_single_for_cpu(). In the case of dma_sync_single_for_cpu(), > > it can only be given back to the DMA agent using > > dma_sync_single_for_device(). > > > > IMHO, only if dma transfer is over dma_sync_*_cpu() can be called to > access the dma buffer safely. If you read the part below of my initial reply, I stated that. Ownership is what it's all about. If you take ownership away from the DMA agent, it must not access the buffer. > Currently, dma_sync_*_cpu() does > nothing like dma_unmap_* in ARM if dma bounce isdisabled. Which is correct given the rules. > > The important point from the above is that _only_ the current owner > > may access the buffer. So, if you've mapped a buffer, accessing the > > buffer subsequently without a call to dma_sync_single_for_cpu() is > > illegal. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html