rk3288: enable iep iommu mode when iommu driver available
authorljf <ljf@rock-chips.com>
Thu, 15 May 2014 01:58:53 +0000 (09:58 +0800)
committerljf <ljf@rock-chips.com>
Thu, 15 May 2014 01:58:53 +0000 (09:58 +0800)
drivers/video/rockchip/iep/hw_iep_reg.c
drivers/video/rockchip/iep/iep_drv.c
drivers/video/rockchip/iep/iep_drv.h

index 175ae424e9c16f5bb0d831e80ae47f1a1edf37ca..0552a3984fe7bddce6fec116841a5acae12303e7 100755 (executable)
@@ -1128,16 +1128,12 @@ static int iep_bufid_to_iova(iep_service_info *pservice, u8 *tbl, int size, stru
     }\r
    \r
     for (i=0; i<size; i++) {\r
-#if 0\r
-        if (copy_from_user(&usr_fd, &reg->reg[addr_tbl_vpu_dec[i]], sizeof(usr_fd)))\r
-            return -EFAULT;\r
-#else\r
         usr_fd = reg->reg[tbl[i]] & 0x3FF;\r
         offset = reg->reg[tbl[i]] >> 10;\r
-        \r
-#endif\r
         if (usr_fd != 0) {\r
             struct ion_handle *hdl;\r
+            int ret;\r
+            struct iep_mem_region *mem_region;\r
             \r
             hdl = ion_import_dma_buf(pservice->ion_client, usr_fd);\r
             if (IS_ERR(hdl)) {\r
@@ -1145,43 +1141,27 @@ static int iep_bufid_to_iova(iep_service_info *pservice, u8 *tbl, int size, stru
                 return PTR_ERR(hdl);\r
             }\r
 \r
-#if 0\r
-            {\r
-                ion_phys_addr_t phy_addr;\r
-                size_t len;\r
-                ion_phys(pservice->ion_client, hdl, &phy_addr, &len);\r
-    \r
-                reg->reg[tbl[i]] = phy_addr + offset;\r
-                \r
+            mem_region = kzalloc(sizeof(struct iep_mem_region), GFP_KERNEL);\r
\r
+            if (mem_region == NULL) {\r
+                dev_err(pservice->iommu_dev, "allocate memory for iommu memory region failed\n");\r
                 ion_free(pservice->ion_client, hdl);\r
+                return -1;\r
             }\r
-#else \r
-            {\r
-                int ret;\r
-                struct iep_mem_region *mem_region;\r
-                mem_region = kzalloc(sizeof(struct iep_mem_region), GFP_KERNEL);\r
-     \r
-                if (mem_region == NULL) {\r
-                    dev_err(pservice->iommu_dev, "allocate memory for iommu memory region failed\n");\r
-                    ion_free(pservice->ion_client, hdl);\r
-                    return -1;\r
-                }\r
-                \r
-                mem_region->hdl = hdl;\r
-                \r
-                ret = ion_map_iommu(pservice->iommu_dev, pservice->ion_client, mem_region->hdl, &mem_region->iova, &mem_region->len);\r
-                if (ret < 0) {\r
-                    dev_err(pservice->iommu_dev, "ion map iommu failed\n");\r
-                    kfree(mem_region);\r
-                    ion_free(pservice->ion_client, hdl);\r
-                    return ret;\r
-                }\r
-                \r
-                reg->reg[tbl[i]] = mem_region->iova + offset;\r
-                INIT_LIST_HEAD(&mem_region->reg_lnk);\r
-                list_add_tail(&mem_region->reg_lnk, &reg->mem_region_list);\r
+            \r
+            mem_region->hdl = hdl;\r
+            \r
+            ret = ion_map_iommu(pservice->iommu_dev, pservice->ion_client, mem_region->hdl, &mem_region->iova, &mem_region->len);\r
+            if (ret < 0) {\r
+                dev_err(pservice->iommu_dev, "ion map iommu failed\n");\r
+                kfree(mem_region);\r
+                ion_free(pservice->ion_client, hdl);\r
+                return ret;\r
             }\r
-#endif\r
+            \r
+            reg->reg[tbl[i]] = mem_region->iova + offset;\r
+            INIT_LIST_HEAD(&mem_region->reg_lnk);\r
+            list_add_tail(&mem_region->reg_lnk, &reg->mem_region_list);\r
         }\r
     }\r
     \r
@@ -1270,7 +1250,7 @@ void iep_config(iep_session *session, IEP_MSG *iep_msg)
 \r
 #if defined(CONFIG_IEP_IOMMU)\r
     if (0 > iep_reg_address_translate(&iep_service, reg)) {\r
-        pr_err("error: translate reg address failed\n");\r
+        IEP_ERR("error: translate reg address failed\n");\r
         kfree(reg);\r
         return;\r
     }\r
index 7135b7bd0ca34b988b4cd186e5b7b2a2b8b90e90..d5c8d96b102547d4d88707d80734a5fc9daf13d4 100755 (executable)
@@ -218,6 +218,13 @@ static void iep_power_on(void)
 #endif\r
 \r
     wake_lock(&iep_drvdata1->wake_lock);\r
+    \r
+#if defined(CONFIG_IEP_IOMMU)\r
+    if (iep_service.iommu_dev) {\r
+        iovmm_activate(iep_service.iommu_dev);\r
+    }\r
+#endif    \r
+    \r
     iep_service.enable = true;\r
 }\r
 \r
@@ -238,6 +245,12 @@ static void iep_power_off(void)
         IEP_WARNING("delay 50 ms for running task\n");\r
         iep_dump();\r
     }\r
+    \r
+#if defined(CONFIG_IEP_IOMMU)\r
+    if (iep_service.iommu_dev) {\r
+        iovmm_deactivate(iep_service.iommu_dev);\r
+    }\r
+#endif    \r
 \r
 #ifdef IEP_CLK_ENABLE\r
     clk_disable_unprepare(iep_drvdata1->aclk_iep);\r
@@ -870,16 +883,17 @@ static int iep_drv_probe(struct platform_device *pdev)
     }\r
     \r
 #if defined(CONFIG_IEP_IOMMU)\r
+    iep_service.iommu_dev = NULL;\r
     iep_power_on();\r
     iep_service.ion_client = rockchip_ion_client_create("iep");\r
     if (IS_ERR(iep_service.ion_client)) {\r
-        dev_err(&pdev->dev, "failed to create ion client for vcodec");\r
+        IEP_ERR("failed to create ion client for vcodec");\r
         return PTR_ERR(iep_service.ion_client);\r
     } else {\r
-        dev_info(&pdev->dev, "vcodec ion client create success!\n");\r
+        IEP_INFO("iep ion client create success!\n");\r
     }\r
    \r
-    mmu_dev = rockchip_get_sysmmu_device_by_compatible("iommu,iep");\r
+    mmu_dev = rockchip_get_sysmmu_device_by_compatible("iommu,iep_mmu");\r
     \r
     if (mmu_dev) {\r
         platform_set_sysmmu(mmu_dev, &pdev->dev);\r
index 39c650a6a4fd5de7c078b9adb42a59ddab98e20f..e0e40baccf91d91778f96f8d61b2a3cc5b781601 100755 (executable)
@@ -6,7 +6,7 @@
 #include <linux/mutex.h>\r
 \r
 #if defined(CONFIG_ROCKCHIP_IOMMU) && defined(CONFIG_ION_ROCKCHIP)\r
-//#define CONFIG_IEP_IOMMU\r
+#define CONFIG_IEP_IOMMU\r
 #endif\r
 \r
 #ifdef CONFIG_IEP_IOMMU\r