Re: contigmalloc() and mmap()

2005-06-15 Thread Apache Xie
I'm unsure about this usage of the timer (callout(?) ) how does the timer know which buffer pages to remove? and if each userspace process does an ioctl to allocate a different buffer, are the new pages also visible to other processes? Use mmap() we can ensure different process access differ

Re: contigmalloc() and mmap()

2005-06-14 Thread Mark Tinguely
> I browsed kernel tree, I found those drivers which use contigmalloc() and > contigfree() always call these two kernel interfaces in _attach() and > _detach(), but in my driver, I call contigmalloc() in ioctl(), and call > contigfree() in a callout function which is set by callout_reset(). >

Re: contigmalloc() and mmap()

2005-06-13 Thread Al Viro
On Mon, Jun 13, 2005 at 12:55:40PM -0600, Scott Long wrote: > >Lot's of driver use file->private to get at per-device data easily, > >but that's just a shortcut. > > Ok, I thought that you were talking about per-process data being in the > file descriptor. Can't be done. FWIW, the main differenc

Re: contigmalloc() and mmap()

2005-06-13 Thread Christoph Hellwig
On Mon, Jun 13, 2005 at 08:59:17PM +0100, Christoph Hellwig wrote: > disk drivers use a completely different set of entry points in Linux, > and don't have access to per-fd data even in the case they're opened > from userland. Character drivers to which this applies OTOH always > get a valid struc

Re: contigmalloc() and mmap()

2005-06-13 Thread Christoph Hellwig
On Mon, Jun 13, 2005 at 12:54:40PM -0700, Julian Elischer wrote: > though, some people use it for that purpose (e.g. in the original posting). driver writers do all kinds of odd things ;-) > it might not be such a bad idea.. > I don't see why the device entrypoints shouldn't have that argument >

Re: contigmalloc() and mmap()

2005-06-13 Thread Julian Elischer
Christoph Hellwig wrote: On Mon, Jun 13, 2005 at 12:55:40PM -0600, Scott Long wrote: Lot's of driver use file->private to get at per-device data easily, but that's just a shortcut. Ok, I thought that you were talking about per-process data being in the file descriptor. No, L

Re: contigmalloc() and mmap()

2005-06-13 Thread Julian Elischer
Scott Long wrote: Christoph Hellwig wrote: On Mon, Jun 13, 2005 at 10:50:26AM -0700, Julian Elischer wrote: Several times in the past we've seen people complainign that Linux allows a device driver to know who called it and somehow it seems to store somewhere some information about who op

Re: contigmalloc() and mmap()

2005-06-13 Thread Scott Long
Christoph Hellwig wrote: On Mon, Jun 13, 2005 at 12:55:40PM -0600, Scott Long wrote: Lot's of driver use file->private to get at per-device data easily, but that's just a shortcut. Ok, I thought that you were talking about per-process data being in the file descriptor. No, Linux has absol

Re: contigmalloc() and mmap()

2005-06-13 Thread Christoph Hellwig
On Mon, Jun 13, 2005 at 12:55:40PM -0600, Scott Long wrote: > >Lot's of driver use file->private to get at per-device data easily, > >but that's just a shortcut. > > Ok, I thought that you were talking about per-process data being in the > file descriptor. No, Linux has absolutely no concept of p

Re: contigmalloc() and mmap()

2005-06-13 Thread Scott Long
Christoph Hellwig wrote: On Mon, Jun 13, 2005 at 12:37:07PM -0600, Scott Long wrote: How does linux handle the implications of fork(2) in this scenario? it's still counted as the same instance. Similar for dup or passing descriptors over AF_UNIX sockets. The data is explictly not per-proce

Re: contigmalloc() and mmap()

2005-06-13 Thread Christoph Hellwig
On Mon, Jun 13, 2005 at 12:37:07PM -0600, Scott Long wrote: > How does linux handle the implications of fork(2) in this scenario? it's still counted as the same instance. Similar for dup or passing descriptors over AF_UNIX sockets. The data is explictly not per-process but per instance. There's

Re: contigmalloc() and mmap()

2005-06-13 Thread Scott Long
Christoph Hellwig wrote: On Mon, Jun 13, 2005 at 10:50:26AM -0700, Julian Elischer wrote: Several times in the past we've seen people complainign that Linux allows a device driver to know who called it and somehow it seems to store somewhere some information about who openned the device.. tho

Re: contigmalloc() and mmap()

2005-06-13 Thread Christoph Hellwig
On Mon, Jun 13, 2005 at 10:50:26AM -0700, Julian Elischer wrote: > > Several times in the past we've seen people complainign that Linux > allows a device driver to know > who called it and somehow it seems to store somewhere some information > about who > openned the device.. thos somehow allows

Re: contigmalloc() and mmap()

2005-06-13 Thread Julian Elischer
2nd try to answer this.. Apache Xie wrote: I have some experiences in writing Linux device driver, but I am new to FreeBSD kernel, although from the first glimpse, there seems no big differences between the kernel operations a char device driver can use, but I met some problems when the driver

Re: contigmalloc() and mmap()

2005-06-13 Thread Julian Elischer
Daniel Eischen wrote: On Mon, 13 Jun 2005, Julian Elischer wrote: Maybe I don't understand the problem but.. I think the problem is that you want to keep a separate buffer for each user, while the drivers you are looking at expect to have only one buffer per device. One answer to this

Re: contigmalloc() and mmap()

2005-06-13 Thread Daniel Eischen
On Mon, 13 Jun 2005, Julian Elischer wrote: > > Maybe I don't understand the problem but.. > > I think the problem is that you want to keep a separate buffer for each > user, ] > while the drivers you are looking at expect to have only one buffer per > device. > > One answer to this would be to mak

Re: contigmalloc() and mmap()

2005-06-13 Thread Julian Elischer
Apache Xie wrote: I have some experiences in writing Linux device driver, but I am new to FreeBSD kernel, although from the first glimpse, there seems no big differences between the kernel operations a char device driver can use, but I met some problems when the driver is running in FreeBSD.

Re: contigmalloc() and mmap()

2005-06-13 Thread Apache Xie
From: Mark Tinguely <[EMAIL PROTECTED]> To: [EMAIL PROTECTED], freebsd-hackers@freebsd.org Subject: Re: contigmalloc() and mmap() Date: Mon, 13 Jun 2005 07:41:33 -0500 (CDT) > I browsed kernel tree, I found those drivers which use contigmalloc() and > contigfree() always ca

contigmalloc() and mmap()

2005-06-13 Thread Apache Xie
I have some experiences in writing Linux device driver, but I am new to FreeBSD kernel, although from the first glimpse, there seems no big differences between the kernel operations a char device driver can use, but I met some problems when the driver is running in FreeBSD. Our device is an exper

contigmalloc and mmap??

2000-05-18 Thread Joy Ganguly
hi i have a buffer obtained from contigmalloc. now i want to mmap it to user space. i have done this in linux but unfortunately i am a freebsd newbie. i read the code and it appeared that the device mmap routine is passed an offset and it has to return the physical page frame no so that the neces