mapping devices

Andrew Tridgell (tridge@cs.anu.edu.au)
Wed, 24 Apr 1996 19:30:28 +1000


I'm having trouble with the following code fragment in do_mmap()

if (flags & VM_LOCKED) {
unsigned long start = addr;
current->mm->locked_vm += len >> PAGE_SHIFT;
do {
char c = get_user((char *) start);
len -= PAGE_SIZE;
start += PAGE_SIZE;
__asm__ __volatile__("": :"r" (c));
} while (len > 0);
}

this is called at the end of every successful mmap() operation. It
seems to be trying to ensure that the memory is paged in if it is
marked as locked.

The problem is that I am using mmap() on device memory which can't
just be read at any time. In fact, reading from this device in the way
that the above code does causes a segv. As we are inside the kernel
this causes a panic.

Should my device driver not be setting the VM_LOCKED flag? I am
setting it as it must not be paged out.

If setting the VM_LOCKED flag is correct then perhaps the above code
should actually be calling the device specific page_in routine if
there is one, rather than just probing the memory.

Andrew

PS: The device is the message queues on the AP+.