From fd450fbd22d7067aa295b0d46d5cbedd945016de Mon Sep 17 00:00:00 2001 From: Depeng Shao Date: Mon, 7 Dec 2020 17:10:57 +0800 Subject: [PATCH] msm: camera: reqmgr: Pause the timer before sensor stream on Sometimes, the cpu load is very high, then the devcies stream on will be delayed, but the CRM watchdog is already enabled before streaming on, then we will have a chance to notify SOF freeze issue. This change pauses the CRM watchdog timer before streaming on sensor and after stopping ife, when we can detect the stream on and stream off delay, but don't notify error, also can detect the real SOF freeze issue. CRs-Fixed: 2804587 Change-Id: Iccaee837930ea22290b109eff45b05300d844312 Signed-off-by: Depeng Shao --- drivers/cam_req_mgr/cam_req_mgr_core.c | 19 ++++++++++++++++--- .../cam_sensor/cam_sensor_core.c | 16 ++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/drivers/cam_req_mgr/cam_req_mgr_core.c b/drivers/cam_req_mgr/cam_req_mgr_core.c index 15ba9a7e9018..646cb6783f54 100644 --- a/drivers/cam_req_mgr/cam_req_mgr_core.c +++ b/drivers/cam_req_mgr/cam_req_mgr_core.c @@ -2078,7 +2078,9 @@ static int __cam_req_mgr_process_sof_freeze(void *priv, void *data) spin_lock_bh(&link->link_state_spin_lock); if ((link->watchdog) && (link->watchdog->pause_timer)) { - CAM_INFO(CAM_CRM, "Watchdog Paused"); + CAM_INFO(CAM_CRM, + "link:%x watchdog paused, maybe stream on/off is delayed", + link->link_hdl); spin_unlock_bh(&link->link_state_spin_lock); return rc; } @@ -3190,8 +3192,16 @@ static int cam_req_mgr_cb_notify_timer( rc = -EPERM; goto end; } - if ((link->watchdog) && (!timer_data->state)) - link->watchdog->pause_timer = true; + if (link->watchdog) { + if (!timer_data->state) + link->watchdog->pause_timer = true; + else + link->watchdog->pause_timer = false; + crm_timer_reset(link->watchdog); + CAM_DBG(CAM_CRM, "link %x pause_timer %d", + link->link_hdl, link->watchdog->pause_timer); + } + spin_unlock_bh(&link->link_state_spin_lock); end: @@ -3238,6 +3248,7 @@ static int cam_req_mgr_cb_notify_stop( goto end; } crm_timer_reset(link->watchdog); + link->watchdog->pause_timer = true; spin_unlock_bh(&link->link_state_spin_lock); task = cam_req_mgr_workq_get_task(link->workq); @@ -4286,6 +4297,8 @@ int cam_req_mgr_link_control(struct cam_req_mgr_link_control *control) link->link_hdl); rc = -EFAULT; } + /* Pause the timer before sensor stream on */ + link->watchdog->pause_timer = true; /* notify nodes */ for (j = 0; j < link->num_devs; j++) { dev = &link->l_dev[j]; diff --git a/drivers/cam_sensor_module/cam_sensor/cam_sensor_core.c b/drivers/cam_sensor_module/cam_sensor/cam_sensor_core.c index 413b5405045d..c1400a8ff99a 100644 --- a/drivers/cam_sensor_module/cam_sensor/cam_sensor_core.c +++ b/drivers/cam_sensor_module/cam_sensor/cam_sensor_core.c @@ -932,6 +932,7 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl, break; } case CAM_START_DEV: { + struct cam_req_mgr_timer_notify timer; if ((s_ctrl->sensor_state == CAM_SENSOR_INIT) || (s_ctrl->sensor_state == CAM_SENSOR_START)) { rc = -EINVAL; @@ -952,6 +953,21 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl, } } s_ctrl->sensor_state = CAM_SENSOR_START; + + if (s_ctrl->bridge_intf.crm_cb && + s_ctrl->bridge_intf.crm_cb->notify_timer) { + timer.link_hdl = s_ctrl->bridge_intf.link_hdl; + timer.dev_hdl = s_ctrl->bridge_intf.device_hdl; + timer.state = true; + rc = s_ctrl->bridge_intf.crm_cb->notify_timer(&timer); + if (rc) { + CAM_ERR(CAM_SENSOR, + "Enable CRM SOF freeze timer failed rc: %d", + rc); + return rc; + } + } + CAM_INFO(CAM_SENSOR, "CAM_START_DEV Success, sensor_id:0x%x,sensor_slave_addr:0x%x", s_ctrl->sensordata->slave_info.sensor_id,