Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Apr 2020 11:13:48 -0700
From:      John Baldwin <jhb@FreeBSD.org>
To:        Warner Losh <imp@bsdimp.com>, Andriy Gapon <avg@freebsd.org>
Cc:        src-committers <src-committers@freebsd.org>, svn-src-all <svn-src-all@freebsd.org>, svn-src-head <svn-src-head@freebsd.org>
Subject:   Re: svn commit: r360241 - head/sys/dev/ichiic
Message-ID:  <a79868d9-7b11-cfda-973f-62f6e0ec633d@FreeBSD.org>
In-Reply-To: <CANCZdfqVwfaOKNTqefpTUJ0%2BQ7i0iGO==AtHaXEvVB-uV2W51A@mail.gmail.com>
References:  <202004240749.03O7nMSc066344@repo.freebsd.org> <CANCZdfok8rf3SWEtKA_ZHVAgPWHCzOM-95w2pP9UTTLn-9995w@mail.gmail.com> <32586115-2c82-2497-ba4c-b3471887518d@FreeBSD.org> <CANCZdfqJaBm=Jx43jU5%2BiB1KVx3f1aoSUTDB3U6z9QnPV_q6uQ@mail.gmail.com> <02449f05-6c43-9cb0-b427-34034a3c358f@FreeBSD.org> <CANCZdfqVwfaOKNTqefpTUJ0%2BQ7i0iGO==AtHaXEvVB-uV2W51A@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 4/24/20 9:57 AM, Warner Losh wrote:
> On Fri, Apr 24, 2020 at 10:07 AM Andriy Gapon <avg@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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?a79868d9-7b11-cfda-973f-62f6e0ec633d>