[lkml]   [2000]   [Nov]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: Locking User memory pages from a driver....

> How do i lock user mode memmory pages from kernel mode driver.. so that i
> can access it whenever i need to from the driver.... I am using linux kernel
> 2.2.14.. can this be done in this kernel version... or is it supported in
> some other newer versions.. like 2.4..

raw I/O. Stock in 2.4, available as a patch in 2.2. You're in luck,
I just released an updated patch against 2.2.17 and 2.2.18preXX yesterday,
based on SCT's raw I/O and with Andrea's fixes.

For example usage see fs/block.c brw_kiovec() and drivers/char/raw.c
Basically you call:

alloc_kiovec() to initialize kiobufs

map_user_kiobuf() to map a kiobuf to a user buffer (best if <= 64K)

Look in the kiobuf to get the iobuf->offset into the first page
and addresses to the pages:

bounce = iobuf->bouncelist[pageind];

if (bounce)
page = bounce;
page = iobuf->pagelist[pageind];

The page is a kernel virtual address as an unsigned long you can
then translate in the usual way (e.g. virt_to_bus() for PCI).
Don't forget to count the length of the last page as
PAGE_SIZE-iobuf->offset or you'll run over in your S/G.

unmap_kiobuf() to unmap the kiobuf and unpin the pages

If you do a lot of DMA I/O with large buffers you'll need to apply
the 22vmfix patch in the same directory or you'll run out memory
and things will start to be OOM killed.

Eric Lowe
Software Engineer, Systran Corporation

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

 \ /
  Last update: 2005-03-22 12:47    [W:0.038 / U:0.220 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site