mm: Introduce new vm_map_pages() and vm_map_pages_zero() API
Subsystems (5)
PATCH v3 1/9 mm: Introduce new vm_map_pages() and vm_map_pages_zero() API
Previouly drivers have their own way of mapping range of kernel pages/memory into user vma and this was done by invoking vm_insert_page() within a loop.
As this pattern is common across different drivers, it can be generalized by creating new functions and use it across the drivers.
vm_map_pages() is the API which could be used to mapped kernel memory/pages in drivers which has considered vm_pgoff
vm_map_pages_zero() is the API which could be used to map range of kernel memory/pages in drivers which has not considered vm_pgoff. vm_pgoff is passed default as 0 for those drivers.
We _could_ then at a later "fix" these drivers which are using vm_map_pages_zero() to behave according to the normal vm_pgoff offsetting simply by removing the _zero suffix on the function name and if that causes regressions, it gives us an easy way to revert.
Tested on Rockchip hardware and display is working, including talking to Lima via prime.
--- include/linux/mm.h | 4 +++ mm/memory.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ mm/nommu.c | 14 ++++++++++ 3 files changed, 99 insertions(+)
include/linux/mm.h +4 -0
@@ -2565,6 +2565,10 @@ unsigned long change_prot_numa(struct vm_area_struct *vma,int remap_pfn_range (struct vm_area_struct *,unsigned long addr,unsigned long pfn,unsigned long size,pgprot_t );int vm_insert_page (struct vm_area_struct *,unsigned long addr,struct page *); +int vm_map_pages (struct vm_area_struct *vma,struct page **pages, +unsigned long num); +int vm_map_pages_zero (struct vm_area_struct *vma,struct page **pages, +unsigned long num);vm_fault_t vmf_insert_pfn (struct vm_area_struct *vma,unsigned long addr,unsigned long pfn); vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
mm/memory.c +81 -0
87 lines not on this page · raw message
mm/nommu.c +14 -0
@@ -473,6 +473,20 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr, }EXPORT_SYMBOL (vm_insert_page); +int vm_map_pages (struct vm_area_struct *vma,struct page **pages, +unsigned long num) +{ +return -EINVAL ; +} +EXPORT_SYMBOL (vm_map_pages); + +int vm_map_pages_zero (struct vm_area_struct *vma,struct page **pages, +unsigned long num) +{ +return -EINVAL ; +} +EXPORT_SYMBOL (vm_map_pages_zero); +/* * sys_brk() for the most part doesn't need the global kernel * lock, except when an application is doing something nasty
Signature · 1 line
1.9.1