Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit abbd9aa9 authored by Jeyaprakash Soundrapandian's avatar Jeyaprakash Soundrapandian Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: camera: icp: Freeing memory in workqueue" into dev/msm-4.9-camx

parents cbbf3df4 984de6dc
Loading
Loading
Loading
Loading
+45 −14
Original line number Diff line number Diff line
@@ -1314,6 +1314,32 @@ static int cam_icp_hw_mgr_create_debugfs_entry(void)
	return rc;
}

static int cam_icp_mgr_process_cmd_and_free_mem(void *priv, void *data)
{
	int rc;
	struct hfi_cmd_work_data *task_data = NULL;
	struct cam_icp_hw_mgr *hw_mgr;

	if (!data || !priv) {
		CAM_ERR(CAM_ICP, "Invalid params%pK %pK", data, priv);
		return -EINVAL;
	}

	hw_mgr = priv;
	task_data = (struct hfi_cmd_work_data *)data;

	if (!task_data->data) {
		CAM_ERR(CAM_ICP, "Invalid data");
		return -EINVAL;
	}

	rc = hfi_write_cmd(task_data->data);

	kfree(task_data->data);
	task_data->data = NULL;
	return rc;
}

static int cam_icp_mgr_process_cmd(void *priv, void *data)
{
	int rc;
@@ -2188,14 +2214,14 @@ static int cam_icp_mgr_abort_handle(
	task_data->data = (void *)abort_cmd;
	task_data->request_id = 0;
	task_data->type = ICP_WORKQ_TASK_CMD_TYPE;
	task->process_cb = cam_icp_mgr_process_cmd;
	task->process_cb = cam_icp_mgr_process_cmd_and_free_mem;
	rc = cam_req_mgr_workq_enqueue_task(task, &icp_hw_mgr,
		CRM_TASK_PRIORITY_0);
	if (rc) {
		kfree(abort_cmd);
		return rc;
	}

	CAM_DBG(CAM_ICP, "payload data = %pK", task_data->data);
	CAM_DBG(CAM_ICP, "fw_handle = %x ctx_data = %pK",
		ctx_data->fw_handle, ctx_data);
	rem_jiffies = wait_for_completion_timeout(&ctx_data->wait_complete,
@@ -2205,7 +2231,6 @@ static int cam_icp_mgr_abort_handle(
		CAM_ERR(CAM_ICP, "FW timeout/err in abort handle command");
	}

	kfree(abort_cmd);
	return rc;
}

@@ -2253,14 +2278,14 @@ static int cam_icp_mgr_destroy_handle(
	task_data->data = (void *)destroy_cmd;
	task_data->request_id = 0;
	task_data->type = ICP_WORKQ_TASK_CMD_TYPE;
	task->process_cb = cam_icp_mgr_process_cmd;
	task->process_cb = cam_icp_mgr_process_cmd_and_free_mem;
	rc = cam_req_mgr_workq_enqueue_task(task, &icp_hw_mgr,
		CRM_TASK_PRIORITY_0);
	if (rc) {
		kfree(destroy_cmd);
		return rc;
	}

	CAM_DBG(CAM_ICP, "payload data = %pK", task_data->data);
	CAM_DBG(CAM_ICP, "fw_handle = %x ctx_data = %pK",
		ctx_data->fw_handle, ctx_data);
	rem_jiffies = wait_for_completion_timeout(&ctx_data->wait_complete,
@@ -2272,8 +2297,6 @@ static int cam_icp_mgr_destroy_handle(
		if (icp_hw_mgr.a5_debug_q)
			cam_icp_mgr_process_dbg_buf();
	}

	kfree(destroy_cmd);
	return rc;
}

@@ -3537,7 +3560,7 @@ static int cam_icp_mgr_create_handle(uint32_t dev_type,

static int cam_icp_mgr_send_ping(struct cam_icp_hw_ctx_data *ctx_data)
{
	struct hfi_cmd_ping_pkt ping_pkt;
	struct hfi_cmd_ping_pkt *ping_pkt;
	struct hfi_cmd_work_data *task_data;
	unsigned long rem_jiffies;
	int timeout = 5000;
@@ -3550,20 +3573,28 @@ static int cam_icp_mgr_send_ping(struct cam_icp_hw_ctx_data *ctx_data)
		return -ENOMEM;
	}

	ping_pkt.size = sizeof(struct hfi_cmd_ping_pkt);
	ping_pkt.pkt_type = HFI_CMD_SYS_PING;
	ping_pkt.user_data = (uint64_t)ctx_data;
	ping_pkt = kzalloc(sizeof(struct hfi_cmd_ping_pkt), GFP_KERNEL);
	if (!ping_pkt) {
		rc = -ENOMEM;
		return rc;
	}
	ping_pkt->size = sizeof(struct hfi_cmd_ping_pkt);
	ping_pkt->pkt_type = HFI_CMD_SYS_PING;
	ping_pkt->user_data = (uint64_t)ctx_data;
	init_completion(&ctx_data->wait_complete);
	task_data = (struct hfi_cmd_work_data *)task->payload;
	task_data->data = (void *)&ping_pkt;
	task_data->data = (void *)ping_pkt;
	task_data->request_id = 0;
	task_data->type = ICP_WORKQ_TASK_CMD_TYPE;
	task->process_cb = cam_icp_mgr_process_cmd;
	task->process_cb = cam_icp_mgr_process_cmd_and_free_mem;

	rc = cam_req_mgr_workq_enqueue_task(task, &icp_hw_mgr,
		CRM_TASK_PRIORITY_0);
	if (rc)
	if (rc) {
		kfree(ping_pkt);
		return rc;
	}
	CAM_DBG(CAM_ICP, "payload data = %pK", task_data->data);

	rem_jiffies = wait_for_completion_timeout(&ctx_data->wait_complete,
			msecs_to_jiffies((timeout)));