public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* copy_to_user speed from dma_alloc_coherent vs. kmalloc buffer
@ 2011-04-20 15:12 Orjan Friberg
  2011-04-20 17:09 ` Orjan Friberg
  0 siblings, 1 reply; 2+ messages in thread
From: Orjan Friberg @ 2011-04-20 15:12 UTC (permalink / raw)
  To: linux-omap@vger.kernel.org

Hi,

I have a driver where I do memory to memory DMA between GPMC and SDRAM. 
  Adding a read function, I found that copy_to_user from a 
dma_alloc_coherent buffer is significantly slower than from a kmalloc'd one.

Looking at arch/arm/include/asm/pgtable.h I suspect this difference in 
speed is due to the fact that the dma_alloc_coherent buffer is unbuffered.

What are my options (besides using mmap)?

* Reserve a portion of memory at boot time to be used as the DMA 
destination buffer, use ioremap_cached + manual cache flush as needed?
* Turn on buffering for the DMA destination buffer for the duration of 
the copy_to_user call, then turn it off again (and flush it from the cache)?
* Something else entirely?


This is on a 3730, on Linux 2.6.32.

Thanks,
Orjan

-- 
Orjan Friberg
FlatFrog Laboratories AB

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: copy_to_user speed from dma_alloc_coherent vs. kmalloc buffer
  2011-04-20 15:12 copy_to_user speed from dma_alloc_coherent vs. kmalloc buffer Orjan Friberg
@ 2011-04-20 17:09 ` Orjan Friberg
  0 siblings, 0 replies; 2+ messages in thread
From: Orjan Friberg @ 2011-04-20 17:09 UTC (permalink / raw)
  To: linux-omap@vger.kernel.org

On 2011-04-20 17:12, Orjan Friberg wrote:
> What are my options (besides using mmap)?

It looks like kmalloc + dma_map_single for the DMA destination buffer 
and then dma_sync_single_for_{cpu,device} around the call to 
copy_to_user pretty much does the trick.  At least the %sys load 
measured with mpstat goes from 13% to 2%.

-- 
Orjan Friberg
FlatFrog Laboratories AB

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-04-20 17:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-20 15:12 copy_to_user speed from dma_alloc_coherent vs. kmalloc buffer Orjan Friberg
2011-04-20 17:09 ` Orjan Friberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox