From patchwork Sun Apr 7 12:41:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen \(ThunderTown\)" X-Patchwork-Id: 161917 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp2603655jan; Sun, 7 Apr 2019 05:48:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqziaPu+4TejSOvR1Wo9eyr3ASULqG7bXxGUF+oF2bEUAEUz5CXU7n7OakxWjBTmJ25VM2VF X-Received: by 2002:a63:7d03:: with SMTP id y3mr22737259pgc.8.1554641302229; Sun, 07 Apr 2019 05:48:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554641302; cv=none; d=google.com; s=arc-20160816; b=oot9Tx9lgIn+DFHifZJk5o4IjkZ12322i9C76I/SUlFDkuj0p0iXOKkPcFxsUZQ8lq b/9YOMaEvGKiH5pUWmh6LqIpTbUVDOH9ISUog0pGWvIN+vXoLhp82qayv4Dj02uprouM H4sQ/C9tA6xzWAjbNbjx6FjjJI24E7l3feZH9gJpeIh1OMXZAoB845mj8ywa1kkDvW/j nl90M3zaBz9snXm3tudLI7aCtJAIlb6CijAhzxcDf3y01HLUT7v4DrvAzGtcDG8PiLqT isa+pXSSdd+U2/mzoHiWRA+RtNGTOuvOV+JbURI7VzA/GElC8mDODAcF2pbxwNhie63K Y4KA== 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; bh=1O6qrBle30VZf+Cta7XnZpisn3xXYPvYPMrBUIakMdc=; b=rXPbZO/rkghKSIzpk7P1dXvPo50Lb1axdiqnGCJjlVHoelp0upt/mQ6V7Nr0FujAd9 F9tmqsJWZ2xcLmyi9DU7cCoEuWwhv9nzZr8CH+0ChxSZ+FKRe2uA89Bs8sENNF5KlhUp w1h8NN5xGMLCtyMZ9/+3pLUk3oZQoycV9j7qcDMpGGcMlNfo6GLtNKnoAGOmjfiJqzY4 eoFs6QvSVYjQN8IaHFdyvHQW9Kcg85KA8P8LqPYAndDUU96jgE3CQ3dObOW/BtSlUEnl 9Oe4P5Csx2UCB1nG2r9hp0gOGXoh4qUEqoiTuVoNXLwjkKIbpakwTHQUlPphRb0Vc6Dk +QfQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z61si25194625plb.81.2019.04.07.05.48.21; Sun, 07 Apr 2019 05:48:22 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726578AbfDGMsO (ORCPT + 31 others); Sun, 7 Apr 2019 08:48:14 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:6699 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726504AbfDGMsN (ORCPT ); Sun, 7 Apr 2019 08:48:13 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id E518EAC886700A348614; Sun, 7 Apr 2019 20:48:10 +0800 (CST) Received: from HGHY1l002753561.china.huawei.com (10.177.23.164) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.408.0; Sun, 7 Apr 2019 20:48:01 +0800 From: Zhen Lei To: Jean-Philippe Brucker , John Garry , Robin Murphy , Will Deacon , Joerg Roedel , Jonathan Corbet , linux-doc , Sebastian Ott , Gerald Schaefer , "Martin Schwidefsky" , Heiko Carstens , Benjamin Herrenschmidt , Paul Mackerras , "Michael Ellerman" , Tony Luck , Fenghua Yu , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , David Woodhouse , iommu , linux-kernel , linux-s390 , linuxppc-dev , x86 , linux-ia64 CC: Zhen Lei , Hanjun Guo Subject: [PATCH v4 2/6] iommu: keep dma mode build options consistent with cmdline options Date: Sun, 7 Apr 2019 20:41:43 +0800 Message-ID: <20190407124147.13576-3-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.19.2.windows.1 In-Reply-To: <20190407124147.13576-1-thunder.leizhen@huawei.com> References: <20190407124147.13576-1-thunder.leizhen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.23.164] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org First, add build option IOMMU_DMA_MODE_LAZY, so that we have the opportunity to set lazy mode as default at build time. Then put the three config options in an choice, make people can only choose one of the three at a time, the same to the boot options iommu.dma_mode. Signed-off-by: Zhen Lei --- drivers/iommu/Kconfig | 30 +++++++++++++++++++++++++++--- drivers/iommu/iommu.c | 4 +++- 2 files changed, 30 insertions(+), 4 deletions(-) -- 1.8.3 diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index b67fcabd668f7b6..19118cfdea1c335 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -74,16 +74,40 @@ config IOMMU_DEBUGFS debug/iommu directory, and then populate a subdirectory with entries as required. -config IOMMU_DEFAULT_PASSTHROUGH - bool "IOMMU passthrough by default" +choice + prompt "IOMMU dma mode" depends on IOMMU_API + default IOMMU_DMA_MODE_STRICT + help + IOMMU dma mode, such as: passthrough, lazy, strict. + +config IOMMU_DMA_MODE_PASSTHROUGH + bool "Configure DMA to bypass the IOMMU" help Enable passthrough by default, removing the need to pass in iommu.dma_mode=passthrough or iommu=pt through command line. If this is enabled, you can still disable with iommu.dma_mode={lazy|strict} or iommu=nopt depending on the architecture. - If unsure, say N here. +config IOMMU_DMA_MODE_LAZY + bool "IOMMU DMA use lazy mode to flush IOTLB and free IOVA" + help + Support lazy mode, where for every IOMMU DMA unmap operation, the + flush operation of IOTLB and the free operation of IOVA are deferred. + They are only guaranteed to be done before the related IOVA will be + reused. Removing the need to pass in kernel parameters through + command line. For example, iommu.dma_mode=lazy on ARM64. If this is + enabled, you can still disable with kernel parameters, such as + iommu.dma_mode=strict depending on the architecture. + +config IOMMU_DMA_MODE_STRICT + bool "IOMMU DMA use strict mode to flush IOTLB and free IOVA" + help + For every IOMMU DMA unmap operation, the flush operation of IOTLB and + the free operation of IOVA are guaranteed to be done in the unmap + function. + +endchoice config OF_IOMMU def_bool y diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index e4d581e6cb8d210..b75e23a2ea08da8 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -39,8 +39,10 @@ static struct kset *iommu_group_kset; static DEFINE_IDA(iommu_group_ida); -#ifdef CONFIG_IOMMU_DEFAULT_PASSTHROUGH +#if defined(CONFIG_IOMMU_DMA_MODE_PASSTHROUGH) #define IOMMU_DEFAULT_DMA_MODE IOMMU_DMA_MODE_PASSTHROUGH +#elif defined(CONFIG_IOMMU_DMA_MODE_LAZY) +#define IOMMU_DEFAULT_DMA_MODE IOMMU_DMA_MODE_LAZY #else #define IOMMU_DEFAULT_DMA_MODE IOMMU_DMA_MODE_STRICT #endif