Skip to contentSkip to conversation

DMA to/from user buffers

DISCUSSION Sebastian Heidl 3 participants 3 messages Sep 4, 2001 – Sep 5, 2001

lore
Share & tools
lore
#0 lore raw

Hi,

two questions about using an user-supplied buffer (e.g. malloced in user space) for DMA transfers:

1. Is it possible ?
2. What restrictions/requirements apply for the buffer (alignment...) ?

Documentation/DMA-mapping.txt only talks about buffers allocated in kernel space.

thanks,
_sh_

#1 lore raw
Quoted 11 lines · Sebastian Heidl

Hi,

two questions about using an user-supplied buffer (e.g. malloced in user space) for DMA transfers:

1. Is it possible ?
2. What restrictions/requirements apply for the buffer (alignment...) ?

Documentation/DMA-mapping.txt only talks about buffers allocated in kernel space.

Lock down the user pages using kiobufs (see include/linux/iobufs.h), then feed these pages to the pci_* functions.

Gerd

Signature · 1 line
Damn lot people confuse usability and eye-candy.
#2 lore raw
In reply to Sebastian Heidl
Quoted 8 lines · Sebastian Heidl

Hi,

two questions about using an user-supplied buffer (e.g. malloced in user space) for DMA transfers:

1. Is it possible ?
2. What restrictions/requirements apply for the buffer (alignment...) ?

There are some obvious problems with this. First, a malloc'ed buffer might not be in memory. It might not be created yet if you haven't touched it, and it might be on swap if you have.

The recommended way is to allocate in the kernel, (probably by the driver that want to do DMA), and mmap this buffer into userspace.

Helge Hafting