[lkml]   [2004]   [Aug]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Subjectquestion on char driver mmap

I have a need for a device driver to map a page of memory between interrupt
handlers and userspace. It's been suggested that I use something like the
following code (simplified):

unsigned long mypage;

int my_mmap(struct file *filp, struct vm_area_struct *vma)
unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;

if (offset & ~PAGE_MASK)
return -ENXIO;

mypage = __get_free_page(GFP_KERNEL);
remap_page_range(vma->vm_start, virt_to_phys((void *) mypage),
PAGE_SIZE, vma->vm_page_prot);
return 0;

This seems to work. If I do this, however, do I need to hook into the munmap()
file operations to handle unmapping, clearing the reserved bit, and freeing the
page, or will the memory subsystem do it for me?


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 14:05    [W:0.019 / U:2.420 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site