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

From: Lukas Wunner
Date: Thu Sep 06 2018 - 07:21:06 EST


On Thu, Sep 06, 2018 at 02:07:56PM +0300, Mika Westerberg wrote:
> 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.

That doesn't make it a *good* practice.


> > > > 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.

Well, there's a difference between "it works and gets the job done,
let's move on" and "let's try to find a solution that fixes not just
this use case but potentially benefits others as well".

FWIW, what I had in mind is a blocking notifier chain that gets called
when a bus registers or unregisters. TB service drivers would then check
if it's tb_bus_type and start initialization.

Thanks,

Lukas