Loading drivers/media/platform/msm/camera_v2/smmu/cam_smmu_api.c +10 −53 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <linux/of_platform.h> #include <linux/iommu.h> #include <linux/dma-mapping.h> #include <linux/msm_dma_iommu_mapping.h> #include "cam_smmu_api.h" #define BYTE_SIZE 8 Loading Loading @@ -333,13 +334,6 @@ static int cam_smmu_attach_device(int idx) return rc; } static void cam_smmu_detach_device(int idx) { struct cam_context_bank_info *cb = &iommu_cb_set.cb_info[idx]; arm_iommu_detach_device(cb->dev); return; } static int cam_smmu_create_add_handle_in_table(char *name, int *hdl) { Loading Loading @@ -442,9 +436,7 @@ static int cam_smmu_attach(int idx) mutex_lock(&iommu_cb_set.cb_info[idx].lock); if (iommu_cb_set.cb_info[idx].state == CAM_SMMU_ATTACH) { pr_err("Error: index %d got attached before\n", idx); ret = -EINVAL; ret = 0; } else if (iommu_cb_set.cb_info[idx].state == CAM_SMMU_DETACH) { ret = cam_smmu_attach_device(idx); if (ret < 0) { Loading @@ -462,28 +454,6 @@ static int cam_smmu_attach(int idx) return ret; } static int cam_smmu_detach(int idx) { int ret; mutex_lock(&iommu_cb_set.cb_info[idx].lock); if (iommu_cb_set.cb_info[idx].state == CAM_SMMU_DETACH) { pr_err("Error: Index %d got detached before\n", idx); ret = -EINVAL; } else if (iommu_cb_set.cb_info[idx].state == CAM_SMMU_ATTACH) { iommu_cb_set.cb_info[idx].state = CAM_SMMU_DETACH; mutex_unlock(&iommu_cb_set.cb_info[idx].lock); cam_smmu_clean_buffer_list(idx); cam_smmu_detach_device(idx); return 0; } else { pr_err("Error: Not detach/attach\n"); ret = -EINVAL; } mutex_unlock(&iommu_cb_set.cb_info[idx].lock); return ret; } static int cam_smmu_map_buffer_and_add_to_list(int idx, int ion_fd, enum dma_data_direction dma_dir, dma_addr_t *paddr_ptr, size_t *len_ptr) Loading Loading @@ -516,10 +486,10 @@ static int cam_smmu_map_buffer_and_add_to_list(int idx, int ion_fd, goto err_detach; } rc = dma_map_sg(iommu_cb_set.cb_info[idx].dev, table->sgl, table->nents, dma_dir); rc = msm_dma_map_sg_lazy(iommu_cb_set.cb_info[idx].dev, table->sgl, table->nents, dma_dir, buf); if (!rc) { pr_err("Error: dma_map_sg failed\n"); pr_err("Error: msm_dma_map_sg_lazy failed\n"); goto err_unmap_sg; } Loading Loading @@ -600,8 +570,9 @@ static int cam_smmu_unmap_buf_and_remove_from_list( } /* iommu buffer clean up */ dma_unmap_sg(iommu_cb_set.cb_info[idx].dev, mapping_info->table->sgl, mapping_info->table->nents, mapping_info->dir); msm_dma_unmap_sg(iommu_cb_set.cb_info[idx].dev, mapping_info->table->sgl, mapping_info->table->nents, mapping_info->dir, mapping_info->buf); dma_buf_unmap_attachment(mapping_info->attach, mapping_info->table, mapping_info->dir); dma_buf_detach(mapping_info->buf, mapping_info->attach); Loading Loading @@ -678,7 +649,7 @@ int cam_smmu_ops(int handle, enum cam_smmu_ops_param ops) break; } case CAM_SMMU_DETACH: { ret = cam_smmu_detach(idx); ret = 0; break; } case CAM_SMMU_VOTE: Loading Loading @@ -786,7 +757,7 @@ EXPORT_SYMBOL(cam_smmu_put_phy_addr); int cam_smmu_destroy_handle(int handle) { int idx, ret; int idx; idx = cam_smmu_find_index_by_handle(handle); if (idx < 0 || idx >= iommu_cb_set.cb_num) { pr_err("Error: index is not valid, index = %d\n", idx); Loading @@ -803,20 +774,6 @@ int cam_smmu_destroy_handle(int handle) cam_smmu_print_list(idx); } mutex_lock(&iommu_cb_set.cb_info[idx].lock); if (iommu_cb_set.cb_info[idx].state == CAM_SMMU_ATTACH) { CDBG("It should get detached before.\n"); mutex_unlock(&iommu_cb_set.cb_info[idx].lock); ret = cam_smmu_detach(idx); if (ret < 0) { pr_err("Error: Detach idx %d fail\n", idx); mutex_unlock(&iommu_table_lock); return -EINVAL; } } else { mutex_unlock(&iommu_cb_set.cb_info[idx].lock); } mutex_destroy(&iommu_cb_set.cb_info[idx].lock); mutex_unlock(&iommu_table_lock); return 0; Loading Loading
drivers/media/platform/msm/camera_v2/smmu/cam_smmu_api.c +10 −53 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <linux/of_platform.h> #include <linux/iommu.h> #include <linux/dma-mapping.h> #include <linux/msm_dma_iommu_mapping.h> #include "cam_smmu_api.h" #define BYTE_SIZE 8 Loading Loading @@ -333,13 +334,6 @@ static int cam_smmu_attach_device(int idx) return rc; } static void cam_smmu_detach_device(int idx) { struct cam_context_bank_info *cb = &iommu_cb_set.cb_info[idx]; arm_iommu_detach_device(cb->dev); return; } static int cam_smmu_create_add_handle_in_table(char *name, int *hdl) { Loading Loading @@ -442,9 +436,7 @@ static int cam_smmu_attach(int idx) mutex_lock(&iommu_cb_set.cb_info[idx].lock); if (iommu_cb_set.cb_info[idx].state == CAM_SMMU_ATTACH) { pr_err("Error: index %d got attached before\n", idx); ret = -EINVAL; ret = 0; } else if (iommu_cb_set.cb_info[idx].state == CAM_SMMU_DETACH) { ret = cam_smmu_attach_device(idx); if (ret < 0) { Loading @@ -462,28 +454,6 @@ static int cam_smmu_attach(int idx) return ret; } static int cam_smmu_detach(int idx) { int ret; mutex_lock(&iommu_cb_set.cb_info[idx].lock); if (iommu_cb_set.cb_info[idx].state == CAM_SMMU_DETACH) { pr_err("Error: Index %d got detached before\n", idx); ret = -EINVAL; } else if (iommu_cb_set.cb_info[idx].state == CAM_SMMU_ATTACH) { iommu_cb_set.cb_info[idx].state = CAM_SMMU_DETACH; mutex_unlock(&iommu_cb_set.cb_info[idx].lock); cam_smmu_clean_buffer_list(idx); cam_smmu_detach_device(idx); return 0; } else { pr_err("Error: Not detach/attach\n"); ret = -EINVAL; } mutex_unlock(&iommu_cb_set.cb_info[idx].lock); return ret; } static int cam_smmu_map_buffer_and_add_to_list(int idx, int ion_fd, enum dma_data_direction dma_dir, dma_addr_t *paddr_ptr, size_t *len_ptr) Loading Loading @@ -516,10 +486,10 @@ static int cam_smmu_map_buffer_and_add_to_list(int idx, int ion_fd, goto err_detach; } rc = dma_map_sg(iommu_cb_set.cb_info[idx].dev, table->sgl, table->nents, dma_dir); rc = msm_dma_map_sg_lazy(iommu_cb_set.cb_info[idx].dev, table->sgl, table->nents, dma_dir, buf); if (!rc) { pr_err("Error: dma_map_sg failed\n"); pr_err("Error: msm_dma_map_sg_lazy failed\n"); goto err_unmap_sg; } Loading Loading @@ -600,8 +570,9 @@ static int cam_smmu_unmap_buf_and_remove_from_list( } /* iommu buffer clean up */ dma_unmap_sg(iommu_cb_set.cb_info[idx].dev, mapping_info->table->sgl, mapping_info->table->nents, mapping_info->dir); msm_dma_unmap_sg(iommu_cb_set.cb_info[idx].dev, mapping_info->table->sgl, mapping_info->table->nents, mapping_info->dir, mapping_info->buf); dma_buf_unmap_attachment(mapping_info->attach, mapping_info->table, mapping_info->dir); dma_buf_detach(mapping_info->buf, mapping_info->attach); Loading Loading @@ -678,7 +649,7 @@ int cam_smmu_ops(int handle, enum cam_smmu_ops_param ops) break; } case CAM_SMMU_DETACH: { ret = cam_smmu_detach(idx); ret = 0; break; } case CAM_SMMU_VOTE: Loading Loading @@ -786,7 +757,7 @@ EXPORT_SYMBOL(cam_smmu_put_phy_addr); int cam_smmu_destroy_handle(int handle) { int idx, ret; int idx; idx = cam_smmu_find_index_by_handle(handle); if (idx < 0 || idx >= iommu_cb_set.cb_num) { pr_err("Error: index is not valid, index = %d\n", idx); Loading @@ -803,20 +774,6 @@ int cam_smmu_destroy_handle(int handle) cam_smmu_print_list(idx); } mutex_lock(&iommu_cb_set.cb_info[idx].lock); if (iommu_cb_set.cb_info[idx].state == CAM_SMMU_ATTACH) { CDBG("It should get detached before.\n"); mutex_unlock(&iommu_cb_set.cb_info[idx].lock); ret = cam_smmu_detach(idx); if (ret < 0) { pr_err("Error: Detach idx %d fail\n", idx); mutex_unlock(&iommu_table_lock); return -EINVAL; } } else { mutex_unlock(&iommu_cb_set.cb_info[idx].lock); } mutex_destroy(&iommu_cb_set.cb_info[idx].lock); mutex_unlock(&iommu_table_lock); return 0; Loading