i trying write linux kernel module map address user using dma_common_mmap()
. want user mmap , write/read address space.
my main problem can't find documentation dma_common_mmap()
, exist? have googled didn't find out how use , let user read/write address.
the documentation dma_common_mmap()
doesn't exist. can @ doxygen comment dma_mmap_attrs()
function:
/** * dma_mmap_attrs - map coherent dma allocation user space * @dev: valid struct device pointer, or null isa , eisa-like devices * @vma: vm_area_struct describing requested user mapping * @cpu_addr: kernel cpu-view address returned dma_alloc_attrs * @handle: device-view address returned dma_alloc_attrs * @size: size of memory requested in dma_alloc_attrs * @attrs: attributes of mapping properties requested in dma_alloc_attrs * * map coherent dma buffer allocated dma_alloc_attrs * user space. coherent dma buffer must not freed * driver until user space mapping has been released. */ static inline int dma_mmap_attrs(struct device *dev, struct vm_area_struct *vma, void *cpu_addr, dma_addr_t dma_addr, size_t size, struct dma_attrs *attrs) { struct dma_map_ops *ops = get_dma_ops(dev); bug_on(!ops); if (ops->mmap) return ops->mmap(dev, vma, cpu_addr, dma_addr, size, attrs); return dma_common_mmap(dev, vma, cpu_addr, dma_addr, size); } #define dma_mmap_coherent(d, v, c, h, s) dma_mmap_attrs(d, v, c, h, s, null)
dma_mmap_attrs()
calls in turn dma_common_mmap()
, documentation (except attrs
param) applies dma_common_mmap()
is.
edit
i think should use dma_mmap_coherent()
(along dma_alloc_coherent()
), pretty same dma_common_mmap()
(see code above). see this example clue on how use both in kernel side , in user-space. see how dma_mmap_coherent()
used in alsa kernel code, in snd_pcm_lib_default_mmap() function.