Extending sys/dev/mii

Stefan Bethke stb at lassitu.de
Sat Jan 21 12:03:01 UTC 2012


Am 21.01.2012 um 02:43 schrieb Warner Losh:

> 
> On Jan 20, 2012, at 5:08 PM, Stefan Bethke wrote:
>> The second problem is that there's currently no way to express a dependency between two devices other than a parent-child relationship.   I would be interested to learn why this appears to be so uncommon that I could not find any discussion of such a feature.  Has it really never before come up?
> 
> Sure there is: you can do it by name.  I wrote a driver that attached to the ISA bus, but also needed to talk to the ppbus that was attached to the printer.  My solution was to have a post-attach name-lookup so that it could then call methods on the other driver's device_t.  I wonder why we can't do that here?


That was my first approach, but the attachment sequence foiled it: arge0 is probed and attached before the device that provides the MDIO bus arge0 needs to attach the miibus and phy.  As far as I can tell, there is no way to express (via code or hints or otherwise) that a device should be attached only after some other device has been attached.

The solution for me was to write miiproxy which contains code that waits for both devices to attach, and then calls a callback on arge0 to complete the interface attachment (attaches miibus, makes the interface available).

From a driver writers point of view, it would be desirable to be able to say "attach this only after 'foo0' has been attached", so the attach method can still be a single, linear piece of code.


Stefan

-- 
Stefan Bethke <stb at lassitu.de>   Fon +49 151 14070811





More information about the freebsd-arch mailing list