Loading drivers/media/platform/msm/ais/cam_cdm/cam_cdm.h +12 −1 Original line number Diff line number Diff line /* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. /* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -251,6 +251,17 @@ struct cam_cdm_intf_mgr { int32_t refcount; }; /** * struct cam_cdm_debugfs_entry : debugfs entry struct * * @dentry : entry of debugfs * @dump_register : flag to dump registers */ struct cam_cdm_debugfs_entry { struct dentry *dentry; bool dump_register; }; int cam_cdm_intf_register_hw_cdm(struct cam_hw_intf *hw, struct cam_cdm_private_dt_data *data, enum cam_cdm_type type, uint32_t *index); Loading drivers/media/platform/msm/ais/cam_cdm/cam_cdm_hw_core.c +39 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,8 @@ static void cam_hw_cdm_work(struct work_struct *work); static struct cam_cdm_debugfs_entry debugfs_entry; /* DT match table entry for all CDM variants*/ static const struct of_device_id msm_cam_hw_cdm_dt_match[] = { { Loading Loading @@ -69,6 +71,31 @@ int cam_hw_cdm_bl_fifo_pending_bl_rb(struct cam_hw_info *cdm_hw, return rc; } static int cam_hw_cdm_create_debugfs_entry(void) { int rc = 0; debugfs_entry.dentry = debugfs_create_dir("camera_cdm", NULL); if (!debugfs_entry.dentry) return -ENOMEM; if (!debugfs_create_bool("dump_register", 0644, debugfs_entry.dentry, &debugfs_entry.dump_register)) { CAM_ERR(CAM_CDM, "failed to create dump_register entry"); rc = -ENOMEM; goto err; } return rc; err: debugfs_remove_recursive(debugfs_entry.dentry); debugfs_entry.dentry = NULL; return rc; } static int cam_hw_cdm_enable_bl_done_irq(struct cam_hw_info *cdm_hw, bool enable) { Loading Loading @@ -186,6 +213,9 @@ void cam_hw_cdm_dump_core_debug_registers( { uint32_t dump_reg, core_dbg, loop_cnt; if (!debugfs_entry.dump_register) return; mutex_lock(&cdm_hw->hw_mutex); cam_cdm_read_hw_reg(cdm_hw, CDM_CFG_CORE_EN, &dump_reg); CAM_ERR(CAM_CDM, "CDM HW core status=%x", dump_reg); Loading Loading @@ -482,6 +512,14 @@ int cam_hw_cdm_submit_bl(struct cam_hw_info *cdm_hw, if ((!rc) && (hw_vaddr_ptr) && (len) && (len >= cdm_cmd->cmd[i].offset)) { if ((len - cdm_cmd->cmd[i].offset) < cdm_cmd->cmd[i].len) { CAM_ERR(CAM_CDM, "Not enough buffer"); rc = -EINVAL; break; } CAM_DBG(CAM_CDM, "Got the HW VA"); if (core->bl_tag >= (CAM_CDM_HWFIFO_SIZE - 1)) Loading Loading @@ -1012,6 +1050,7 @@ int cam_hw_cdm_probe(struct platform_device *pdev) } cdm_hw->open_count--; mutex_unlock(&cdm_hw->hw_mutex); cam_hw_cdm_create_debugfs_entry(); CAM_DBG(CAM_CDM, "CDM%d probe successful", cdm_hw_intf->hw_idx); Loading drivers/media/platform/msm/ais/cam_fd/fd_hw_mgr/cam_fd_hw_mgr.c +9 −0 Original line number Diff line number Diff line Loading @@ -596,6 +596,15 @@ static int cam_fd_mgr_util_prepare_io_buf_info(int32_t iommu_hdl, return -ENOMEM; } if (io_cfg[i].offsets[plane] >= size) { CAM_ERR(CAM_FD, "Invalid cpu buf %d %d %d", io_cfg[i].direction, io_cfg[i].resource_type, plane); rc = -EINVAL; goto rel_cpu_buf; } io_addr[plane] += io_cfg[i].offsets[plane]; } Loading drivers/media/platform/msm/ais/cam_icp/cam_icp_context.c +16 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,14 @@ static int cam_icp_context_dump_active_request(void *data, unsigned long iova, return -EINVAL; } mutex_lock(&ctx->ctx_mutex); if (ctx->state < CAM_CTX_ACQUIRED || ctx->state > CAM_CTX_ACTIVATED) { CAM_ERR(CAM_ICP, "Invalid state icp ctx %d state %d", ctx->ctx_id, ctx->state); goto end; } CAM_INFO(CAM_ICP, "iommu fault for icp ctx %d state %d", ctx->ctx_id, ctx->state); Loading @@ -63,6 +71,8 @@ static int cam_icp_context_dump_active_request(void *data, unsigned long iova, req->request_id, rc); } end: mutex_unlock(&ctx->ctx_mutex); return rc; } Loading Loading @@ -137,6 +147,12 @@ static int __cam_icp_config_dev_in_ready(struct cam_context *ctx, return rc; } if ((len < sizeof(struct cam_packet)) || (cmd->offset >= (len - sizeof(struct cam_packet)))) { CAM_ERR(CAM_CTXT, "Not enough buf"); return -EINVAL; } packet = (struct cam_packet *) ((uint8_t *)packet_addr + (uint32_t)cmd->offset); Loading drivers/media/platform/msm/ais/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c +109 −18 Original line number Diff line number Diff line Loading @@ -64,6 +64,37 @@ static struct cam_icp_hw_mgr icp_hw_mgr; static void cam_icp_mgr_process_dbg_buf(unsigned int debug_lvl); static int cam_icp_dump_io_cfg(struct cam_icp_hw_ctx_data *ctx_data, int32_t buf_handle) { uintptr_t vaddr_ptr; uint32_t *ptr; size_t len; int rc, i; char buf[512]; int used = 0; rc = cam_mem_get_cpu_buf(buf_handle, &vaddr_ptr, &len); if (rc) { CAM_ERR(CAM_ICP, "Unable to get io_cfg buf address for %d", ctx_data->ctx_id); return rc; } len = len / sizeof(uint32_t); ptr = (uint32_t *)vaddr_ptr; for (i = 0; i < len; i++) { used += snprintf(buf + used, sizeof(buf) - used, "0X%08X-", ptr[i]); if (!(i % 8)) { CAM_INFO(CAM_ICP, "%s: %s", __func__, buf); used = 0; } } return rc; } static int cam_icp_send_ubwc_cfg(struct cam_icp_hw_mgr *hw_mgr) { struct cam_hw_intf *a5_dev_intf = NULL; Loading Loading @@ -1262,6 +1293,44 @@ static int cam_icp_mgr_ipe_bps_power_collapse(struct cam_icp_hw_mgr *hw_mgr, return rc; } static int cam_icp_mgr_ipe_bps_get_gdsc_control( struct cam_icp_hw_mgr *hw_mgr) { int rc = 0; struct cam_hw_intf *ipe0_dev_intf = NULL; struct cam_hw_intf *ipe1_dev_intf = NULL; struct cam_hw_intf *bps_dev_intf = NULL; ipe0_dev_intf = hw_mgr->ipe0_dev_intf; ipe1_dev_intf = hw_mgr->ipe1_dev_intf; bps_dev_intf = hw_mgr->bps_dev_intf; if ((!ipe0_dev_intf) || (!bps_dev_intf)) { CAM_ERR(CAM_ICP, "dev intfs are wrong"); return -EINVAL; } if (icp_hw_mgr.ipe_bps_pc_flag) { rc = bps_dev_intf->hw_ops.process_cmd( bps_dev_intf->hw_priv, CAM_ICP_BPS_CMD_POWER_COLLAPSE, NULL, 0); rc = ipe0_dev_intf->hw_ops.process_cmd( ipe0_dev_intf->hw_priv, CAM_ICP_IPE_CMD_POWER_COLLAPSE, NULL, 0); if (ipe1_dev_intf) { rc = ipe1_dev_intf->hw_ops.process_cmd( ipe1_dev_intf->hw_priv, CAM_ICP_IPE_CMD_POWER_COLLAPSE, NULL, 0); } } return rc; } static int cam_icp_set_dbg_default_clk(void *data, u64 val) { icp_hw_mgr.icp_debug_clk = val; Loading Loading @@ -1786,13 +1855,16 @@ static int cam_icp_ipebps_reset(struct cam_icp_hw_mgr *hw_mgr) ipe1_dev_intf = hw_mgr->ipe1_dev_intf; bps_dev_intf = hw_mgr->bps_dev_intf; if (hw_mgr->bps_ctxt_cnt) { rc = bps_dev_intf->hw_ops.process_cmd( bps_dev_intf->hw_priv, CAM_ICP_BPS_CMD_RESET, NULL, 0); if (rc) CAM_ERR(CAM_ICP, "bps reset failed"); } if (hw_mgr->ipe_ctxt_cnt) { rc = ipe0_dev_intf->hw_ops.process_cmd( ipe0_dev_intf->hw_priv, CAM_ICP_IPE_CMD_RESET, Loading @@ -1808,6 +1880,7 @@ static int cam_icp_ipebps_reset(struct cam_icp_hw_mgr *hw_mgr) if (rc) CAM_ERR(CAM_ICP, "ipe1 reset failed"); } } return 0; } Loading @@ -1827,6 +1900,7 @@ static int cam_icp_mgr_trigger_recovery(struct cam_icp_hw_mgr *hw_mgr) sfr_buffer = (struct sfr_buf *)icp_hw_mgr.hfi_mem.sfr_buf.kva; CAM_WARN(CAM_ICP, "SFR:%s", sfr_buffer->msg); cam_icp_mgr_ipe_bps_get_gdsc_control(hw_mgr); cam_icp_ipebps_reset(hw_mgr); atomic_set(&hw_mgr->recovery, 1); Loading Loading @@ -3449,6 +3523,17 @@ static int cam_icp_mgr_process_cmd_desc(struct cam_icp_hw_mgr *hw_mgr, goto rel_cmd_buf; } *fw_cmd_buf_iova_addr = addr; if (cmd_desc[i].offset >= len || ((len - cmd_desc[i].offset) < cmd_desc[i].size)){ CAM_ERR(CAM_ICP, "Invalid offset/length, i %d offset 0x%x len 0x%x size 0x%x", i, cmd_desc[i].offset, len, cmd_desc[i].size); goto rel_cmd_buf; } *fw_cmd_buf_iova_addr = (*fw_cmd_buf_iova_addr + cmd_desc[i].offset); rc = cam_mem_get_cpu_buf(cmd_desc[i].mem_handle, Loading Loading @@ -4052,8 +4137,12 @@ static int cam_icp_mgr_prepare_hw_update(void *hw_mgr_priv, packet = prepare_args->packet; if (cam_packet_util_validate_packet(packet, prepare_args->remain_len)) if (cam_packet_util_validate_packet(packet, prepare_args->remain_len)) { mutex_unlock(&ctx_data->ctx_mutex); CAM_ERR(CAM_ICP, "ctx id: %u packet req id %lld validate fail", ctx_data->ctx_id, packet->header.request_id); return -EINVAL; } rc = cam_icp_mgr_pkt_validation(packet); if (rc) { Loading Loading @@ -4674,6 +4763,8 @@ static int cam_icp_mgr_acquire_hw(void *hw_mgr_priv, void *acquire_hw_args) rc = cam_icp_mgr_send_config_io(ctx_data, io_buf_addr); if (rc) { CAM_ERR(CAM_ICP, "IO Config command failed %d", rc); cam_icp_dump_io_cfg(ctx_data, icp_dev_acquire_info->io_config_cmd_handle); goto ioconfig_failed; } Loading Loading
drivers/media/platform/msm/ais/cam_cdm/cam_cdm.h +12 −1 Original line number Diff line number Diff line /* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. /* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -251,6 +251,17 @@ struct cam_cdm_intf_mgr { int32_t refcount; }; /** * struct cam_cdm_debugfs_entry : debugfs entry struct * * @dentry : entry of debugfs * @dump_register : flag to dump registers */ struct cam_cdm_debugfs_entry { struct dentry *dentry; bool dump_register; }; int cam_cdm_intf_register_hw_cdm(struct cam_hw_intf *hw, struct cam_cdm_private_dt_data *data, enum cam_cdm_type type, uint32_t *index); Loading
drivers/media/platform/msm/ais/cam_cdm/cam_cdm_hw_core.c +39 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,8 @@ static void cam_hw_cdm_work(struct work_struct *work); static struct cam_cdm_debugfs_entry debugfs_entry; /* DT match table entry for all CDM variants*/ static const struct of_device_id msm_cam_hw_cdm_dt_match[] = { { Loading Loading @@ -69,6 +71,31 @@ int cam_hw_cdm_bl_fifo_pending_bl_rb(struct cam_hw_info *cdm_hw, return rc; } static int cam_hw_cdm_create_debugfs_entry(void) { int rc = 0; debugfs_entry.dentry = debugfs_create_dir("camera_cdm", NULL); if (!debugfs_entry.dentry) return -ENOMEM; if (!debugfs_create_bool("dump_register", 0644, debugfs_entry.dentry, &debugfs_entry.dump_register)) { CAM_ERR(CAM_CDM, "failed to create dump_register entry"); rc = -ENOMEM; goto err; } return rc; err: debugfs_remove_recursive(debugfs_entry.dentry); debugfs_entry.dentry = NULL; return rc; } static int cam_hw_cdm_enable_bl_done_irq(struct cam_hw_info *cdm_hw, bool enable) { Loading Loading @@ -186,6 +213,9 @@ void cam_hw_cdm_dump_core_debug_registers( { uint32_t dump_reg, core_dbg, loop_cnt; if (!debugfs_entry.dump_register) return; mutex_lock(&cdm_hw->hw_mutex); cam_cdm_read_hw_reg(cdm_hw, CDM_CFG_CORE_EN, &dump_reg); CAM_ERR(CAM_CDM, "CDM HW core status=%x", dump_reg); Loading Loading @@ -482,6 +512,14 @@ int cam_hw_cdm_submit_bl(struct cam_hw_info *cdm_hw, if ((!rc) && (hw_vaddr_ptr) && (len) && (len >= cdm_cmd->cmd[i].offset)) { if ((len - cdm_cmd->cmd[i].offset) < cdm_cmd->cmd[i].len) { CAM_ERR(CAM_CDM, "Not enough buffer"); rc = -EINVAL; break; } CAM_DBG(CAM_CDM, "Got the HW VA"); if (core->bl_tag >= (CAM_CDM_HWFIFO_SIZE - 1)) Loading Loading @@ -1012,6 +1050,7 @@ int cam_hw_cdm_probe(struct platform_device *pdev) } cdm_hw->open_count--; mutex_unlock(&cdm_hw->hw_mutex); cam_hw_cdm_create_debugfs_entry(); CAM_DBG(CAM_CDM, "CDM%d probe successful", cdm_hw_intf->hw_idx); Loading
drivers/media/platform/msm/ais/cam_fd/fd_hw_mgr/cam_fd_hw_mgr.c +9 −0 Original line number Diff line number Diff line Loading @@ -596,6 +596,15 @@ static int cam_fd_mgr_util_prepare_io_buf_info(int32_t iommu_hdl, return -ENOMEM; } if (io_cfg[i].offsets[plane] >= size) { CAM_ERR(CAM_FD, "Invalid cpu buf %d %d %d", io_cfg[i].direction, io_cfg[i].resource_type, plane); rc = -EINVAL; goto rel_cpu_buf; } io_addr[plane] += io_cfg[i].offsets[plane]; } Loading
drivers/media/platform/msm/ais/cam_icp/cam_icp_context.c +16 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,14 @@ static int cam_icp_context_dump_active_request(void *data, unsigned long iova, return -EINVAL; } mutex_lock(&ctx->ctx_mutex); if (ctx->state < CAM_CTX_ACQUIRED || ctx->state > CAM_CTX_ACTIVATED) { CAM_ERR(CAM_ICP, "Invalid state icp ctx %d state %d", ctx->ctx_id, ctx->state); goto end; } CAM_INFO(CAM_ICP, "iommu fault for icp ctx %d state %d", ctx->ctx_id, ctx->state); Loading @@ -63,6 +71,8 @@ static int cam_icp_context_dump_active_request(void *data, unsigned long iova, req->request_id, rc); } end: mutex_unlock(&ctx->ctx_mutex); return rc; } Loading Loading @@ -137,6 +147,12 @@ static int __cam_icp_config_dev_in_ready(struct cam_context *ctx, return rc; } if ((len < sizeof(struct cam_packet)) || (cmd->offset >= (len - sizeof(struct cam_packet)))) { CAM_ERR(CAM_CTXT, "Not enough buf"); return -EINVAL; } packet = (struct cam_packet *) ((uint8_t *)packet_addr + (uint32_t)cmd->offset); Loading
drivers/media/platform/msm/ais/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c +109 −18 Original line number Diff line number Diff line Loading @@ -64,6 +64,37 @@ static struct cam_icp_hw_mgr icp_hw_mgr; static void cam_icp_mgr_process_dbg_buf(unsigned int debug_lvl); static int cam_icp_dump_io_cfg(struct cam_icp_hw_ctx_data *ctx_data, int32_t buf_handle) { uintptr_t vaddr_ptr; uint32_t *ptr; size_t len; int rc, i; char buf[512]; int used = 0; rc = cam_mem_get_cpu_buf(buf_handle, &vaddr_ptr, &len); if (rc) { CAM_ERR(CAM_ICP, "Unable to get io_cfg buf address for %d", ctx_data->ctx_id); return rc; } len = len / sizeof(uint32_t); ptr = (uint32_t *)vaddr_ptr; for (i = 0; i < len; i++) { used += snprintf(buf + used, sizeof(buf) - used, "0X%08X-", ptr[i]); if (!(i % 8)) { CAM_INFO(CAM_ICP, "%s: %s", __func__, buf); used = 0; } } return rc; } static int cam_icp_send_ubwc_cfg(struct cam_icp_hw_mgr *hw_mgr) { struct cam_hw_intf *a5_dev_intf = NULL; Loading Loading @@ -1262,6 +1293,44 @@ static int cam_icp_mgr_ipe_bps_power_collapse(struct cam_icp_hw_mgr *hw_mgr, return rc; } static int cam_icp_mgr_ipe_bps_get_gdsc_control( struct cam_icp_hw_mgr *hw_mgr) { int rc = 0; struct cam_hw_intf *ipe0_dev_intf = NULL; struct cam_hw_intf *ipe1_dev_intf = NULL; struct cam_hw_intf *bps_dev_intf = NULL; ipe0_dev_intf = hw_mgr->ipe0_dev_intf; ipe1_dev_intf = hw_mgr->ipe1_dev_intf; bps_dev_intf = hw_mgr->bps_dev_intf; if ((!ipe0_dev_intf) || (!bps_dev_intf)) { CAM_ERR(CAM_ICP, "dev intfs are wrong"); return -EINVAL; } if (icp_hw_mgr.ipe_bps_pc_flag) { rc = bps_dev_intf->hw_ops.process_cmd( bps_dev_intf->hw_priv, CAM_ICP_BPS_CMD_POWER_COLLAPSE, NULL, 0); rc = ipe0_dev_intf->hw_ops.process_cmd( ipe0_dev_intf->hw_priv, CAM_ICP_IPE_CMD_POWER_COLLAPSE, NULL, 0); if (ipe1_dev_intf) { rc = ipe1_dev_intf->hw_ops.process_cmd( ipe1_dev_intf->hw_priv, CAM_ICP_IPE_CMD_POWER_COLLAPSE, NULL, 0); } } return rc; } static int cam_icp_set_dbg_default_clk(void *data, u64 val) { icp_hw_mgr.icp_debug_clk = val; Loading Loading @@ -1786,13 +1855,16 @@ static int cam_icp_ipebps_reset(struct cam_icp_hw_mgr *hw_mgr) ipe1_dev_intf = hw_mgr->ipe1_dev_intf; bps_dev_intf = hw_mgr->bps_dev_intf; if (hw_mgr->bps_ctxt_cnt) { rc = bps_dev_intf->hw_ops.process_cmd( bps_dev_intf->hw_priv, CAM_ICP_BPS_CMD_RESET, NULL, 0); if (rc) CAM_ERR(CAM_ICP, "bps reset failed"); } if (hw_mgr->ipe_ctxt_cnt) { rc = ipe0_dev_intf->hw_ops.process_cmd( ipe0_dev_intf->hw_priv, CAM_ICP_IPE_CMD_RESET, Loading @@ -1808,6 +1880,7 @@ static int cam_icp_ipebps_reset(struct cam_icp_hw_mgr *hw_mgr) if (rc) CAM_ERR(CAM_ICP, "ipe1 reset failed"); } } return 0; } Loading @@ -1827,6 +1900,7 @@ static int cam_icp_mgr_trigger_recovery(struct cam_icp_hw_mgr *hw_mgr) sfr_buffer = (struct sfr_buf *)icp_hw_mgr.hfi_mem.sfr_buf.kva; CAM_WARN(CAM_ICP, "SFR:%s", sfr_buffer->msg); cam_icp_mgr_ipe_bps_get_gdsc_control(hw_mgr); cam_icp_ipebps_reset(hw_mgr); atomic_set(&hw_mgr->recovery, 1); Loading Loading @@ -3449,6 +3523,17 @@ static int cam_icp_mgr_process_cmd_desc(struct cam_icp_hw_mgr *hw_mgr, goto rel_cmd_buf; } *fw_cmd_buf_iova_addr = addr; if (cmd_desc[i].offset >= len || ((len - cmd_desc[i].offset) < cmd_desc[i].size)){ CAM_ERR(CAM_ICP, "Invalid offset/length, i %d offset 0x%x len 0x%x size 0x%x", i, cmd_desc[i].offset, len, cmd_desc[i].size); goto rel_cmd_buf; } *fw_cmd_buf_iova_addr = (*fw_cmd_buf_iova_addr + cmd_desc[i].offset); rc = cam_mem_get_cpu_buf(cmd_desc[i].mem_handle, Loading Loading @@ -4052,8 +4137,12 @@ static int cam_icp_mgr_prepare_hw_update(void *hw_mgr_priv, packet = prepare_args->packet; if (cam_packet_util_validate_packet(packet, prepare_args->remain_len)) if (cam_packet_util_validate_packet(packet, prepare_args->remain_len)) { mutex_unlock(&ctx_data->ctx_mutex); CAM_ERR(CAM_ICP, "ctx id: %u packet req id %lld validate fail", ctx_data->ctx_id, packet->header.request_id); return -EINVAL; } rc = cam_icp_mgr_pkt_validation(packet); if (rc) { Loading Loading @@ -4674,6 +4763,8 @@ static int cam_icp_mgr_acquire_hw(void *hw_mgr_priv, void *acquire_hw_args) rc = cam_icp_mgr_send_config_io(ctx_data, io_buf_addr); if (rc) { CAM_ERR(CAM_ICP, "IO Config command failed %d", rc); cam_icp_dump_io_cfg(ctx_data, icp_dev_acquire_info->io_config_cmd_handle); goto ioconfig_failed; } Loading