Mailing List Archive

[GIT PATCH] more Driver core patches for 2.6.19
Here are some more driver core patches for 2.6.19

They contain:
- minor driver core bugfixes and memory savings
- debugfs bugfixes and inotify support added.
- userspace io driver interface added. This allows the ability
to write userspace drivers for some types of hardware much
easier than before, going through a simple interface to get
accesses to irqs and memory regions. A small kernel portion
is still needed to handle the irq properly, but that is it.
- other minor cleanups and fixes.

All of these patches have been in the -mm tree for a while.

Please pull from:
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6.git/
or if master.kernel.org hasn't synced up yet:
master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6.git/

Patches will be sent as a follow-on to this message to lkml for people
to see.

thanks,

greg k-h

Documentation/DocBook/kernel-api.tmpl | 4 +
Documentation/DocBook/uio-howto.tmpl | 434 +++++++++++++++++++++++
drivers/Kconfig | 1 +
drivers/Makefile | 1 +
drivers/base/class.c | 2 +
drivers/base/platform.c | 4 +-
drivers/uio/Kconfig | 39 ++
drivers/uio/Makefile | 4 +
drivers/uio/uio.c | 618 +++++++++++++++++++++++++++++++++
drivers/uio/uio_dummy.c | 174 +++++++++
drivers/uio/uio_events.c | 119 +++++++
drivers/uio/uio_irq.c | 86 +++++
drivers/uio/uio_parport.c | 84 +++++
fs/debugfs/inode.c | 39 ++-
include/linux/platform_device.h | 2 +-
include/linux/uio_driver.h | 71 ++++
kernel/module.c | 25 ++
kernel/power/Kconfig | 9 +-
18 files changed, 1700 insertions(+), 16 deletions(-)
create mode 100644 Documentation/DocBook/uio-howto.tmpl
create mode 100644 drivers/uio/Kconfig
create mode 100644 drivers/uio/Makefile
create mode 100644 drivers/uio/uio.c
create mode 100644 drivers/uio/uio_dummy.c
create mode 100644 drivers/uio/uio_events.c
create mode 100644 drivers/uio/uio_irq.c
create mode 100644 drivers/uio/uio_parport.c
create mode 100644 include/linux/uio_driver.h

---------------

Akinobu Mita (1):
driver core: delete virtual directory on class_unregister()

Andrew Morton (1):
Driver core: "platform_driver_probe() can save codespace": save codespace

David Brownell (1):
Driver core: deprecate PM_LEGACY, default it to N

Hans J. Koch (4):
UIO: Add the User IO core code
UIO: Documentation
UIO: dummy test module for the uio core
UIO: irq test module for the uio core

Kay Sievers (1):
Driver core: show "initstate" of module

Mathieu Desnoyers (5):
DebugFS : inotify create/mkdir support
DebugFS : coding style fixes
DebugFS : file/directory creation error handling
DebugFS : more file/directory creation error handling
DebugFS : file/directory removal fix

Scott Wood (1):
Driver core: Make platform_device_add_data accept a const pointer

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PATCH] more Driver core patches for 2.6.19 [ In reply to ]
On Wed, 13 Dec 2006, Greg KH wrote:
>
> - userspace io driver interface added. This allows the ability
> to write userspace drivers for some types of hardware much
> easier than before, going through a simple interface to get
> accesses to irqs and memory regions. A small kernel portion
> is still needed to handle the irq properly, but that is it.

Ok, what kind of ass-hat idiotic thing is this?

irqreturn_t uio_irq_handler(int irq, void *dev_id)
{
return IRQ_HANDLED;
}

exactly what is the point here? No way will I pull this kind of crap. You
just seem to have guaranteed a dead machine if the irq is level-triggered,
since it will keep on happening forever.

Please remove.

YOU CANNOT DO IRQ'S BY LETTING USER SPACE SORT IT OUT!

It's really that easy. The irq handler has to be _entirely_ in kernel
space. No user-space ass-hattery here.

And I don't care one whit if it happens to work on parport with an old
legacy ISA interrupt that is edge-triggered. That's not even the
interesting case. Never will be.

NAK NAK NAK NAK.

Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PATCH] more Driver core patches for 2.6.19 [ In reply to ]
On Wed, Dec 13, 2006 at 12:12:04PM -0800, Linus Torvalds wrote:
>
>
> On Wed, 13 Dec 2006, Greg KH wrote:
> >
> > - userspace io driver interface added. This allows the ability
> > to write userspace drivers for some types of hardware much
> > easier than before, going through a simple interface to get
> > accesses to irqs and memory regions. A small kernel portion
> > is still needed to handle the irq properly, but that is it.
>
> Ok, what kind of ass-hat idiotic thing is this?
>
> irqreturn_t uio_irq_handler(int irq, void *dev_id)
> {
> return IRQ_HANDLED;
> }
>
> exactly what is the point here? No way will I pull this kind of crap. You
> just seem to have guaranteed a dead machine if the irq is level-triggered,
> since it will keep on happening forever.

It's a stupid test module for the uio core for isa devices. It's not
the main code, or core.

> Please remove.
>
> YOU CANNOT DO IRQ'S BY LETTING USER SPACE SORT IT OUT!

I agree, that's why this code doesn't let userspace sort it out. You
have to have a kernel driver to handle the irq.

> It's really that easy. The irq handler has to be _entirely_ in kernel
> space. No user-space ass-hattery here.

Agreed.

> And I don't care one whit if it happens to work on parport with an old
> legacy ISA interrupt that is edge-triggered. That's not even the
> interesting case. Never will be.

I agree. But that's all that this test module did. It handled an isa
interrupt that was edge triggered.

> NAK NAK NAK NAK.

Ok, I can pull this example module out if you want, but people seem to
want examples these days. If I do that, any objection to the rest?

thanks,

greg k-h
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PATCH] more Driver core patches for 2.6.19 [ In reply to ]
On 12/13/06, Linus Torvalds <torvalds@osdl.org> wrote:
> Ok, what kind of ass-hat idiotic thing is this?

C'mon, Linus, tell us how you _really_ feel.

Seriously, though, please please pretty please do not allow a facility
for "going through a simple interface to get accesses to irqs and
memory regions" into the mainline kernel, with or without toy ISA
examples. Embedded systems integrators have enough trouble with chip
vendors who think that exposing the device registers to userspace
constitutes a "driver". The correct description is more like "porting
shim for MMU-less RTOS tasks"; and if the BSP vendors of the world can
make a nickel supplying them, more power to them. Just not in
mainline, please.

Cheers,
- Michael
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PATCH] more Driver core patches for 2.6.19 [ In reply to ]
On Wed, 13 Dec 2006, Greg KH wrote:
>
> It's a stupid test module for the uio core for isa devices. It's not
> the main code, or core.

Doesn't matter.

IT IS SO FUNDAMENTALLY AND HORRIBLY WRONG THAT I REFUSE TO HAVE IT IN MY
TREE.

As an "example", the _only_ thing it can possibly ever do is to just
confuse people - in other words, it's an _anti_example, not a real one.

> Ok, I can pull this example module out if you want, but people seem to
> want examples these days. If I do that, any objection to the rest?

I'm really not convinced about the user-mode thing unless somebody can
show me a good reason for it. Not just some "wouldn't it be nice" kind of
thing. A real, honest-to-goodness reason that we actually _want_ to see
used.

No features just for features sake.

So please push the tree without this userspace IO driver at all. And if
you actually have a real user, not just an example, that is worthy and
shows why such a driver in user space is actually a good thing, _then_ we
can push that.

In other words, I'd like to see code that uses this that is actually
_better_ than an in-kernel driver in some way.

For USB, the user-mode thing made sense. You have tons of random devices,
and the abstraction level is higher to begin with. Quite frankly, I simply
don't even see the same being true for something like this.

Btw: there's one driver we _know_ we want to support in user space, and
that's the X kind of direct-rendering thing. So if you can show that this
driver infrastructure actually makes sense as a replacement for the DRI
layer, then _that_ would be a hell of a convincing argument.

There may be others. Feel free to fill in the blank: ________.

Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PATCH] more Driver core patches for 2.6.19 [ In reply to ]
On Wed, Dec 13, 2006 at 12:38:05PM -0800, Michael K. Edwards wrote:
> Seriously, though, please please pretty please do not allow a facility
> for "going through a simple interface to get accesses to irqs and
> memory regions" into the mainline kernel, with or without toy ISA
> examples.

Why? X does it today :)

> Embedded systems integrators have enough trouble with chip vendors who
> think that exposing the device registers to userspace constitutes a
> "driver".

Yes, and because of this, they create binary only drivers today. Lots
of them. All over the place. Doing crazy stupid crap in kernelspace.

Then there are people who do irq stuff in userspace but get it wrong.
I've seen that happen many times in lots of different research papers
and presentations.

This interface does it correctly, and it allows those people who for
some reason feel they do want to keep their logic in non-gpl code, to do
it.

It also allows code that needs floating point to not be in the kernel
and in one instance using this interface actually sped up the device
because of the lack of the need to go between kernel and userspace a
bunch of times.

> The correct description is more like "porting shim for MMU-less RTOS
> tasks"; and if the BSP vendors of the world can make a nickel
> supplying them, more power to them. Just not in mainline, please.

Again, X does this today, and does does lots of other applications.
This is a way to do it in a sane manner, to keep people who want to do
floating point out of the kernel, and to make some embedded people much
happier to use Linux, gets them from being so mad at Linux because we
keep changing the internal apis, and makes me happier as they stop
violating my copyright by creating closed drivers in the kernel.

thanks,

greg k-h
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PATCH] more Driver core patches for 2.6.19 [ In reply to ]
On Wed, 13 Dec 2006, Michael K. Edwards wrote:
>
> On 12/13/06, Linus Torvalds <torvalds@osdl.org> wrote:
> > Ok, what kind of ass-hat idiotic thing is this?
>
> C'mon, Linus, tell us how you _really_ feel.

I'll try to be less subtle next time ;)

> Seriously, though, please please pretty please do not allow a facility
> for "going through a simple interface to get accesses to irqs and
> memory regions" into the mainline kernel, with or without toy ISA
> examples.

I do agree.

I'm not violently opposed to something like this in practice (we've
already allowed it for USB devices), but there definitely needs to be a
real reason that helps _us_, not just some ass-hat vendor that looks for a
way to avoid open-sourcing their driver.

If there are real and valid uses (and as mentioned, I actually think that
the whole graphics-3D-engine-thing is such a use) where a kernel driver
simply doesn't work out well, or where there are serious tecnical reasons
why it wants to be in user space (and "stability" is not one such thing:
if you access hardware directly in user space, and your driver is buggy,
the machine is equally deal, and a hell of a lot harder to control to
boot).

Microkernel people have their heads up their arses, none of their
arguments have actually ever made any real logical sense. So look
elsewhere for real reasons to do it in user space.

Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PATCH] more Driver core patches for 2.6.19 [ In reply to ]
On Wed, 13 Dec 2006, Linus Torvalds wrote:
>
> Btw: there's one driver we _know_ we want to support in user space, and
> that's the X kind of direct-rendering thing. So if you can show that this
> driver infrastructure actually makes sense as a replacement for the DRI
> layer, then _that_ would be a hell of a convincing argument.

Btw, the other side of this argument is that if a user-space driver
infrastructure can _not_ help the DRI kind of situation, then it's largely
by definition not interesting. Merging something like that would just mean
that we end up with multiple _different_ user-space helper infrastructure
shells, which sounds distinctly unpalatable.

Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PATCH] more Driver core patches for 2.6.19 [ In reply to ]
> Ok, what kind of ass-hat idiotic thing is this?
>
> irqreturn_t uio_irq_handler(int irq, void *dev_id)
> {
> return IRQ_HANDLED;
> }
>
> exactly what is the point here? No way will I pull this kind of crap. You
> just seem to have guaranteed a dead machine if the irq is level-triggered,
> since it will keep on happening forever.
>
> Please remove.
>
> YOU CANNOT DO IRQ'S BY LETTING USER SPACE SORT IT OUT!

Actually, you can... but wether you want is a different story :-)

You can simply mask it, have it handled by userspace and re-enable it
when that's done. Though say hello to horrible interrupt latencies and
hope you aren't sharing it with anything critical...

I don't mean I -like- the approach... I just say it can be made to
sort-of work. But I don't see the point.

Ben.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PATCH] more Driver core patches for 2.6.19 [ In reply to ]
On Wed, 2006-12-13 at 13:08 -0800, Linus Torvalds wrote:
>
> On Wed, 13 Dec 2006, Linus Torvalds wrote:
> >
> > Btw: there's one driver we _know_ we want to support in user space, and
> > that's the X kind of direct-rendering thing. So if you can show that this
> > driver infrastructure actually makes sense as a replacement for the DRI
> > layer, then _that_ would be a hell of a convincing argument.
>
> Btw, the other side of this argument is that if a user-space driver
> infrastructure can _not_ help the DRI kind of situation, then it's largely

with DRI you have the case where "something" needs to do security
validation of the commands that are sent to the card. (to avoid a
non-privileged user to DMA all over your memory)

That and a tiny bit of resource management is the bulk of the kernel DRM
code... and I don't think userspace can do it fundamentally better.
Sure you could pipe things to a root daemon instead of doing a system
call. But I don't see that being superior.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PATCH] more Driver core patches for 2.6.19 [ In reply to ]
>You can simply mask it, have it handled by userspace and re-enable it
>when that's done. Though say hello to horrible interrupt latencies and
>hope you aren't sharing it with anything critical...

For the sharing case, some sort of softirq should be created. That is, when a
hard interrupt is generated and the irq handler is executed, set a flag that at
some other point in time, the irq is delivered to userspace. Like you do with
signals in userspace:

void sighandler(int s) {
exit_main_loop_soon = 1;
}

something similar could be done in kernelspace without interrupting important
devices/irq_handlers sharing the same IRQ.


-`J'
--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PATCH] more Driver core patches for 2.6.19 [ In reply to ]
On Thu, 14 Dec 2006, Benjamin Herrenschmidt wrote:
>
> Actually, you can... but wether you want is a different story :-)
>
> You can simply mask it, have it handled by userspace and re-enable it
> when that's done.

Nope. Again, this whole mentality is WRONG.

It DOES NOT WORK. No architecture does per-device interrupts portably,
which means that you'll always see sharing.

And once you see sharing, you have small "details" like the harddisk
interrupt or network interrupt that the user-land driver will depend on.

Oops. Instant deadlock.

> I don't mean I -like- the approach... I just say it can be made to
> sort-of work. But I don't see the point.

No. The point really is that it fundamentally _cannot_ work. Not in the
real world.

It can only work in some alternate reality where you can always disable
interrupts per-device, and even in that alternate reality it would be
wrong to use that quoted interrupt handler: not only do you need to
disable the irq, you need to have an "acknowledge" phase too

So you'd actually have to fix things _architecturally_, not just add some
code to the irq handler.

Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PATCH] more Driver core patches for 2.6.19 [ In reply to ]
Greg KH wrote:
> On Wed, Dec 13, 2006 at 12:38:05PM -0800, Michael K. Edwards wrote:
>> Seriously, though, please please pretty please do not allow a facility
>> for "going through a simple interface to get accesses to irqs and
>> memory regions" into the mainline kernel, with or without toy ISA
>> examples.
>
> Why? X does it today :)

Umm ... and you're trying to use the current X model for a positive
example of what we should be doing? that's ... interesting.

>> Embedded systems integrators have enough trouble with chip vendors who
>> think that exposing the device registers to userspace constitutes a
>> "driver".
>
> Yes, and because of this, they create binary only drivers today. Lots
> of them. All over the place. Doing crazy stupid crap in kernelspace.

So let's come out and ban binary modules, rather than pussyfooting
around, if that's what we actually want to do.

It comes down to a question of whether we have enough leverage to push
them into doing what we want, or not - are we prepared to call their
bluff?

The current half-assed solution of chipping slowly away at things by
making them EXPORT_SYMBOL_GPL one by one makes little sense - would
be better if we actually made an affirmative decision one way or the
other. And yes, I know which side of that argument you'd fall on ;-)

> Again, X does this today, and does does lots of other applications.
> This is a way to do it in a sane manner, to keep people who want to do
> floating point out of the kernel, and to make some embedded people much
> happier to use Linux, gets them from being so mad at Linux because we
> keep changing the internal apis, and makes me happier as they stop
> violating my copyright by creating closed drivers in the kernel.

I don't see how this really any different than letting them create
GPL shims to export data to binary modules (aside from all the legal
wanking over minutae details, which really isn't that interesting).

M.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PATCH] more Driver core patches for 2.6.19 [ In reply to ]
On Wed, 2006-12-13 at 12:58 -0800, Linus Torvalds wrote:
> In other words, I'd like to see code that uses this that is actually
> _better_ than an in-kernel driver in some way.
>
> For USB, the user-mode thing made sense. You have tons of random devices,
> and the abstraction level is higher to begin with. Quite frankly, I simply
> don't even see the same being true for something like this.

We started to work on this for industrial I/O devices. Many of them are
dual port memory based, others are dedicated chips for motion control or
field busses.

The design requires to have an in kernel stub driver with interrupt
handler which is capable to handle shared interrupts. User space
_cannot_ override an irq_disable(), it just has access to the chip
registers of the device, which is possible right now as well.

The risk, that such a driver stalls the kernel is exactly the same as
the risk you have with any other badly written driver.

This is a real world example of such a drivers interrupt handler:

/*
* The chip specific portion of the interrupt handler. The framework code
* takes care of userspace notification when we return IRQ_HANDLED
*/
static irqreturn_t sercos_handler(int irq, void *dev_id, struct pt_regs *reg)
{
/* Check, if this interrupt is originated from the SERCOS chip */
if (!(sercos_read(IRQ_STATUS) & SERCOS_INTERRUPT_MASK))
return IRQ_NONE;

/* Acknowledge the chip interrupts */
sercos_write(IRQ_ACK1, SERCOS_INTERRUPT_ACK1);
sercos_write(IRQ_ACK2, SERCOS_INTERRUPT_ACK2);

return IRQ_HANDLED;
}

With a full kernel driver we need:

1. Interrupt handler
check interrupt
acknowledge interrupt
copy data from/to chip into a kernel buffer
wakeup user space task
2. read data from driver, which goes through copy to user
3. do calculations
4. write data to driver, which goes through copy from user

After changing the driver concept we have only:
1. Interrupt handler
check interrupt
acknowledge interrupt
wakeup user space task
2. User space task handles the mmaped chip directly

The change gave a serious performance gain in the range of 20% after the
application was optimized for dealing with the chip directly.

There are tons of such exotic hardware devices out there, which now have
either a closed source driver or an out of tree patch with an horrible
amount of individual ioctl functions to get to the same point with less
performance.

> Btw: there's one driver we _know_ we want to support in user space, and
> that's the X kind of direct-rendering thing. So if you can show that this
> driver infrastructure actually makes sense as a replacement for the DRI
> layer, then _that_ would be a hell of a convincing argument.

I did not look closely into that, but I think that it is a valid usage
candidate. The interface of graphic cards is user space mappable and it
probably needs some interrupt handling + notification mechanism as well
as the devices mentioned above.

tglx


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PATCH] more Driver core patches for 2.6.19 [ In reply to ]
> Btw: there's one driver we _know_ we want to support in user space, and
> that's the X kind of direct-rendering thing. So if you can show that this
> driver infrastructure actually makes sense as a replacement for the DRI
> layer, then _that_ would be a hell of a convincing argument.

And even X is trying to move away from that at least partially... With
the DRI driver handling IRQs and processing command buffers... except
for cards with multiple hardware contexts, but then, we are in a case
similar to Infiniband where the HW is -designed- to have specific areas
mapped into user space, and there is still a kernel driver to arbitrate,
decide who gets what, establish those mappings, etc...

Thus X isn't even a good example :-)

Ben.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PATCH] more Driver core patches for 2.6.19 [ In reply to ]
On Wed, 13 Dec 2006 13:32:50 -0800
Martin Bligh <mbligh@mbligh.org> wrote:

> So let's come out and ban binary modules, rather than pussyfooting
> around, if that's what we actually want to do.

Give people 12 months warning (time to work out what they're going to do,
talk with the legal dept, etc) then make the kernel load only GPL-tagged
modules.

I think I'd favour that. It would aid those people who are trying to
obtain device specs, and who are persuading organisations to GPL their drivers.

(Whereas the patch which is proposed in this thread hinders those people)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PATCH] more Driver core patches for 2.6.19 [ In reply to ]
On 12/13/06, Greg KH <gregkh@suse.de> wrote:
> On Wed, Dec 13, 2006 at 12:38:05PM -0800, Michael K. Edwards wrote:
> > Seriously, though, please please pretty please do not allow a facility
> > for "going through a simple interface to get accesses to irqs and
> > memory regions" into the mainline kernel, with or without toy ISA
> > examples.
>
> Why? X does it today :)

Er, I rest my case? Anyway, the history around X11 is completely
different from the present situation, and there were good arguments at
the time for structuring the problem so that the X server was
relatively kernel-neutral even if it was banging directly on a
framebuffer, and later on 2-D acceleration hardware. As graphics
chips have become more sophisticated, pure-userspace X11 has become
less tenable.

> > Embedded systems integrators have enough trouble with chip vendors who
> > think that exposing the device registers to userspace constitutes a
> > "driver".
>
> Yes, and because of this, they create binary only drivers today. Lots
> of them. All over the place. Doing crazy stupid crap in kernelspace.

It does not get less crazy and stupid because we open a big hole from
kernelspace to userspace and let them pretend that they have a GPL
"driver" when all of the chip init logic is peeked and poked from the
same closed code in userspace. Most low-level drivers (the kind that
involve IRQs and registers local to the CPU; USB is different) cannot
be done right from userspace and we shouldn't encourage people to try.

> Then there are people who do irq stuff in userspace but get it wrong.
> I've seen that happen many times in lots of different research papers
> and presentations.

Their problems need not become our problems.

> This interface does it correctly, and it allows those people who for
> some reason feel they do want to keep their logic in non-gpl code, to do
> it.

People who want to keep their logic in non-GPL code do so by providing
binary-only drivers. That's a sane compromise in certain sectors, and
occasionally results in the eventual opening of the driver (when the
illusion of competitive advantage in closed-ness wears off) in
integrable shape. A customer with some leverage and technical skill
can negotiate for access to the source code so that he can fix the
bugs that are biting him, rebuild with a toolchain that isn't from the
Dark Ages, and so forth: a real-life demonstration to the vendor that
letting outsiders work on the code will sell more chips. But if you
actively encourage a brain-damaged userspace driver strategy, that
opportunity is lost.

> It also allows code that needs floating point to not be in the kernel
> and in one instance using this interface actually sped up the device
> because of the lack of the need to go between kernel and userspace a
> bunch of times.

What instance is that? Are you sure it wasn't a case of things being
done in the driver that should have been done in a library all along?

> > The correct description is more like "porting shim for MMU-less RTOS
> > tasks"; and if the BSP vendors of the world can make a nickel
> > supplying them, more power to them. Just not in mainline, please.
>
> Again, X does this today, and does does lots of other applications.
> This is a way to do it in a sane manner, to keep people who want to do
> floating point out of the kernel, and to make some embedded people much
> happier to use Linux, gets them from being so mad at Linux because we
> keep changing the internal apis, and makes me happier as they stop
> violating my copyright by creating closed drivers in the kernel.

Today's problem is that too many chip suppliers' in-house software
people have neither the skills nor the schedule room nor the influence
to insist that drivers be written competently and maintainably,
whether or not they are maintained in the public view. So chipmakers
turn to the BSP vendors, whose business model is built around being
the only people who can do incremental development on the code they
write.

I'm not at all hostile to BSP vendors or to chipmakers who wind up in
this position; that's the way most of the industry works nowadays.
But I do want to know when I'm dealing with that situation, because
the appropriate strategies for getting a product to market are
different when it costs the chip vendor real cash money each time they
commission a recompile to meet some customer's expectations.
Pretending that driver code doesn't need reviewing every few months as
the kernel's locking strategies, timer handling, internal APIs, etc.
evolve makes things worse.

Just like the only thing worse that a salesperson who's on commission
is a salesperson who isn't on commission, the only thing worse than a
closed device driver in kernelspace is a closed device driver in
userspace.

Cheers,
- Michael
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PATCH] more Driver core patches for 2.6.19 [ In reply to ]
> No. The point really is that it fundamentally _cannot_ work. Not in the
> real world.
>
> It can only work in some alternate reality where you can always disable
> interrupts per-device, and even in that alternate reality it would be
> wrong to use that quoted interrupt handler: not only do you need to
> disable the irq, you need to have an "acknowledge" phase too
>
> So you'd actually have to fix things _architecturally_, not just add some
> code to the irq handler.

Oh, it works well enough for non shared iqs if you are really anal about
it, but I agree that it sucks and I don't see the point of having it in
linux. The flow has to be different for level vs. edge and it's really
ugly but it works. I've seen people doing it in embedded space. But
again, I do agree it sucks big time :-)

the edge flow is easy. the level one is:

- IRQ happens
- kernel handler masks it and queue a msg for userland
- later on, userland gets the message, talks to the device,
(MMAP'ed mmio, acks the interrupt on the device itself) and
does an ioctl/syscall/write/whatever to tell kernel it's done
- kernel unmasks it.

But yeah, I hate it too, so let's not waste time talking about how to
make it work :-)

Ben.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PATCH] more Driver core patches for 2.6.19 [ In reply to ]
On 12/13/06, Andrew Morton <akpm@osdl.org> wrote:
> On Wed, 13 Dec 2006 13:32:50 -0800
> Martin Bligh <mbligh@mbligh.org> wrote:
>
> > So let's come out and ban binary modules, rather than pussyfooting
> > around, if that's what we actually want to do.
>
> Give people 12 months warning (time to work out what they're going to do,
> talk with the legal dept, etc) then make the kernel load only GPL-tagged
> modules.

IIRC, Linus has deliberately and explicitly estopped himself from
claiming that loading a binary-only driver is a GPL violation. Do you
really want to create an arbitrage opportunity for intermediaries who
undo technical measures that don't match Linus's declared policy or,
in many people's opinion, the law in at least some jurisdictions?
(I'm not going to go all amateur-lawyer on you, but the transcript of
oral argument at the Supreme Court level in Lotus v. Borland makes
really interesting reading no matter where you live or what your
stance is on GPL-and-linking.)

> I think I'd favour that. It would aid those people who are trying to
> obtain device specs, and who are persuading organisations to GPL their drivers.

I don't think it would. There is a strong argument that GPL drivers
in the mainline kernel are a good idea on technical and business
grounds. Making a federal case out of it is a distraction at best.

There is a widespread delusion that closed driver code is an asset in
an accounting sense. It costs a lot of money to create and even more
to maintain in any kind of usable condition. As long as managers of
chip development projects get away with shifting some of the real cost
of creating yet another buggy undocumented one-off CPU interface onto
a "software" team in a different cost center, the pressure to label
the code base an intangible asset is overwhelming. It usually takes a
reorg or two to diffuse the responsibility enough to call it a sunk
cost, at which point someone might be brave enough to argue that
opening it up would save money and/or sell more chips.

As things stand, there is a slippery slope (in a good way) from a
totally-closed, one-off, buggy vendor driver to a GPL'ed driver in the
mainline kernel. Customers get impatient for drivers that work, the
vendor allows a customer or a mutually acceptable third party to work
on the code, the sky doesn't fall. There are some situations where
the business strategy of keeping the driver closed is defensible on
both engineering and regulatory/barrier-to-entry grounds, but they're
fairly rare; and some fraction of vendors come around to that view in
time.

> (Whereas the patch which is proposed in this thread hinders those people)

There we agree.

Cheers,
- Michael
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PATCH] more Driver core patches for 2.6.19 [ In reply to ]
On Thu, 2006-12-14 at 09:14 +1100, Benjamin Herrenschmidt wrote:
> the edge flow is easy. the level one is:
>
> - IRQ happens
> - kernel handler masks it and queue a msg for userland
> - later on, userland gets the message, talks to the device,
> (MMAP'ed mmio, acks the interrupt on the device itself) and
> does an ioctl/syscall/write/whatever to tell kernel it's done
> - kernel unmasks it.

That's simply not true.

- IRQ happens
- kernel handler runs and masks the chip irq, which removes the IRQ
request
- user space message get queued or waiting reader woken
- kernel handler returns IRQ_HANDLED, which reenables the irq in the PIC
- user space handles the device
- user space reenables the device irq

No need for an ioctl. Neither for edge nor for level irqs.

tglx


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PATCH] more Driver core patches for 2.6.19 [ In reply to ]
On Wed, 2006-12-13 at 23:30 +0100, Thomas Gleixner wrote:
> On Thu, 2006-12-14 at 09:14 +1100, Benjamin Herrenschmidt wrote:
> > the edge flow is easy. the level one is:
> >
> > - IRQ happens
> > - kernel handler masks it and queue a msg for userland
> > - later on, userland gets the message, talks to the device,
> > (MMAP'ed mmio, acks the interrupt on the device itself) and
> > does an ioctl/syscall/write/whatever to tell kernel it's done
> > - kernel unmasks it.
>
> That's simply not true.
>
> - IRQ happens
> - kernel handler runs and masks the chip irq, which removes the IRQ
> request
> - user space message get queued or waiting reader woken
> - kernel handler returns IRQ_HANDLED, which reenables the irq in the PIC
> - user space handles the device
> - user space reenables the device irq
>
> No need for an ioctl. Neither for edge nor for level irqs.

Wait wait wait... your scenario implies that the kernel has knowledge of
the chip to mask the irq in the chip in the first place.

If that is the case, then you have a chip specific kernel driver,
yadada, the whole story is moot :-)

We were talking about the idea of having some "generic" reflector of
irqs to userspace without device specific knowledge.

Ben.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PATCH] more Driver core patches for 2.6.19 [ In reply to ]
On Thu, 2006-12-14 at 09:14 +1100, Benjamin Herrenschmidt wrote:
> Oh, it works well enough for non shared iqs if you are really anal about

It works well for shared irqs. Thats the whole reason why you need an in
kernel part.

tglx


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PATCH] more Driver core patches for 2.6.19 [ In reply to ]
On Wed, 2006-12-13 at 23:40 +0100, Thomas Gleixner wrote:
> On Thu, 2006-12-14 at 09:14 +1100, Benjamin Herrenschmidt wrote:
> > Oh, it works well enough for non shared iqs if you are really anal about
>
> It works well for shared irqs. Thats the whole reason why you need an in
> kernel part.

As soon as you have an in-kernel part that is chip specific, yes, of
course it works, because essentially, what you have done is a kernel
driver for your chip and the whole discussion is moot :-) And I agree,
that's the right thing to do btw.

Ben.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PATCH] more Driver core patches for 2.6.19 [ In reply to ]
On Dec 13, 2006, at 17:20:35, Michael K. Edwards wrote:
> On 12/13/06, Andrew Morton <akpm@osdl.org> wrote:
>> On Wed, 13 Dec 2006 13:32:50 -0800 Martin Bligh
>> <mbligh@mbligh.org> wrote:
>>> So let's come out and ban binary modules, rather than
>>> pussyfooting around, if that's what we actually want to do.
>>
>> Give people 12 months warning (time to work out what they're going
>> to do, talk with the legal dept, etc) then make the kernel load
>> only GPL-tagged modules.
>
> IIRC, Linus has deliberately and explicitly estopped himself from
> claiming that loading a binary-only driver is a GPL violation. Do
> you really want to create an arbitrage opportunity for
> intermediaries who undo technical measures that don't match Linus's
> declared policy or, in many people's opinion, the law in at least
> some jurisdictions? (I'm not going to go all amateur-lawyer on you,
> but the transcript of oral argument at the Supreme Court level in
> Lotus v. Borland makes really interesting reading no matter where
> you live or what your stance is on GPL-and-linking.)

Ok, so what Linus said is true for any code that _Linus_ wrote up
until this point. It is perfectly fine for the iptables developers
to say "I think linking with my GPL IPTables code for makes your code
a derivative work of mine", although I don't really have the legal
knowledge to argue technical points either way.

Corporations change their mind on licensing all the time; though you
can never revoke privileges you already granted on existing
materials. As soon as you start creating new material (in the Linux
case at a rate of multiple megs per month) you can set new licensing
requirements on that new code as long as it's compatible with the
requirements on the old code which it's linked against.

Cheers,
Kyle Moffett

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PATCH] more Driver core patches for 2.6.19 [ In reply to ]
On Thu, 2006-12-14 at 09:39 +1100, Benjamin Herrenschmidt wrote:
> > No need for an ioctl. Neither for edge nor for level irqs.
>
> Wait wait wait... your scenario implies that the kernel has knowledge of
> the chip to mask the irq in the chip in the first place.
>
> If that is the case, then you have a chip specific kernel driver,
> yadada, the whole story is moot :-)
>
> We were talking about the idea of having some "generic" reflector of
> irqs to userspace without device specific knowledge.

Which simply is not possible, especially for shared irqs.

Can you please elaborate why this effort is moot, instead of throwing
the usual flamewar arguments around ?

The concept of UIO divides the problem in two spaces:

- kernel interface, which controls interrupts and mapping
- user space restricted interface

I don't see why the necessarity of a kernel stub driver is a killer
argument. The chip internals, which companies might want to protect are
certainly not in the interrupt registers.

Aside of that there are huge performance gains for certain application /
driver scenarios and I really don't see an advantage that people are
doing excactly the same thing in out of tree hackeries with a lot of
inconsistent user land interfaces.

tglx



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

1 2 3  View All