rk3368: iommu: expose iommu tlb invalidate operation to owner
authorSimon <xxm@rock-chips.com>
Tue, 7 Apr 2015 09:50:00 +0000 (17:50 +0800)
committerSimon <xxm@rock-chips.com>
Fri, 17 Apr 2015 03:11:45 +0000 (11:11 +0800)
Signed-off-by: Simon <xxm@rock-chips.com>
drivers/iommu/rockchip-iommu.c
drivers/iommu/rockchip-iommu.h [changed mode: 0755->0644]
drivers/iommu/rockchip-iovmm.c [changed mode: 0755->0644]
include/linux/rockchip-iovmm.h [changed mode: 0755->0644]

index be089f10ecd8e12d39754bd2a334bfbe419b2764..da9492073f70b1c913f9cd32cb08c51c11dd1ff4 100644 (file)
@@ -754,6 +754,34 @@ static int rockchip_iommu_enable(struct iommu_drvdata *data, unsigned int pgtabl
        return 0;
 }
 
+int rockchip_iommu_tlb_invalidate_global(struct device *dev)
+{
+       unsigned long flags;
+       struct iommu_drvdata *data = dev_get_drvdata(dev->archdata.iommu);
+       int ret;
+
+       spin_lock_irqsave(&data->data_lock, flags);
+
+       if (rockchip_is_iommu_active(data)) {
+               int i;
+
+               for (i = 0; i < data->num_res_mem; i++) {
+                       ret = rockchip_iommu_zap_tlb(data->res_bases[i]);
+                       if (ret)
+                               dev_err(dev->archdata.iommu, "(%s) %s failed\n",
+                                       data->dbgname, __func__);
+               }
+       } else {
+               dev_dbg(dev->archdata.iommu, "(%s) Disabled. Skipping invalidating TLB.\n",
+                       data->dbgname);
+               ret = -1;
+       }
+
+       spin_unlock_irqrestore(&data->data_lock, flags);
+
+       return ret;
+}
+
 int rockchip_iommu_tlb_invalidate(struct device *dev)
 {
        unsigned long flags;
old mode 100755 (executable)
new mode 100644 (file)
index e470115..d206b55
@@ -79,12 +79,17 @@ static inline int rockchip_init_iovmm(struct device *iommu,
  * This function flush all TLB entry in iommu
  */
 int rockchip_iommu_tlb_invalidate(struct device *owner);
+int rockchip_iommu_tlb_invalidate_global(struct device *owner);
 
 #else /* CONFIG_ROCKCHIP_IOMMU */
 static inline int rockchip_iommu_tlb_invalidate(struct device *owner)
 {
        return -1;
 }
+static int rockchip_iommu_tlb_invalidate_global(struct device *owner)
+{
+       return -1;
+}
 
 #endif
 
old mode 100755 (executable)
new mode 100644 (file)
index 3be0072..193e0b5
@@ -30,6 +30,13 @@ static struct rk_vm_region *find_region(struct rk_iovmm *vmm, dma_addr_t iova)
        return NULL;
 }
 
+int rockchip_iovmm_invalidate_tlb(struct device *dev)
+{
+       int ret = rockchip_iommu_tlb_invalidate_global(dev);
+
+       return ret;
+}
+
 void rockchip_iovmm_set_fault_handler(struct device *dev,
                                       rockchip_iommu_fault_handler_t handler)
 {
old mode 100755 (executable)
new mode 100644 (file)
index 3a7dae2..9196634
@@ -107,7 +107,8 @@ void rockchip_iovmm_set_fault_handler(struct device *dev,
  * return value: non-zero if the fault is correctly resolved.
  *                zero if the fault is not handled.
  */
+
+int rockchip_iovmm_invalidate_tlb(struct device *dev);
 #else
 static inline int rockchip_iovmm_activate(struct device *dev)
 {
@@ -142,6 +143,10 @@ static inline void rockchip_iovmm_set_fault_handler(struct device *dev,
                                       rockchip_iommu_fault_handler_t handler)
 {
 }
+static inline int rockchip_iovmm_invalidate_tlb(struct device *dev)
+{
+       return -ENOSYS;
+}
 
 #endif /* CONFIG_ROCKCHIP_IOVMM */