Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp63283rwr; Thu, 4 May 2023 14:57:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ49SRXPIkp3SkBsd5SQwQ5k9zuLcNIeXpbqdmKkQ++vn+6gqDeuW4bJt6SFHE0VAndwqkbf X-Received: by 2002:a05:6a00:846:b0:641:4e80:a7c0 with SMTP id q6-20020a056a00084600b006414e80a7c0mr4764016pfk.22.1683237460618; Thu, 04 May 2023 14:57:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683237460; cv=none; d=google.com; s=arc-20160816; b=uGCRvVZiTaPk3HKgQOsN3z+9H94+S1qSjWq4vLvD7IWStYQp08G2b12ivUbqnmKqrf 2R/ZEF4RFW+hhHrcYHIj05YpCmhDd05S8pZpbMgdIOpRvmT0RXQfxm6D8U7ZX4Zav1iF bV32Svt9actrZk//Fxrdk4fZplHUP96XTz4uTyl938wJk2M0WmMqWyOZyoxIaUEA1UvE CkQEMFmzEeyWscmxkJkdPtWOeMvNjDf5eqUpXR32LH3n3ybK4yPPh6UGvihk9p1143C8 yU1VfHZgZ3jk3kA8le2fVrFXUVQEDL0ws7haHVo9gwpaQGqTGy34oud1ZK2hy8RWiUZE OABA== 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=+n/LdOQsIEaD+Z8C+ZCiLTSOGoSC2LK5wuw232d2V0c=; b=bLASgoLY10XWk8npAmoNS3zyJPt/NoKfAiX5SGGsdo8b22TtfwM3tC2H2Q5gVnQWNl nULUH9iZeu29d+VvPFUAoVxVYigW0cNcJjKk6NhHIllRb3XqsFWce2G86PTK64SExLOa Whv7xYqK/OBAVGZGrMaQ2uPtEqWYxgeh6EfpeaG4y3BC0p6hJ2vfabuvbk7MbiCkSdHg gfU5MXVSKdn8EsIBBcvsZpLclEFcm5o/6RmTkVqN8yAOGktcui6nLL23C4d9AsEKTSCe 0fRcAqjehViBsMv4AtpmUStqM5ZuT3WNKZK0YIwsEu6Rp2tyVbC2mlmuZG30ISGldDwy aTAg== 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 b193-20020a6334ca000000b0052c63dae5c1si354573pga.658.2023.05.04.14.57.28; Thu, 04 May 2023 14:57:40 -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 S229698AbjEDVLJ (ORCPT + 99 others); Thu, 4 May 2023 17:11:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229574AbjEDVLE (ORCPT ); Thu, 4 May 2023 17:11:04 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2011814376 for ; Thu, 4 May 2023 14:11:03 -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 220EF12FC; Thu, 4 May 2023 14:11:47 -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 EDD3B3F67D; Thu, 4 May 2023 14:11:01 -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 2/2] iommu: Use flush queue capability Date: Thu, 4 May 2023 22:10:56 +0100 Message-Id: <1c552d99e8ba452bdac48209fa74c0bdd52fd9d9.1683233867.git.robin.murphy@arm.com> 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 It remains really handy to have distinct DMA domain types within core code for the sake of default domain policy selection, but we can now hide that detail from drivers by using the new capability instead. Signed-off-by: Robin Murphy --- Note that IOMMU_DOMAIN_ALLOC_FLAGS would go away again with the proposed domain_alloc_paging() interface design. --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 1 - drivers/iommu/arm/arm-smmu/arm-smmu.c | 3 +-- drivers/iommu/dma-iommu.c | 3 ++- drivers/iommu/intel/iommu.c | 1 - drivers/iommu/iommu.c | 3 ++- include/linux/iommu.h | 1 + 6 files changed, 6 insertions(+), 6 deletions(-) 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 6d65a7e81df4..1ed9c4ed5db9 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2024,7 +2024,6 @@ static struct iommu_domain *arm_smmu_domain_alloc(unsigned type) if (type != IOMMU_DOMAIN_UNMANAGED && type != IOMMU_DOMAIN_DMA && - type != IOMMU_DOMAIN_DMA_FQ && type != IOMMU_DOMAIN_IDENTITY) return NULL; diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c index 7f4ee365912c..a86acd76c1df 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c @@ -856,8 +856,7 @@ static struct iommu_domain *arm_smmu_domain_alloc(unsigned type) struct arm_smmu_domain *smmu_domain; if (type != IOMMU_DOMAIN_UNMANAGED && type != IOMMU_DOMAIN_IDENTITY) { - if (using_legacy_binding || - (type != IOMMU_DOMAIN_DMA && type != IOMMU_DOMAIN_DMA_FQ)) + if (using_legacy_binding || type != IOMMU_DOMAIN_DMA) return NULL; } /* diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 7a9f0b0bddbd..c4bdd2587daf 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -586,7 +586,8 @@ static int iommu_dma_init_domain(struct iommu_domain *domain, dma_addr_t base, goto done_unlock; /* If the FQ fails we can simply fall back to strict mode */ - if (domain->type == IOMMU_DOMAIN_DMA_FQ && iommu_dma_init_fq(domain)) + if (domain->type == IOMMU_DOMAIN_DMA_FQ && + (!device_iommu_capable(dev, IOMMU_CAP_DEFERRED_FLUSH) || iommu_dma_init_fq(domain))) domain->type = IOMMU_DOMAIN_DMA; ret = iova_reserve_iommu_regions(dev, domain); diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index ff923298f8ed..8096273b034c 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -4064,7 +4064,6 @@ static struct iommu_domain *intel_iommu_domain_alloc(unsigned type) case IOMMU_DOMAIN_BLOCKED: return &blocking_domain; case IOMMU_DOMAIN_DMA: - case IOMMU_DOMAIN_DMA_FQ: case IOMMU_DOMAIN_UNMANAGED: dmar_domain = alloc_domain(type); if (!dmar_domain) { diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index f1dcfa3f1a1b..7078bf4a8ec8 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1980,11 +1980,12 @@ static struct iommu_domain *__iommu_domain_alloc(const struct bus_type *bus, unsigned type) { struct iommu_domain *domain; + unsigned int alloc_type = type & IOMMU_DOMAIN_ALLOC_FLAGS; if (bus == NULL || bus->iommu_ops == NULL) return NULL; - domain = bus->iommu_ops->domain_alloc(type); + domain = bus->iommu_ops->domain_alloc(alloc_type); if (!domain) return NULL; diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 1b7180d6edae..d31642596675 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -65,6 +65,7 @@ struct iommu_domain_geometry { #define __IOMMU_DOMAIN_SVA (1U << 4) /* Shared process address space */ +#define IOMMU_DOMAIN_ALLOC_FLAGS ~__IOMMU_DOMAIN_DMA_FQ /* * This are the possible domain-types * -- 2.39.2.101.g768bb238c484.dirty