public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ben Nizette <ben.nizette@iinet.net.au>
To: "linux-os (Dick Johnson)" <linux-os@analogic.com>
Cc: Greg KH <greg@kroah.com>,
	linux-kernel@vger.kernel.org, tglx@linutronix.de
Subject: Re: Userspace I/O driver core
Date: Fri, 15 Dec 2006 08:55:26 +1100	[thread overview]
Message-ID: <4581C84E.3080209@iinet.net.au> (raw)
In-Reply-To: <Pine.LNX.4.61.0612141110310.31046@chaos.analogic.com>

linux-os (Dick Johnson) wrote:
> On Wed, 13 Dec 2006, Greg KH wrote:
>>
>> If anyone has any questions on how to use this interface, or anything
>> else about it, please let me and Thomas know.
>>
>> thanks,
>>
>> greg k-h
[snip]
> There are well thought-out methods of creating hardware interfaces that 
 > have a successfully history of implementation both in Linux and Unix.
 > There are well established APIs that are used to expose devices to
 > user-space with controlled privilege, access mechanisms, and built-in
 > locking to provide atomic access to the functionality of the devices
 > without user-space code needing to understand the device intricacies
 > (and probably getting it wrong).
> 
> I recently returned from a conference where somebody had designed a 
 > driver that exposes PCI registers and FPGA device registers to
 > user-space. Their problem was how to provide "call-backs" when an
 > interrupt occurred. They were convinced that all they had to do was
 > to have some user-space procedure that could be called when an
 > interrupt occurred. Then their so-called driver would work. They had
 > no clue about the fact that an interrupt can occur at any time not
 > just when somebody is ready and waiting for it, that one usually has
 > sections of code that must not be interrupted, etc.

This is almost exactly the situation I find myself in and a situation 
for which UIO is perfect.  UIO is not a hole through the kernel in to 
memory, it is a well defined API of the type you describe above (albeit 
not 'established' yet).  UIO interrupts are _handled_ in kernel space 
but subsequently _signalled_ in userspace.  There are no issues of 
kernel code directly calling any userspace functionallity.
 >
 > Driver code needs to be protected from undue user-space interference
 > otherwise the device can't be synchronized, shared, or accessed
 > through the operating system's APIs.

And this is what UIO does, it allows userspace interaction without 
userspace interference.  It provides a safe an sanitized view of the 
hardware to processes which make more sense in userland.
> 
> Every time I showed how the driver couldn't work properly, the 
 > designer so convinced of his superior methods, would devise a
 > work-around. For instance, to protect a section of code from being
 > modified in an interrupt, the user-space driver was to be executed
 > with iopl(3) and interrupts disabled. To protect the kernel from the
 > ISR being modified or replaced, the code would be checksummed every
 > time an interrupt occurred, etc. I could go on. Drivers have no place
 > user space.
> 
No, dumb drivers with dodgy kernel interfaces don't have a place 
_anywhere_.  If this under-educated person was using UIO there would be 
no need for any of his hacks, a userspace driver would be feasible, 
clean, neat and perfectly allowable.

Regards,
	Ben

      reply	other threads:[~2006-12-14 22:05 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-14  1:06 Userspace I/O driver core Greg KH
2006-12-14  5:48 ` Ben Nizette
2006-12-14  9:44 ` Avi Kivity
2006-12-14 10:19   ` Arjan van de Ven
2006-12-14 10:46     ` Avi Kivity
2006-12-14 10:54       ` Arjan van de Ven
2006-12-14 10:56         ` Avi Kivity
2006-12-14 17:54           ` Greg KH
2006-12-16 14:48     ` Dr. David Alan Gilbert
2006-12-14 10:25   ` Hans-Jürgen Koch
2006-12-14 10:48     ` Avi Kivity
2006-12-14 12:39       ` Jan Engelhardt
2006-12-14 13:38         ` Avi Kivity
2006-12-14 17:48           ` Jan Engelhardt
2006-12-14 18:00       ` Greg KH
2006-12-14 10:52 ` Alan
2006-12-14 11:22   ` Thomas Gleixner
2006-12-14 11:39     ` Alan
2006-12-14 11:37       ` Hans-Jürgen Koch
2006-12-14 12:45         ` Alan
2006-12-14 12:37 ` Jan Engelhardt
2006-12-14 16:10 ` linux-os (Dick Johnson)
2006-12-14 21:55   ` Ben Nizette [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4581C84E.3080209@iinet.net.au \
    --to=ben.nizette@iinet.net.au \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-os@analogic.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox