Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3468228pxj; Sun, 20 Jun 2021 22:18:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFbI33AqMH1On5nvyC3AHfadC9GfHCW0y5baSPbpVeu7bZgmRmTrIytL5oZVAZN+mKh0lg X-Received: by 2002:a92:d58e:: with SMTP id a14mr10762374iln.44.1624252695641; Sun, 20 Jun 2021 22:18:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624252695; cv=none; d=google.com; s=arc-20160816; b=MxdPveERU1MR8zAHIZVJzcjJoEBQzRInpCf98bAFSkMOS6k7+SyajZ4TM5NFGBU8lT mRln/vUln+nouX6touAbfQjZx9SIFUyANVry/ANsbjxm9m+Pj0rw5isNy41IAEzEjr27 mCDEJQv4k1jC84thVcBggE7YOZILkKRPhvkATP+DU6QRhu1LriwXC4Fd1vdVowq0qIpd sYBUNim/GRaab/bSBReUJtmCJYSbSonpoCQutTF1DRbUHeoZFKtFa2sn2iwt4iPEC3CJ CmaBGhKeODOrdNOKyKcu72KdZeSPR1lBnKBjfZpw18bHE0EWiWgcJvO7+1nehOGm6U1P pgeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject:from :references:to:cc:ironport-sdr:ironport-sdr; bh=a6jayNdL/jUBOQtlyy0oJppm4PzFu6Ec0/jMdvv8Vvk=; b=elGDnZMYcrfygscsVmlvA5wClY8XQBFfVp0eXIuEDpnwD0nMbB18Ztg+IaE0Jo9xJW 2r3xEFnrdmimuajCKH5Z8MU23sGWfoRGGRr9T0m28Ba6x+C64JiuU6MvRcOqQCioOBdi jI1N+D1aPBq9DIwqkFK5e1rlQYAzyqsgEhv2idEVLbp0kK/bZlsvSCPRPhX13e8Z1sG5 l7VhKizKv4wXCRKddlHK7ZkY5oRbEzLJddKVD0lejaQpP7tdVDcIma6x91m71Dgfyutm sUe0+XTfBFdFihS6jqaAVecYZIhVC6BnvG0jswhCsBYhW2aYlpYJr08QaHQzQDpZ3SS3 DB2A== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r8si12232294ill.83.2021.06.20.22.18.03; Sun, 20 Jun 2021 22:18:15 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229621AbhFUFTr (ORCPT + 99 others); Mon, 21 Jun 2021 01:19:47 -0400 Received: from mga06.intel.com ([134.134.136.31]:49645 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbhFUFTq (ORCPT ); Mon, 21 Jun 2021 01:19:46 -0400 IronPort-SDR: 3hn5S7zWgrUGkcg3Ypl98Hf5aaL8yznB6a2V7+IgnT1r+syQJsuQIhR0FkiPui0rbiWWoPSJ3j gF5YmjyyXxrA== X-IronPort-AV: E=McAfee;i="6200,9189,10021"; a="267919629" X-IronPort-AV: E=Sophos;i="5.83,289,1616482800"; d="scan'208";a="267919629" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jun 2021 22:17:32 -0700 IronPort-SDR: 9Xxri7XJd9v6KBQMO9fhv7VvxtB0dH0OGtBQ4S0a8I7KOm46M0mLtWytuAniowgdp2Wya2YagJ ed//po5RjGhA== X-IronPort-AV: E=Sophos;i="5.83,289,1616482800"; d="scan'208";a="453761991" Received: from blu2-mobl3.ccr.corp.intel.com (HELO [10.254.211.249]) ([10.254.211.249]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jun 2021 22:17:29 -0700 Cc: baolu.lu@linux.intel.com, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, linuxarm@huawei.com, thunder.leizhen@huawei.com, chenxiang66@hisilicon.com, linux-doc@vger.kernel.org To: John Garry , joro@8bytes.org, will@kernel.org, dwmw2@infradead.org, robin.murphy@arm.com, corbet@lwn.net References: <1624016058-189713-1-git-send-email-john.garry@huawei.com> <1624016058-189713-7-git-send-email-john.garry@huawei.com> From: Lu Baolu Subject: Re: [PATCH v14 6/6] iommu: Remove mode argument from iommu_set_dma_strict() Message-ID: Date: Mon, 21 Jun 2021 13:17:11 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <1624016058-189713-7-git-send-email-john.garry@huawei.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/6/18 19:34, John Garry wrote: > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > index 60b1ec42e73b..ff221d3ddcbc 100644 > --- a/drivers/iommu/iommu.c > +++ b/drivers/iommu/iommu.c > @@ -349,10 +349,9 @@ static int __init iommu_dma_setup(char *str) > } > early_param("iommu.strict", iommu_dma_setup); > > -void iommu_set_dma_strict(bool strict) > +void iommu_set_dma_strict(void) > { > - if (strict || !(iommu_cmd_line & IOMMU_CMD_LINE_STRICT)) > - iommu_dma_strict = strict; > + iommu_dma_strict = true; > } Sorry for this late comment. Normally the cache invalidation policy should come from the user. We have pre-build kernel option and also a kernel boot command iommu.strict to override it. These seem reasonable. We also have a helper (iommu_set_dma_strict()) so that the vendor iommu driver could squeeze in and change the previous settings mostly due to: a) vendor iommu driver specific kernel boot command. (We are about to deprecate those.) b) quirky hardware. c) kernel optimization (e.x. strict mode in VM environment). a) and b) are mandatory, while c) is optional. In any instance should c) override the flush mode specified by the user. Hence, probably we should also have another helper like: void iommu_set_dma_strict_optional() { if (!(iommu_cmd_line & IOMMU_CMD_LINE_STRICT)) iommu_dma_strict = true; } Any thoughts? Best regards, baolu