From patchwork Fri Mar 22 14:11:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen \(ThunderTown\)" X-Patchwork-Id: 160901 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp863449jan; Fri, 22 Mar 2019 07:13:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqy6kjQjRZpTMza41icJAup0LGffOoqv73W5ZvHfwQAE8R9e9vOVP3zHcUGsR7rgaBu2YILm X-Received: by 2002:a17:902:e90b:: with SMTP id cs11mr9580417plb.197.1553263996070; Fri, 22 Mar 2019 07:13:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553263996; cv=none; d=google.com; s=arc-20160816; b=OuZuS/rv+RSTxKAhuJbco/xLcw/DfCShJuGFAnvqFUENyivS54bEokxyGsnyv2+dZV Acmh3GexRGI/hlpAQbnOkRa7uhxSiYU5E7JV7u4m7F+gi/PQdfN35o9v5aOxDgxwfrlP oOpHVPZCqfFdPaJWpN9fnoVucZe0ori+1DHsratxfKw0BG5/EUKX14NPMaRbZEiuRjYg 7coZnRYkYsBBr0Eo8PEWlopE2z1rf2SWFic0hBo/lAFqbaUxUuvnc+kd/CbNm1Sg4E4I xzpXqcJtMJdJtfTHq4ZfjJLlbexaoM+XYOSClKhpyNl81G9UXbxXytdpTCxjqM1czv8r bUOA== 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=p8JCXmmY4mdPUz7mgUhIfbPf8AQLAZKy10uEiCK7Llk=; b=QcbR0ZZ4k9OS936ZedhIFJf9vsCskHWi21YqDTa2bVlNhn4Z5YFoOvSVx+0lCg4YCU Gfu+maJAsojdR9a4KOrF+H8UCex5Dj7UJg/RsPVC6RuQ8AMENEuxylVrmorz1cK3xFMh vJGsIzs+EK54gxgrj2dJ/dLuRKqC7N9q98CLdPjoMl7VJ3dyReDemi3oSAcT15PvdSn0 9VWFsqmINAcLCYyraIuqX5h59RoInMWUHo/xHn1Ewm1v07rPtet0C521A8sBoboHMrx4 pjEZ8xpsIHIT6IepNJcZjECfQxxFvyn8tjpzd/9UcEiBL2a2DSGLgI081Lcn+6qewr10 z31Q== 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 33si7534283plg.3.2019.03.22.07.13.15; Fri, 22 Mar 2019 07:13:16 -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 S1728552AbfCVONO (ORCPT + 31 others); Fri, 22 Mar 2019 10:13:14 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:50636 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727749AbfCVONN (ORCPT ); Fri, 22 Mar 2019 10:13:13 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 42CBACF8E40F0F7716F4; Fri, 22 Mar 2019 22:12:20 +0800 (CST) Received: from HGHY1l002753561.china.huawei.com (10.177.23.164) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.408.0; Fri, 22 Mar 2019 22:12:10 +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 1/1] iommu: Add config option to set lazy mode as default Date: Fri, 22 Mar 2019 22:11:21 +0800 Message-ID: <20190322141121.18428-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 defalut, 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..5ec9780f564eaf8 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -85,6 +85,20 @@ config IOMMU_DEFAULT_PASSTHROUGH If unsure, say N here. +config IOMMU_LAZY_MODE + bool "IOMMU use lazy mode to flush IOTLB and free IOVA" + depends on IOMMU_API + help + For every IOMMU 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 iommu.strict=0 + through command line on ARM64(Now, intel_iommu, amd_iommu, s390_iommu use + lazy mode as deault). If this is enabled, you can still disable with kernel + parameters, such as iommu.strict=1, intel_iommu=strict, amd_iommu=fullflush + or s390_iommu=strict 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..e307d70d1578b3b 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_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;