Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3594649imm; Wed, 5 Sep 2018 02:47:30 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbituvOHwsHGg3NdAU1KHU4QF/yWRSvo1j2T3+nmShkkpkm2TgueWcN2oYJTqPL4/T8B+jM X-Received: by 2002:a17:902:a987:: with SMTP id bh7-v6mr38887636plb.182.1536140850727; Wed, 05 Sep 2018 02:47:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536140850; cv=none; d=google.com; s=arc-20160816; b=0Zz0EEFPCr5ND73dZeNEpCLsw4j6GhRL6o6paKTZeHkwCJIUBJTkbXcT8+fzJLnA96 lMiOVzDFcwQEJDOfOVuZyIky6Up0suX4UjdFpXSnE0FxzahupHx2rQ+QKJ/GsN20Tj+s NbqLTbQCoOb2u+Yj2hSJOfewvPH+5t+IWY3QDpcGQRO7HYtS9Lcv3HiXvrA4TDhIzG9v CJJIBSWoLlgA9WMvASbzbKcwkxyXmxzLe4FcbKEgxxYZLHbEKP1xI8VmGyUboB7GD0vM dVHLnNgWxNI9GLqjF8csNjx8Lco5xrHzQgbUnVlmRTHSZfO/3xAlsOS5EkXxpGiky4wi 84Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=FcNiT/WNC0ULaOqEisrq4uhCDDzABQj/w+FqpTeQBKQ=; b=kRrSyt9+W02tSrxLJSg9DFriE4StAda/T/PYdY/rycfsZuNLtwMcy+vV9z8nyw8dmw YgKEZayrA6l8umMQrnGi5cBFTN42J4U9R2DKIT9t7gsEa5HbmpK0CivmyrWho3vzcKPY pQA6XRot8e0ars4tD044UqoEDn7BBB7pZgcoZXldxGJS8cYVaxHQAILzCgheClbf9AHn sO+fpFvS5QsWHfg/3i1PnVC7TDIPi2/df8gihdExp/BobHNNG3TlJkSPdGUid/8U8wEb nHryQq0Rkbuh21G49yIcg9t7Qjn5TYvZmIqcP+vy+7s6y/1gAgaD8DbK/jzAII/6xZZF FAIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j15-v6si1490241pgi.478.2018.09.05.02.47.15; Wed, 05 Sep 2018 02:47:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728074AbeIEOPc (ORCPT + 99 others); Wed, 5 Sep 2018 10:15:32 -0400 Received: from mga17.intel.com ([192.55.52.151]:50621 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725862AbeIEOPc (ORCPT ); Wed, 5 Sep 2018 10:15:32 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Sep 2018 02:46:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,333,1531810800"; d="scan'208";a="70493450" Received: from lahna.fi.intel.com (HELO lahna) ([10.237.72.157]) by orsmga007.jf.intel.com with SMTP; 05 Sep 2018 02:46:03 -0700 Received: by lahna (sSMTP sendmail emulation); Wed, 05 Sep 2018 12:46:02 +0300 Date: Wed, 5 Sep 2018 12:46:02 +0300 From: Mika Westerberg To: Lukas Wunner Cc: linux-kernel@vger.kernel.org, Andreas Noever , Michael Jamet , Yehezkel Bernat , Lu Baolu Subject: Re: [PATCH 2/2] thunderbolt: Initialize after IOMMUs Message-ID: <20180905094602.GH2283@lahna.fi.intel.com> References: <20180903132012.23531-1-mika.westerberg@linux.intel.com> <20180903132012.23531-2-mika.westerberg@linux.intel.com> <20180905084746.xmckzskxzsdliz3e@wunner.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180905084746.xmckzskxzsdliz3e@wunner.de> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > --- > > 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.