Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4543798pxj; Tue, 8 Jun 2021 17:31:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxl/DyvjFYORPuBcQNDb7w565JJtMDxZ/CsIqwiHnQ7bKXDSRJrI8M981P9/u3ppLLebRI X-Received: by 2002:a17:907:2bd6:: with SMTP id gv22mr25794232ejc.431.1623198698078; Tue, 08 Jun 2021 17:31:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623198698; cv=none; d=google.com; s=arc-20160816; b=evgZdBjrJWr7wIOxCL5yNmJ1B6PP2c6w/KQgq/2Wu2ayd9nRIv1U0HjfQexN+fm3Zn iEjwXigzkoU/c7C9BSHLWaKf7Bw9f21g5lhIjUMkbRqse0uq3v8kSMAl5XDHapPg2kcC j7IfavXyc+3lSfuqcs20sOxKEHVIVv56kUlUEvHpJf4aND3EEkmaMBfRFR24MeDtC2MT 5kpaqk9j96JREHzk2CvelP4B4jsZPwn4RGfPwKUTEOBaM1cs5FESkQEJA1hzvrbwfW3M P9QQ3V7yEdyFp/k3qJGiRZcX3nhC/npIh1zHTvUZcylRFBIuCUDzZG6xQbQd/lClmZl8 ck1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=cNxE6/CodVLnklZNQSAY20F8tZxN4mX2U3L6Pn7Z6xw=; b=PqJct66ts9o8LcahFbPFRVMhL5HSwRtAYdNgBGed9HBYgX1Psoyl0PSQDXOzMoTpk9 kxT8OyFuYFj54USoQmuCNMz79Pr3xt1amxQVy851YXSpg9xo0c8LaJdxsYEjMIRlMJJZ UgHnsB370OUZX95MBWza/rRwt4Vfjylz4+7Dca6sfiJk+nedrNy7LoOHilDXFK2YzsXp 2ydSzKJW4gcqmp9oyRb+EJ4XRZ3yqmBbRWazvGjpVOZ9RorRB9VRyxRt1RjIgpOlbwJR T78ecDDp5zlKys84XzB97RyCXl5dpME6UwyYst47goDx+2s48QHHLmCF0ZDrZcwl5KrS f/eQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u23si1109960edi.175.2021.06.08.17.31.14; Tue, 08 Jun 2021 17:31:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233018AbhFHNZG (ORCPT + 99 others); Tue, 8 Jun 2021 09:25:06 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:3179 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233030AbhFHNY4 (ORCPT ); Tue, 8 Jun 2021 09:24:56 -0400 Received: from fraeml739-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4FzrKN52vhz6H76q; Tue, 8 Jun 2021 21:13:44 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml739-chm.china.huawei.com (10.206.15.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 8 Jun 2021 15:23:02 +0200 Received: from localhost.localdomain (10.69.192.58) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 8 Jun 2021 14:22:59 +0100 From: John Garry To: , , , , CC: , , , , , , John Garry Subject: [PATCH v11 3/3] iommu/amd: Add support for IOMMU default DMA mode build options Date: Tue, 8 Jun 2021 21:18:28 +0800 Message-ID: <1623158308-180604-4-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1623158308-180604-1-git-send-email-john.garry@huawei.com> References: <1623158308-180604-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.58] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhen Lei The default DMA mode lazy, but allow this to be set to strict mode at build time. It may still be overridden by the relevant boot option. Also make IOMMU_DEFAULT_LAZY default for when AMD_IOMMU config is set. [jpg: Rebase for relocated file] Signed-off-by: Zhen Lei Signed-off-by: John Garry --- drivers/iommu/Kconfig | 2 +- drivers/iommu/amd/init.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index b68ec7ed23c0..6d99150050b9 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -95,7 +95,7 @@ choice depends on IOMMU_API depends on X86 || IA64 || X86_64 || ARM || ARM64 - default IOMMU_DEFAULT_LAZY if INTEL_IOMMU + default IOMMU_DEFAULT_LAZY if (AMD_IOMMU || INTEL_IOMMU) default IOMMU_DEFAULT_STRICT help This option allows an IOMMU DMA mode to be chosen at build time, to diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c index d006724f4dc2..af662fc37cbe 100644 --- a/drivers/iommu/amd/init.c +++ b/drivers/iommu/amd/init.c @@ -160,7 +160,8 @@ u16 amd_iommu_last_bdf; /* largest PCI device id we have to handle */ LIST_HEAD(amd_iommu_unity_map); /* a list of required unity mappings we find in ACPI */ -bool amd_iommu_unmap_flush; /* if true, flush on every unmap */ +/* if true, flush on every unmap */ +bool amd_iommu_unmap_flush = IS_ENABLED(CONFIG_IOMMU_DEFAULT_STRICT); LIST_HEAD(amd_iommu_list); /* list of all AMD IOMMUs in the system */ -- 2.26.2