msm: camera: common: memset usage optimization

Remove unnecessary memsets of the structure variables
whose fields are assigned prior to their usage or they
are dynamically allocated with calls that set the memory
to 0. This memset usage optimization is to improve
performance.

CRs-Fixed: 3228092
Change-Id: Iec68c6d072863627959ce603cff28afd26a1c408
Signed-off-by: Sokchetra Eung <quic_eung@quicinc.com>
このコミットが含まれているのは:
Sokchetra Eung
2022-06-22 16:10:27 -07:00
committed by Camera Software Integration
コミット d2a1f0c968
20個のファイルの変更20行の追加72行の削除

ファイルの表示

@@ -447,7 +447,6 @@ int32_t cam_context_config_dev_to_hw(
packet = (struct cam_packet *) ((uint8_t *)packet_addr +
(uint32_t)cmd->offset);
memset(&cfg, 0, sizeof(cfg));
cfg.packet = packet;
cfg.ctxt_to_hw_map = ctx->ctxt_to_hw_map;
cfg.priv = NULL;
@@ -531,7 +530,6 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx,
ctx->last_flush_req = 0;
/* preprocess the configuration */
memset(&cfg, 0, sizeof(cfg));
cfg.packet = packet;
cfg.remain_len = remain_len;
cfg.ctxt_to_hw_map = ctx->ctxt_to_hw_map;
@@ -544,6 +542,8 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx,
cfg.in_map_entries = req->in_map_entries;
cfg.pf_data = &(req->pf_data);
cfg.priv = req->req_priv;
cfg.num_in_map_entries = 0;
cfg.num_out_map_entries = 0;
rc = ctx->hw_mgr_intf->hw_prepare_update(
ctx->hw_mgr_intf->hw_mgr_priv, &cfg);
@@ -751,7 +751,7 @@ end:
int32_t cam_context_flush_ctx_to_hw(struct cam_context *ctx)
{
struct cam_hw_flush_args flush_args;
struct cam_hw_flush_args flush_args = {0};
struct list_head temp_list;
struct list_head *list;
struct cam_ctx_request *req;
@@ -760,7 +760,6 @@ int32_t cam_context_flush_ctx_to_hw(struct cam_context *ctx)
bool free_req;
CAM_DBG(CAM_CTXT, "[%s] E: NRT flush ctx", ctx->dev_name);
memset(&flush_args, 0, sizeof(flush_args));
/*
* flush pending requests, take the sync lock to synchronize with the
@@ -778,7 +777,6 @@ int32_t cam_context_flush_ctx_to_hw(struct cam_context *ctx)
"[%s][%d] : Moving all pending requests from pending_list to temp_list",
ctx->dev_name, ctx->ctx_id);
flush_args.num_req_pending = 0;
flush_args.last_flush_req = ctx->last_flush_req;
list_for_each(list, &temp_list) {
num_entries++;
@@ -863,7 +861,6 @@ int32_t cam_context_flush_ctx_to_hw(struct cam_context *ctx)
spin_unlock(&ctx->lock);
if (ctx->hw_mgr_intf->hw_flush) {
flush_args.num_req_active = 0;
num_entries = 0;
list_for_each(list, &temp_list) {
num_entries++;
@@ -947,7 +944,7 @@ int32_t cam_context_flush_req_to_hw(struct cam_context *ctx,
struct cam_flush_dev_cmd *cmd)
{
struct cam_ctx_request *req = NULL;
struct cam_hw_flush_args flush_args;
struct cam_hw_flush_args flush_args = {0};
uint32_t i = 0;
int32_t sync_id = 0;
int rc = 0;
@@ -955,9 +952,6 @@ int32_t cam_context_flush_req_to_hw(struct cam_context *ctx,
CAM_DBG(CAM_CTXT, "[%s] E: NRT flush req", ctx->dev_name);
memset(&flush_args, 0, sizeof(flush_args));
flush_args.num_req_pending = 0;
flush_args.num_req_active = 0;
flush_args.flush_req_pending = kzalloc(sizeof(void *), GFP_KERNEL);
if (!flush_args.flush_req_pending) {
CAM_ERR(CAM_CTXT, "[%s][%d] : Flush array memory alloc fail",
@@ -1584,7 +1578,7 @@ int32_t cam_context_dump_dev_to_hw(struct cam_context *ctx,
ctx->dev_name, ctx->ctx_id);
return -EFAULT;
}
memset(&dump_args, 0, sizeof(dump_args));
if (ctx->hw_mgr_intf->hw_dump) {
dump_args.ctxt_to_hw_map = ctx->ctxt_to_hw_map;
dump_args.buf_handle = cmd->buf_handle;

ファイルの表示

@@ -2702,7 +2702,7 @@ static void cam_cpas_dump_monitor_array(
for (i = 0; i < num_entries; i++) {
entry = &cpas_core->monitor_entries[index];
CAM_CONVERT_TIMESTAMP_FORMAT(entry->timestamp, hrs, min, sec, ms);
memset(log_buf, 0, sizeof(log_buf));
log_buf[0] = '\0';
len = 0;
CAM_INFO(CAM_CPAS,

ファイルの表示

@@ -576,8 +576,6 @@ void hfi_send_system_cmd(uint32_t type, uint64_t data, uint32_t size)
case HFI_CMD_SYS_INIT: {
struct hfi_cmd_sys_init init;
memset(&init, 0, sizeof(init));
init.size = sizeof(struct hfi_cmd_sys_init);
init.pkt_type = type;
hfi_write_cmd(&init);

ファイルの表示

@@ -2278,7 +2278,6 @@ static void cam_icp_mgr_dump_active_req_info(void)
continue;
}
memset(log_info, 0, buf_size);
len = 0;
for (j = 0; j < CAM_FRAME_CMD_MAX; j++) {
if (!ctx_data->hfi_frame_process.request_id[j])
@@ -3102,9 +3101,6 @@ static int cam_icp_alloc_secheap_mem(struct cam_mem_mgr_memory_desc *secheap)
struct cam_mem_mgr_memory_desc out;
struct cam_smmu_region_info secheap_info;
memset(&alloc, 0, sizeof(alloc));
memset(&out, 0, sizeof(out));
rc = cam_smmu_get_region_info(icp_hw_mgr.iommu_hdl,
CAM_SMMU_REGION_SECHEAP,
&secheap_info);
@@ -3138,8 +3134,6 @@ static int cam_icp_alloc_sfr_mem(struct cam_mem_mgr_memory_desc *sfr)
struct cam_mem_mgr_request_desc alloc;
struct cam_mem_mgr_memory_desc out;
memset(&alloc, 0, sizeof(alloc));
memset(&out, 0, sizeof(out));
alloc.size = SZ_8K;
alloc.align = 0;
alloc.flags = CAM_MEM_FLAG_HW_READ_WRITE |
@@ -3163,8 +3157,6 @@ static int cam_icp_alloc_shared_mem(struct cam_mem_mgr_memory_desc *qtbl)
struct cam_mem_mgr_request_desc alloc;
struct cam_mem_mgr_memory_desc out;
memset(&alloc, 0, sizeof(alloc));
memset(&out, 0, sizeof(out));
alloc.size = SZ_1M;
alloc.align = 0;
alloc.flags = CAM_MEM_FLAG_HW_READ_WRITE |
@@ -3293,9 +3285,6 @@ static int cam_icp_allocate_hfi_mem(void)
uint32_t offset;
uint64_t size;
memset(&alloc, 0, sizeof(alloc));
memset(&out, 0, sizeof(out));
alloc.size = fwuncached_region_info.iova_len;
alloc.align = 0;
alloc.flags = CAM_MEM_FLAG_KMD_ACCESS;

ファイルの表示

@@ -2406,7 +2406,7 @@ static int __cam_isp_ctx_apply_pending_req(
struct cam_isp_context *ctx_isp = priv;
struct cam_ctx_request *req;
struct cam_isp_ctx_req *req_isp;
struct cam_hw_config_args cfg;
struct cam_hw_config_args cfg = {0};
if (!ctx_isp) {
CAM_ERR(CAM_ISP, "Invalid ctx_isp:%pK", ctx);
@@ -2447,14 +2447,11 @@ static int __cam_isp_ctx_apply_pending_req(
req->request_id, ctx_isp->substate_activated, ctx->ctx_id);
req_isp = (struct cam_isp_ctx_req *) req->req_priv;
memset(&cfg, 0, sizeof(cfg));
cfg.ctxt_to_hw_map = ctx_isp->hw_ctx;
cfg.request_id = req->request_id;
cfg.hw_update_entries = req_isp->cfg;
cfg.num_hw_update_entries = req_isp->num_cfg;
cfg.priv = &req_isp->hw_update_data;
cfg.init_packet = 0;
cfg.priv = &req_isp->hw_update_data;
/*
* Offline mode may receive the SOF and REG_UPD earlier than

ファイルの表示

@@ -9860,8 +9860,6 @@ static int cam_isp_packet_generic_blob_handler(void *user_data,
prepare_hw_data = (struct cam_isp_prepare_hw_update_data *) prepare->priv;
memset(&prepare_hw_data->bw_clk_config.bw_config_v2, 0,
sizeof(prepare_hw_data->bw_clk_config.bw_config_v2));
prepare_hw_data->bw_clk_config.bw_config_v2.usage_type = bw_config->usage_type;
prepare_hw_data->bw_clk_config.bw_config_v2.num_paths = bw_config->num_paths;
@@ -9930,8 +9928,7 @@ static int cam_isp_packet_generic_blob_handler(void *user_data,
}
prepare_hw_data = (struct cam_isp_prepare_hw_update_data *) prepare->priv;
memset(&prepare_hw_data->bw_clk_config.bw_config_v2, 0,
sizeof(prepare_hw_data->bw_clk_config.bw_config_v2));
prepare_hw_data->bw_clk_config.bw_config_v2.usage_type = bw_config->usage_type;
prepare_hw_data->bw_clk_config.bw_config_v2.num_paths = bw_config->num_paths;
@@ -10837,7 +10834,6 @@ static int cam_isp_sfe_send_scratch_buf_upd(
struct cam_isp_hw_get_wm_update wm_update;
dma_addr_t io_addr[CAM_PACKET_MAX_PLANES];
memset(io_addr, 0, sizeof(io_addr));
update_buf.res = hw_res;
update_buf.cmd_type = cmd_type;
update_buf.cmd.cmd_buf_addr = cpu_addr;
@@ -14755,8 +14751,6 @@ int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf, int *iommu_hdl)
atomic_set(&g_ife_hw_mgr.active_ctx_cnt, 0);
for (i = 0; i < CAM_IFE_CTX_MAX; i++) {
memset(&g_ife_hw_mgr.ctx_pool[i], 0,
sizeof(g_ife_hw_mgr.ctx_pool[i]));
INIT_LIST_HEAD(&g_ife_hw_mgr.ctx_pool[i].list);
INIT_LIST_HEAD(&g_ife_hw_mgr.ctx_pool[i].res_list_ife_in.list);

ファイルの表示

@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include <media/cam_defs.h>
@@ -1758,7 +1759,7 @@ int cam_isp_add_csid_reg_update(
(kmd_buf_info->used_bytes +
reg_update_size);
memset(&rup_args->cmd, 0, sizeof(struct cam_isp_hw_cmd_buf_update));
rup_args->cmd.used_bytes = 0;
rup_args->cmd.cmd_buf_addr = kmd_buf_info->cpu_addr +
kmd_buf_info->used_bytes/4 +
reg_update_size/4;
@@ -1919,7 +1920,6 @@ int cam_isp_get_cmd_buf_count(
((uint8_t *)&prepare->packet->payload +
prepare->packet->cmd_buf_offset);
memset(cmd_buf_count, 0, sizeof(struct cam_isp_cmd_buf_count));
for (i = 0; i < prepare->packet->num_cmd_buf; i++) {
if (!cmd_desc[i].length)
continue;

ファイルの表示

@@ -1134,7 +1134,7 @@ static int cam_ife_csid_ver2_rx_err_bottom_half(
data_idx = csid_hw->rx_cfg.phy_sel -1;
log_buf = csid_hw->log_buf;
memset(log_buf, 0, sizeof(csid_hw->log_buf));
log_buf[0] = '\0';
csid_reg = (struct cam_ife_csid_ver2_reg_info *)
csid_hw->core_info->csid_reg;
@@ -1532,7 +1532,6 @@ static int cam_ife_csid_ver2_parse_path_irq_status(
csid_hw->core_info->csid_reg;
log_buf = csid_hw->log_buf;
memset(log_buf, 0, sizeof(csid_hw->log_buf));
irq_reg_tag = cam_ife_csid_get_irq_reg_tag_ptr();

ファイルの表示

@@ -91,7 +91,6 @@ int cam_ife_csid_init_soc_resources(struct cam_hw_soc_info *soc_info,
goto free_soc_private;
}
memset(&cpas_register_param, 0, sizeof(cpas_register_param));
if (is_custom)
strlcpy(cpas_register_param.identifier, "csid-custom",
CAM_HW_IDENTIFIER_LENGTH);

ファイルの表示

@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include <linux/slab.h>
@@ -107,7 +108,6 @@ int cam_sfe_init_soc_resources(struct cam_hw_soc_info *soc_info,
goto free_soc_private;
}
memset(&cpas_register_param, 0, sizeof(cpas_register_param));
strlcpy(cpas_register_param.identifier, "sfe",
CAM_HW_IDENTIFIER_LENGTH);
cpas_register_param.cell_index = soc_info->index;

ファイルの表示

@@ -245,7 +245,6 @@ static void cam_sfe_top_check_module_status(
i, log_buf);
len = 0;
found = false;
memset(log_buf, 0, sizeof(uint8_t)*1024);
}
}
@@ -1944,14 +1943,7 @@ int cam_sfe_top_init(
goto free_top_priv;
}
top_priv->applied_clk_rate = 0;
top_priv->reserve_cnt = 0;
top_priv->start_stop_cnt = 0;
top_priv->priv_per_stream = NULL;
top_priv->event_cb = NULL;
top_priv->num_in_ports = sfe_top_hw_info->num_inputs;
memset(&top_priv->core_cfg, 0x0,
sizeof(struct cam_sfe_core_cfg));
CAM_DBG(CAM_SFE,
"Initializing SFE [%u] top with hw_version: 0x%x",

ファイルの表示

@@ -180,7 +180,6 @@ int cam_vfe_init_soc_resources(struct cam_hw_soc_info *soc_info,
goto free_soc_private;
}
memset(&cpas_register_param, 0, sizeof(cpas_register_param));
strlcpy(cpas_register_param.identifier, "ife",
CAM_HW_IDENTIFIER_LENGTH);
cpas_register_param.cell_index = soc_info->index;

ファイルの表示

@@ -1054,9 +1054,7 @@ static int cam_vfe_bus_ver3_acquire_wm(
{
int32_t wm_idx = 0, rc;
struct cam_vfe_bus_ver3_wm_resource_data *rsrc_data = NULL;
char wm_mode[50];
memset(wm_mode, '\0', sizeof(wm_mode));
char wm_mode[50] = {'\0'};
if (wm_res->res_state != CAM_ISP_RESOURCE_STATE_AVAILABLE) {
CAM_ERR(CAM_ISP, "WM:%d not available state:%d",

ファイルの表示

@@ -446,7 +446,6 @@ static void cam_vfe_top_ver4_print_debug_reg_status(
}
CAM_INFO(CAM_ISP, "VFE[%u]: Top Debug Status: %s", soc_info->index, log_buf);
len = 0;
memset(log_buf, 0, sizeof(uint8_t)*CAM_VFE_LEN_LOG_BUF);
}
cam_vfe_top_ver4_check_module_status(num_reg, reg_val,

ファイルの表示

@@ -1555,7 +1555,7 @@ static int cam_mem_util_unmap(int32_t idx,
tbl.bufq[idx].flags = 0;
tbl.bufq[idx].buf_handle = -1;
memset(tbl.bufq[idx].hdls, 0,
sizeof(int32_t) * CAM_MEM_MMU_MAX_HANDLE);
sizeof(int32_t) * tbl.bufq[idx].num_hdl);
CAM_DBG(CAM_MEM,
"Ion buf at idx = %d freeing fd = %d, imported %d, dma_buf %pK, i_ino %lu",

ファイルの表示

@@ -4374,7 +4374,7 @@ int cam_req_mgr_link(struct cam_req_mgr_ver_info *link_info)
int rc = 0;
int wq_flag = 0;
char buf[128];
struct cam_create_dev_hdl root_dev;
struct cam_create_dev_hdl root_dev = {0};
struct cam_req_mgr_core_session *cam_session;
struct cam_req_mgr_core_link *link;
@@ -4410,10 +4410,10 @@ int cam_req_mgr_link(struct cam_req_mgr_ver_info *link_info)
}
CAM_DBG(CAM_CRM, "link reserved %pK %x", link, link->link_hdl);
memset(&root_dev, 0, sizeof(struct cam_create_dev_hdl));
root_dev.session_hdl = link_info->u.link_info_v1.session_hdl;
root_dev.priv = (void *)link;
root_dev.dev_id = CAM_CRM;
mutex_lock(&link->lock);
/* Create unique dev handle for link */
link->link_hdl = cam_create_device_hdl(&root_dev);
@@ -4485,7 +4485,7 @@ int cam_req_mgr_link_v2(struct cam_req_mgr_ver_info *link_info)
int rc = 0;
int wq_flag = 0;
char buf[128];
struct cam_create_dev_hdl root_dev;
struct cam_create_dev_hdl root_dev = {0};
struct cam_req_mgr_core_session *cam_session;
struct cam_req_mgr_core_link *link;
@@ -4522,7 +4522,6 @@ int cam_req_mgr_link_v2(struct cam_req_mgr_ver_info *link_info)
}
CAM_DBG(CAM_CRM, "link reserved %pK %x", link, link->link_hdl);
memset(&root_dev, 0, sizeof(struct cam_create_dev_hdl));
root_dev.session_hdl = link_info->u.link_info_v2.session_hdl;
root_dev.priv = (void *)link;
root_dev.dev_id = CAM_CRM;

ファイルの表示

@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include <linux/init.h>
@@ -713,8 +714,6 @@ static int cam_res_mgr_shared_pinctrl_init(
}
for (i = 0; i < dt->num_shared_pctrl_gpio; i++) {
memset(pctrl_active, '\0', sizeof(pctrl_active));
memset(pctrl_suspend, '\0', sizeof(pctrl_suspend));
snprintf(pctrl_active, sizeof(pctrl_active),
"%s%s",
cam_res->dt.pctrl_name[i],

ファイルの表示

@@ -1946,8 +1946,6 @@ static int cam_sync_component_bind(struct device *dev,
cam_sync_init_entity(sync_dev);
video_set_drvdata(sync_dev->vdev, sync_dev);
memset(&sync_dev->sync_table, 0, sizeof(sync_dev->sync_table));
memset(&sync_dev->bitmap, 0, sizeof(sync_dev->bitmap));
bitmap_zero(sync_dev->bitmap, CAM_SYNC_MAX_OBJS);
/*

ファイルの表示

@@ -651,8 +651,6 @@ int cam_dma_fence_driver_init(void)
for (i = 0; i < CAM_DMA_FENCE_MAX_FENCES; i++)
spin_lock_init(&g_cam_dma_fence_dev->row_spinlocks[i]);
memset(&g_cam_dma_fence_dev->rows, 0, sizeof(g_cam_dma_fence_dev->rows));
memset(&g_cam_dma_fence_dev->bitmap, 0, sizeof(g_cam_dma_fence_dev->bitmap));
bitmap_zero(g_cam_dma_fence_dev->bitmap, CAM_DMA_FENCE_MAX_FENCES);
g_cam_dma_fence_dev->dma_fence_context = dma_fence_context_alloc(1);

ファイルの表示

@@ -607,9 +607,7 @@ static const char *cam_soc_util_get_supported_clk_levels(
{
int i = 0;
memset(supported_clk_info, 0, sizeof(supported_clk_info));
strlcat(supported_clk_info, "Supported levels: ",
sizeof(supported_clk_info));
scnprintf(supported_clk_info, sizeof(supported_clk_info), "Supported levels: ");
for (i = 0; i < CAM_MAX_VOTE; i++) {
if (soc_info->clk_level_valid[i] == true) {
@@ -2310,8 +2308,6 @@ static int cam_soc_util_request_pinctrl(
}
for (i = 0; i < num_of_map_idx; i++) {
memset(pctrl_active, '\0', sizeof(pctrl_active));
memset(pctrl_suspend, '\0', sizeof(pctrl_suspend));
of_property_read_u32_index(of_node,
"pctrl-idx-mapping", i, &idx);