title: DMA write fails when dma_alloc_coherent is replaced with dma_map_single
body: <p>I am experimenting the DMA flow with and without SMMU on ARM.
  Our custom application requires kernel address, physical address and bus address.</p>
  
  <p>With SMMU enabled, I managed to get the kernel address and bus address using <code>dma_alloc_coherent()</code>, but I could not get the physical address via <code>virt_to_phys()</code>.
  That made me replace <code>dma_alloc_coherent()</code> with <code>dma_map_single</code> as follows:</p>
  
  <pre><code>// Get kernel address
  res-&gt;KernelAddress = (u64)kzalloc( size , GFP_KERNEL | GFP_DMA);
  
  // Get bus address
  res-&gt;BusAddress = (u64)dma_map_single(&amp;DevExt-&gt;pdev-&gt;dev, &amp;res-&gt;KernelAddress, size, PCI_DMA_BIDIRECTIONAL);
  
  // Get physical address
  res-&gt;PhysicalAddress = (u64)virt_to_phys( (void*)res-&gt;KernelAddress );
  
  dma_sync_single_for_cpu(&amp;DevExt-&gt;pdev-&gt;dev, res-&gt;BusAddress, size, PCI_DMA_BIDIRECTIONAL);
  
  // Map physical address to virtual address in user space
  if (remap_pfn_range(vma, vma-&gt;kern_addr, vma-&gt;phys_addr,size,vma-&gt;vm_page_prot));
  </code></pre>
  
  <p>There was no issue with the above flow. 
  I managed to get 3 addresses but DMA write to the returned location failed.
  Are other DMA APIs required for the above flow to work?</p>
  
  <p>It is better if any snippet is shared!</p>