I want to map device memory (NIC) to the kernel space memory region by using
ioremap_wc(). And then I want to remap memory region from kernel space to user space, and I can use 2 functions for this:
mmap(3) usually use the second:
What is the difference between
remap_pfn_range(), and when do I need to use
vm_insert_page() instead of
vm_insert_page() allows drivers to insert individual pages they've allocated into a user vma. The page has to be allocate within the kernel independently. It requires the page be an order-zero allocation obtained for this purpose. It does not put out warnings, and does not require that PG_reserved be set.
Traditionally, this was done with
remap_pfn_range() which took an arbitrary page protection parameter.
vm_insert_page() doesn't allow that. Your vma protection will have to be set up correctly, which means that if you want a shared writeable mapping, you'd better ask for a shared writeable mapping!
remap_pfn_range() is used for mapping or remapping a group of pages into the memory.