Skip to contentSkip to conversation

Probs with PCI bus master DMA to user space

DISCUSSION Norbert Roos 2 participants 5 messages Feb 20, 2001

lore
Share & tools
lore
#0 lore raw
Quoted 2 lines

Allocate the buffers in the kernel and mmap() them into user space

But the buffers are usually allocated with malloc() by any application which wants to use my driver.. otherwise my driver would have to offer a malloc-like function, but I can hardly force the application to use my own malloc function.

#1 lore raw
Quoted 6 lines · Norbert Roos
Quoted 1 line

Allocate the buffers in the kernel and mmap() them into user space

But the buffers are usually allocated with malloc() by any application which wants to use my driver.. otherwise my driver would have to offer a malloc-like function, but I can hardly force the application to use my own malloc function.

If you are writing the driver, sure you can.

Jeff

#2 lore raw
Quoted 6 lines · Jeff Garzik
Quoted 4 lines

But the buffers are usually allocated with malloc() by any application which wants to use my driver.. otherwise my driver would have to offer a malloc-like function, but I can hardly force the application to use my own malloc function.

If you are writing the driver, sure you can.

??

The application is doing something like

fd = open("/dev/mydriver");
buf = malloc();
fill_buffer_with_data(buf);
 write(fd,buf);

And now i should tell the programmer not to use malloc() but my special driver-malloc?
Or do you mean something different?

Norbert

#3 lore raw
Quoted 13 lines · Norbert Roos
Quoted 6 lines · Jeff Garzik
Quoted 4 lines

But the buffers are usually allocated with malloc() by any application which wants to use my driver.. otherwise my driver would have to offer a malloc-like function, but I can hardly force the application to use my own malloc function.

If you are writing the driver, sure you can.

??

The application is doing something like

Quoted 8 lines

fd = open("/dev/mydriver");
buf = malloc();
fill_buffer_with_data(buf);
 write(fd,buf);

And now i should tell the programmer not to use malloc() but my special driver-malloc?
Or do you mean something different?

fd = open(...);
buf = mmap(fd, ...);
fill_buffer_with_data(buf);
ioctl(fd, ...); /* tell kernel data is there */

There are variations depending on the application, but you get the picture. A buffer copy is eliminated when mmap is used, too, making your application faster.

Jeff

#4 lore raw
Quoted 5 lines · Jeff Garzik
Quoted 2 lines · Norbert Roos

Jeff Garzik wrote:

Quoted 9 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

But the buffers are usually allocated with malloc() by any application which wants to use my driver.. otherwise my driver would have to offer a

fd = open(...);
buf = mmap(fd, ...);
fill_buffer_with_data(buf);
ioctl(fd, ...); /* tell kernel data is there */

Hm hm - this is exactly what i wanted to avoid: The application should not
be modified only to be able to use my driver - and if it is using malloc(), it would have to be modified..

Thanks anyway!

Norbert