Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5352401ybi; Tue, 28 May 2019 11:32:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQyBo1rwOSImIAskUHHvjLotZ2Hj1d23hAXw9HchGjPk52IqYjGkRZPhu1REK+sYDFQNZq X-Received: by 2002:a63:1d14:: with SMTP id d20mr119846689pgd.281.1559068377325; Tue, 28 May 2019 11:32:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559068377; cv=none; d=google.com; s=arc-20160816; b=h4oR1jIgYM/p4qFHFWhrw6XaU1zz6OrDXyy36JIfsyCywaO6aDxSSIWJDVqGHwxWUV ymzcCZinKeZEMwdSJZ/5kKFZLf1FiCoFp0tJTpLzOiX6VB5zEm2mwM5vbdXovAwaViTI soXtVLTbAtuqWTP50w+tHH7y7QAqqplszq2povrVrIiQe6cHdSu0l1C2UbbxBv0kU/7s jg93XFS89ls2SSdx0KD+zjJIu8gSnnH/Few6c4+8G+tL4mg4rZAkC/hqMl5hlS7845VI iLtRLPvLhNPStaV/v7tjpVxlhvHjXdynJ/XQaTnBiPXLcYi3TXsiNrzN3bmt2Of0DmNe P+cw== 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=b4If2HNPp3B1YWDdSoDgUQyWPIlmkxa6h+Pl06M3FFoKlPMiyCpsl/GfnRCNTRO4Lw EX1wPWkz0jFkLTbZtS9WQBa/D2cE1w5HPjKom1PCUyRCI4nZtJPCK0KyYD93rWgNcax+ YfoufxAhgyvNuFWp4rA7jDO1KPEMCwPncU9s0R2SpQi7ASuFqz863xupROcK4HRE0ul3 T7RaKIVPbtS3RqqTU1bfEn7vL+IZADlTCgR21yRqAg9NHpQpH0UpecRJ2kcazGuaEXHC D+kHo6psLjaRglEWO72mec9TIOkJq1eiunlHEQcAByHybBkjEb6DgciYiU7Mnj/bpfj5 iAyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=Arista-A header.b=2sCXXHF0; 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 l15si25460866pfd.285.2019.05.28.11.32.41; Tue, 28 May 2019 11:32:57 -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=2sCXXHF0; 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 S1728212AbfE1SaP (ORCPT + 99 others); Tue, 28 May 2019 14:30:15 -0400 Received: from smtp.aristanetworks.com ([54.193.82.35]:38972 "EHLO uscaw2-clmxp01.aristanetworks.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728171AbfE1SaD (ORCPT ); Tue, 28 May 2019 14:30:03 -0400 Received: from uscaw2-clmxp01.aristanetworks.com (localhost [127.0.0.1]) by uscaw2-clmxp01.aristanetworks.com (Postfix) with ESMTP id B5B0F21459D5; Tue, 28 May 2019 11:30:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=Arista-A; t=1559068202; bh=Ur8IpLq8gF2to3WfM7YOfN36My26fjgqB6sAL0vxTRg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=2sCXXHF0Kk/W/V823fzZrplTnrsbuto8mew1pgv5z3zK6llbvpzOy/ZR2w/Tz4YBC raTu+yPMJyQ1L4n1wO9fdgkJYdSKkz9UoaXku2QjxBYeg5DlRrG1Aqe96iYJAkAuVy MLSTvIy5iHTFbAuwjndwFMArd8aBz8DF9omc2QVnH/2lSnzkQLBx3N1DgXq3vEu1Pp AqBzyBUPdZt2dr4aRjJY8+N2ISs4B/itsTgByc9TkulAXPkSqrAX0y9/YfPBj05YrU /AF+D+nLEZLG/C7l5ATkC84BIhBoBRaKbrtXCRXRWTNhvIjBt7dK8M9kN5FKuJZQ7Z cRqx/fjQ3mH3g== Received: from chmeee (unknown [10.95.80.198]) by uscaw2-clmxp01.aristanetworks.com (Postfix) with ESMTP id AD1A13134185; Tue, 28 May 2019 11:30:02 -0700 (PDT) Received: from kevmitch by chmeee with local (Exim 4.92) (envelope-from ) id 1hVgrK-0000xS-77; Tue, 28 May 2019 11:30:02 -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: Tue, 28 May 2019 11:29:57 -0700 Message-Id: <20190528182958.3623-3-kevmitch@arista.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190528182958.3623-1-kevmitch@arista.com> References: <20190528182958.3623-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