public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Lukas Wunner <lukas@wunner.de>
Cc: linux-kernel@vger.kernel.org,
	Andreas Noever <andreas.noever@gmail.com>,
	Michael Jamet <michael.jamet@intel.com>,
	Yehezkel Bernat <YehezkelShB@gmail.com>,
	Lu Baolu <baolu.lu@linux.intel.com>
Subject: Re: [PATCH 2/2] thunderbolt: Initialize after IOMMUs
Date: Wed, 5 Sep 2018 12:46:02 +0300	[thread overview]
Message-ID: <20180905094602.GH2283@lahna.fi.intel.com> (raw)
In-Reply-To: <20180905084746.xmckzskxzsdliz3e@wunner.de>

On Wed, Sep 05, 2018 at 10:47:46AM +0200, Lukas Wunner wrote:
> On Mon, Sep 03, 2018 at 04:20:12PM +0300, Mika Westerberg wrote:
> > If IOMMU is enabled and Thunderbolt driver is built into the kernel
> > image, it will be probed before IOMMUs are attached to the PCI bus.
> > Because of this DMA mappings the driver does will not go through IOMMU
> > and start failing right after IOMMUs are enabled.
> > 
> > For this reason move the Thunderbolt driver initialization happen at
> > rootfs level.
> > 
> > Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> > ---
> >  drivers/thunderbolt/nhi.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c
> > index 88cff05a1808..5cd6bdfa068f 100644
> > --- a/drivers/thunderbolt/nhi.c
> > +++ b/drivers/thunderbolt/nhi.c
> > @@ -1191,5 +1191,5 @@ static void __exit nhi_unload(void)
> >  	tb_domain_exit();
> >  }
> >  
> > -fs_initcall(nhi_init);
> > +rootfs_initcall(nhi_init);
> >  module_exit(nhi_unload);
> 
> What if the rootfs is located on a Thunderbolt-attached drive and
> the thunderbolt driver needs to establish tunnels to that drive
> before rootfs can be accessed?  Doesn't the above break such a setup?

No, then you put the driver as part of your initrd.

> I think the dependency on the IOMMU should be open coded by returning
> -EPROBE_DEFER from the ->probe hook if it's not yet attached.
> Shuffling around initcall order is just applying duct tape.

It is not a dependency. The same thing can happen with any other driver
if they happen to initialize any DMA with the device before IOMMUs are
initialized.

> Commit acb40d841257 already changed module_init() to fs_initcall()
> and now it has to be changed again.  Shows how fragile this is.

It is a bit fragile but I don't see any other way to handle this than
trusting on the link ordering. Both -EPROBE_DEFER and device_links are
out of the question AFAICT.

  reply	other threads:[~2018-09-05  9:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-03 13:20 [PATCH 1/2] thunderbolt: Do not handle ICM events after domain is stopped Mika Westerberg
2018-09-03 13:20 ` [PATCH 2/2] thunderbolt: Initialize after IOMMUs Mika Westerberg
2018-09-05  8:47   ` Lukas Wunner
2018-09-05  9:46     ` Mika Westerberg [this message]
2018-09-06  8:13       ` Lukas Wunner
2018-09-06 10:36         ` Mika Westerberg
2018-09-06 11:00           ` Lukas Wunner
2018-09-06 11:07             ` Mika Westerberg
2018-09-06 11:21               ` Lukas Wunner
2018-09-06 11:46                 ` Mika Westerberg
2018-09-14  7:52   ` Mika Westerberg
2018-09-14  7:52 ` [PATCH 1/2] thunderbolt: Do not handle ICM events after domain is stopped Mika Westerberg
  -- strict thread matches above, loose matches on Subject: below --
2018-09-24 10:20 [PATCH 0/2] thunderbolt: Fixes for v4.19-rc6 Mika Westerberg
2018-09-24 10:20 ` [PATCH 2/2] thunderbolt: Initialize after IOMMUs Mika Westerberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180905094602.GH2283@lahna.fi.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=YehezkelShB@gmail.com \
    --cc=andreas.noever@gmail.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=michael.jamet@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox