[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1616160348-29451-5-git-send-email-john.garry@huawei.com>
Date: Fri, 19 Mar 2021 21:25:46 +0800
From: John Garry <john.garry@...wei.com>
To: <joro@...tes.org>, <will@...nel.org>, <jejb@...ux.ibm.com>,
<martin.petersen@...cle.com>, <hch@....de>,
<m.szyprowski@...sung.com>, <robin.murphy@....com>
CC: <iommu@...ts.linux-foundation.org>, <linux-kernel@...r.kernel.org>,
<linux-scsi@...r.kernel.org>, <linuxarm@...wei.com>,
John Garry <john.garry@...wei.com>
Subject: [PATCH 4/6] iommu: Add iommu_dma_set_opt_size()
Add a function which allows the max optimised IOMMU DMA size to be set.
Signed-off-by: John Garry <john.garry@...wei.com>
---
drivers/iommu/dma-iommu.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index 15b7270a5c2a..a5dfbd6c0496 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -447,6 +447,21 @@ static dma_addr_t iommu_dma_alloc_iova(struct iommu_domain *domain,
return (dma_addr_t)iova << shift;
}
+__maybe_unused
+static void iommu_dma_set_opt_size(struct device *dev, size_t size)
+{
+ struct iommu_domain *domain = iommu_get_dma_domain(dev);
+ struct iommu_dma_cookie *cookie = domain->iova_cookie;
+ struct iova_domain *iovad = &cookie->iovad;
+ unsigned long shift, iova_len;
+
+ shift = iova_shift(iovad);
+ iova_len = size >> shift;
+ iova_len = roundup_pow_of_two(iova_len);
+
+ iova_rcache_set_upper_limit(iovad, iova_len);
+}
+
static void iommu_dma_free_iova(struct iommu_dma_cookie *cookie,
dma_addr_t iova, size_t size, struct page *freelist)
{
--
2.26.2
Powered by blists - more mailing lists