Subject: Re: mmap() from kernel to user
To: der Mouse <mouse@Rodents.Montreal.QC.CA>
From: Kamal R. Prasad <kamalp@acm.org>
List: tech-kern
Date: 11/22/2004 11:23:13
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 mmap().

>>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 
userspace.

>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 
filesystem.

>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.

regards
-kamal

>/~\ The ASCII				der Mouse
>\ / Ribbon Campaign
> X  Against HTML	       mouse@rodents.montreal.qc.ca
>/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B
>  
>