From patchwork Wed Mar 27 15:00:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhen Lei X-Patchwork-Id: 161266 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp6587620jan; Wed, 27 Mar 2019 08:01:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqylegRrzI2sz7IPMQlQk8uyfy3agMeT0uuRRoYni+6e3gPg+tOVT7JZJZvlYXgU/o0B5NUz X-Received: by 2002:a63:e653:: with SMTP id p19mr35548388pgj.284.1553698911472; Wed, 27 Mar 2019 08:01:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553698911; cv=none; d=google.com; s=arc-20160816; b=VwOX0E390v3m6UkVfdt4biFyyz5UP8MxDsPdQj0hH+m2GmrAPgcK6IeB1/fCaiDARZ Pyc0wveA7TZ/CLHh0HtSXJL5XxS+7T3Bwbil0go8UInhEJPWTTJZswJDmZCxjcLbyX9Z RrZcYZhLdVvMHPfbi00flwosEP6Dfj6/W0YkZOFDGjqzosgjtgDYQ7tNAYciapRCB1Pg /ilXXHEXScy+PsB71ZLO5kxj+P9tv+xnosothfC0M4bxoET3N+Pq4WxByT2683LwmHUp SU29BpMfACr8kXqWNUZKJoLAXKjxdkg/JzP5uq7LUMveFhnobEtKoJvrmr5g8Z9wi0qs OzsQ== 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 :message-id:date:subject:cc:to:from; bh=9wb4iS7DwOjD2wqRDFd5rObbo+v/i5ZLCorU2SeRxY8=; b=NOLkuDCn4pmtu+w5bprnnieX0MoJYrDivNa2QlJ7ghkSKecjguJZQfSyc37R42gGVA oiO9oxD48vZ7QX1b/khvOHhWxmaB+N+sw7YBFkm7xEvYo5wVxADiBuTlgUiK3qbHmTy5 UMD9nL1GxzuKactoA3zlo7NpG3GaAy0foHrKmAmONCc4pL2bUMinBZ6mMBc4qSV80vUP EO/lXK/4NIYGfmZLPKuLmclKtNAAvdoQgrgn7EVkXo2wqjwfx84OEgT1GRtIBjv5rm5F wxGk8/dR1y5rPY3d80gld9ApcdWbol4rn6K3az320B0qzJi+UBe6Oyuh6OLPYve62p1Y 4J2Q== 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 a5si3282718plm.171.2019.03.27.08.01.51; Wed, 27 Mar 2019 08:01:51 -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 S1728761AbfC0PBt (ORCPT + 31 others); Wed, 27 Mar 2019 11:01:49 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5195 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728133AbfC0PBt (ORCPT ); Wed, 27 Mar 2019 11:01:49 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 76FD69C447E6CE066E30; Wed, 27 Mar 2019 23:01:38 +0800 (CST) Received: from HGHY1l002753561.china.huawei.com (10.177.23.164) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.408.0; Wed, 27 Mar 2019 23:01:32 +0800 From: Zhen Lei To: Jean-Philippe Brucker , John Garry , Robin Murphy , Will Deacon , Joerg Roedel , iommu , linux-kernel CC: Zhen Lei , Hanjun Guo Subject: [PATCH v2 1/1] iommu: Add config option to set lazy mode as default Date: Wed, 27 Mar 2019 23:00:30 +0800 Message-ID: <20190327150030.11112-1-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.19.2.windows.1 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 This allows the default behaviour to be controlled by a kernel config option instead of changing the command line for the kernel to include "iommu.strict=0" on ARM64 where this is desired. This is similar to CONFIG_IOMMU_DEFAULT_PASSTHROUGH. Note: At present, intel_iommu, amd_iommu and s390_iommu use lazy mode as default, so there is no need to add code for them. Signed-off-by: Zhen Lei --- drivers/iommu/Kconfig | 14 ++++++++++++++ drivers/iommu/iommu.c | 5 +++++ 2 files changed, 19 insertions(+) -- 1.8.3 diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index 6f07f3b21816c64..5daa110d0e83a07 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -85,6 +85,20 @@ config IOMMU_DEFAULT_PASSTHROUGH If unsure, say N here. +config IOMMU_DMA_DEFAULT_LAZY_MODE + bool "IOMMU DMA use lazy mode to flush IOTLB and free IOVA" + depends on IOMMU_API + 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.strict=0 on ARM64. If this is + enabled, you can still disable with kernel parameters, such as + iommu.strict=1 depending on the architecture. + + If unsure, say N here. + config OF_IOMMU def_bool y depends on OF && IOMMU_API diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 33a982e33716369..5acb98e79b5b32d 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -43,7 +43,12 @@ #else static unsigned int iommu_def_domain_type = IOMMU_DOMAIN_DMA; #endif + +#ifdef CONFIG_IOMMU_DMA_DEFAULT_LAZY_MODE +static bool iommu_dma_strict __read_mostly; +#else static bool iommu_dma_strict __read_mostly = true; +#endif struct iommu_callback_data { const struct iommu_ops *ops;