|
|
Subscribe / Log in / New account

A fresh look at the kernel's device model

A fresh look at the kernel's device model

Posted May 29, 2015 17:19 UTC (Fri) by Alan.Stern (subscriber, #12437)
Parent article: A fresh look at the kernel's device model

There is one important point that argues against merging the "class" and "bus" concepts into one. Namely, a device can belong to both a bus and a class -- but it can't belong to two buses or two classes.

Another interesting point worth mentioning: When the device model was originally created, a large part of the motivation was to have a single common framework for power management. In particular, for system suspend (runtime PM was not added to the kernel until considerably later).


to post comments

A fresh look at the kernel's device model

Posted May 30, 2015 0:15 UTC (Sat) by neilbrown (subscriber, #359) [Link] (1 responses)

> Namely, a device can belong to both a bus and a class

I can see how this is possible. I'm having trouble seeing how it is useful. Is there an example I can look at?

I can almost imagine that a bus might be able to include some of its devices in one class and some in another class. But I think I would either just make them different types, or have two related devices, one in the bus one in the class. Maybe an example will help clarify for me.

Thanks!

A fresh look at the kernel's device model

Posted Jun 6, 2015 17:22 UTC (Sat) by Alan.Stern (subscriber, #12437) [Link]

I can't think of any examples. In practice, drivers embed multiple struct devices in their private data structures. Generally one of these devices belongs to a bus and the others to classes.

A fresh look at the kernel's device model

Posted Jun 4, 2015 11:46 UTC (Thu) by ksandstr (guest, #60862) [Link]

>Namely, a device can belong to both a bus and a class -- but it can't belong to two buses or two classes.

Doesn't multi-path I/O break this constraint by having the same piece of hardware accessible through multiple hardware busses? Then a bus address identification no longer identifies an unique device, and there would possibly be fewer hardware devices than there are bus addresses associated with them. Conceptually there's little that stops a PCI-like hardware bus from being accessible through multiple bridges as well, e.g. in some weird-arse redundant cluster environment.

This whole set-up sounds like an ad-hoc reimplementation of a shitty Java, with "struct device" corresponding to the Object base class, and classes to interfaces, but only permitting one class per device (thereby e.g. splitting multi-class devices into many and a "parent" device that handles PM for them all). The temptation to tear it down for simplification's sake is obvious. However, there's a lot of good in having a structure that forbids explosions of abstract hierarchy wank during future development, especially when the obvious alternative would replace the structural hierarchy with a more homogenous structure (i.e. like Java, but not as shittily) and force a mild level of such wank for an ante to achieve functional parity.

Really the question is: what are the policies associated with the flexibly homogeneous substitute, and how do they combine to a better outcome in the next 15 years than the current status? Does having such policies, instead of program-defined structure, reduce the kernel's architectural strength? If so, shouldn't that policy be part of the kernel in some way that retains that strength (by e.g. being as much subject to debate as changes to code are) to the degree that historically-proven code does?

The "Unix way" is, roughly speaking, one where the kernel provides low-level mechanisms that arise from the combined natures of hardware and OS concepts, and lets consumers define policy to their detriment alone. With udev and the other freedesktop.org stuff we've seen over the past decade, this separation has become reversed: now userspace policy is entering the kernel and influencing its architecture. This trend is not currently showing signs of being about to reverse, so I question whether it should have a potential in-road to the eventual flattening (and thereby vendorization) of device drivers within the kernel.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds