remap_page_range in 2.2.7

fmcgirt@swcp.com
Tue, 08 Jun 1999 20:07:33 -0000


I have posted this earlier but no response. I am using remap_page_range to
map a kernel dma buffer to user space by setting RESERVED bit in appropriate pages. I am unable to find the problem - has remap_page_range changed from 2.0.x to 2.2.x so that it does not work on RAM even with the RESERVED bit
set???? Others doing the same have also posted the same problem (without
resolution) so I don't think it is just me. All other uses of remap work
fine - such as with PCI mmeory regions. About ready to go to something
else and give up for the time being but hope there is a solution.

Earlier Posting:

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/