The HyperNews Linux KHG Discussion Pages

Question: DMA to user space

Forum: Device Drivers
Date: Wed, 11 Jun 1997 09:23:28 GMT
From: Marcel Boosten <Marcel.Boosten@cern.ch>

Hello,

I'm developing a device driver for a PCI board meant for
high performance communication. Interaction with the board
is possible via DMA. In order to get optimal performance
I need to do DMA directly to user space.

QUESTION:
How do I implement DMA to user space?

SUBQUESTIONS:
In "The Linux Kernel", David A Rusling writes the following:
"Device drivers have to be careful when using DMA. First
of all the DMA controller knows nothing of virtual memory,
it only has access to the physical memory in the system.
Therefore the memory that is being DMA'd to or from must
be a contiguous block of physical memory. This means that
you cannot DMA directly into the virtual address space of
a process. YOU CAN HOWEVER LOCK THE PROCESSES PHYSICAL
PAGES INTO MEMORY, PREVENTING THEM FROM BEING SWAPPED OUT
TO THE SWAP DEVICE DURING A DMA OPERATION. Secondly, the
DMA controller cannot access the whole of physical memory.
The DMA channel's address register represents the first 16
bits of the DMA address, the next 8 bits come from the page
register. This means that DMA requests are limited to the
bottom 16 Mbytes of memory."
[see http://www.linuxhq.com/guides/TLK/node87.html]

Reading this the following subquestions arise:
  - How can one lock specific process pages?
  - How can one obtain the physical address of
    the pages involved?
  - How can one ensure that the pages involved
    are DMA-able (below 16Mb)?
  - Is it possible to obtain a continues block of
    physical memory in user space?  

Greetings,
  Marcel