Loading arch/arm64/boot/dts/qcom/sm8150-camera.dtsi +1 −1 Original line number Diff line number Diff line Loading @@ -534,7 +534,7 @@ "svs_l1", "nominal", "turbo"; control-camnoc-axi-clk; camnoc-bus-width = <32>; camnoc-axi-clk-bw-margin-perc = <10>; camnoc-axi-clk-bw-margin-perc = <20>; qcom,msm-bus,name = "cam_ahb"; qcom,msm-bus,num-cases = <7>; qcom,msm-bus,num-paths = <1>; Loading drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c +3 −23 Original line number Diff line number Diff line Loading @@ -2681,7 +2681,6 @@ static int cam_icp_mgr_hw_close(void *hw_priv, void *hw_close_args) cam_icp_free_hfi_mem(); hw_mgr->fw_download = false; hw_mgr->secure_mode = CAM_SECURE_MODE_NON_SECURE; CAM_DBG(CAM_ICP, "Exit"); return rc; Loading Loading @@ -3940,7 +3939,6 @@ static int cam_icp_mgr_release_hw(void *hw_mgr_priv, void *release_hw_args) CAM_DBG(CAM_ICP, "Last Release"); cam_icp_mgr_icp_power_collapse(hw_mgr); cam_icp_hw_mgr_reset_clk_info(hw_mgr); hw_mgr->secure_mode = CAM_SECURE_MODE_NON_SECURE; rc = cam_ipe_bps_deint(hw_mgr); } mutex_unlock(&hw_mgr->hw_mgr_mutex); Loading Loading @@ -4072,47 +4070,29 @@ static int cam_icp_get_acquire_info(struct cam_icp_hw_mgr *hw_mgr, return -EFAULT; } if (!hw_mgr->ctxt_cnt) { hw_mgr->secure_mode = icp_dev_acquire_info.secure_mode; } else { if (hw_mgr->secure_mode != icp_dev_acquire_info.secure_mode) { CAM_ERR(CAM_ICP, "secure mode mismatch driver:%d, context:%d", hw_mgr->secure_mode, icp_dev_acquire_info.secure_mode); return -EINVAL; } } acquire_size = sizeof(struct cam_icp_acquire_dev_info) + ((icp_dev_acquire_info.num_out_res - 1) * sizeof(struct cam_icp_res_info)); ctx_data->icp_dev_acquire_info = kzalloc(acquire_size, GFP_KERNEL); if (!ctx_data->icp_dev_acquire_info) { if (!hw_mgr->ctxt_cnt) hw_mgr->secure_mode = CAM_SECURE_MODE_NON_SECURE; if (!ctx_data->icp_dev_acquire_info) return -ENOMEM; } if (copy_from_user(ctx_data->icp_dev_acquire_info, (void __user *)args->acquire_info, acquire_size)) { CAM_ERR(CAM_ICP, "Failed in acquire: size = %d", acquire_size); if (!hw_mgr->ctxt_cnt) hw_mgr->secure_mode = CAM_SECURE_MODE_NON_SECURE; kfree(ctx_data->icp_dev_acquire_info); ctx_data->icp_dev_acquire_info = NULL; return -EFAULT; } CAM_DBG(CAM_ICP, "%x %x %x %x %x %x %x %u", CAM_DBG(CAM_ICP, "%x %x %x %x %x %x %x", ctx_data->icp_dev_acquire_info->dev_type, ctx_data->icp_dev_acquire_info->in_res.format, ctx_data->icp_dev_acquire_info->in_res.width, ctx_data->icp_dev_acquire_info->in_res.height, ctx_data->icp_dev_acquire_info->in_res.fps, ctx_data->icp_dev_acquire_info->num_out_res, ctx_data->icp_dev_acquire_info->scratch_mem_size, hw_mgr->secure_mode); ctx_data->icp_dev_acquire_info->scratch_mem_size); p_icp_out = ctx_data->icp_dev_acquire_info->out_res; for (i = 0; i < icp_dev_acquire_info.num_out_res; i++) Loading drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c +21 −5 Original line number Diff line number Diff line Loading @@ -764,6 +764,8 @@ static int cam_ife_hw_mgr_acquire_res_ife_out_pixel( if (!ife_src_res->hw_res[j]) continue; hw_intf = ife_src_res->hw_res[j]->hw_intf; if (j == CAM_ISP_HW_SPLIT_LEFT) { vfe_acquire.vfe_out.split_id = CAM_ISP_HW_SPLIT_LEFT; Loading @@ -771,7 +773,7 @@ static int cam_ife_hw_mgr_acquire_res_ife_out_pixel( /*TBD */ vfe_acquire.vfe_out.is_master = 1; vfe_acquire.vfe_out.dual_slave_core = 1; (hw_intf->hw_idx == 0) ? 1 : 0; } else { vfe_acquire.vfe_out.is_master = 0; vfe_acquire.vfe_out.dual_slave_core = Loading @@ -781,10 +783,10 @@ static int cam_ife_hw_mgr_acquire_res_ife_out_pixel( vfe_acquire.vfe_out.split_id = CAM_ISP_HW_SPLIT_RIGHT; vfe_acquire.vfe_out.is_master = 0; vfe_acquire.vfe_out.dual_slave_core = 0; vfe_acquire.vfe_out.dual_slave_core = (hw_intf->hw_idx == 0) ? 1 : 0; } hw_intf = ife_src_res->hw_res[j]->hw_intf; rc = hw_intf->hw_ops.reserve(hw_intf->hw_priv, &vfe_acquire, sizeof(struct cam_vfe_acquire_args)); Loading Loading @@ -990,6 +992,7 @@ static int cam_ife_mgr_acquire_cid_res( struct cam_ife_hw_mgr_res *cid_res_temp, *cid_res_iterator; struct cam_csid_hw_reserve_resource_args csid_acquire; uint32_t acquired_cnt = 0; struct cam_isp_out_port_info *out_port = NULL; ife_hw_mgr = ife_ctx->hw_mgr; *cid_res = NULL; Loading @@ -1007,6 +1010,9 @@ static int cam_ife_mgr_acquire_cid_res( csid_acquire.res_id = csid_path; CAM_DBG(CAM_ISP, "path %d", csid_path); if (in_port->num_out_res) out_port = &(in_port->data[0]); /* Try acquiring CID resource from previously acquired HW */ list_for_each_entry(cid_res_iterator, &ife_ctx->res_list_ife_cid, list) { Loading @@ -1015,6 +1021,12 @@ static int cam_ife_mgr_acquire_cid_res( if (!cid_res_iterator->hw_res[i]) continue; if (cid_res_iterator->is_secure == 1 || (cid_res_iterator->is_secure == 0 && in_port->num_out_res && out_port->secure_mode == 1)) continue; hw_intf = cid_res_iterator->hw_res[i]->hw_intf; rc = hw_intf->hw_ops.reserve(hw_intf->hw_priv, &csid_acquire, sizeof(csid_acquire)); Loading Loading @@ -1054,7 +1066,7 @@ static int cam_ife_mgr_acquire_cid_res( } /* Acquire Left if not already acquired */ for (i = 0; i < CAM_IFE_CSID_HW_NUM_MAX; i++) { for (i = CAM_IFE_CSID_HW_NUM_MAX - 1; i >= 0; i--) { if (!ife_hw_mgr->csid_devices[i]) continue; Loading @@ -1070,7 +1082,7 @@ static int cam_ife_mgr_acquire_cid_res( } } if (i == CAM_IFE_CSID_HW_NUM_MAX || !csid_acquire.node_res) { if (i == -1 || !csid_acquire.node_res) { CAM_ERR(CAM_ISP, "Can not acquire ife cid resource for path %d", csid_path); goto put_res; Loading @@ -1084,6 +1096,10 @@ static int cam_ife_mgr_acquire_cid_res( /* CID(DT_ID) value of acquire device, require for path */ cid_res_temp->res_id = csid_acquire.node_res->res_id; cid_res_temp->is_dual_vfe = in_port->usage_type; if (in_port->num_out_res) cid_res_temp->is_secure = out_port->secure_mode; cam_ife_hw_mgr_put_res(&ife_ctx->res_list_ife_cid, cid_res); /* Loading drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.h +2 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ enum cam_ife_hw_mgr_res_type { * @parent: point to the parent resource node. * @children: point to the children resource nodes * @child_num: numbe of the child resource node. * @is_secure informs whether the resource is in secure mode or not * */ struct cam_ife_hw_mgr_res { Loading @@ -63,6 +64,7 @@ struct cam_ife_hw_mgr_res { struct cam_ife_hw_mgr_res *parent; struct cam_ife_hw_mgr_res *child[CAM_IFE_HW_OUT_RES_MAX]; uint32_t num_children; uint32_t is_secure; }; Loading drivers/media/platform/msm/camera/cam_req_mgr/cam_mem_mgr.c +89 −40 Original line number Diff line number Diff line Loading @@ -287,7 +287,7 @@ EXPORT_SYMBOL(cam_mem_get_cpu_buf); int cam_mem_mgr_cache_ops(struct cam_mem_cache_ops_cmd *cmd) { int rc = 0, idx; uint32_t ion_cache_ops; uint32_t cache_dir; unsigned long dmabuf_flag = 0; if (!cmd) Loading @@ -301,39 +301,57 @@ int cam_mem_mgr_cache_ops(struct cam_mem_cache_ops_cmd *cmd) if (!tbl.bufq[idx].active) { rc = -EINVAL; goto fail; goto end; } if (cmd->buf_handle != tbl.bufq[idx].buf_handle) { rc = -EINVAL; goto fail; goto end; } rc = dma_buf_get_flags(tbl.bufq[idx].dma_buf, &dmabuf_flag); if (rc) { CAM_ERR(CAM_MEM, "cache get flags failed %d", rc); goto fail; goto end; } if (dmabuf_flag & ION_FLAG_CACHED) { switch (cmd->mem_cache_ops) { case CAM_MEM_CLEAN_CACHE: ion_cache_ops = 1; cache_dir = DMA_FROM_DEVICE; break; case CAM_MEM_INV_CACHE: ion_cache_ops = 2; cache_dir = DMA_TO_DEVICE; break; case CAM_MEM_CLEAN_INV_CACHE: ion_cache_ops = 3; cache_dir = DMA_BIDIRECTIONAL; break; default: CAM_ERR(CAM_MEM, "invalid cache ops :%d", cmd->mem_cache_ops); rc = -EINVAL; goto fail; goto end; } } else { CAM_DBG(CAM_MEM, "BUF is not cached"); goto end; } fail: rc = dma_buf_begin_cpu_access(tbl.bufq[idx].dma_buf, cache_dir); if (rc) { CAM_ERR(CAM_MEM, "dma begin access failed rc=%d", rc); goto end; } rc = dma_buf_end_cpu_access(tbl.bufq[idx].dma_buf, cache_dir); if (rc) { CAM_ERR(CAM_MEM, "dma end access failed rc=%d", rc); goto end; } end: mutex_unlock(&tbl.bufq[idx].q_lock); return rc; } Loading Loading @@ -368,7 +386,7 @@ static int cam_mem_util_get_dma_buf_fd(size_t len, int rc = 0; if (!buf || !fd) { CAM_ERR(CAM_MEM, "Invalid params"); CAM_ERR(CAM_MEM, "Invalid params, buf=%pK, fd=%pK", buf, fd); return -EINVAL; } Loading @@ -378,7 +396,7 @@ static int cam_mem_util_get_dma_buf_fd(size_t len, *fd = dma_buf_fd(*buf, O_CLOEXEC); if (*fd < 0) { CAM_ERR(CAM_MEM, "get fd fail"); CAM_ERR(CAM_MEM, "get fd fail, *fd=%d", *fd); rc = -EINVAL; goto get_fd_fail; } Loading Loading @@ -429,13 +447,8 @@ static int cam_mem_util_ion_alloc(struct cam_mem_mgr_alloc_cmd *cmd, } static int cam_mem_util_check_flags(struct cam_mem_mgr_alloc_cmd *cmd) static int cam_mem_util_check_alloc_flags(struct cam_mem_mgr_alloc_cmd *cmd) { if (!cmd->flags) { CAM_ERR(CAM_MEM, "Invalid flags"); return -EINVAL; } if (cmd->num_hdl > CAM_MEM_MMU_MAX_HANDLE) { CAM_ERR(CAM_MEM, "Num of mmu hdl exceeded maximum(%d)", CAM_MEM_MMU_MAX_HANDLE); Loading @@ -459,14 +472,16 @@ static int cam_mem_util_check_map_flags(struct cam_mem_mgr_map_cmd *cmd) } if (cmd->num_hdl > CAM_MEM_MMU_MAX_HANDLE) { CAM_ERR(CAM_MEM, "Num of mmu hdl exceeded maximum(%d)", CAM_MEM_MMU_MAX_HANDLE); CAM_ERR(CAM_MEM, "Num of mmu hdl %d exceeded maximum(%d)", cmd->num_hdl, CAM_MEM_MMU_MAX_HANDLE); return -EINVAL; } if (cmd->flags & CAM_MEM_FLAG_PROTECTED_MODE && cmd->flags & CAM_MEM_FLAG_KMD_ACCESS) { CAM_ERR(CAM_MEM, "Kernel mapping in secure mode not allowed"); CAM_ERR(CAM_MEM, "Kernel mapping in secure mode not allowed, flags=0x%x", cmd->flags); return -EINVAL; } Loading @@ -492,12 +507,13 @@ static int cam_mem_util_map_hw_va(uint32_t flags, int dir = cam_mem_util_get_dma_dir(flags); if (dir < 0) { CAM_ERR(CAM_MEM, "fail to map DMA direction"); CAM_ERR(CAM_MEM, "fail to map DMA direction, dir=%d", dir); return dir; } CAM_DBG(CAM_MEM, "map_hw_va : flags = %x, dir=%d, num_hdls=%d", flags, dir, num_hdls); CAM_DBG(CAM_MEM, "map_hw_va : fd = %d, flags = 0x%x, dir=%d, num_hdls=%d", fd, flags, dir, num_hdls); if (flags & CAM_MEM_FLAG_PROTECTED_MODE) { for (i = 0; i < num_hdls; i++) { Loading @@ -509,7 +525,8 @@ static int cam_mem_util_map_hw_va(uint32_t flags, if (rc < 0) { CAM_ERR(CAM_MEM, "Failed to securely map to smmu"); "Failed to securely map to smmu, i=%d, fd=%d, dir=%d, mmu_hdl=%d, rc=%d", i, fd, dir, mmu_hdls[i], rc); goto multi_map_fail; } } Loading @@ -523,7 +540,9 @@ static int cam_mem_util_map_hw_va(uint32_t flags, region); if (rc < 0) { CAM_ERR(CAM_MEM, "Failed to map to smmu"); CAM_ERR(CAM_MEM, "Failed to map to smmu, i=%d, fd=%d, dir=%d, mmu_hdl=%d, region=%d, rc=%d", i, fd, dir, mmu_hdls[i], region, rc); goto multi_map_fail; } } Loading Loading @@ -558,9 +577,10 @@ int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd) } len = cmd->len; rc = cam_mem_util_check_flags(cmd); rc = cam_mem_util_check_alloc_flags(cmd); if (rc) { CAM_ERR(CAM_MEM, "Invalid flags: flags = %X", cmd->flags); CAM_ERR(CAM_MEM, "Invalid flags: flags = 0x%X, rc=%d", cmd->flags, rc); return rc; } Loading @@ -568,12 +588,15 @@ int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd) &dmabuf, &fd); if (rc) { CAM_ERR(CAM_MEM, "Ion allocation failed"); CAM_ERR(CAM_MEM, "Ion Alloc failed, len=%llu, align=%llu, flags=0x%x, num_hdl=%d", cmd->len, cmd->align, cmd->flags, cmd->num_hdl); return rc; } idx = cam_mem_get_slot(); if (idx < 0) { CAM_ERR(CAM_MEM, "Failed in getting mem slot, idx=%d", idx); rc = -ENOMEM; goto slot_fail; } Loading @@ -600,7 +623,9 @@ int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd) region); if (rc) { CAM_ERR(CAM_MEM, "Failed in map_hw_va, rc=%d", rc); CAM_ERR(CAM_MEM, "Failed in map_hw_va, flags=0x%x, fd=%d, region=%d, num_hdl=%d, rc=%d", cmd->flags, fd, region, cmd->num_hdl, rc); goto map_hw_fail; } } Loading Loading @@ -631,8 +656,9 @@ int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd) cmd->out.fd = tbl.bufq[idx].fd; cmd->out.vaddr = 0; CAM_DBG(CAM_MEM, "buf handle: %x, fd: %d, len: %zu", cmd->out.buf_handle, cmd->out.fd, CAM_DBG(CAM_MEM, "fd=%d, flags=0x%x, num_hdl=%d, idx=%d, buf handle=%x, len=%zu", cmd->out.fd, cmd->flags, cmd->num_hdl, idx, cmd->out.buf_handle, tbl.bufq[idx].len); return rc; Loading @@ -657,8 +683,11 @@ int cam_mem_mgr_map(struct cam_mem_mgr_map_cmd *cmd) return -EINVAL; } if (cmd->num_hdl > CAM_MEM_MMU_MAX_HANDLE) if (cmd->num_hdl > CAM_MEM_MMU_MAX_HANDLE) { CAM_ERR(CAM_MEM, "Num of mmu hdl %d exceeded maximum(%d)", cmd->num_hdl, CAM_MEM_MMU_MAX_HANDLE); return -EINVAL; } rc = cam_mem_util_check_map_flags(cmd); if (rc) { Loading @@ -681,9 +710,14 @@ int cam_mem_mgr_map(struct cam_mem_mgr_map_cmd *cmd) &hw_vaddr, &len, CAM_SMMU_REGION_IO); if (rc) if (rc) { CAM_ERR(CAM_MEM, "Failed in map_hw_va, flags=0x%x, fd=%d, region=%d, num_hdl=%d, rc=%d", cmd->flags, cmd->fd, CAM_SMMU_REGION_IO, cmd->num_hdl, rc); goto map_fail; } } idx = cam_mem_get_slot(); if (idx < 0) { Loading Loading @@ -716,6 +750,11 @@ int cam_mem_mgr_map(struct cam_mem_mgr_map_cmd *cmd) cmd->out.buf_handle = tbl.bufq[idx].buf_handle; cmd->out.vaddr = 0; CAM_DBG(CAM_MEM, "fd=%d, flags=0x%x, num_hdl=%d, idx=%d, buf handle=%x, len=%zu", cmd->fd, cmd->flags, cmd->num_hdl, idx, cmd->out.buf_handle, tbl.bufq[idx].len); return rc; map_fail: Loading Loading @@ -745,15 +784,19 @@ static int cam_mem_util_unmap_hw_va(int32_t idx, fd = tbl.bufq[idx].fd; CAM_DBG(CAM_MEM, "unmap_hw_va : fd=%x, flags=0x%x, num_hdls=%d, client=%d", fd, flags, num_hdls, client); "unmap_hw_va : idx=%d, fd=%x, flags=0x%x, num_hdls=%d, client=%d", idx, fd, flags, num_hdls, client); if (flags & CAM_MEM_FLAG_PROTECTED_MODE) { for (i = 0; i < num_hdls; i++) { rc = cam_smmu_unmap_stage2_iova(mmu_hdls[i], fd); if (rc < 0) if (rc < 0) { CAM_ERR(CAM_MEM, "Failed in secure unmap, i=%d, fd=%d, mmu_hdl=%d, rc=%d", i, fd, mmu_hdls[i], rc); goto unmap_end; } } } else { for (i = 0; i < num_hdls; i++) { if (client == CAM_SMMU_MAPPING_USER) { Loading @@ -768,10 +811,14 @@ static int cam_mem_util_unmap_hw_va(int32_t idx, client); rc = -EINVAL; } if (rc < 0) if (rc < 0) { CAM_ERR(CAM_MEM, "Failed in unmap, i=%d, fd=%d, mmu_hdl=%d, region=%d, rc=%d", i, fd, mmu_hdls[i], region, rc); goto unmap_end; } } } return rc; Loading Loading @@ -941,7 +988,8 @@ int cam_mem_mgr_release(struct cam_mem_mgr_release_cmd *cmd) idx = CAM_MEM_MGR_GET_HDL_IDX(cmd->buf_handle); if (idx >= CAM_MEM_BUFQ_MAX || idx <= 0) { CAM_ERR(CAM_MEM, "Incorrect index extracted from mem handle"); CAM_ERR(CAM_MEM, "Incorrect index %d extracted from mem handle", idx); return -EINVAL; } Loading @@ -952,11 +1000,12 @@ int cam_mem_mgr_release(struct cam_mem_mgr_release_cmd *cmd) if (tbl.bufq[idx].buf_handle != cmd->buf_handle) { CAM_ERR(CAM_MEM, "Released buf handle not matching within table"); "Released buf handle %d not matching within table %d, idx=%d", cmd->buf_handle, tbl.bufq[idx].buf_handle, idx); return -EINVAL; } CAM_DBG(CAM_MEM, "Releasing hdl = %x", cmd->buf_handle); CAM_DBG(CAM_MEM, "Releasing hdl = %x, idx = %d", cmd->buf_handle, idx); rc = cam_mem_util_unmap(idx, CAM_SMMU_MAPPING_USER); return rc; Loading Loading
arch/arm64/boot/dts/qcom/sm8150-camera.dtsi +1 −1 Original line number Diff line number Diff line Loading @@ -534,7 +534,7 @@ "svs_l1", "nominal", "turbo"; control-camnoc-axi-clk; camnoc-bus-width = <32>; camnoc-axi-clk-bw-margin-perc = <10>; camnoc-axi-clk-bw-margin-perc = <20>; qcom,msm-bus,name = "cam_ahb"; qcom,msm-bus,num-cases = <7>; qcom,msm-bus,num-paths = <1>; Loading
drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c +3 −23 Original line number Diff line number Diff line Loading @@ -2681,7 +2681,6 @@ static int cam_icp_mgr_hw_close(void *hw_priv, void *hw_close_args) cam_icp_free_hfi_mem(); hw_mgr->fw_download = false; hw_mgr->secure_mode = CAM_SECURE_MODE_NON_SECURE; CAM_DBG(CAM_ICP, "Exit"); return rc; Loading Loading @@ -3940,7 +3939,6 @@ static int cam_icp_mgr_release_hw(void *hw_mgr_priv, void *release_hw_args) CAM_DBG(CAM_ICP, "Last Release"); cam_icp_mgr_icp_power_collapse(hw_mgr); cam_icp_hw_mgr_reset_clk_info(hw_mgr); hw_mgr->secure_mode = CAM_SECURE_MODE_NON_SECURE; rc = cam_ipe_bps_deint(hw_mgr); } mutex_unlock(&hw_mgr->hw_mgr_mutex); Loading Loading @@ -4072,47 +4070,29 @@ static int cam_icp_get_acquire_info(struct cam_icp_hw_mgr *hw_mgr, return -EFAULT; } if (!hw_mgr->ctxt_cnt) { hw_mgr->secure_mode = icp_dev_acquire_info.secure_mode; } else { if (hw_mgr->secure_mode != icp_dev_acquire_info.secure_mode) { CAM_ERR(CAM_ICP, "secure mode mismatch driver:%d, context:%d", hw_mgr->secure_mode, icp_dev_acquire_info.secure_mode); return -EINVAL; } } acquire_size = sizeof(struct cam_icp_acquire_dev_info) + ((icp_dev_acquire_info.num_out_res - 1) * sizeof(struct cam_icp_res_info)); ctx_data->icp_dev_acquire_info = kzalloc(acquire_size, GFP_KERNEL); if (!ctx_data->icp_dev_acquire_info) { if (!hw_mgr->ctxt_cnt) hw_mgr->secure_mode = CAM_SECURE_MODE_NON_SECURE; if (!ctx_data->icp_dev_acquire_info) return -ENOMEM; } if (copy_from_user(ctx_data->icp_dev_acquire_info, (void __user *)args->acquire_info, acquire_size)) { CAM_ERR(CAM_ICP, "Failed in acquire: size = %d", acquire_size); if (!hw_mgr->ctxt_cnt) hw_mgr->secure_mode = CAM_SECURE_MODE_NON_SECURE; kfree(ctx_data->icp_dev_acquire_info); ctx_data->icp_dev_acquire_info = NULL; return -EFAULT; } CAM_DBG(CAM_ICP, "%x %x %x %x %x %x %x %u", CAM_DBG(CAM_ICP, "%x %x %x %x %x %x %x", ctx_data->icp_dev_acquire_info->dev_type, ctx_data->icp_dev_acquire_info->in_res.format, ctx_data->icp_dev_acquire_info->in_res.width, ctx_data->icp_dev_acquire_info->in_res.height, ctx_data->icp_dev_acquire_info->in_res.fps, ctx_data->icp_dev_acquire_info->num_out_res, ctx_data->icp_dev_acquire_info->scratch_mem_size, hw_mgr->secure_mode); ctx_data->icp_dev_acquire_info->scratch_mem_size); p_icp_out = ctx_data->icp_dev_acquire_info->out_res; for (i = 0; i < icp_dev_acquire_info.num_out_res; i++) Loading
drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c +21 −5 Original line number Diff line number Diff line Loading @@ -764,6 +764,8 @@ static int cam_ife_hw_mgr_acquire_res_ife_out_pixel( if (!ife_src_res->hw_res[j]) continue; hw_intf = ife_src_res->hw_res[j]->hw_intf; if (j == CAM_ISP_HW_SPLIT_LEFT) { vfe_acquire.vfe_out.split_id = CAM_ISP_HW_SPLIT_LEFT; Loading @@ -771,7 +773,7 @@ static int cam_ife_hw_mgr_acquire_res_ife_out_pixel( /*TBD */ vfe_acquire.vfe_out.is_master = 1; vfe_acquire.vfe_out.dual_slave_core = 1; (hw_intf->hw_idx == 0) ? 1 : 0; } else { vfe_acquire.vfe_out.is_master = 0; vfe_acquire.vfe_out.dual_slave_core = Loading @@ -781,10 +783,10 @@ static int cam_ife_hw_mgr_acquire_res_ife_out_pixel( vfe_acquire.vfe_out.split_id = CAM_ISP_HW_SPLIT_RIGHT; vfe_acquire.vfe_out.is_master = 0; vfe_acquire.vfe_out.dual_slave_core = 0; vfe_acquire.vfe_out.dual_slave_core = (hw_intf->hw_idx == 0) ? 1 : 0; } hw_intf = ife_src_res->hw_res[j]->hw_intf; rc = hw_intf->hw_ops.reserve(hw_intf->hw_priv, &vfe_acquire, sizeof(struct cam_vfe_acquire_args)); Loading Loading @@ -990,6 +992,7 @@ static int cam_ife_mgr_acquire_cid_res( struct cam_ife_hw_mgr_res *cid_res_temp, *cid_res_iterator; struct cam_csid_hw_reserve_resource_args csid_acquire; uint32_t acquired_cnt = 0; struct cam_isp_out_port_info *out_port = NULL; ife_hw_mgr = ife_ctx->hw_mgr; *cid_res = NULL; Loading @@ -1007,6 +1010,9 @@ static int cam_ife_mgr_acquire_cid_res( csid_acquire.res_id = csid_path; CAM_DBG(CAM_ISP, "path %d", csid_path); if (in_port->num_out_res) out_port = &(in_port->data[0]); /* Try acquiring CID resource from previously acquired HW */ list_for_each_entry(cid_res_iterator, &ife_ctx->res_list_ife_cid, list) { Loading @@ -1015,6 +1021,12 @@ static int cam_ife_mgr_acquire_cid_res( if (!cid_res_iterator->hw_res[i]) continue; if (cid_res_iterator->is_secure == 1 || (cid_res_iterator->is_secure == 0 && in_port->num_out_res && out_port->secure_mode == 1)) continue; hw_intf = cid_res_iterator->hw_res[i]->hw_intf; rc = hw_intf->hw_ops.reserve(hw_intf->hw_priv, &csid_acquire, sizeof(csid_acquire)); Loading Loading @@ -1054,7 +1066,7 @@ static int cam_ife_mgr_acquire_cid_res( } /* Acquire Left if not already acquired */ for (i = 0; i < CAM_IFE_CSID_HW_NUM_MAX; i++) { for (i = CAM_IFE_CSID_HW_NUM_MAX - 1; i >= 0; i--) { if (!ife_hw_mgr->csid_devices[i]) continue; Loading @@ -1070,7 +1082,7 @@ static int cam_ife_mgr_acquire_cid_res( } } if (i == CAM_IFE_CSID_HW_NUM_MAX || !csid_acquire.node_res) { if (i == -1 || !csid_acquire.node_res) { CAM_ERR(CAM_ISP, "Can not acquire ife cid resource for path %d", csid_path); goto put_res; Loading @@ -1084,6 +1096,10 @@ static int cam_ife_mgr_acquire_cid_res( /* CID(DT_ID) value of acquire device, require for path */ cid_res_temp->res_id = csid_acquire.node_res->res_id; cid_res_temp->is_dual_vfe = in_port->usage_type; if (in_port->num_out_res) cid_res_temp->is_secure = out_port->secure_mode; cam_ife_hw_mgr_put_res(&ife_ctx->res_list_ife_cid, cid_res); /* Loading
drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.h +2 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ enum cam_ife_hw_mgr_res_type { * @parent: point to the parent resource node. * @children: point to the children resource nodes * @child_num: numbe of the child resource node. * @is_secure informs whether the resource is in secure mode or not * */ struct cam_ife_hw_mgr_res { Loading @@ -63,6 +64,7 @@ struct cam_ife_hw_mgr_res { struct cam_ife_hw_mgr_res *parent; struct cam_ife_hw_mgr_res *child[CAM_IFE_HW_OUT_RES_MAX]; uint32_t num_children; uint32_t is_secure; }; Loading
drivers/media/platform/msm/camera/cam_req_mgr/cam_mem_mgr.c +89 −40 Original line number Diff line number Diff line Loading @@ -287,7 +287,7 @@ EXPORT_SYMBOL(cam_mem_get_cpu_buf); int cam_mem_mgr_cache_ops(struct cam_mem_cache_ops_cmd *cmd) { int rc = 0, idx; uint32_t ion_cache_ops; uint32_t cache_dir; unsigned long dmabuf_flag = 0; if (!cmd) Loading @@ -301,39 +301,57 @@ int cam_mem_mgr_cache_ops(struct cam_mem_cache_ops_cmd *cmd) if (!tbl.bufq[idx].active) { rc = -EINVAL; goto fail; goto end; } if (cmd->buf_handle != tbl.bufq[idx].buf_handle) { rc = -EINVAL; goto fail; goto end; } rc = dma_buf_get_flags(tbl.bufq[idx].dma_buf, &dmabuf_flag); if (rc) { CAM_ERR(CAM_MEM, "cache get flags failed %d", rc); goto fail; goto end; } if (dmabuf_flag & ION_FLAG_CACHED) { switch (cmd->mem_cache_ops) { case CAM_MEM_CLEAN_CACHE: ion_cache_ops = 1; cache_dir = DMA_FROM_DEVICE; break; case CAM_MEM_INV_CACHE: ion_cache_ops = 2; cache_dir = DMA_TO_DEVICE; break; case CAM_MEM_CLEAN_INV_CACHE: ion_cache_ops = 3; cache_dir = DMA_BIDIRECTIONAL; break; default: CAM_ERR(CAM_MEM, "invalid cache ops :%d", cmd->mem_cache_ops); rc = -EINVAL; goto fail; goto end; } } else { CAM_DBG(CAM_MEM, "BUF is not cached"); goto end; } fail: rc = dma_buf_begin_cpu_access(tbl.bufq[idx].dma_buf, cache_dir); if (rc) { CAM_ERR(CAM_MEM, "dma begin access failed rc=%d", rc); goto end; } rc = dma_buf_end_cpu_access(tbl.bufq[idx].dma_buf, cache_dir); if (rc) { CAM_ERR(CAM_MEM, "dma end access failed rc=%d", rc); goto end; } end: mutex_unlock(&tbl.bufq[idx].q_lock); return rc; } Loading Loading @@ -368,7 +386,7 @@ static int cam_mem_util_get_dma_buf_fd(size_t len, int rc = 0; if (!buf || !fd) { CAM_ERR(CAM_MEM, "Invalid params"); CAM_ERR(CAM_MEM, "Invalid params, buf=%pK, fd=%pK", buf, fd); return -EINVAL; } Loading @@ -378,7 +396,7 @@ static int cam_mem_util_get_dma_buf_fd(size_t len, *fd = dma_buf_fd(*buf, O_CLOEXEC); if (*fd < 0) { CAM_ERR(CAM_MEM, "get fd fail"); CAM_ERR(CAM_MEM, "get fd fail, *fd=%d", *fd); rc = -EINVAL; goto get_fd_fail; } Loading Loading @@ -429,13 +447,8 @@ static int cam_mem_util_ion_alloc(struct cam_mem_mgr_alloc_cmd *cmd, } static int cam_mem_util_check_flags(struct cam_mem_mgr_alloc_cmd *cmd) static int cam_mem_util_check_alloc_flags(struct cam_mem_mgr_alloc_cmd *cmd) { if (!cmd->flags) { CAM_ERR(CAM_MEM, "Invalid flags"); return -EINVAL; } if (cmd->num_hdl > CAM_MEM_MMU_MAX_HANDLE) { CAM_ERR(CAM_MEM, "Num of mmu hdl exceeded maximum(%d)", CAM_MEM_MMU_MAX_HANDLE); Loading @@ -459,14 +472,16 @@ static int cam_mem_util_check_map_flags(struct cam_mem_mgr_map_cmd *cmd) } if (cmd->num_hdl > CAM_MEM_MMU_MAX_HANDLE) { CAM_ERR(CAM_MEM, "Num of mmu hdl exceeded maximum(%d)", CAM_MEM_MMU_MAX_HANDLE); CAM_ERR(CAM_MEM, "Num of mmu hdl %d exceeded maximum(%d)", cmd->num_hdl, CAM_MEM_MMU_MAX_HANDLE); return -EINVAL; } if (cmd->flags & CAM_MEM_FLAG_PROTECTED_MODE && cmd->flags & CAM_MEM_FLAG_KMD_ACCESS) { CAM_ERR(CAM_MEM, "Kernel mapping in secure mode not allowed"); CAM_ERR(CAM_MEM, "Kernel mapping in secure mode not allowed, flags=0x%x", cmd->flags); return -EINVAL; } Loading @@ -492,12 +507,13 @@ static int cam_mem_util_map_hw_va(uint32_t flags, int dir = cam_mem_util_get_dma_dir(flags); if (dir < 0) { CAM_ERR(CAM_MEM, "fail to map DMA direction"); CAM_ERR(CAM_MEM, "fail to map DMA direction, dir=%d", dir); return dir; } CAM_DBG(CAM_MEM, "map_hw_va : flags = %x, dir=%d, num_hdls=%d", flags, dir, num_hdls); CAM_DBG(CAM_MEM, "map_hw_va : fd = %d, flags = 0x%x, dir=%d, num_hdls=%d", fd, flags, dir, num_hdls); if (flags & CAM_MEM_FLAG_PROTECTED_MODE) { for (i = 0; i < num_hdls; i++) { Loading @@ -509,7 +525,8 @@ static int cam_mem_util_map_hw_va(uint32_t flags, if (rc < 0) { CAM_ERR(CAM_MEM, "Failed to securely map to smmu"); "Failed to securely map to smmu, i=%d, fd=%d, dir=%d, mmu_hdl=%d, rc=%d", i, fd, dir, mmu_hdls[i], rc); goto multi_map_fail; } } Loading @@ -523,7 +540,9 @@ static int cam_mem_util_map_hw_va(uint32_t flags, region); if (rc < 0) { CAM_ERR(CAM_MEM, "Failed to map to smmu"); CAM_ERR(CAM_MEM, "Failed to map to smmu, i=%d, fd=%d, dir=%d, mmu_hdl=%d, region=%d, rc=%d", i, fd, dir, mmu_hdls[i], region, rc); goto multi_map_fail; } } Loading Loading @@ -558,9 +577,10 @@ int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd) } len = cmd->len; rc = cam_mem_util_check_flags(cmd); rc = cam_mem_util_check_alloc_flags(cmd); if (rc) { CAM_ERR(CAM_MEM, "Invalid flags: flags = %X", cmd->flags); CAM_ERR(CAM_MEM, "Invalid flags: flags = 0x%X, rc=%d", cmd->flags, rc); return rc; } Loading @@ -568,12 +588,15 @@ int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd) &dmabuf, &fd); if (rc) { CAM_ERR(CAM_MEM, "Ion allocation failed"); CAM_ERR(CAM_MEM, "Ion Alloc failed, len=%llu, align=%llu, flags=0x%x, num_hdl=%d", cmd->len, cmd->align, cmd->flags, cmd->num_hdl); return rc; } idx = cam_mem_get_slot(); if (idx < 0) { CAM_ERR(CAM_MEM, "Failed in getting mem slot, idx=%d", idx); rc = -ENOMEM; goto slot_fail; } Loading @@ -600,7 +623,9 @@ int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd) region); if (rc) { CAM_ERR(CAM_MEM, "Failed in map_hw_va, rc=%d", rc); CAM_ERR(CAM_MEM, "Failed in map_hw_va, flags=0x%x, fd=%d, region=%d, num_hdl=%d, rc=%d", cmd->flags, fd, region, cmd->num_hdl, rc); goto map_hw_fail; } } Loading Loading @@ -631,8 +656,9 @@ int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd) cmd->out.fd = tbl.bufq[idx].fd; cmd->out.vaddr = 0; CAM_DBG(CAM_MEM, "buf handle: %x, fd: %d, len: %zu", cmd->out.buf_handle, cmd->out.fd, CAM_DBG(CAM_MEM, "fd=%d, flags=0x%x, num_hdl=%d, idx=%d, buf handle=%x, len=%zu", cmd->out.fd, cmd->flags, cmd->num_hdl, idx, cmd->out.buf_handle, tbl.bufq[idx].len); return rc; Loading @@ -657,8 +683,11 @@ int cam_mem_mgr_map(struct cam_mem_mgr_map_cmd *cmd) return -EINVAL; } if (cmd->num_hdl > CAM_MEM_MMU_MAX_HANDLE) if (cmd->num_hdl > CAM_MEM_MMU_MAX_HANDLE) { CAM_ERR(CAM_MEM, "Num of mmu hdl %d exceeded maximum(%d)", cmd->num_hdl, CAM_MEM_MMU_MAX_HANDLE); return -EINVAL; } rc = cam_mem_util_check_map_flags(cmd); if (rc) { Loading @@ -681,9 +710,14 @@ int cam_mem_mgr_map(struct cam_mem_mgr_map_cmd *cmd) &hw_vaddr, &len, CAM_SMMU_REGION_IO); if (rc) if (rc) { CAM_ERR(CAM_MEM, "Failed in map_hw_va, flags=0x%x, fd=%d, region=%d, num_hdl=%d, rc=%d", cmd->flags, cmd->fd, CAM_SMMU_REGION_IO, cmd->num_hdl, rc); goto map_fail; } } idx = cam_mem_get_slot(); if (idx < 0) { Loading Loading @@ -716,6 +750,11 @@ int cam_mem_mgr_map(struct cam_mem_mgr_map_cmd *cmd) cmd->out.buf_handle = tbl.bufq[idx].buf_handle; cmd->out.vaddr = 0; CAM_DBG(CAM_MEM, "fd=%d, flags=0x%x, num_hdl=%d, idx=%d, buf handle=%x, len=%zu", cmd->fd, cmd->flags, cmd->num_hdl, idx, cmd->out.buf_handle, tbl.bufq[idx].len); return rc; map_fail: Loading Loading @@ -745,15 +784,19 @@ static int cam_mem_util_unmap_hw_va(int32_t idx, fd = tbl.bufq[idx].fd; CAM_DBG(CAM_MEM, "unmap_hw_va : fd=%x, flags=0x%x, num_hdls=%d, client=%d", fd, flags, num_hdls, client); "unmap_hw_va : idx=%d, fd=%x, flags=0x%x, num_hdls=%d, client=%d", idx, fd, flags, num_hdls, client); if (flags & CAM_MEM_FLAG_PROTECTED_MODE) { for (i = 0; i < num_hdls; i++) { rc = cam_smmu_unmap_stage2_iova(mmu_hdls[i], fd); if (rc < 0) if (rc < 0) { CAM_ERR(CAM_MEM, "Failed in secure unmap, i=%d, fd=%d, mmu_hdl=%d, rc=%d", i, fd, mmu_hdls[i], rc); goto unmap_end; } } } else { for (i = 0; i < num_hdls; i++) { if (client == CAM_SMMU_MAPPING_USER) { Loading @@ -768,10 +811,14 @@ static int cam_mem_util_unmap_hw_va(int32_t idx, client); rc = -EINVAL; } if (rc < 0) if (rc < 0) { CAM_ERR(CAM_MEM, "Failed in unmap, i=%d, fd=%d, mmu_hdl=%d, region=%d, rc=%d", i, fd, mmu_hdls[i], region, rc); goto unmap_end; } } } return rc; Loading Loading @@ -941,7 +988,8 @@ int cam_mem_mgr_release(struct cam_mem_mgr_release_cmd *cmd) idx = CAM_MEM_MGR_GET_HDL_IDX(cmd->buf_handle); if (idx >= CAM_MEM_BUFQ_MAX || idx <= 0) { CAM_ERR(CAM_MEM, "Incorrect index extracted from mem handle"); CAM_ERR(CAM_MEM, "Incorrect index %d extracted from mem handle", idx); return -EINVAL; } Loading @@ -952,11 +1000,12 @@ int cam_mem_mgr_release(struct cam_mem_mgr_release_cmd *cmd) if (tbl.bufq[idx].buf_handle != cmd->buf_handle) { CAM_ERR(CAM_MEM, "Released buf handle not matching within table"); "Released buf handle %d not matching within table %d, idx=%d", cmd->buf_handle, tbl.bufq[idx].buf_handle, idx); return -EINVAL; } CAM_DBG(CAM_MEM, "Releasing hdl = %x", cmd->buf_handle); CAM_DBG(CAM_MEM, "Releasing hdl = %x, idx = %d", cmd->buf_handle, idx); rc = cam_mem_util_unmap(idx, CAM_SMMU_MAPPING_USER); return rc; Loading