Take a look at function vm_insert_page()
or remap_pfn_range()
in mm/memory.c.
You can find an example at: drivers/media/v4l2-core/videobuf2-dma-sg.c, function vb2_dma_sg_mmap()
Can mmap handle non-contiguous page ranges in a linux driver?
-
21-04-2022 - |
Question
I'd like to be able to map a single user space address to multiple blocks of low kernel memory. I have a driver where I allocate multiple 4MB blocks using pci_alloc_consistent(). Ideally, I'd like user space process to see 8MB (i.e. 2 4MB blocks) as a single buffer mapped to its virtual address space. Is this possible in mmmap()? Or, is there a way to allocate a chunk of kernel memory greater than 4MB using pci_alloc_consistent() (or other apis as long as memory is dma compatible)?
I'd appreciate any pointers. Thanks.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow