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

Commit a27f7d32 authored by Vishalsingh Hajeri's avatar Vishalsingh Hajeri
Browse files

msm: camera: crm: Perform the notification in workq on sof freeze



In case of SOF freeze perform the task of notifying the devices
in a workq instead of timer callback context to avoid watchdog
bite from mutex lock.

Change-Id: Ie787900e4a7f28209d9aa1d7e580186982f918db
Signed-off-by: default avatarVishalsingh Hajeri <vhajeri@codeaurora.org>
parent f19f0dbb
Loading
Loading
Loading
Loading
+49 −12
Original line number Diff line number Diff line
@@ -1140,24 +1140,26 @@ static void __cam_req_mgr_notify_sof_freeze(
}

/**
 * __cam_req_mgr_sof_freeze()
 * __cam_req_mgr_process_sof_freeze()
 *
 * @brief : Apoptosis - Handles case when connected devices are not responding
 * @data  : timer pointer
 * @priv  : link information
 * @data  : task data
 *
 */
static void __cam_req_mgr_sof_freeze(unsigned long data)
static int __cam_req_mgr_process_sof_freeze(void *priv, void *data)
{
	struct cam_req_mgr_timer     *timer = (struct cam_req_mgr_timer *)data;
	struct cam_req_mgr_core_link    *link = NULL;
	struct cam_req_mgr_core_session *session = NULL;
	struct cam_req_mgr_message       msg;
	int rc = 0;

	if (!timer) {
		CAM_ERR(CAM_CRM, "NULL timer");
		return;
	if (!data || !priv) {
		CAM_ERR(CAM_CRM, "input args NULL %pK %pK", data, priv);
		return -EINVAL;
	}
	link = (struct cam_req_mgr_core_link *)timer->parent;

	link = (struct cam_req_mgr_core_link *)priv;
	session = (struct cam_req_mgr_core_session *)link->parent;

	CAM_ERR(CAM_CRM, "SOF freeze for session %d link 0x%x",
@@ -1171,12 +1173,47 @@ static void __cam_req_mgr_sof_freeze(unsigned long data)
	msg.u.err_msg.request_id = 0;
	msg.u.err_msg.link_hdl   = link->link_hdl;

	rc = cam_req_mgr_notify_message(&msg,
		V4L_EVENT_CAM_REQ_MGR_ERROR, V4L_EVENT_CAM_REQ_MGR_EVENT);

	if (cam_req_mgr_notify_message(&msg,
		V4L_EVENT_CAM_REQ_MGR_ERROR, V4L_EVENT_CAM_REQ_MGR_EVENT))
	if (rc)
		CAM_ERR(CAM_CRM,
			"Error notifying SOF freeze for session %d link 0x%x",
			session->session_hdl, link->link_hdl);
			"Error notifying SOF freeze for session %d link 0x%x rc %d",
			session->session_hdl, link->link_hdl, rc);

	return rc;
}

/**
 * __cam_req_mgr_sof_freeze()
 *
 * @brief : Callback function for timer timeout indicating SOF freeze
 * @data  : timer pointer
 *
 */
static void __cam_req_mgr_sof_freeze(unsigned long data)
{
	struct cam_req_mgr_timer     *timer = (struct cam_req_mgr_timer *)data;
	struct crm_workq_task               *task = NULL;
	struct cam_req_mgr_core_link        *link = NULL;
	struct crm_task_payload             *task_data;

	if (!timer) {
		CAM_ERR(CAM_CRM, "NULL timer");
		return;
	}

	link = (struct cam_req_mgr_core_link *)timer->parent;
	task = cam_req_mgr_workq_get_task(link->workq);
	if (!task) {
		CAM_ERR(CAM_CRM, "No empty task");
		return;
	}

	task_data = (struct crm_task_payload *)task->payload;
	task_data->type = CRM_WORKQ_TASK_NOTIFY_FREEZE;
	task->process_cb = &__cam_req_mgr_process_sof_freeze;
	cam_req_mgr_workq_enqueue_task(task, link, CRM_TASK_PRIORITY_0);
}

/**
+1 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ enum crm_workq_task_type {
	CRM_WORKQ_TASK_APPLY_REQ,
	CRM_WORKQ_TASK_NOTIFY_SOF,
	CRM_WORKQ_TASK_NOTIFY_ERR,
	CRM_WORKQ_TASK_NOTIFY_FREEZE,
	CRM_WORKQ_TASK_SCHED_REQ,
	CRM_WORKQ_TASK_FLUSH_REQ,
	CRM_WORKQ_TASK_INVALID,