diff options
Diffstat (limited to 'gcip-kernel-driver/drivers/gcip/gcip-iommu.c')
-rw-r--r-- | gcip-kernel-driver/drivers/gcip/gcip-iommu.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/gcip-kernel-driver/drivers/gcip/gcip-iommu.c b/gcip-kernel-driver/drivers/gcip/gcip-iommu.c index 75509cd..50170c6 100644 --- a/gcip-kernel-driver/drivers/gcip/gcip-iommu.c +++ b/gcip-kernel-driver/drivers/gcip/gcip-iommu.c @@ -85,7 +85,11 @@ static int iovad_initialize_domain(struct gcip_iommu_domain *domain) init_iova_domain(&domain->iova_space.iovad, dpool->granule, max_t(unsigned long, 1, dpool->base_daddr >> ilog2(dpool->granule))); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0) + return iova_domain_init_rcaches(&domain->iova_space.iovad); +#else return 0; +#endif } static void iovad_finalize_domain(struct gcip_iommu_domain *domain) @@ -204,12 +208,14 @@ static ssize_t dma_iommu_map_sg(struct gcip_iommu_domain *domain, struct scatter if (!nents_mapped) return 0; - iova = sg_dma_address(sgl); + if (!domain->default_domain) { + iova = sg_dma_address(sgl); - ret = (ssize_t)iommu_map_sg(domain->domain, iova, sgl, nents, prot); - if (ret <= 0) { - dma_unmap_sg_attrs(domain->dev, sgl, nents, dir, attrs); - return 0; + ret = (ssize_t)iommu_map_sg(domain->domain, iova, sgl, nents, prot); + if (ret <= 0) { + dma_unmap_sg_attrs(domain->dev, sgl, nents, dir, attrs); + return 0; + } } return nents_mapped; @@ -222,11 +228,13 @@ static void dma_iommu_unmap_sg(struct gcip_iommu_domain *domain, struct scatterl size_t size = 0; int i; - for_each_sg (sgl, sg, nents, i) - size += sg_dma_len(sg); + if (!domain->default_domain) { + for_each_sg (sgl, sg, nents, i) + size += sg_dma_len(sg); - if (!iommu_unmap(domain->domain, sg_dma_address(sgl), size)) - dev_warn(domain->dev, "Failed to unmap sg"); + if (!iommu_unmap(domain->domain, sg_dma_address(sgl), size)) + dev_warn(domain->dev, "Failed to unmap sg"); + } dma_unmap_sg_attrs(domain->dev, sgl, nents, dir, attrs); } @@ -443,6 +451,7 @@ struct gcip_iommu_domain *gcip_iommu_get_domain_for_dev(struct device *dev) gdomain->dev = dev; gdomain->legacy_mode = true; + gdomain->default_domain = true; return gdomain; } |