Re: [PATCH 2/2] thunderbolt: Initialize after IOMMUs

From: Mika Westerberg
Date: Thu Sep 06 2018 - 07:08:04 EST


On Thu, Sep 06, 2018 at 01:00:49PM +0200, Lukas Wunner wrote:
> On Thu, Sep 06, 2018 at 01:36:02PM +0300, Mika Westerberg wrote:
> > On Thu, Sep 06, 2018 at 10:13:37AM +0200, Lukas Wunner wrote:
> > > So with this patch, you rely on the linker ordering nhi_init() after
> > > ir_dev_scope_init(), however to the best of my knowledge the link
> > > order is not guaranteed.
> >
> > What says that?
>
> Within the same initcall level, the ordering is determined by the Makefile
> AFAIK. Someone changes the Makefile, your dependency scheme falls apart.

There are other drivers doing the same so they would fail as well. It is
common practice AFAIK.

> > > Looking at commit acb40d841257, which started this, I'm wondering
> > > why you did not simply export tbnet_init() and call it from the
> > > thunderbolt driver after the property stuff has been fully set up?
> > > After all, thunderbolt-net is useless without thunderbolt or am I
> > > missing something? Then you could revert back to module_init().
> >
> > The same reason you don't call PCI driver functions from PCI core. It
> > makes absolutely zero sense.
> >
> > Thunderbolt is bus and provides driver API to drivers. We hopefully are
> > getting other service drivers (say SCSI over TBT) that are going to be
> > use the same interfaces.
>
> Then add a blocking notifier chain into which these service drivers can
> hook. Other buses have that as well.

It is really too complex to add notifier just for that. This works fine
and is not against any kernel principles I am aware of.