Since the memory is allocated using dma_alloc_coherent(), you need to use remap_pfn_range() API to export this region to the userspace. Any good documentation on remap_pfn_range() API would do.
Please go through the below notes as well.
There are times that call for exposing resources from the kernel space to the user space for various reasons of which performance is one. The resources here include the following
MMIO regions (Including the PCIe BARs that get mapped into host system’s MMIO regions)
Memory allocations done by kernel drivers
In either case, the API to be used is remap_pfn_range(). As one of the input arguments, this API needs the physical address and the size of the region which needs to be exposed to the user space.
In case of (1), it is straightforward as the physical address location is known directly.
In case of (2), most of the time, memory is allocated using DMA APIs like dma_alloc_coherent() etc… where only the CPU VA (a.k.a kernel virtual address) is known and not the physical address. To get the physical address from the kernel virtual address, there are again two ways that can be used.
Before jumping into both the methods, please do note that it might be tempting to use the macro __pa() for this purpose, but it may not work. It may work on x86 systems but It surely doesn’t work on ARM systems as the the kernel’s logical address is not going to be same as the kernel virtual address (in which case__pa() works and it generally is the case in case of x86 systems)
Method-1: (Getting the physical address from VA (a.k.a CPU-VA))
The API vmalloc_to_pfn() can be used to get the pfn directly from the CPU-VA
Method-2: (Getting the physical address from IOVA)
This is a two step process. First use iommu_get_domain_for_dev() to get the IOMMU domain of the device and then use iommu_iova_to_phys() to get the physical address.