|
@@ -17,6 +17,7 @@
|
|
|
#include <linux/bitops.h>
|
|
|
#include <linux/delay.h>
|
|
|
#include <linux/debugfs.h>
|
|
|
+#include <linux/rwsem.h>
|
|
|
#include <media/cam_defs.h>
|
|
|
#include <media/cam_icp.h>
|
|
|
#include <media/cam_cpas.h>
|
|
@@ -54,6 +55,8 @@
|
|
|
|
|
|
#define ICP_DEVICE_IDLE_TIMEOUT 400
|
|
|
|
|
|
+DECLARE_RWSEM(frame_in_process_sem);
|
|
|
+
|
|
|
static struct cam_icp_hw_mgr icp_hw_mgr;
|
|
|
|
|
|
static void cam_icp_mgr_process_dbg_buf(unsigned int debug_lvl);
|
|
@@ -2457,6 +2460,17 @@ static int cam_icp_mgr_handle_frame_process(uint32_t *msg_ptr, int flag)
|
|
|
mutex_unlock(&ctx_data->ctx_mutex);
|
|
|
}
|
|
|
|
|
|
+ if (cam_presil_mode_enabled()) {
|
|
|
+ if (!atomic_read(&icp_hw_mgr.frame_in_process)) {
|
|
|
+ CAM_ERR(CAM_PRESIL, "presil: frame_in_process not set");
|
|
|
+ } else {
|
|
|
+ icp_hw_mgr.frame_in_process_ctx_id = -1;
|
|
|
+ atomic_set(&icp_hw_mgr.frame_in_process, 0);
|
|
|
+ up_write(&frame_in_process_sem);
|
|
|
+ CAM_DBG(CAM_PRESIL, "presil: unlocked frame_in_process");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -2654,6 +2668,23 @@ static int cam_icp_mgr_process_direct_ack_msg(uint32_t *msg_ptr)
|
|
|
ioconfig_ack = (struct hfi_msg_ipebps_async_ack *)msg_ptr;
|
|
|
ctx_data = (struct cam_icp_hw_ctx_data *)
|
|
|
U64_TO_PTR(ioconfig_ack->user_data1);
|
|
|
+
|
|
|
+ if (cam_presil_mode_enabled()) {
|
|
|
+ if (atomic_read(&icp_hw_mgr.frame_in_process)) {
|
|
|
+ if (icp_hw_mgr.frame_in_process_ctx_id == ctx_data->ctx_id) {
|
|
|
+ CAM_DBG(CAM_PRESIL, "presil: frame process abort ctx %d",
|
|
|
+ icp_hw_mgr.frame_in_process_ctx_id);
|
|
|
+ icp_hw_mgr.frame_in_process_ctx_id = -1;
|
|
|
+ atomic_set(&icp_hw_mgr.frame_in_process, 0);
|
|
|
+ up_write(&frame_in_process_sem);
|
|
|
+ } else {
|
|
|
+ CAM_WARN(CAM_PRESIL, "presil: abort mismatch %d %d",
|
|
|
+ icp_hw_mgr.frame_in_process_ctx_id,
|
|
|
+ ctx_data->ctx_id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (ctx_data->state != CAM_ICP_CTX_STATE_FREE)
|
|
|
complete(&ctx_data->wait_complete);
|
|
|
CAM_DBG(CAM_ICP, "received IPE/BPS/ ABORT: ctx_state =%d",
|
|
@@ -4728,6 +4759,17 @@ static int cam_icp_mgr_config_hw(void *hw_mgr_priv, void *config_hw_args)
|
|
|
}
|
|
|
|
|
|
ctx_data = config_args->ctxt_to_hw_map;
|
|
|
+ if (cam_presil_mode_enabled()) {
|
|
|
+ CAM_DBG(CAM_PRESIL, "presil: locking frame_in_process %d req id %u",
|
|
|
+ atomic_read(&hw_mgr->frame_in_process), config_args->request_id);
|
|
|
+ down_write(&frame_in_process_sem);
|
|
|
+ atomic_set(&hw_mgr->frame_in_process, 1);
|
|
|
+ hw_mgr->frame_in_process_ctx_id = ctx_data->ctx_id;
|
|
|
+ CAM_DBG(CAM_PRESIL, "presil: locked frame_in_process req id %u ctx_id %d",
|
|
|
+ config_args->request_id, hw_mgr->frame_in_process_ctx_id);
|
|
|
+ msleep(100);
|
|
|
+ }
|
|
|
+
|
|
|
mutex_lock(&hw_mgr->hw_mgr_mutex);
|
|
|
mutex_lock(&ctx_data->ctx_mutex);
|
|
|
if (ctx_data->state != CAM_ICP_CTX_STATE_ACQUIRED) {
|
|
@@ -6968,6 +7010,9 @@ int cam_icp_hw_mgr_init(struct device_node *of_node, uint64_t *hw_mgr_hdl,
|
|
|
mutex_init(&icp_hw_mgr.hw_mgr_mutex);
|
|
|
spin_lock_init(&icp_hw_mgr.hw_mgr_lock);
|
|
|
|
|
|
+ atomic_set(&icp_hw_mgr.frame_in_process, 0);
|
|
|
+ icp_hw_mgr.frame_in_process_ctx_id = -1;
|
|
|
+
|
|
|
for (i = 0; i < CAM_ICP_CTX_MAX; i++) {
|
|
|
mutex_init(&icp_hw_mgr.ctx_data[i].ctx_mutex);
|
|
|
if (cam_presil_mode_enabled()) {
|