Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7141995ybi; Thu, 13 Jun 2019 10:15:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqw65BNaii3RHqYnHsBuD0Ahqny1N33f3e47csS4RP84kYFb3HZMTlrrOhqAFR9hQ5ugJiKZ X-Received: by 2002:a17:90a:710c:: with SMTP id h12mr724839pjk.36.1560446137231; Thu, 13 Jun 2019 10:15:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560446137; cv=none; d=google.com; s=arc-20160816; b=Fc62f3ivdzHv04CzVNt9Q6o1i6YCbc7+1J8zXPj3IJ/HZgVZZ1W1sQgK+wut83Af62 i0TJaGNx5M7quWixCXviNZMwuFZL8eeTYidy9Zm/sPkjEEaOYBWrHOBNMH+1G0WiwgGU MbtaZWPeTHu53EwiOXjKA8ejTlFLlJO4sBumbLTYVukga+VlAjC4lcMbko0Pm48wmFuh Ho5DXtp6EgcuyOZA0RJ8AcNCncCy0dnn8UiqMgsJCLDfAPn6QdMEoWovzYKL6wUBNhZj uxqZspTK8/9VmnLVIT8gydHE2fp2YpsI80GM3HALfHdRsHfhVIn17yKEx0Y/QGT8PApK uJWg== 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=e3lOUIANAt2dVlSkBCT3pwq3eK3eLd64P3efBE5jGpyn7nVyef0NRbjsAQLBwAiu9h w0xr8J0K6WB/i/IkWQ4hwy9zRmMqvp+hZ3W/l5kngQX9W+V+2zTG9kBUV30nN7xJeSDv H3IOV1thxzK7xxYgttGrMXSnJ62iOz0rp/LV96BYiv0vhwNlnJZ3zYd1AZs3zNlO1cRt 9Qtf73ofw9XKWttOZp2ln7SU/F7ZJ9gh4QtG2zEiXXi4HBx93F5j6ygxCkGzoLcmNam3 2tdjbLVnE5L8HGmkcG9G7r7PeAx8VpMAiWuNAdhr5xvOYpue2oQQJ6J4zpXZQACziDBm pMUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=Arista-A header.b=JiNDT2mG; 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 j23si101178pff.159.2019.06.13.10.14.58; Thu, 13 Jun 2019 10:15: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=JiNDT2mG; 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 S1728986AbfFMROv (ORCPT + 99 others); Thu, 13 Jun 2019 13:14:51 -0400 Received: from smtp.aristanetworks.com ([54.193.82.35]:49794 "EHLO smtp.aristanetworks.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728804AbfFLVwd (ORCPT ); Wed, 12 Jun 2019 17:52:33 -0400 Received: from smtp.aristanetworks.com (localhost [127.0.0.1]) by smtp.aristanetworks.com (Postfix) with ESMTP id E1821214A723; Wed, 12 Jun 2019 14:52:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=Arista-A; t=1560376352; bh=Ur8IpLq8gF2to3WfM7YOfN36My26fjgqB6sAL0vxTRg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=JiNDT2mGQDJpPadWx/HVKnahToM6mdkvhVNTqFXUAHzewlCL8vqpkVq8f7zFiFoZo IpGYNc2OtqUqC+Iptrq0G++UjjmwIAZQuRNsYVX7t4EwJFQMAF/Fuy35eX7Qq0JLMF +5sSp8NNtah8lrnFpgd9+E5WAQIiGhJNTFxWALOehE+b1ji35pXq468TZIUhw51IKS 8P8AjTExOOMsLXB0xTi682CahR5GAScGrrI5/DV+JvbhKnKIJRFPYdShMFVIcq13mP AGMVwa/FnLnP/keBulaigFW4oaRV8IUMyGW/+dx5CoCKSt4qJJNsxZZDQaLSV5x5jn IiBZDHy032kHw== Received: from chmeee (unknown [10.80.4.152]) by smtp.aristanetworks.com (Postfix) with ESMTP id D20273180B64; Wed, 12 Jun 2019 14:52:32 -0700 (PDT) Received: from kevmitch by chmeee with local (Exim 4.92) (envelope-from ) id 1hbBAW-0003KI-LA; Wed, 12 Jun 2019 14:52:32 -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: Wed, 12 Jun 2019 14:52:04 -0700 Message-Id: <20190612215203.12711-3-kevmitch@arista.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190612215203.12711-1-kevmitch@arista.com> References: <20190612215203.12711-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