Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux: Kernel

[GIT PATCH] more Driver core patches for 2.6.19

 

 

First page Previous page 1 2 3 Next page Last page  View All Linux kernel RSS feed   Index | Next | Previous | View Threaded


tglx at linutronix

Dec 13, 2006, 3:15 PM

Post #26 of 68 (8547 views)
Permalink
Re: [GIT PATCH] more Driver core patches for 2.6.19 [In reply to]

On Thu, 2006-12-14 at 09:45 +1100, Benjamin Herrenschmidt wrote:
> 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.

Still the framework has a benefit, as it removes the bunch of
incompatible out of tree attempts to achieve the same result.

tglx


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


torvalds at osdl

Dec 13, 2006, 3:28 PM

Post #27 of 68 (8548 views)
Permalink
Re: [GIT PATCH] more Driver core patches for 2.6.19 [In reply to]

On Wed, 13 Dec 2006, Jan Engelhardt wrote:
>
> 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:

NO.

The whole point is, YOU CANNOT DO THIS.

You need to shut the device up. Otherwise it keeps screaming.

Please, people, don't confuse the issue any further. A hardware driver

ABSOLUTELY POSITIVELY HAS TO

have an in-kernel irq handler that knows how to turn the irq off.

End of story. No ifs, buts, maybes about it.

You cannot have a generic kernel driver that doesn't know about the
low-level hardware (not with current hardware - you could make the "shut
the f*ck up" a generic thing if you designed hardware properly, but that
simply does not exist in general right now).

In short: a user-space device driver has exactly TWO choices:

- don't use interrupts at all, just polling

- have an in-kernel irq handler that at a minimum knows how to test
whether the irq came from that device and knows how to shut it up.

This means NOT A GENERIC DRIVER. That simply isn't an option on the
table, no matter how much people would like it to be.

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


medwards.linux at gmail

Dec 13, 2006, 3:39 PM

Post #28 of 68 (8564 views)
Permalink
Re: [GIT PATCH] more Driver core patches for 2.6.19 [In reply to]

On 12/13/06, Thomas Gleixner <tglx [at] linutronix> wrote:
> 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.

Greg's effort is noble but I think it is targeted at the wrong problem
and would actually make things worse. Inconsistent interfaces from
one "driver" to another are the surface design flaw that obscures the
fundamental design flaw of exposing hardware to userland: abdication
of the driver writer's responsibility to choose and justify which
things belong in the driver and which belong in a hardware-agnostic
driver framework or a userspace library instead.

When you are talking about unique, one-off hardware, it doesn't really
matter whether the shim for a closed, out-of-tree, userspace driver
fits into a framework or not. Who cares whether they use the
preferred MMIO reservation paths or just throw ioctl(POKE_ME_HARDER)
or mmap(/dev/mem) at the problem? But I don't want to see ALSA or
iwconfig or i2c-core or any of the other competently designed and
implemented driver frameworks mangled into unusability by attempts to
facilitate this "design pattern".

Truth in advertising is an advantage even if it doesn't change the
underlying reality. I can (and do) tell chip vendors, "that's not a
driver, that's a shim for some other customer's pre-existing eCos
task", and justify the cost of writing an actual driver to the client.
I may or may not succeed in arguing that the new driver should be
designed to an existing API when that means rethinking the userspace
app, or that it should be implemented against a current kernel and
offered promptly up to the appropriate Linus lieutenant. But at least
the project isn't crippled by confusion about whether or not the
existing blob constitutes a driver.

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


gregkh at suse

Dec 13, 2006, 3:40 PM

Post #29 of 68 (8574 views)
Permalink
Re: [GIT PATCH] more Driver core patches for 2.6.19 [In reply to]

On Wed, Dec 13, 2006 at 12:58:24PM -0800, Linus Torvalds wrote:
> 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.

Ok, Thomas just showed at least one example of where this interface is a
big advantage over the all-in-kernel model. I'll work with him and try
to dig up other real examples before submitting this code again.

In the mean time, I'll leave it in my tree and it will get some more
exposure in the -mm releases.

> So please push the tree without this userspace IO driver at all.

Done.

Please pull from:
master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6.git/

It contains the changes listed below.

thanks,

greg k-h


drivers/base/class.c | 2 ++
drivers/base/platform.c | 4 ++--
fs/debugfs/inode.c | 39 ++++++++++++++++++++++++++++++---------
include/linux/platform_device.h | 2 +-
kernel/module.c | 25 +++++++++++++++++++++++++
kernel/power/Kconfig | 9 +++++----
6 files changed, 65 insertions(+), 16 deletions(-)

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

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

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 [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


alan at lxorguk

Dec 13, 2006, 3:55 PM

Post #30 of 68 (8574 views)
Permalink
Re: [GIT PATCH] more Driver core patches for 2.6.19 [In reply to]

> IIRC, Linus has deliberately and explicitly estopped himself from
> claiming that loading a binary-only driver is a GPL violation. Do you

He only owns a small amount of the code. Furthermore he imported third
party GPL code using the license as sole permission. So he may have dug a
personal hole but many of the rest of us have been repeatedly saying
whenever he said that - that we do not agree. The FSF has always said
binary modules are wrong and there is FSF code imported into the kernel
by Linus on license only grounds.

Whether it is a good idea is a different question.

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


alan at lxorguk

Dec 13, 2006, 3:56 PM

Post #31 of 68 (8549 views)
Permalink
Re: [GIT PATCH] more Driver core patches for 2.6.19 [In reply to]

On Wed, 13 Dec 2006 23:30:55 +0100
Thomas Gleixner <tglx [at] linutronix> wrote:

> - IRQ happens
> - kernel handler runs and masks the chip irq, which removes the IRQ
> request

IRQ is shared with the disk driver, box dead. Plus if this is like the
uio crap in -mm its full of security holes.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


alan at lxorguk

Dec 13, 2006, 4:00 PM

Post #32 of 68 (8559 views)
Permalink
Re: [GIT PATCH] more Driver core patches for 2.6.19 [In reply to]

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

So they can go off and write themselves a driver. Without putting junk in
the kernel "just in case", and if the driver and the user space code
using it are closely interdependant I'd suggest they look up the *legal*
definition of derivative work.

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


gregkh at suse

Dec 13, 2006, 4:08 PM

Post #33 of 68 (8557 views)
Permalink
Re: [GIT PATCH] more Driver core patches for 2.6.19 [In reply to]

On Wed, Dec 13, 2006 at 11:56:01PM +0000, Alan wrote:
> On Wed, 13 Dec 2006 23:30:55 +0100
> Thomas Gleixner <tglx [at] linutronix> wrote:
>
> > - IRQ happens
> > - kernel handler runs and masks the chip irq, which removes the IRQ
> > request
>
> IRQ is shared with the disk driver, box dead. Plus if this is like the
> uio crap in -mm its full of security holes.

All of those security holes should now be taken care of, as all of the
nasty memory stuff has been either cleaned up or ripped out.

Please take a look at the most recent stuff (thomas just mentioned to me
on irc that he has a few more minor fixes for it) and let me know if you
still see any problems.

thanks,

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


viro at ftp

Dec 13, 2006, 6:11 PM

Post #34 of 68 (8548 views)
Permalink
Re: [GIT PATCH] more Driver core patches for 2.6.19 [In reply to]

On Wed, Dec 13, 2006 at 11:55:00PM +0000, Alan wrote:
> > IIRC, Linus has deliberately and explicitly estopped himself from
> > claiming that loading a binary-only driver is a GPL violation. Do you
>
> He only owns a small amount of the code. Furthermore he imported third
> party GPL code using the license as sole permission. So he may have dug a
> personal hole but many of the rest of us have been repeatedly saying
> whenever he said that - that we do not agree. The FSF has always said
> binary modules are wrong and there is FSF code imported into the kernel
> by Linus on license only grounds.
>
> Whether it is a good idea is a different question.

Wait a bloody minute - the only FSF code in the kernel I know of is from
libgcc, which does allow linking to non-GPL code. Is there anything else?
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


duncan.sands at math

Dec 14, 2006, 12:49 AM

Post #35 of 68 (8503 views)
Permalink
Re: [GIT PATCH] more Driver core patches for 2.6.19 [In reply to]

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

Qemu? It would be nice if emulators could directly drive hardware:
useful for reverse engineering windows drivers for example.

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


tglx at linutronix

Dec 14, 2006, 1:15 AM

Post #36 of 68 (8512 views)
Permalink
Re: [GIT PATCH] more Driver core patches for 2.6.19 [In reply to]

On Wed, 2006-12-13 at 23:56 +0000, Alan wrote:
> On Wed, 13 Dec 2006 23:30:55 +0100
> Thomas Gleixner <tglx [at] linutronix> wrote:
>
> > - IRQ happens
> > - kernel handler runs and masks the chip irq, which removes the IRQ
> > request
>
> IRQ is shared with the disk driver, box dead.

Err ?

IRQ happens

IRQ is disabled by the generic handling code

Handler is invoked and checks, whether the irq is from the device or
not.
- If not, it returns IRQ_NONE, so the next driver (e.g. disk) is
invoked.
- If yes, it masks the chip on the device, which disables the chip
interrupt line and returns IRQ_HANDLED.

In both cases the IRQ gets reenabled from the generic irq handling code
on return, so why is the box dead ?

tglx


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


muli at il

Dec 14, 2006, 1:30 AM

Post #37 of 68 (8534 views)
Permalink
Re: [GIT PATCH] more Driver core patches for 2.6.19 [In reply to]

On Wed, Dec 13, 2006 at 10:15:47PM +0100, Arjan van de Ven wrote:

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

We also have the interesting case where your card is behind an
isolation-capable IOMMU, so if you let userspace program it, you need
a userspace-accessible DMA-API for IOMMU mappings (or to pre-map
everything in the IOMMU, which loses on some of the benefits of
isolation-capable IOMMUs (i.e., only map what you need to use right
now)).

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


hjk at linutronix

Dec 14, 2006, 1:56 AM

Post #38 of 68 (8526 views)
Permalink
Re: [GIT PATCH] more Driver core patches for 2.6.19 [In reply to]

Am Donnerstag, 14. Dezember 2006 09:49 schrieb Duncan Sands:
> > 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.
>
> Qemu? It would be nice if emulators could directly drive hardware:
> useful for reverse engineering windows drivers for example.

I really think there is a big misunderstanding in this whole discussion.
Userspace IO (UIO) was never intended to be a generic userspace
interface to all kinds of hardware. I completely agree with Linus and all
others who expressed that opinion that a full-fledged kernel module is the,
let's say, most beautiful way of writing a driver. But it's not always the
best way. Let's look at a real world example:

A small German manufacturer produces high-end AD converter cards. He sells
100 pieces per year, only in Germany and only with Windows drivers. He would
now like to make his cards work with Linux. He has two driver programmers
with little experience in writing Linux kernel drivers. What do you tell him?
Write a large kernel module from scratch? Completely rewrite his code
because it uses floating point arithmetics?

And even if they did that, do we really want it? Do we want to add large
kernel modules for each exotic card? With UIO, everything becomes much cleaner:

* They let somebody write the small kernel module they need to handle
interrupts in a _clean_ way. This module can easily be checked and could
even be included in a mainline kernel.

* They do the rest in userspace, with all the libraries and tools they're
used to. That's what they _can_ do.

Note that this is a _technical_ reason. I'm not talking about all that
licensing possibilities that were discussed here.

UIO's intention is to allow manufacturers of industrial IO hardware to
support Linux without the need to hire half a dozen experienced kernel
developers. It makes their kernels more stable and easier to maintain.
We don't get flooded with requests to include large modules for exotic
hardware into the mainline kernel.

The alternative is what we have at the moment: Manufacturers don't support
Linux at all, because it's too difficult to handle for them, or they do
it in a way that either violates our licence or leads to unstable
customized kernels (or both).

So, your qemu suggestion is certainly interesting. But, really, we never
thought of such a general thing while we were working at that code.
I thought I had to make that clear. Reading this thread, one could get
the impression we wanted to start a revolution and handle all hardware
in userspace from now on. This is definetly wrong.

Hans

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


hjk at linutronix

Dec 14, 2006, 2:13 AM

Post #39 of 68 (8525 views)
Permalink
Re: [GIT PATCH] more Driver core patches for 2.6.19 [In reply to]

Am Donnerstag, 14. Dezember 2006 10:30 schrieb Muli Ben-Yehuda:
> On Wed, Dec 13, 2006 at 10:15:47PM +0100, Arjan van de Ven wrote:
>
> > 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)
>
> We also have the interesting case where your card is behind an
> isolation-capable IOMMU, so if you let userspace program it, you need
> a userspace-accessible DMA-API for IOMMU mappings (or to pre-map
> everything in the IOMMU, which loses on some of the benefits of
> isolation-capable IOMMUs (i.e., only map what you need to use right
> now)).

Userspace IO (UIO) was never intended to replace all kinds of possible
drivers. We wanted to address the situation where a manufacturer of
industrial I/O cards wants to do a large part of his driver in userspace
to simplify his development process. That's all.
Most of these I/O cards have registers or dual ported RAM that can be
mapped to userspace. This is possible with a standard kernel and is done
every day. Problem is that you can't handle interrupts. UIO simply adds
this capability and offers a standardized interface.
The code Greg added to his tree can do this for most hardware found
on industrial IO boards. That's all we wanted to achieve for now. If
somebody wants to support more sophisticated things, suggestions are
welcome.

Hans

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


jengelh at linux01

Dec 14, 2006, 3:18 AM

Post #40 of 68 (8519 views)
Permalink
Re: [GIT PATCH] more Driver core patches for 2.6.19 [In reply to]

>> 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:
>
>NO.
>
>The whole point is, YOU CANNOT DO THIS.
>
>You need to shut the device up. Otherwise it keeps screaming.
>
>Please, people, don't confuse the issue any further. A hardware driver
>
> ABSOLUTELY POSITIVELY HAS TO
>
>have an in-kernel irq handler that knows how to turn the irq off.
>
>End of story. No ifs, buts, maybes about it.

I don't get you. The rtc module does something similar (RTC generates
interrupts and notifies userspace about it)


irqreturn_t uio_handler(...) {
disable interrupts for this dev;
set a flag that notifies userspace the next best time;
seomstruct->flag |= IRQ_ARRIVED;
return IRQ_HANDLED;
}


/* Userspace->kernel notification, e.g. by means of a device node
/dev/uio or some ioctl. */
int uio_write(...) {
somestruct->flag &= ~IRQ_ARRIVED;
enable interrupts for the device;
}



> - have an in-kernel irq handler that at a minimum knows how to test
> whether the irq came from that device and knows how to shut it up.
>
>This means NOT A GENERIC DRIVER. That simply isn't an option on the
>table, no matter how much people would like it to be.


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


jengelh at linux01

Dec 14, 2006, 3:26 AM

Post #41 of 68 (8517 views)
Permalink
Re: [GIT PATCH] more Driver core patches for 2.6.19 [In reply to]

> irqreturn_t uio_handler(...) {
> disable interrupts for this dev;
> set a flag that notifies userspace the next best time;
> seomstruct->flag |= IRQ_ARRIVED;
> return IRQ_HANDLED;
> }

Rather than IRQ_HANDLED, it should have been: remove this irq handler
from the irq handlers for irq number N, so that it does not get called
again until userspace has acked it.

See, maybe I don't have enough clue yet to exactly figure out why you
say it does not work. However, this is how simple people see it 8)


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


alan at lxorguk

Dec 14, 2006, 3:33 AM

Post #42 of 68 (8534 views)
Permalink
Re: [GIT PATCH] more Driver core patches for 2.6.19 [In reply to]

> > IRQ is shared with the disk driver, box dead.
>
> Err ?
>
> IRQ happens
>
> IRQ is disabled by the generic handling code
>
> Handler is invoked and checks, whether the irq is from the device or
> not.
> - If not, it returns IRQ_NONE, so the next driver (e.g. disk) is
> invoked.
> - If yes, it masks the chip on the device, which disables the chip
> interrupt line and returns IRQ_HANDLED.
>
> In both cases the IRQ gets reenabled from the generic irq handling code
> on return, so why is the box dead ?

I wrote this before your "generic" layer was in fact explained further to
not be generic at all and involve a new driver for each device. Your
original explanation was not clear.

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


galibert at pobox

Dec 14, 2006, 3:51 AM

Post #43 of 68 (8520 views)
Permalink
Re: [GIT PATCH] more Driver core patches for 2.6.19 [In reply to]

On Thu, Dec 14, 2006 at 10:56:03AM +0100, Hans-Jürgen Koch wrote:
> A small German manufacturer produces high-end AD converter cards. He sells
> 100 pieces per year, only in Germany and only with Windows drivers. He would
> now like to make his cards work with Linux. He has two driver programmers
> with little experience in writing Linux kernel drivers. What do you tell him?
> Write a large kernel module from scratch? Completely rewrite his code
> because it uses floating point arithmetics?

Write a small kernel module which:
- create a device node per-card
- read the data from the A/D as fast as possible and buffer it in main
memory without touching it
- implements a read interface to read data from the buffer
- implement ioctls for whatever controls you need

And that's it. All the rest can be done in userspace, safely, with
floating point, C++ and everything. If the driver programmers are
worth their pay, their driver is probably already split logically at
where the userspace-kernel interface would be.

And small means small, like 200 lines or so, more if you want to have
fun with sysfs, poll, aio and their ilk, but that's not a necessity.

OG.

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


James at superbug

Dec 14, 2006, 4:27 AM

Post #44 of 68 (8537 views)
Permalink
Re: [GIT PATCH] more Driver core patches for 2.6.19 [In reply to]

Duncan Sands wrote:
>> 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.
>
> Qemu? It would be nice if emulators could directly drive hardware:
> useful for reverse engineering windows drivers for example.
>
> Duncan.

I have reverse engineered many windows drivers, and what you suggest is
not at all helpful. For reverse engineering, one wants to see what is
happening. I.e. capture all the IO, MMIO and DMA accesses.
Your suggestion bypasses this possibility.
For reverse engineering windows drivers, one puts breakpoints in the
HAL.DLL code or replaces the HAL.DLL code with a debugging version of it
while actually running windows.

Your approach runs into problems.
e.g
There is a register on the card that sets the DMA base address, but you
don't know which register this is. If you let the driver inside QEMU
write to this register, it will write values suitable for the Virtual
machine instead of values suitable to for host OS. The DMA transaction
will write all over the wrong memory location resulting in CRASH.

One might be able to get round some of these problem with a combination
of QEMU and a hacked up HAL.DLL, but it will be complicated.

James

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


alan at lxorguk

Dec 14, 2006, 4:39 AM

Post #45 of 68 (8504 views)
Permalink
Re: [GIT PATCH] more Driver core patches for 2.6.19 [In reply to]

On Thu, 14 Dec 2006 10:56:03 +0100
Hans-Jürgen Koch <hjk [at] linutronix> wrote:

> * They let somebody write the small kernel module they need to handle
> interrupts in a _clean_ way. This module can easily be checked and could
> even be included in a mainline kernel.

And might as well do the mmap work as well. I'm not clear what uio gives
us that a decently written pair of PCI and platform template drivers for
people to use would not do more cleanly.

Also many of these cases you might not want stuff in userspace but the
uio model would push it that way which seems to be an unfortunate side
effect. Yes some probably do want to go that way but not all.

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


hjk at linutronix

Dec 14, 2006, 4:45 AM

Post #46 of 68 (8508 views)
Permalink
Re: [GIT PATCH] more Driver core patches for 2.6.19 [In reply to]

Am Donnerstag, 14. Dezember 2006 12:51 schrieb Olivier Galibert:
> On Thu, Dec 14, 2006 at 10:56:03AM +0100, Hans-Jürgen Koch wrote:
> > A small German manufacturer produces high-end AD converter cards. He sells
> > 100 pieces per year, only in Germany and only with Windows drivers. He would
> > now like to make his cards work with Linux. He has two driver programmers
> > with little experience in writing Linux kernel drivers. What do you tell him?
> > Write a large kernel module from scratch? Completely rewrite his code
> > because it uses floating point arithmetics?
>
> Write a small kernel module which:

What you suggest is not a "small kernel module". It's what we have now,
writing a complete driver.

> - create a device node per-card

That's what UIO does, plus some standard sysfs files, that tell you e.g.
the size of the cards memory you can map. There are standard file names
that allow you e.g. to automatically search for all registered uio
drivers and their properties.

> - read the data from the A/D as fast as possible and buffer it in main
> memory without touching it

If the card already has that data in its dual port RAM, you do an
unneccessary copy.

> - implements a read interface to read data from the buffer

Here you do the next unneccessary copy.

> - implement ioctls for whatever controls you need

Implementing ioctls for everything is bad coding style and a has bad
performance. I said "high-end AD card", that means you have a
signal processor on that board, want to download firmware to it
and so on. You end up copying lots of data between user space
and kernel space.

>
> And that's it.

Yes, that's a complete kernel driver that you'd never get into
a mainline kernel. Furthermore, the card manufacturer would have to
employ at least two experienced Linux _kernel_ programmers. That's
too much for a small company who's business is something different.

> All the rest can be done in userspace, safely, with
> floating point, C++ and everything. If the driver programmers are
> worth their pay, their driver is probably already split logically at
> where the userspace-kernel interface would be.
>
> And small means small, like 200 lines or so, more if you want to have
> fun with sysfs, poll, aio and their ilk, but that's not a necessity.

You can achieve 100 lines with uio, including sysfs and poll. What you
describe would never fit in 200 lines for a non-trivial card.

Hans

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


hjk at linutronix

Dec 14, 2006, 5:08 AM

Post #47 of 68 (8521 views)
Permalink
Re: [GIT PATCH] more Driver core patches for 2.6.19 [In reply to]

Am Donnerstag, 14. Dezember 2006 13:39 schrieb Alan:
> On Thu, 14 Dec 2006 10:56:03 +0100
> Hans-Jürgen Koch <hjk [at] linutronix> wrote:
>
> > * They let somebody write the small kernel module they need to handle
> > interrupts in a _clean_ way. This module can easily be checked and could
> > even be included in a mainline kernel.
>
> And might as well do the mmap work as well. I'm not clear what uio gives
> us that a decently written pair of PCI and platform template drivers for
> people to use would not do more cleanly.

* Creation of /dev device files.
* Creation of standardized sysfs files.
* Interrupt registration and handling.
* mmap for physical and logical memory.
* read, poll, and fasync for interrupt handling.
* a predefined, clean design that the hardware manufacturer can use.

>
> Also many of these cases you might not want stuff in userspace but the
> uio model would push it that way which seems to be an unfortunate side
> effect. Yes some probably do want to go that way but not all.

Alright, but everybody has the choice. If the alternative is to have no
Linux drivers at all because it's too expensive, then somebody might
consider UIO. To have the big parts of the driver in userspace allows
them to remain stable across different kernel versions. Driver updates
can take place without changing the kernel. For some manufacturers
these will be strong arguments in favor of UIO.

Hans

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


riel at redhat

Dec 14, 2006, 7:13 AM

Post #48 of 68 (8531 views)
Permalink
Re: [GIT PATCH] more Driver core patches for 2.6.19 [In reply to]

Michael K. Edwards wrote:

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

Any volunteers to expand on that in the Kernelnewbies section
on this subject? So far the "business ground" is only half a
page or so :)

http://kernelnewbies.org/UpstreamMerge

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


jengelh at linux01

Dec 14, 2006, 9:02 AM

Post #49 of 68 (8514 views)
Permalink
Re: [GIT PATCH] more Driver core patches for 2.6.19 [In reply to]

On Dec 14 2006 10:56, Hans-Jürgen Koch wrote:
>
>A small German manufacturer produces high-end AD converter cards. He sells
>100 pieces per year, only in Germany and only with Windows drivers. He would
>now like to make his cards work with Linux. He has two driver programmers
>with little experience in writing Linux kernel drivers. What do you tell him?
>Write a large kernel module from scratch? Completely rewrite his code
>because it uses floating point arithmetics?

They use floating point in (Windows) kernelspace? Oh my.


-`J'
--


hjk at linutronix

Dec 14, 2006, 9:17 AM

Post #50 of 68 (8513 views)
Permalink
Re: [GIT PATCH] more Driver core patches for 2.6.19 [In reply to]

Am Donnerstag, 14. Dezember 2006 18:02 schrieb Jan Engelhardt:
>
> On Dec 14 2006 10:56, Hans-Jürgen Koch wrote:
> >
> >A small German manufacturer produces high-end AD converter cards. He sells
> >100 pieces per year, only in Germany and only with Windows drivers. He would
> >now like to make his cards work with Linux. He has two driver programmers
> >with little experience in writing Linux kernel drivers. What do you tell him?
> >Write a large kernel module from scratch? Completely rewrite his code
> >because it uses floating point arithmetics?
>
> They use floating point in (Windows) kernelspace? Oh my.

To be honest, I never really understood where kernel space starts and user space
ends in Windows, so I'm not sure about this :-)

Hans

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

First page Previous page 1 2 3 Next page Last page  View All Linux kernel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.