From: Janghyuck Kim Date: Sat, 7 May 2016 06:45:32 +0000 (+0900) Subject: [COMMON] iommu/exynos: add iova_to_phys X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=234d9a21dbfde41ff92e999dd961c700e7a47a28;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git [COMMON] iommu/exynos: add iova_to_phys iova_to_phys() is implemented to return physical address from iova. Change-Id: I0e0d0f91231889efadb10a18b1e07d60b01ce1dc Signed-off-by: Janghyuck Kim --- diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 13109cea161b..e69b0cb63bcc 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -971,7 +971,25 @@ err: static phys_addr_t exynos_iommu_iova_to_phys(struct iommu_domain *iommu_domain, dma_addr_t d_iova) { - return 0; + struct exynos_iommu_domain *domain = to_exynos_domain(iommu_domain); + sysmmu_iova_t iova = (sysmmu_iova_t)d_iova; + sysmmu_pte_t *entry; + phys_addr_t phys = 0; + + entry = section_entry(domain->pgtable, iova); + + if (lv1ent_section(entry)) { + phys = section_phys(entry) + section_offs(iova); + } else if (lv1ent_page(entry)) { + entry = page_entry(entry, iova); + + if (lv2ent_large(entry)) + phys = lpage_phys(entry) + lpage_offs(iova); + else if (lv2ent_small(entry)) + phys = spage_phys(entry) + spage_offs(iova); + } + + return phys; } static int exynos_iommu_of_xlate(struct device *master,