Article 55WGC Using mmap() for sharing memory between application and driver

Using mmap() for sharing memory between application and driver

by
anujsingh.kr
from LinuxQuestions.org on (#55WGC)
I am facing some problem while trying to share memory between an application and driver using mmap().

Background:

- I have an application and a corresponding driver for a device.
- I call mmap() for x-mega bytes from application mchar_mmap() is implemented in the driver to handle this call.
- In driver I allocate contiguous memory using dma_alloc_coferent() for x-megabytes (CMA is configured on the system)
- Inside mchar_mmap(), I associate the allocated memory to the user provided virtual address: remap_pfn_range(vma, vma->vm_start, mapoffset>>PAGE_SHIFT, vma->vm_end - vma->vm_start, PAGE_SHARED);
Hence the mmap() call from application passes and application receives a user virtual address corresponding(mapped) to the memory shared by the driver.

Problem description:

Now, when the application writes some data to the range, I expect it to be seen from the driver. But when I read the the address range(which was allocated and shared by driver) from driver, I am not able to get the same data which application has written.

Please suggest the possibilities of mistakes I could have done, or, is my expectation wrong.latest?d=yIl2AUoC8zA latest?i=xx8u2Zl3mdQ:lz4jbi8q-Qs:F7zBnMy latest?i=xx8u2Zl3mdQ:lz4jbi8q-Qs:V_sGLiP latest?d=qj6IDK7rITs latest?i=xx8u2Zl3mdQ:lz4jbi8q-Qs:gIN9vFwxx8u2Zl3mdQ
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments