svn commit: r360241 - head/sys/dev/ichiic

John Baldwin jhb at FreeBSD.org
Fri Apr 24 18:13:52 UTC 2020


On 4/24/20 9:57 AM, Warner Losh wrote:
> On Fri, Apr 24, 2020 at 10:07 AM Andriy Gapon <avg at freebsd.org> wrote:
>> Let's use ig4 as an example.
>> Across its source files we had the following DRIVER_MODULE declarations:
>> DRIVER_MODULE(ig4iic, acpi, ... -- in ig4_acpi.c
>> DRIVER_MODULE(iicbus, ig4iic, ... -- in ig4_iic.c
>> DRIVER_MODULE(acpi_iicbus, ig4iic, ... -- in ig4_iic.c
>> The first one is needed to register ig4iic driver under acpi bus.  Other
>> two are
>> needed to register iicbus and acpi_iicbus drivers under ig4iic bus.
>> The order is not explicitly defined, so the corresponding declaration can
>> be
>> processed in any order when ig4.ko is loaded and so the corresponding
>> devclass_add_driver() can be called in any order.
>>
> 
> It's a bug in newbus if that matters. I'll grant that it does today, but it
> shouldn't. In the past we've worked around this issue in a number of
> different ways (including having 3 different modules with the order encoded
> into those modules). It also indicates, perhaps, bugs in the iic acpi
> enumeration stuff, but that's a harder case to make without more careful
> study since I know that acpi_iic works around the bit of a mismatch between
> newbus' device model and ACPI's.

FWIW, this is a longstanding bug, and it is the reason DRIVER_MODULE_ORDERED
exists[1], precisely so you can get all the child driver module's registered first
and have the "top-most" (in the hierarchy) driver register last so that all
the others are ready as new child devices are created.  The _ORDERED solution
is the only one I'm aware of that we have used for a single module containing
multiple drivers.  It may be that we have split up into tiny modules in the
past, but that solution is probably worse as the dependencies are usually
the wrong way around (the "leaf" drivers probably depend on the parent drivers
so they get loaded in the exact wrong order for this case where you want all
the leaf drivers registered before an instance of the parent driver attaches)

1: https://svnweb.freebsd.org/base?view=revision&revision=225079

-- 
John Baldwin


More information about the svn-src-all mailing list