2001-07-02 14:04:15

by mdaljeet

[permalink] [raw]
Subject: Re: mmap



[email protected] wrote:
> I am doing the following:
>
> malloc some memory is user space
> pass its pointer to some kernel module
> in the kernel module...do a pci_alloc_consistent so that i get a
memory
> region for PCI DMA operations

Wrong approach, you can use kiobufs if you want DMA to the malloc()ed
userspace memory:

* lock down the user memory using map_user_kiobuf() + lock_kiovec()
(see linux/iobuf.h).
* translate the iobuf->maplist into a scatterlist [1]
* feed pci_map_sg() with the scatterlist to get DMA addresses.
you can pass to the hardware.

And the reverse to free everything when you are done of course.

Gerd

[1] IMHO it would be more useful if iobufs would use a scatterlist
instead of an struct page* array.


--
Gerd Knorr <[email protected]> -- SuSE Labs, Au?enstelle Berlin


Attachments:
(No filename) (1.28 kB)
(No filename) (1.06 kB)
Download all attachments

2001-07-03 17:46:54

by Jens Axboe

[permalink] [raw]
Subject: Re: mmap

On Mon, Jul 02 2001, [email protected] wrote:
> [1] IMHO it would be more useful if iobufs would use a scatterlist
> instead of an struct page* array.

No that would be horrible, at least with the current scatterlist. A page
based scatterlist would be alright though -- but this boils down to the
per-page offset debate again.

--
Jens Axboe