Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3861887pxj; Tue, 15 Jun 2021 10:11:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBYc0k/D+ZiXA006QNYE0zDzdKdd7AA/pmC4IIZ0TkOY2Xk8HLMnMtFj92UwprHF9smCRz X-Received: by 2002:aa7:dd0b:: with SMTP id i11mr603466edv.51.1623777107943; Tue, 15 Jun 2021 10:11:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623777107; cv=none; d=google.com; s=arc-20160816; b=vD+yiA3zrRy/e6ZcDOLa4gisXKAjbqObUvXw7ZUaXtMFIc3S24xwHrHcoVeh+S90JJ hIDVt0SOhsroaMLWlKsvm3V4Gf1xFQZlIaVla/htPwThHAnCJ8O+0HkkH87EOrlzfbkV oIKqa6q9q9FqVBqsG46B1Q1UQEVv4qdHcjRJU5D6aoEyp3X5rJ8cCiqHbe2ySG/onpNr 9EHxZTBnUArgQYQItmGJSwcxFCiGRdfqjyCHc6i3V1EguT9Ixx80tv4O41W5DQh7EbZL pFtYwwoHJJM1c5Ofl+YinI9t5UqXCB9mdkQCrysJVVHHc/qgo9VOG6L/iSd0dSZDvEkS 4VSA== 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:dkim-signature; bh=VM9eS4wpKjlcLvx49KV21kWfbFyNQfWYWNDlPRoPyeE=; b=qWiq6irDDh/w0pXUQPKz+xEUZVirx5yKZWgGjalK+naRNpa8GFeK65CjSaFWEGgmUC S6rEeAXrPdlND+q2TL0IJLv89Vn+wRAbgmK1XWmHx1HuJnFU1maBPTO8MANXCXVLn5n9 MxVpgemYM7MiQwK12Ia50s0VioIvNuNWnl429jvQzMPsultBPTUw98Wu05uAc/hRlvYb LLm5rPgQWqrCNPzQ/lAbIm77BEk8AKns6OrOXjSNB4t7OToBSIOaSAtj+WJWzo3kyByz ZSp9viG9NeFtYVrpHx6y4Mbp7DWizOM8mU5W4zfWfqzNzOmGpVJiXJAZjDJC7pIZlQM7 FDlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@quicinc.com header.s=qcdkim header.b=MsGZsvFj; 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=quicinc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a4si15258924ejj.485.2021.06.15.10.11.24; Tue, 15 Jun 2021 10:11:47 -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; dkim=fail header.i=@quicinc.com header.s=qcdkim header.b=MsGZsvFj; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231446AbhFORLL (ORCPT + 99 others); Tue, 15 Jun 2021 13:11:11 -0400 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]:34909 "EHLO alexa-out-sd-02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230457AbhFORK4 (ORCPT ); Tue, 15 Jun 2021 13:10:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1623776931; x=1655312931; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=sxWsrx4i4RcguP2ruhmRSpZY5bZXyPiuYAMWoJj1fSY=; b=MsGZsvFjZ/74mQEos4lBM6RapocyUNJq9bFL/R7zvyasXvSdGIF/09Um kPUS9G7JSgYK+HVdZ1Z1RjSOnkqJd6LQCttWl0ahYZ2tkUOdtCabZN7Ui KL7SuirsfHCy3PJsXYAjZUexSB5s35tZmE7p9H8l5hHBfwsAnTtEmOUas 8=; Received: from unknown (HELO ironmsg03-sd.qualcomm.com) ([10.53.140.143]) by alexa-out-sd-02.qualcomm.com with ESMTP; 15 Jun 2021 10:08:51 -0700 X-QCInternal: smtphost Received: from nasanexm03e.na.qualcomm.com ([10.85.0.48]) by ironmsg03-sd.qualcomm.com with ESMTP/TLS/AES256-SHA; 15 Jun 2021 10:08:51 -0700 Received: from th-lint-040.qualcomm.com (10.80.80.8) by nasanexm03e.na.qualcomm.com (10.85.0.48) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 15 Jun 2021 10:08:51 -0700 From: Georgi Djakov To: , CC: , , , , , , , Subject: [PATCH v6 06/15] iommu: Split 'addr_merge' argument to iommu_pgsize() into separate parts Date: Tue, 15 Jun 2021 10:08:24 -0700 Message-ID: <1623776913-390160-7-git-send-email-quic_c_gdjako@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1623776913-390160-1-git-send-email-quic_c_gdjako@quicinc.com> References: <1623776913-390160-1-git-send-email-quic_c_gdjako@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanexm03e.na.qualcomm.com (10.85.0.48) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Will Deacon The 'addr_merge' parameter to iommu_pgsize() is a fabricated address intended to describe the alignment requirements to consider when choosing an appropriate page size. On the iommu_map() path, this address is the logical OR of the virtual and physical addresses. Subsequent improvements to iommu_pgsize() will need to check the alignment of the virtual and physical components of 'addr_merge' independently, so pass them in as separate parameters and reconstruct 'addr_merge' locally. No functional change. Signed-off-by: Will Deacon Signed-off-by: Isaac J. Manjarres Signed-off-by: Georgi Djakov --- drivers/iommu/iommu.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 80e471ada358..80e14c139d40 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -2375,12 +2375,13 @@ phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova) } EXPORT_SYMBOL_GPL(iommu_iova_to_phys); -static size_t iommu_pgsize(struct iommu_domain *domain, - unsigned long addr_merge, size_t size) +static size_t iommu_pgsize(struct iommu_domain *domain, unsigned long iova, + phys_addr_t paddr, size_t size) { unsigned int pgsize_idx; unsigned long pgsizes; size_t pgsize; + unsigned long addr_merge = paddr | iova; /* Page sizes supported by the hardware and small enough for @size */ pgsizes = domain->pgsize_bitmap & GENMASK(__fls(size), 0); @@ -2433,7 +2434,7 @@ static int __iommu_map(struct iommu_domain *domain, unsigned long iova, pr_debug("map: iova 0x%lx pa %pa size 0x%zx\n", iova, &paddr, size); while (size) { - size_t pgsize = iommu_pgsize(domain, iova | paddr, size); + size_t pgsize = iommu_pgsize(domain, iova, paddr, size); pr_debug("mapping: iova 0x%lx pa %pa pgsize 0x%zx\n", iova, &paddr, pgsize); @@ -2521,8 +2522,9 @@ static size_t __iommu_unmap(struct iommu_domain *domain, * or we hit an area that isn't mapped. */ while (unmapped < size) { - size_t pgsize = iommu_pgsize(domain, iova, size - unmapped); + size_t pgsize; + pgsize = iommu_pgsize(domain, iova, iova, size - unmapped); unmapped_page = ops->unmap(domain, iova, pgsize, iotlb_gather); if (!unmapped_page) break;