|
|
Subscribe / Log in / New account

Device dependencies and deferred probing

By Jonathan Corbet
November 3, 2015

2015 Kernel Summit
A "device" as seen by a user of a modern system is, often as not, a set of multiple independent devices working together. This organization is flexible, but it also can lead to problems for device drivers. How does a driver instantiate a new device if the other devices it depends on are not yet available? One answer is deferred probing — delaying the setup of a device until its dependencies show up. Mark Brown led a somewhat inconclusive Kernel Summit session on deferred probing and possible alternatives.

The core problem, Mark said, is that there is no way to tell the kernel's device model about dependencies between devices. Rafael Wysocki responded that the real issue is dependencies between drivers, but Mark disagreed, saying that a dependency shows itself as one device waiting for [Mark Brown] another specific device to be instantiated. He noted that there is currently a deferred probing patch set under discussion, but it doesn't address the full problem. In particular, it doesn't address suspend/resume operations (when devices must be suspended and resumed in the proper order), and it does nothing to speed boot time.

Grant Likely said that the problem is with the tree-oriented device model, which is not able to describe the dependencies in real-world systems. This point was generally agreed — it has been understood for a while — but solutions are still hard to come by. Greg Kroah-Hartman described deferred probing as a "hack workaround" for the problem, but didn't immediately offer a less hacky alternative.

There was some talk about the nature of device dependencies. Some of them are described in the system's firmware (or device tree). Others only show up when drivers initialize themselves and can't be seen at boot time. Dependencies can even change over the lifetime of the system as devices are configured in different ways. Tim Bird suggested using the phandles (inter-device references) found in the system's device tree; there is a lot of dependency information to be found there. Most dependencies are "stupid clocks and regulators"; creating a graph of such dependencies prior to device probing would solve a lot of problems, he said.

Greg, despite his earlier comment on deferred probing, now asked whether a more complex dependency graph was needed. Nobody has demonstrated real problems resulting from excessive deferral of device probing. Tim said that readily available dependency information could at least be used to perform hinting; Rafael agreed that pulling together as much information as possible would help the kernel to get the probing order roughly right.

As a whole, the group seemed to agree that the problem is real, and that it should somehow be solved in the driver core. An important first step would be to come up with a way to register dependencies from the information that is already available. Rafael promised to post a proposal with some ideas; he followed through later that day.

Index entries for this article
KernelDevice drivers/Asynchronous probing
ConferenceKernel Summit/2015


to post comments

Device dependencies and deferred probing

Posted Nov 4, 2015 13:14 UTC (Wed) by tpetazzoni (subscriber, #53127) [Link] (1 responses)

Rafael Wysocki responded that the real issue is dependencies between drivers

It is not exactly what Rafael said I believe. What Rafael said is that dependencies are not just between devices, but between devices that are actually *bound* to a driver to manage them. Indeed if a device A needs another device B, it doesn't just need this device B to have its platform_device registered. It also needs device B to be bound to a device driver, of which the ->probe() method has been called to actually do something with device B, so that it can be used by device A.

So device A ->probe() should ideally only be triggered when device B ->probe() has completed. Having device B "registered" is not sufficient.

Device dependencies and deferred probing

Posted Nov 6, 2015 12:30 UTC (Fri) by broonie (subscriber, #7078) [Link]

Yes, exactly.


Copyright © 2015, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds