Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp37258rwr; Thu, 4 May 2023 14:28:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ56OkWhtUearnJtdtpJFA8ZD8Leb6HhvgpTD0kwRWrAh8G9/C0NUOsa2sHzORL5s8EiwsQB X-Received: by 2002:a17:903:48c:b0:19d:1bc1:ce22 with SMTP id jj12-20020a170903048c00b0019d1bc1ce22mr4830249plb.5.1683235700012; Thu, 04 May 2023 14:28:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683235699; cv=none; d=google.com; s=arc-20160816; b=kVjd9UVY6P9r+FssQDY+ytgF8XuoJguvl422FwvlrHmWOp2TfiywWkRg61BxfFVk/9 OW9OtUsnK14yo8iFKY3nrNPJIi2q2WFOMwehEeKUskBeNnX5jbN//hJ5qVfp/dQTIhF4 rADEXQWKeBcdtD9k1oPWmlFKJ4z5xleKRDqmK/Tp5XbrFvZeTM7Hx/btuy0HrGi+8MOU atGyrk636O15JOft8iDqXUIxqpp3VPqardWVUU0o39Iy8xM/vHf+NzDAeSBQlSLupBal 7rYUrTTMNSMXYFgsY7MJSJxForpWMlYW0ZsthisS4qiYt/t84pswTVmzDjuHuT6Y7xCE 3WcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=e4/knk0orBcO/7DkmjAlk/OIGRMaYIjsFRHqXcq1wuw=; b=A4hqiCh09S1DrEMRmmjhBdBnB1T04jQ3mKNrFioi1sGIceAUkV9ZL30fceby98lIYY HrwQYqufCaOf63Og9IgAHlCcp3+6mY8G2qXhyRUY8C6JQMcettu+Y6aiwv0r2BIx6EdZ Y0eTbzJz3UB6MHZd8bwnUcDgQSckB3ojwpJXm9SwIgSurbljNJ6BpqH6JP9P7UJ5RSyB BIwBHJrD61A+xFmXdyA58Cjl/t+8pGzuKBeY8ICIgnEgV4L2jDQcfwubYxzwwssaiWf/ riS1cPDS+HCbCVwAGlgZ5kJsE1/+aTU1bujLz4jf0XQHnKkNJQlNQU2+2vzQ74Nl43sq UmXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q9-20020a170902788900b0019ca1961bc1si34570pll.108.2023.05.04.14.28.04; Thu, 04 May 2023 14:28:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229668AbjEDVLG (ORCPT + 99 others); Thu, 4 May 2023 17:11:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229564AbjEDVLD (ORCPT ); Thu, 4 May 2023 17:11:03 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 09BF71493C for ; Thu, 4 May 2023 14:11:02 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0BB242F4; Thu, 4 May 2023 14:11:46 -0700 (PDT) Received: from e121345-lin.cambridge.arm.com (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D76B13F67D; Thu, 4 May 2023 14:11:00 -0700 (PDT) From: Robin Murphy To: joro@8bytes.org, jgg@nvidia.com Cc: will@kernel.org, schnelle@linux.ibm.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] iommu: Add a capability for flush queue support Date: Thu, 4 May 2023 22:10:55 +0100 Message-Id: X-Mailer: git-send-email 2.39.2.101.g768bb238c484.dirty In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Passing a special type to domain_alloc to indirectly query whether flush queues are a worthwhile optimisation with the given driver is a bit clunky, and looking increasingly anachronistic. Let's put that into an explicit capability instead. Signed-off-by: Robin Murphy --- drivers/iommu/amd/iommu.c | 2 ++ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 1 + drivers/iommu/arm/arm-smmu/arm-smmu.c | 1 + drivers/iommu/intel/iommu.c | 1 + include/linux/iommu.h | 5 +++++ 5 files changed, 10 insertions(+) diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index 4a314647d1f7..9b7bd6bed664 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -2293,6 +2293,8 @@ static bool amd_iommu_capable(struct device *dev, enum iommu_cap cap) return amdr_ivrs_remap_support; case IOMMU_CAP_ENFORCE_CACHE_COHERENCY: return true; + case IOMMU_CAP_DEFERRED_FLUSH: + return true; default: break; } diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c index 3fd83fb75722..6d65a7e81df4 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2008,6 +2008,7 @@ static bool arm_smmu_capable(struct device *dev, enum iommu_cap cap) /* Assume that a coherent TCU implies coherent TBUs */ return master->smmu->features & ARM_SMMU_FEAT_COHERENCY; case IOMMU_CAP_NOEXEC: + case IOMMU_CAP_DEFERRED_FLUSH: return true; default: return false; diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c index 6e0813b26fb6..7f4ee365912c 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c @@ -1325,6 +1325,7 @@ static bool arm_smmu_capable(struct device *dev, enum iommu_cap cap) return cfg->smmu->features & ARM_SMMU_FEAT_COHERENT_WALK || device_get_dma_attr(dev) == DEV_DMA_COHERENT; case IOMMU_CAP_NOEXEC: + case IOMMU_CAP_DEFERRED_FLUSH: return true; default: return false; diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index b871a6afd803..ff923298f8ed 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -4369,6 +4369,7 @@ static bool intel_iommu_capable(struct device *dev, enum iommu_cap cap) switch (cap) { case IOMMU_CAP_CACHE_COHERENCY: + case IOMMU_CAP_DEFERRED_FLUSH: return true; case IOMMU_CAP_PRE_BOOT_PROTECTION: return dmar_platform_optin(); diff --git a/include/linux/iommu.h b/include/linux/iommu.h index e8c9a7da1060..1b7180d6edae 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -127,6 +127,11 @@ enum iommu_cap { * this device. */ IOMMU_CAP_ENFORCE_CACHE_COHERENCY, + /* + * IOMMU driver does not issue TLB maintenance during .unmap, so can + * usefully support the non-strict DMA flush queue. + */ + IOMMU_CAP_DEFERRED_FLUSH, }; /* These are the possible reserved region types */ -- 2.39.2.101.g768bb238c484.dirty