mmap() Failure with 2.2.7

fmcgirt@swcp.com
Fri, 21 May 1999 13:42:06 -0000


I have a contiguous memory buffer in my driver that I have allocated by:

bufAddress = __get_dma_pages(GFP_KERNEL,order);

that I want to map to user space.

The following worked for 2.0.36-3SMP on RH 5.2 but does not
work for 2.2.7SMP on RH 6.0. It gives no error indication
but when I try to store data in the buffer and read it back,
the data is garbage (0xffffffff).

I would appreciate knowing the proper way to do this or
any suggestions about how to proceed.

Frank McGirt
fmcgirt@swcp.com

2.0.36 implementation:

1. in driver reserve buffer by setting RESERVED bit so that
remap_page range() will work
max_page = MAX_BUFFER_SIZE/PAGE_SIZE
paddr = bufAddress;
for( i = 0; i < max_page; i++ ) {
page = &mem_map[MAP_NR(paddr)];
set_bit(PG_reserved,&page->flags);
paddr += PAGE_SIZE;
}

2. call mmap() from app as:
mmap(0,bufferLength,PROT_READ|PROT_WRITE,MAP_SHARED,fd,bufAddress);

3. in driver mmap() implemented as:
mmap(struct file *file, struct vm_area_struct *vmarea)
{
...
remap_page_range(vmarea->vm_start, vmarea->vm_offset, vmarea->end -
vmarea->start, vmarea->vm_page_prot);
vmarea->vm_file = file;
file->f_dentry->d_inode-i_count++;

return 0;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/