From patchwork Mon May 10 14:17:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 433157 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp2896434jao; Mon, 10 May 2021 07:27:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKzD/s+oxJ81bvH6NinPzQ6kgmiA0IpCpDnxKoj+/LJtvCIYNFFrv+4vAwWB9gp1w0pkYZ X-Received: by 2002:a02:7110:: with SMTP id n16mr21719032jac.69.1620656834572; Mon, 10 May 2021 07:27:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620656834; cv=none; d=google.com; s=arc-20160816; b=GIWjNUX7e/aj3I73+CExW2lKWZzFQcRhtI5ocYEL8JFanHH0n+1IYl4rkZf+Nv86il ae3q98z6H7Ga94SpTcNwqDjEvO8PF7EtvUFCXVDlVOrCVl8Fv2KPrAqaESET18Mqltd2 PLrof2x2HdEXip3krC4w67ccbQlH19xW9EqiT+BKekHYjWtrwMs0dR3TFby//di5Yn4X wew/OIcF0m6frorDwhS9XNyPHPiEF+Pwr2H8d2381pdXC0wHfjo5dY9xEgFjeMEYi3Wp wIxm1PP9k5ZwesCSVRhS3LypBxjzDFbRD3/zQXiXAB9rA2Laf8Tx/e13QuLdnRDNbS+4 IugA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=/32nLBDRL8jKTEMjozf/nnNTt9LaEOB0GtMFOdJwa68=; b=ZzfoDKuxgq1CvbJaFSzAfbZoFLv5fDNBWjo/HtgxyApl8TlSSQtpD2NWAR0baokoxk yudnAxV9L1XMbcPvuGkT54Dp3U7EcbJVFNUf/PtLP6HQg1G+efYhiIgwxp8x9pkfijdf Rzc0GgFBscQ0SGYim+njcHhNKpFK3a8qGw0Pt+6lcZxTqoHNrS2x5O3NcQoHOkxR4LiX 5RC+fLLfNuB7fMV6bTXW0hO9xBXhi198NdqTkEyQPCqBSm7LvOknb0IoVHDo7AoIAwda JrAYU758Xjd4wW/MCBESmDEeSed6ubQ+x5uk1s6sbW9+quK4ojNDMVHrryD5g54mb5YD T91A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a13si13610863ilr.121.2021.05.10.07.27.14 for ; Mon, 10 May 2021 07:27:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-scsi-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-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238232AbhEJO2R (ORCPT ); Mon, 10 May 2021 10:28:17 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2680 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238906AbhEJOZr (ORCPT ); Mon, 10 May 2021 10:25:47 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Ff39B5PH8z1BKwK; Mon, 10 May 2021 22:19:58 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.498.0; Mon, 10 May 2021 22:22:27 +0800 From: John Garry To: , , , , CC: , , , , , , John Garry Subject: [PATCH v2 10/15] dma-iommu: Use init_iova_domain_ext() for IOVA domain init Date: Mon, 10 May 2021 22:17:24 +0800 Message-ID: <1620656249-68890-11-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1620656249-68890-1-git-send-email-john.garry@huawei.com> References: <1620656249-68890-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Pass the max opt iova len to init the IOVA domain, if set. Signed-off-by: John Garry --- drivers/iommu/dma-iommu.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) -- 2.26.2 diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 4fb82c554ede..574d7a901fd2 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -358,6 +358,8 @@ static int iommu_dma_init_domain(struct iommu_domain *domain, dma_addr_t base, struct iommu_dma_cookie *cookie = domain->iova_cookie; unsigned long order, base_pfn; struct iova_domain *iovad; + size_t max_opt_dma_size; + unsigned long iova_len; if (!cookie || cookie->type != IOMMU_DMA_IOVA_COOKIE) return -EINVAL; @@ -391,7 +393,18 @@ static int iommu_dma_init_domain(struct iommu_domain *domain, dma_addr_t base, return 0; } - init_iova_domain(iovad, 1UL << order, base_pfn); + max_opt_dma_size = iommu_group_get_max_opt_dma_size(dev->iommu_group); + + if (max_opt_dma_size) { + unsigned long shift = __ffs(1UL << order); + + iova_len = max_opt_dma_size >> shift; + iova_len = roundup_pow_of_two(iova_len); + } else { + iova_len = 0; + } + + init_iova_domain_ext(iovad, 1UL << order, base_pfn, iova_len); if (!cookie->fq_domain && (!dev || !dev_is_untrusted(dev)) && domain->ops->flush_iotlb_all && !iommu_get_dma_strict(domain)) {