mmap最终下发到驱动程序,通过设置vma属性可以实现no cache的映射:
static int xxx_nocache_mmap(struct file *filp, struct vm_area_struct *vma)
{
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); //赋nocache标志
vma->vm_pgoff = ((u32)map_start >> PAGE_SHIFT);
if(rempa_pfn_range(vma, vma->vm_start, vma->vm_pgoff, vma->vm_end - vm_start, vma->vm_page_prot));
return - EAGGIN;
return 0;
}