dma_alloc_coherent / dma_map_single question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I have the following situation:
1. I'm using dma_alloc_coherent to allocate memory for DeviceA
2. I use DeviceA to fill the memory buffer.

Everything is fine so far but at this point I would like to DMA the
memory to DeviceB and I'm not sure the proper way of doing it.

Is it allowed/ok/proper to call dma_map_single for DeviceB using the
address returned from dma_alloc_coherent called on DeviceA?  This
seems to work fine in x86_64 but it feels like I'm breaking the rules
because:
 1. dma_map_single is supposed to be called with kmalloc addresses.
 2. Since the address is from both dma_alloc_coherent and
dma_map_single, I don't know if the dma_sync_* functions are necessary
or not.

I'm worried that I'm just getting lucky having this work and a future
kernel update will break me since I'm not really following the rules.
My code may eventually have to run on ARM too, and I'm not sure it
would work.

I have also considered:
1. Call dma_alloc_coherent for DeviceB and memcpy the data from
DeviceA into it.  This would work but I don't want the performance hit
of double buffering.
2. Get rid of the the dma_alloc_coherent for deviceA use
kmalloc/dma_map_single instead.   This would work and maybe is the
right thing to do.  This requires the extra hassle of dma_sync_*
functions which I was trying to avoid.

Is there a better way of doing this that I'm missing?

Thanks,
Brian V.



[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux PCI]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux