Subject: Re: mmap() from kernel to user
To: Kamal R. Prasad <email@example.com>
From: Lennart Augustsson <firstname.lastname@example.org>
Date: 11/22/2004 08:25:55
I don't understand what you want to do? Do you simply want
the device mmap()-ed? Why don't you do it the normal way?
For most USB devices I would think that mmap() is a bad idea.
Remember that with mmap() you can read at random places in
the data, so if your device doesn't support this you would
be forced to buffer all data in the kernel.
Why don't you want to use copyout()? The speed of the USB 1.1
bus is low compared to the speed of a copyout() on any modern
The device can never overwhelm the system with data. A device
is only allowed to send when asked to do so.
Kamal R. Prasad wrote:
> der Mouse wrote:
>>> I have a device driver in the works for a usb device. I want to
>>> mmap(ANON_MAP) and pass the fd to userspace
>> ...what fd? mmap doesn't create fds.
> oops. when you do an annonymous mmap() it dis-regards the fd arg to
>>> and have it read the fd for the bulk data obtained by the kernel.
>> Sounds as though you want the kernel to create a file descriptor for
>> userland to read. How you get it to userland is a minor detail.
> The device driver will get a lot of data from the device and want to
> pass it out to the userland. Instead of using copyout,. I wanted to pass
> a pointer so that the userland could just read access the ptr to read
> the data, The problem is that there is no hard disk on the embedded
> platform that is going to run this code, so I cannot open("..") then
> pass the fd to mmap() in the kernel, followed by a similar thing in the
>> If I wanted to do this, I'd create a socketpair - in modern NetBSD you
>> could also use a pipe, maybe - and hand one end to userland, keeping
>> the other end for the driver's use.
> Isn't a pipe/socketpair going to be expensive for large amounts of
> data(USB has a bandwidth of 12 Mbps -and that is the upper limit of the
> data which I wish to transfer from kernel to user)? The most efficient
> mechanism I can think of is either shared memoru or memory mapped files.
> I want to be able to use either of these 2, without referring to the
>> I don't know enough about USB to speak to the other questions.
> OK. The USB framework has a mechanism called bulk pipe for transferring
> large amts of data. I wanted to make sure the device doesn't overwhelm
> the system.
>> /~\ The ASCII der Mouse
>> \ / Ribbon Campaign
>> X Against HTML email@example.com
>> / \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B