linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: viro@parcelfarce.linux.theplanet.co.uk
To: Hannu Savolainen <hannu@opensound.com>
Cc: Linus Torvalds <torvalds@osdl.org>, 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: Re: Driver API (was Re: Linux GPL and binary module exception clause?)
Date: Thu, 11 Dec 2003 10:06:27 +0000	[thread overview]
Message-ID: <20031211100627.GJ4176@parcelfarce.linux.theplanet.co.uk> (raw)
In-Reply-To: <Pine.LNX.4.58.0312102256520.3787@zeus.compusonic.fi>

On Thu, Dec 11, 2003 at 02:50:20AM +0200, Hannu Savolainen wrote:
 
> 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.

It doesn't work.  Let me give you an example: right now we have a way to get
from struct inode to struct block device - inode->i_bdev.  You can wrap it
into helper functions, whatever - it won't live to 2.8.

	Why?  Because if we want to handle device removal in a sane way, that
association will have to go.  We will still have a need (and a way) to get
from opened struct file of block device to its struct block_device.  And _that_
association will remain stable through the entire life of struct file.  Even
when the mapping from inode to block device gets changed.

	And it means that arguments of block device ->open(), ->release() and
->ioctl() will change - instead of struct inode we will pass the struct
block_device directly.  It's OK - callers have a way to get the thing and
methods themselves... right now the first thing they do is
	struct block_device *bdev = inode->i_bdev;
and either don't use inode afterwards at all or (very few) use it in a way
that can be replaced with use of bdev (e.g. inode->i_rdev -> bdev->bd_dev,
etc.).  The sole exception (floppy.c) still can get what it wants from the
second argument of ->open() (struct file *).

	The rest of the tree also can deal - I've done that and patches are
in -mm right now.  Most of them are easily mergable in 2.6, BTW.

	See what it means?  No fscking way to deal with that in wrappers.
Simply because the old assumption (inode->block_device remains stable)
is flat out wrong with new kernel.  Note that "just add a new API and leave
the old one for old drivers" would *NOT* work here.

	And yes, it's an interface change.  Caused by the fact that old
interface is Wrong(tm) (BTW, large part of that one is my fault - design
mistake in 2.3 that hadn't become obvious until 2.5.late).  Sure, we can
declare the new variant a part of ABI and have the glue for 2.4 and 2.6
wrap the new ->open()/->ioctl()/->release() with boilerplate that will
produce old-style ones.  _That_ direction is easy.  But that won't help
you with ABI - it allows to put new driver into old kernel, not the other
way round.  Which, come to think of it, is hardly a surprise - hindsight
is always 20/20 and all such.

	There is a good measure of interface quality - the less boilerplate
code you need to use it, the better.  It's not a trivial observation and
not just a matter of aesthetics.  It also means that there's less chance
of non-trivial breakage.  Note that you can wrap a good interface into bad
one - and that can usually be done in a uniform way (i.e. by _adding_ that
boilerplate code).  You can't go the other way round.  Case above is a good
example of that effect.

	See the problem now?  We can keep the same payload code if it uses
a good interface and we add wrappers to make it work with kernels that give
worse interfaces.  So if we design a really good one, we can say "that's our
ABI" and... what, exactly?  As long as new kernels have interfaces that are
not better than our, we are OK.  But it simply means that
	a) we should just use that good interface (and no glue) as kernel one.
	b) as soon as we have a need to improve the kernel interface, no amount
of glue is going to save that "ABI".
	c) in case if we decide to make kernel interface *WORSE*, our ABI will
really shine - then we will simply add glue to deal with degraded kernel.

	Which leaves only one question - why in damnation name would we ever
go for the case (c)?

	In other words, the nature of interface changes is such that usually
you can do glue between old interface and new driver and not the other way
round.  Which kills ABI idea - either you get a particular interface 100%
right and no glue is needed (then interface never changes simply because it's
Right(tm) and needs no changes) or you do not and no glue will save you as
soon as change becomes necessary.

	I'm a fairly arrogant bastard, but I do *not* claim that I can do
all interfaces right at once and avoid design mistakes.  Do you?  And if
yes, where can I get the drugs you are on?

  parent reply	other threads:[~2003-12-11 10:06 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                                         ` Driver API (was Re: Linux GPL and binary module exception clause?) Hannu Savolainen
2003-12-11  4:01                                           ` Peter Chubb
2003-12-11 15:47                                             ` Jason Kingsland
2003-12-11 22:47                                               ` Peter Chubb
2003-12-11 10:06                                           ` viro [this message]
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=20031211100627.GJ4176@parcelfarce.linux.theplanet.co.uk \
    --to=viro@parcelfarce.linux.theplanet.co.uk \
    --cc=KendallB@scitechsoft.com \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=andre@linux-ide.org \
    --cc=arjanv@redhat.com \
    --cc=hannu@opensound.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).