Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1376827yba; Thu, 16 May 2019 20:38:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJZYb2kRvVgiq6TR1C32MPsketSMMOiBcVm3cc98Mqn2pxPU3YrxAASAoOc+/leZBtK2ci X-Received: by 2002:a62:5ec2:: with SMTP id s185mr59948912pfb.16.1558064317726; Thu, 16 May 2019 20:38:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558064317; cv=none; d=google.com; s=arc-20160816; b=KURiZ325fK/VR3OUzhSPQpUMskXPK+ogODSXi6sh/5WsjW8IIsVXH3Aesy2zkUmEms Rm6Pt2N6jnfAWEF877e0GD//9dn7vGYQKzobudXWqSV/ztuG7d0H5O3Yl99M+pz7u7uf 6V9drALGAvJyCPkO/Jf+Lxz+zU2MsihB8qh5tmeMrHkyp8EE2+dmSBXZBaGnvf+NTTtt nEiAow4Cjo4b6p1p74mNvmFTIfGfoYqQV9NL4gm7egaTfWIBJ6sdc05fvunp2tws0LdW o4SsSzCAYeaXMa3SWIClkjyzTsMnNpma+BXSNARF6AttpKUFHn7+Tagp6lFaEVvsdYl1 c53A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ur8IpLq8gF2to3WfM7YOfN36My26fjgqB6sAL0vxTRg=; b=LFS2UUk13FfD7aVt+vggMnGe56HXm8jAU4Xgh/2Be8j9Zqg0f8gB+iN8OxACHWMYSO +oPKRf2qeL3vhjDEw87U407CSiAdh4zfPaxwR6UVmEhBWMRy9+SHpPkePEkVQYoKOIaD 4LJjie264rTn3kDevu9UXzSUXGVdmWjVF5tGYjZOCkHox6nT/ypMjWnbVBgF+R11kzIB i77M6uDeLD/D+3Cmh/E0YZlRE/2Jgh7z1Qt+erMR5yEX8qdOWjhhE5cZn5tMo15YCUb8 xpkosh6/88RvZdNaitblT3oHvvnvveTqLH2bSACNZWX6/ZJ1YRL0V8KpF5LSTU/b8/H2 8aVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=Arista-A header.b=dQMpvlg5; 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=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=arista.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u63si7698415pfu.88.2019.05.16.20.38.21; Thu, 16 May 2019 20:38:37 -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; dkim=pass header.i=@arista.com header.s=Arista-A header.b=dQMpvlg5; 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=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=arista.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727808AbfEQBA2 (ORCPT + 99 others); Thu, 16 May 2019 21:00:28 -0400 Received: from mx.aristanetworks.com ([162.210.129.12]:44361 "EHLO prod-mx.aristanetworks.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726575AbfEQBAY (ORCPT ); Thu, 16 May 2019 21:00:24 -0400 X-Greylist: delayed 415 seconds by postgrey-1.27 at vger.kernel.org; Thu, 16 May 2019 21:00:24 EDT Received: from prod-mx.aristanetworks.com (localhost [127.0.0.1]) by prod-mx.aristanetworks.com (Postfix) with ESMTP id 0883241CAC2; Thu, 16 May 2019 17:53:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=Arista-A; t=1558054431; bh=Ur8IpLq8gF2to3WfM7YOfN36My26fjgqB6sAL0vxTRg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=dQMpvlg5uCPVYtQeo2HxgUYHaVALw7Q7kJIUCv21j7o7nMhoxj5YRhfNGRmZWTK0b eUpZhTl6jHNYju8TWV8OmjhFKZGSsznKNRpDGSSssYoqfRuKa6Dzwe9IH7EsoLBXKB 9KEpk9beM6D3sw262x15L9LMF4lgpXmHqG5dPg6yChbIAlSDyTuJXNolenrtDpi1ut RlgMlChMllvAhW3Ig7Fe3nVhRm6ia6/7HAN413A34NaSYOMKyQkTloR8NaP/sssJrG fHUX40b1XSJ38ZHoTIyIku+oAmSC373eZoKriZCEuQAegm5grXpeUWSbqfqWFAftD3 9anCpcbXcOPPg== Received: from chmeee (unknown [10.95.92.211]) by prod-mx.aristanetworks.com (Postfix) with ESMTP id F1DD341CAC1; Thu, 16 May 2019 17:53:50 -0700 (PDT) Received: from kevmitch by chmeee with local (Exim 4.92) (envelope-from ) id 1hRR7r-000203-Ll; Thu, 16 May 2019 17:53:31 -0700 From: Kevin Mitchell To: Joerg Roedel Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Kevin Mitchell Subject: [PATCH 2/3] iommu/amd: move gart fallback to amd_iommu_init Date: Thu, 16 May 2019 17:52:41 -0700 Message-Id: <20190517005242.20257-3-kevmitch@arista.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190517005242.20257-1-kevmitch@arista.com> References: <20190517005242.20257-1-kevmitch@arista.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The fallback to the GART driver in the case amd_iommu doesn't work was executed in a function called free_iommu_resources, which didn't really make sense. This was even being called twice if amd_iommu=off was specified on the command line. The only complication is that it needs to be verified that amd_iommu has fully relinquished control by calling free_iommu_resources and emptying the amd_iommu_list. Signed-off-by: Kevin Mitchell --- drivers/iommu/amd_iommu_init.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index 3798d7303c99..5f3df5ae6ba8 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c @@ -2345,15 +2345,6 @@ static void __init free_iommu_resources(void) amd_iommu_dev_table = NULL; free_iommu_all(); - -#ifdef CONFIG_GART_IOMMU - /* - * We failed to initialize the AMD IOMMU - try fallback to GART - * if possible. - */ - gart_iommu_init(); - -#endif } /* SB IOAPIC is always on this device in AMD systems */ @@ -2774,6 +2765,16 @@ static int __init amd_iommu_init(void) } } +#ifdef CONFIG_GART_IOMMU + if (ret && list_empty(&amd_iommu_list)) { + /* + * We failed to initialize the AMD IOMMU - try fallback + * to GART if possible. + */ + gart_iommu_init(); + } +#endif + for_each_iommu(iommu) amd_iommu_debugfs_setup(iommu); -- 2.20.1