From 5c0b9cbdf90771692a64898f9cb9810b6933c20f Mon Sep 17 00:00:00 2001 From: Shubhraprakash Das Date: Fri, 2 Dec 2011 18:01:57 -0700 Subject: [PATCH] msm: iommu: Create iommu api to return the page table address Create a new iommu api to return the base address of the domain's pagetable. Change-Id: Ibf5425fa7ae253b16bfe795614bd7943efd7e3e3 Signed-off-by: Shubhraprakash Das --- drivers/iommu/iommu.c | 9 +++++++++ drivers/iommu/msm_iommu.c | 7 +++++++ include/linux/iommu.h | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index f1126834d2e..ef69d91516d 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -358,6 +358,15 @@ int iommu_unmap_range(struct iommu_domain *domain, unsigned int iova, } EXPORT_SYMBOL_GPL(iommu_unmap_range); +phys_addr_t iommu_get_pt_base_addr(struct iommu_domain *domain) +{ + if (unlikely(domain->ops->get_pt_base_addr == NULL)) + return 0; + + return domain->ops->get_pt_base_addr(domain); +} +EXPORT_SYMBOL_GPL(iommu_get_pt_base_addr); + int iommu_device_group(struct device *dev, unsigned int *groupid) { if (iommu_present(dev->bus) && dev->bus->iommu_ops->device_group) diff --git a/drivers/iommu/msm_iommu.c b/drivers/iommu/msm_iommu.c index 8a4d9a9d4ca..1125eb7344f 100644 --- a/drivers/iommu/msm_iommu.c +++ b/drivers/iommu/msm_iommu.c @@ -669,6 +669,12 @@ fail: return 0; } +static phys_addr_t msm_iommu_get_pt_base_addr(struct iommu_domain *domain) +{ + struct msm_priv *priv = domain->priv; + return __pa(priv->pgtable); +} + static struct iommu_ops msm_iommu_ops = { .domain_init = msm_iommu_domain_init, .domain_destroy = msm_iommu_domain_destroy, @@ -678,6 +684,7 @@ static struct iommu_ops msm_iommu_ops = { .unmap = msm_iommu_unmap, .iova_to_phys = msm_iommu_iova_to_phys, .domain_has_cap = msm_iommu_domain_has_cap, + .get_pt_base_addr = msm_iommu_get_pt_base_addr, .pgsize_bitmap = MSM_IOMMU_PGSIZES, }; diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 40720fc9556..95b15d6ef6c 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -19,6 +19,7 @@ #ifndef __LINUX_IOMMU_H #define __LINUX_IOMMU_H +#include #include #include @@ -79,6 +80,7 @@ struct iommu_ops { unsigned long iova); int (*domain_has_cap)(struct iommu_domain *domain, unsigned long cap); + phys_addr_t (*get_pt_base_addr)(struct iommu_domain *domain); int (*device_group)(struct device *dev, unsigned int *groupid); unsigned long pgsize_bitmap; }; @@ -103,6 +105,7 @@ extern phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, unsigned long iova); extern int iommu_domain_has_cap(struct iommu_domain *domain, unsigned long cap); +extern phys_addr_t iommu_get_pt_base_addr(struct iommu_domain *domain); extern void iommu_set_fault_handler(struct iommu_domain *domain, iommu_fault_handler_t handler); extern int iommu_device_group(struct device *dev, unsigned int *groupid); @@ -212,6 +215,11 @@ static inline int domain_has_cap(struct iommu_domain *domain, return 0; } +static inline phys_addr_t iommu_get_pt_base_addr(struct iommu_domain *domain) +{ + return 0; +} + static inline void iommu_set_fault_handler(struct iommu_domain *domain, iommu_fault_handler_t handler) {