We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

Showing results for 
Search instead for 
Did you mean: 
Visitor memonabhi
Registered: ‎04-24-2019

Why memory allocated by dma_alloc_coherent() gives better performance ?

I am writing a driver code to read and write from AXI LITE peripheral. Since AXI LITE is a memory mapped interface, I am implementing the mmap function in my driver code. I am doing some experiment by

  1. allocating the memory using dma_alloc_coherent() API and than mapping it to user space by using dma_mmap_cohernet() API {giving Better performance}.
  2. I am mapping the memory to user space by using remap_pfn_range() API along with pgprot_noncached() API to avoid the caching problem {giving poor performance}.

I am seeing better performance while reading and writing in case of dma_alloc_coherent() compare to the remap_pfn_range(). But if i am removing pgprot_noncached() from the code, than performance of memory, mapped by remap_pfn_range also improving but i am seeing mismatch of data, which is because of caching problem.

  1. {provide better performce}

     virt = dmam_alloc_coherent(dev,size, &phys, GFP_KERNEL);
      dma_mmap_coherent(dev, vma, virt, phys, size);

2.{provide poor performce}

 vma->vm_flags |= VM_IO | VM_DONTDUMP;
  vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
    remap_pfn_range(vma, vma->vm_start, mem->start,>>PAGE_SHIFT, size, vma>vm_page_prot);

My doubts are :-

  1. I am unable to understand, why there is a performance hit in case of dma_alloc_coherent ?

  2. I am assuming dma_alloc_coherent gives by default non cached memory while in the other case we are making the memory non cached explicitly by using pgprot_noncahced() API. does pgprot_noncached() API perform some memory operation or translation which leads to overhead ?

Tags (2)
0 Kudos