linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hannu Savolainen <hannu@opensound.com>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Larry McVoy <lm@bitmover.com>,
	Andre Hedrick <andre@linux-ide.org>,
	Arjan van de Ven <arjanv@redhat.com>,
	Valdis.Kletnieks@vt.edu,
	Kendall Bennett <KendallB@scitechsoft.com>,
	linux-kernel@vger.kernel.org
Subject: Driver API (was Re: Linux GPL and binary module exception clause?)
Date: Thu, 11 Dec 2003 02:50:20 +0200 (EET)	[thread overview]
Message-ID: <Pine.LNX.4.58.0312102256520.3787@zeus.compusonic.fi> (raw)
In-Reply-To: <Pine.LNX.4.58.0312101108150.29676@home.osdl.org>

On Wed, 10 Dec 2003, Linus Torvalds wrote:

> I'd like to make it clear that I'm actually much softer on this than many
> other people - I've been making it clear that I think that binary-only
> modules _are_ ok, but that the burden of proof of ok'ness is squarely on
> the shoulders of the company that makes them.
Ok. That makes perfect sense.

It would be fair to have an official list of kernel services that are 100%
OK for use by binary-only device drivers (or kernel modules in general).
If anybody needs to use a service outside this list they know they may be
on thin ice. What I'm proposing into this kind of list are the basic
services needed to implement a character device driver (driver entry
points, kmalloc/vmalloc, mutex and sleep primitives, device I/O, userspace
access and few others). These all are primitives that can be found from
any "generic" kernel programming text book. Also they are available in
every operating system I have been worked with. So it would be very hard
to argue that using them could make aything "derived work".
I don't use anything but the charcater device interface so I can't say if
there is anything else that could/should be listed.

Even better would be a proper device driver ABI for "loosely integrated"
device drivers. It's possible to hide differences between kernel releases
so that the same driver can work with wide range of kernel versions).
There are some performance penalties but they are not significant. And the
drivers included in the kernel source tree don't need to use this
interface so I don't see there any _technical_ reasons against this idea.
I can volunteer to implement this interface if it's OK. Some motivation
for the ABI as well as some technical ideas will be at the end of this
message.

I don't make any statement about the correctness of the "derived work"
issue. However I think it's at least fair to avoid using kernel internals
in a way kernel developers don't like. It would be best for the future of
Linux that there is some agreement about this issue.

Developing software under GPL is everybody's right but not responsibility.
In distant future it may happen that all software gets distributed under
GPL or a similar license. However before that moment there will always be
some kind of gray zone between the open source and the closed source
worlds. And for various reasons somebody must live on the "right" side.
For example in my case we can't GPL our product for reasons that are beyond
our control (for example large parts of the source code are licensed from
hardware manufacturers and other companies under NDA). So I don't see it
fair that some developers think they have the right to enforce everybody
else to work under GPL.

-----
Why a driver ABI is required?

The reason wy I propose the driver ABI is that the current LKM mechanism
is quite unacceptable. It was fairly good sometimes around 1.2.x and
2.0.0 days but for some reason things have gotten worse and worse after
that. We  have learned to live with it. It just causes some waste of time
that could otherwise be spent on something productive. However for many
companies without prior LKM experience it's a big challenge.

Today there are 50-100 different kernel images released by numerous Linux
distribution vendors. In most Linux systems there are no development tools
installed so it's "impossible" to install any kernel modules from the
sources.  This is true also with "pure GPL" modules. To be able to compile
the module the user needs to install first the kernel sources, gcc,
binutils and make (if they have that much of free disk space left). After
figuring out what and how to install he also needs to figure out how to
configure the kernel (headers) in the right way. This is not something an
average Linux user can do. Many of them don't even know how to get to the
command line. For this reason companies making kernel modules must
distribute a precompiled module for each of the 50-100 different
distribution kernel images that are in active use (or a subset of them).
The number is very large because many distribution vendors release 2 to 8
different kernel images (SMP/UP, athlon/PIII/P4/etc) every time. And this
must be done also if the driver sources are under GPL.

There is not a problem if the module is compiled by the maintainer of
the distribution or if the user has compiled his kernel himself. However
it's impossible idea that drivers for every possible device could be
included in the kernel source tree or in some other way be compiled by the
distribution vendor. It can happen with devices that are in "mass"
production. However the world is full of other devices that are
interesting to about 0.0001% of all Linux users.

In the current way it's pretty impossible to produce Linux drivers (even
under GPL) because installing it would be too demanding. Things would be
much easier if the same driver image works with most (or every) kernels.
Another approach would be having the development tools and the properly
configured kernel sources included in the minimum configurations of each
Linux distribution but I would call this massive overkill.

Yet another problem is that there is no way to know which symbols are
only for kernel internal use and which ones can be safely used in some
drivers. Some routines change between kernel versions which often makes
drivers uncompilable. It's not difficult to find examples of this from
the net. Many companies have released Linux drivers for their hardware
but have then forgotten them. The result is that the driver sources are
available from the manufacturer but they don't compile any more. It's
usually difficult to fix them because they use unknown kernel routines
that have not been in the kernel since year 0. Having a stable driver
API or ABI very much eliminates this problem.

I understand that many of the kernel team members are against any kind of
non-GPL kernel space code. But I can't understand how making it difficult
to use it could make Linux better as an operating system. OTOH making it
easier to use binary only modules will also make it easier to use GPL
modules too.

Technical stuff
---------------

It's not true that kernel space code cannot be compiled without using the
kernel headers. OSS (Open Sound System) has for some time been compiled
against the standard (libc) headers. Just one of the source files contains
all the kernel dependent stuff and gets compiled against the kernel
headers. The reason is not trying to avoid any GPL issues. This is just
the only way to do that because otherwise the whole driver has to be
recompiled separately for each possible kernel (OK, it would have to be
shipped with sources too). We compile it against the libc headers to make
sure that no kernel inline code gets accidently called (which would cause
serious incompatibility problems). Also it's easier to set up the
compiling environment in this way (kernel headers often contain headers
that conflict with some other headers). The system headers are
required just because they contain values for some important constants.

The remaining "wrapper" module needs to be compiled against the right
kernel headers. It's kind of kernel ABI module. Instead of being a part
of the kernel it's part of our product (which is not the right place).

In it's current form the wrapper contains just wrappers around some
fundamental kernel routines and methods to access the required
fields of some kernel structures. The "client" driver sees the kernel
structures as some kind of cookies. It needs to call the right method to
read/write a field in this structure.

This kind of "1:1" wrapper is actually rather silly mechanism but it's
easy to implement. I'm currently re-designing the wrapper so that it
provides higher level of abstraction. In this way there is less overhead
because fewer calls need to be done between the wrapper and the client
driver. This wrapper will be released under LGPL (or GPL) so it will be
available for use by everybody who needs it. It can also be included in
the kernel sources.

Implementing drivers on top of this kind of wrapper causes some
performance impact. However it's not an issue. Many drivers actually
make other kernel calls rather infrequently so usually there is no inpact
at all. Most of time they spend by doing register I/O and things like
that. HW access can be done with the usual kernel inline routines without
any risk. Or the inline functions can be implemented inside the driver.

Best regards,

Hannu
-----
Hannu Savolainen (hannu@opensound.com)
http://www.opensound.com (Open Sound System (OSS))
http://www.compusonic.fi (Finnish OSS pages)
OH2GLH QTH: Karkkila, Finland LOC: KP20CM

  reply	other threads:[~2003-12-11  0:51 UTC|newest]

Thread overview: 180+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-04 23:50 Linux GPL and binary module exception clause? Paul Adams
2003-12-05  0:07 ` Nick Piggin
2003-12-05  2:07   ` Kendall Bennett
2003-12-05 15:57     ` Thierry Vignaud
2003-12-05  4:23   ` Peter Chubb
2003-12-05  4:42     ` Nick Piggin
2003-12-05  8:23       ` Peter Chubb
2003-12-05 17:19         ` Linus Torvalds
2003-12-05 18:42           ` Jeremy Fitzhardinge
2003-12-05  5:13     ` Valdis.Kletnieks
2003-12-05  5:26       ` Hua Zhong
2003-12-05  6:34       ` David Schwartz
2003-12-05  6:58         ` Linus Torvalds
2003-12-05 11:16           ` David Schwartz
2003-12-05 13:34             ` Anders Karlsson
2003-12-05 14:03             ` Ryan Anderson
2003-12-05 16:38               ` Shawn Willden
2003-12-05 16:54                 ` Arjan van de Ven
2003-12-05 17:03                   ` Shawn Willden
2003-12-05 22:36                   ` Derek Fawcus
2003-12-05 17:34                 ` Linus Torvalds
2003-12-05 17:35               ` Hua Zhong
2003-12-05 18:12                 ` Filip Van Raemdonck
2003-12-05 18:37                   ` Hua Zhong
2003-12-05 19:56                     ` 'Filip Van Raemdonck'
2003-12-05 20:26                       ` Hua Zhong
2003-12-06  0:08                         ` Filip Van Raemdonck
2003-12-05 19:55               ` David Schwartz
2003-12-05 20:14                 ` Linus Torvalds
2003-12-05 21:16                   ` Shawn Willden
2003-12-09  0:17                   ` Kernel 2.6-test10 on an Opteron Ananda Bhattacharya
2003-12-09 12:16                     ` Petr Sebor
2003-12-09 20:31                     ` bill davidsen
2003-12-08 15:38                 ` Linux GPL and binary module exception clause? Jesse Pollard
2003-12-05 14:59             ` Jesse Pollard
2003-12-05 19:15               ` Kendall Bennett
2003-12-05 18:44           ` Kendall Bennett
2003-12-05 19:09             ` Valdis.Kletnieks
2003-12-05 19:22               ` Arjan van de Ven
2003-12-10 13:52                 ` Andre Hedrick
2003-12-10 15:18                   ` Linus Torvalds
2003-12-10 15:32                     ` Larry McVoy
2003-12-10 16:21                       ` Linus Torvalds
2003-12-10 16:34                         ` Larry McVoy
2003-12-10 17:10                           ` Linus Torvalds
2003-12-10 17:25                             ` Chris Friesen
2003-12-10 17:58                               ` Linus Torvalds
2003-12-10 17:56                             ` Larry McVoy
2003-12-10 18:02                               ` Linus Torvalds
2003-12-10 18:08                                 ` Larry McVoy
2003-12-10 18:17                                   ` Linus Torvalds
2003-12-10 18:38                                     ` Larry McVoy
2003-12-10 19:15                                       ` Linus Torvalds
2003-12-11  0:50                                         ` Hannu Savolainen [this message]
2003-12-11  4:01                                           ` Driver API (was Re: Linux GPL and binary module exception clause?) Peter Chubb
2003-12-11 15:47                                             ` Jason Kingsland
2003-12-11 22:47                                               ` Peter Chubb
2003-12-11 10:06                                           ` viro
2003-12-11 12:47                                             ` Hannu Savolainen
2003-12-11 13:33                                               ` viro
2003-12-11 14:54                                                 ` Hannu Savolainen
2003-12-10 18:37                                   ` Linux GPL and binary module exception clause? Jan-Benedict Glaw
2003-12-10 19:51                                 ` Hua Zhong
2003-12-10 20:09                                 ` Andre Hedrick
2003-12-11  1:24                               ` Andrew Pimlott
2003-12-11  7:43                               ` Rob Landley
2003-12-11  8:11                                 ` Hua Zhong
2003-12-11  8:37                                   ` Rob Landley
2003-12-11 18:22                                     ` Hua Zhong
2003-12-11 21:20                                     ` Andre Hedrick
2003-12-11 21:59                                       ` Rob Landley
2003-12-11 22:42                                         ` Andre Hedrick
2003-12-12  5:39                                           ` Rob Landley
2003-12-12  7:21                                             ` Andre Hedrick
2003-12-12  7:39                                               ` Rob Landley
2003-12-12  7:56                                                 ` Andre Hedrick
2003-12-12  9:27                                                   ` Rob Landley
2003-12-10 18:14                             ` David Schwartz
2003-12-10 18:21                               ` Linus Torvalds
2003-12-10 19:48                             ` Kendall Bennett
2003-12-11  7:32                           ` Rob Landley
2003-12-11 14:03                             ` Geert Uytterhoeven
2003-12-10 22:49                         ` Oliver Hunt
2003-12-10 17:15                     ` Hua Zhong
2003-12-10 17:42                       ` Linus Torvalds
2003-12-10 19:32                         ` Andre Hedrick
2003-12-10 22:43                           ` Jason Kingsland
2003-12-10 22:49                             ` Andre Hedrick
2003-12-10 23:11                           ` Linus Torvalds
2003-12-10 23:24                             ` Andre Hedrick
2003-12-10 19:48                         ` Kendall Bennett
2003-12-10 21:15                           ` viro
2003-12-10 22:36                             ` Kendall Bennett
2003-12-10 23:13                               ` viro
2003-12-11 15:29                               ` Jesse Pollard
2003-12-11 18:47                                 ` Kendall Bennett
2003-12-11 18:55                                   ` Nick Piggin
2003-12-11 22:18                                   ` Jesse Pollard
2003-12-10 22:18                           ` Larry McVoy
2003-12-10 22:25                             ` Andre Hedrick
2003-12-10 23:38                             ` Linus Torvalds
2003-12-11  1:03                               ` Larry McVoy
2003-12-11 14:46                                 ` Ingo Molnar
2003-12-10 23:39                             ` Andrea Arcangeli
2003-12-11 17:44                             ` Robin Rosenberg
2003-12-11 17:56                               ` Valdis.Kletnieks
2003-12-11 18:16                                 ` Nick Piggin
2003-12-11 18:50                                 ` Mihai RUSU
2003-12-11 18:37                               ` David Schwartz
2003-12-11 12:04                         ` David Woodhouse
2003-12-10 17:49                       ` Jörn Engel
2003-12-10 18:16                     ` Andre Hedrick
2003-12-05 19:25               ` Kendall Bennett
2003-12-05 19:26             ` Linus Torvalds
2003-12-05 15:50         ` Valdis.Kletnieks
2003-12-05 18:44         ` Kendall Bennett
2003-12-06  0:02           ` Maciej Zenczykowski
2003-12-05 18:44       ` Kendall Bennett
2003-12-10 13:16       ` Andre Hedrick
2003-12-10 15:02         ` Jesse Pollard
2003-12-10 20:37           ` Theodore Ts'o
2003-12-11 16:26             ` Jesse Pollard
2003-12-05 13:52   ` Richard B. Johnson
2003-12-05  0:09 ` Oliver Hunt
2003-12-05 10:55   ` Russell King
2003-12-05  0:46 ` Erik Andersen
2003-12-05  0:58   ` Zwane Mwaikambo
2003-12-05  1:03     ` Erik Andersen
2003-12-05  1:21       ` Larry McVoy
2003-12-05  1:30         ` Hua Zhong
2003-12-05  1:58         ` Linus Torvalds
2003-12-06  3:00           ` Larry McVoy
2003-12-06  4:39             ` Linus Torvalds
2003-12-06  5:14               ` Larry McVoy
2003-12-06  5:48                 ` Linus Torvalds
2003-12-06 17:14                   ` Larry McVoy
2003-12-06 15:38                 ` Theodore Ts'o
2003-12-06 16:47                   ` Jason Kingsland
2003-12-06 21:30                   ` David Schwartz
2003-12-06 21:42                     ` Larry McVoy
2003-12-07 13:01               ` Ingo Molnar
2003-12-07 22:11                 ` Rob Landley
2003-12-06 14:13             ` Andrew Pimlott
2003-12-06 17:50               ` Larry McVoy
2003-12-06 21:19                 ` Theodore Ts'o
2003-12-06 21:45                   ` Larry McVoy
2003-12-08 16:34                 ` Andrew Pimlott
2003-12-11 12:37           ` David Woodhouse
2003-12-11 12:42             ` Andre Hedrick
2003-12-11 12:58               ` David Woodhouse
2003-12-12 20:26                 ` Brian Beattie
2003-12-13 12:03                   ` David Woodhouse
2003-12-13 15:04                     ` jeff millar
2003-12-13 17:27                     ` Gene Heskett
2003-12-14  0:51                     ` Linux, Inc. (Re: Linux GPL and binary module exception clause?) Andre Hedrick
2003-12-14  1:06                       ` Andre Hedrick
2003-12-14  2:40                         ` David S. Miller
2003-12-14  2:37                           ` Andre Hedrick
2003-12-14  6:55                         ` Rob Landley
2003-12-14  6:35                       ` Rob Landley
2003-12-11 13:54             ` Linux GPL and binary module exception clause? Andrew Pimlott
2003-12-11 15:12               ` David Woodhouse
2003-12-05  3:58         ` Jason Kingsland
2003-12-05  1:58   ` David Schwartz
2003-12-05  4:58     ` Erik Andersen
2003-12-05  6:34       ` David Schwartz
2003-12-05  6:43         ` Linus Torvalds
2003-12-05  2:07   ` Kendall Bennett
2003-12-05  7:39     ` Stefan Smietanowski
2003-12-05  1:47 ` Linus Torvalds
2003-12-10 12:57   ` Andre Hedrick
2003-12-10 15:14     ` Linus Torvalds
2003-12-10 15:25       ` Larry McVoy
2003-12-10 18:58         ` Andre Hedrick
2003-12-12 19:40     ` Pavel Machek
2003-12-12 22:08       ` Andre Hedrick
2003-12-12 23:06         ` Jamie Lokier
2003-12-12 23:43         ` Pavel Machek
2003-12-15 18:01     ` Adam Sampson
2003-12-15 21:12       ` Andre Hedrick

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=Pine.LNX.4.58.0312102256520.3787@zeus.compusonic.fi \
    --to=hannu@opensound.com \
    --cc=KendallB@scitechsoft.com \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=andre@linux-ide.org \
    --cc=arjanv@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lm@bitmover.com \
    --cc=torvalds@osdl.org \
    /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;
as well as URLs for NNTP newsgroup(s).