소스 검색

msm: camera: core: Handle request abort and signal fence CANCEL

Handle request abort cases from underlying hw mgr, hw layers.
This will handle in differentiating ERROR vs ABORT returned
from firmware in case of ICP and signal the fence accordingly.
By the time flush is issued to firmware, if a request is not
yet processed, firmware signals with Abort, which needs to be
propogated as CANCEL instead of ERROR to core context layer
so that context layer signals the fence accordingly as
ERROR or CANCEL.

CRs-Fixed: 2702771
Change-Id: I8fe6bd1c8f5cf09b99196a1caac1283032418f8c
Signed-off-by: Pavan Kumar Chilamkurthi <[email protected]>
Pavan Kumar Chilamkurthi 5 년 전
부모
커밋
e618f72d9f

+ 11 - 12
drivers/cam_core/cam_context_utils.c

@@ -32,7 +32,7 @@ static inline int cam_context_validate_thread(void)
 }
 
 int cam_context_buf_done_from_hw(struct cam_context *ctx,
-	void *done_event_data, uint32_t bubble_state)
+	void *done_event_data, uint32_t evt_id)
 {
 	int j;
 	int result;
@@ -84,21 +84,20 @@ int cam_context_buf_done_from_hw(struct cam_context *ctx,
 	 */
 	list_del_init(&req->list);
 	spin_unlock(&ctx->lock);
-	if (!bubble_state) {
+	if (evt_id == CAM_CTX_EVT_ID_SUCCESS)
 		result = CAM_SYNC_STATE_SIGNALED_SUCCESS;
-	} else {
-		CAM_DBG(CAM_REQ,
-			"[%s][ctx_id %d] : req[%llu] is done with error",
-			ctx->dev_name, ctx->ctx_id, req->request_id);
-
-		for (j = 0; j < req->num_out_map_entries; j++)
-			CAM_DBG(CAM_REQ, "fence %d signaled with error",
-				req->out_map_entries[j].sync_id);
-
+	else  if (evt_id == CAM_CTX_EVT_ID_CANCEL)
+		result = CAM_SYNC_STATE_SIGNALED_CANCEL;
+	else
 		result = CAM_SYNC_STATE_SIGNALED_ERROR;
-	}
+
+	CAM_DBG(CAM_REQ,
+		"[%s][ctx_id %d] : req[%llu] : Signaling %d",
+		ctx->dev_name, ctx->ctx_id, req->request_id, result);
 
 	for (j = 0; j < req->num_out_map_entries; j++) {
+		CAM_DBG(CAM_REQ, "fence %d signal with %d",
+			req->out_map_entries[j].sync_id, result);
 		cam_sync_signal(req->out_map_entries[j].sync_id, result);
 		req->out_map_entries[j].sync_id = -1;
 	}

+ 2 - 2
drivers/cam_core/cam_context_utils.h

@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
- * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
  */
 
 #ifndef _CAM_CONTEXT_UTILS_H_
@@ -9,7 +9,7 @@
 #include <linux/types.h>
 
 int cam_context_buf_done_from_hw(struct cam_context *ctx,
-	void *done_event_data, uint32_t bubble_state);
+	void *done_event_data, uint32_t evt_id);
 int32_t cam_context_release_dev_to_hw(struct cam_context *ctx,
 	struct cam_release_dev_cmd *cmd);
 int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx,

+ 4 - 0
drivers/cam_core/cam_hw_mgr_intf.h

@@ -35,6 +35,10 @@ enum cam_context_dump_id {
 	CAM_CTX_DUMP_TYPE_MAX,
 };
 
+#define CAM_CTX_EVT_ID_SUCCESS 0
+#define CAM_CTX_EVT_ID_ERROR   1
+#define CAM_CTX_EVT_ID_CANCEL  2
+
 /* hardware event callback function type */
 typedef int (*cam_hw_event_cb_func)(void *context, uint32_t evt_id,
 	void *evt_data);

+ 3 - 4
drivers/cam_fd/fd_hw_mgr/cam_fd_hw_mgr.c

@@ -947,7 +947,7 @@ static int32_t cam_fd_mgr_workq_irq_cb(void *priv, void *data)
 	struct cam_fd_mgr_work_data *work_data;
 	struct cam_fd_mgr_frame_request *frame_req = NULL;
 	enum cam_fd_hw_irq_type irq_type;
-	bool frame_abort = true;
+	uint32_t evt_id = CAM_CTX_EVT_ID_ERROR;
 	int rc;
 
 	if (!data || !priv) {
@@ -1013,12 +1013,11 @@ static int32_t cam_fd_mgr_workq_irq_cb(void *priv, void *data)
 			if (rc) {
 				CAM_ERR(CAM_FD, "Failed in CMD_PRESTART %d",
 					rc);
-				frame_abort = true;
 				goto notify_context;
 			}
 		}
 
-		frame_abort = false;
+		evt_id = CAM_CTX_EVT_ID_SUCCESS;
 	}
 
 	trace_cam_irq_handled("FD", irq_type);
@@ -1035,7 +1034,7 @@ notify_context:
 		buf_data.request_id = frame_req->request_id;
 
 		rc = frame_req->hw_ctx->event_cb(frame_req->hw_ctx->cb_priv,
-			frame_abort, &buf_data);
+			evt_id, &buf_data);
 		if (rc)
 			CAM_ERR(CAM_FD, "Error in event cb handling %d", rc);
 	}

+ 14 - 6
drivers/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c

@@ -1995,7 +1995,7 @@ static int cam_icp_mgr_cleanup_ctx(struct cam_icp_hw_ctx_data *ctx_data)
 			continue;
 		buf_data.request_id = hfi_frame_process->request_id[i];
 		ctx_data->ctxt_event_cb(ctx_data->context_priv,
-			false, &buf_data);
+			CAM_CTX_EVT_ID_SUCCESS, &buf_data);
 		hfi_frame_process->request_id[i] = 0;
 		if (ctx_data->hfi_frame_process.in_resource[i] > 0) {
 			CAM_DBG(CAM_ICP, "Delete merged sync in object: %d",
@@ -2096,6 +2096,7 @@ static int cam_icp_mgr_handle_frame_process(uint32_t *msg_ptr, int flag)
 	struct hfi_frame_process_info *hfi_frame_process;
 	struct cam_hw_done_event_data buf_data;
 	uint32_t clk_type;
+	uint32_t event_id;
 
 	ioconfig_ack = (struct hfi_msg_ipebps_async_ack *)msg_ptr;
 	request_id = ioconfig_ack->user_data2;
@@ -2138,12 +2139,13 @@ static int cam_icp_mgr_handle_frame_process(uint32_t *msg_ptr, int flag)
 	idx = i;
 
 	if (flag == ICP_FRAME_PROCESS_FAILURE) {
-		if (ioconfig_ack->err_type == CAMERAICP_EABORTED)
+		if (ioconfig_ack->err_type == CAMERAICP_EABORTED) {
 			CAM_WARN(CAM_ICP,
 				"ctx_id %d req %llu dev %d has been aborted[flushed]",
 				ctx_data->ctx_id, request_id,
 				ctx_data->icp_dev_acquire_info->dev_type);
-		else
+			event_id = CAM_CTX_EVT_ID_CANCEL;
+		} else {
 			CAM_ERR(CAM_ICP,
 				"Done with error: %u err_type= [%s] on ctx_id %d dev %d for req %llu",
 				ioconfig_ack->err_type,
@@ -2152,10 +2154,14 @@ static int cam_icp_mgr_handle_frame_process(uint32_t *msg_ptr, int flag)
 				ctx_data->ctx_id,
 				ctx_data->icp_dev_acquire_info->dev_type,
 				request_id);
+			event_id = CAM_CTX_EVT_ID_ERROR;
+		}
+	} else {
+		event_id = CAM_CTX_EVT_ID_SUCCESS;
 	}
 
 	buf_data.request_id = hfi_frame_process->request_id[idx];
-	ctx_data->ctxt_event_cb(ctx_data->context_priv, flag, &buf_data);
+	ctx_data->ctxt_event_cb(ctx_data->context_priv, event_id, &buf_data);
 	hfi_frame_process->request_id[idx] = 0;
 	if (ctx_data->hfi_frame_process.in_resource[idx] > 0) {
 		CAM_DBG(CAM_ICP, "Delete merged sync in object: %d",
@@ -3890,7 +3896,8 @@ static int cam_icp_mgr_handle_config_err(
 	struct cam_hw_done_event_data buf_data;
 
 	buf_data.request_id = *(uint64_t *)config_args->priv;
-	ctx_data->ctxt_event_cb(ctx_data->context_priv, false, &buf_data);
+	ctx_data->ctxt_event_cb(ctx_data->context_priv, CAM_CTX_EVT_ID_SUCCESS,
+		&buf_data);
 
 	ctx_data->hfi_frame_process.request_id[idx] = 0;
 	ctx_data->hfi_frame_process.fw_process_flag[idx] = false;
@@ -4962,7 +4969,8 @@ static int cam_icp_mgr_send_abort_status(struct cam_icp_hw_ctx_data *ctx_data)
 		if (!hfi_frame_process->request_id[idx])
 			continue;
 
-		ctx_data->ctxt_event_cb(ctx_data->context_priv, true,
+		ctx_data->ctxt_event_cb(ctx_data->context_priv,
+			CAM_CTX_EVT_ID_CANCEL,
 			&hfi_frame_process->request_id[idx]);
 
 		/* now release memory for hfi frame process command */

+ 4 - 2
drivers/cam_jpeg/jpeg_hw/cam_jpeg_hw_mgr.c

@@ -175,7 +175,8 @@ static int cam_jpeg_mgr_process_irq(void *priv, void *data)
 	}
 	buf_data.request_id =
 		PTR_TO_U64(p_cfg_req->hw_cfg_args.priv);
-	ctx_data->ctxt_event_cb(ctx_data->context_priv, 0, &buf_data);
+	ctx_data->ctxt_event_cb(ctx_data->context_priv, CAM_CTX_EVT_ID_SUCCESS,
+		&buf_data);
 
 	mutex_lock(&g_jpeg_hw_mgr.hw_mgr_mutex);
 	list_add_tail(&p_cfg_req->list, &hw_mgr->free_req_list);
@@ -505,7 +506,8 @@ end_callcb:
 		}
 		buf_data.request_id =
 			(uintptr_t)p_cfg_req->hw_cfg_args.priv;
-		ctx_data->ctxt_event_cb(ctx_data->context_priv, 0, &buf_data);
+		ctx_data->ctxt_event_cb(ctx_data->context_priv,
+			CAM_CTX_EVT_ID_ERROR, &buf_data);
 	}
 end_unusedev:
 	mutex_lock(&hw_mgr->hw_mgr_mutex);

+ 6 - 6
drivers/cam_lrme/lrme_hw_mgr/cam_lrme_hw_mgr.c

@@ -498,7 +498,7 @@ static int cam_lrme_mgr_cb(void *data,
 {
 	struct cam_lrme_hw_mgr *hw_mgr = &g_lrme_hw_mgr;
 	int rc = 0;
-	bool frame_abort = true;
+	uint32_t evt_id = CAM_CTX_EVT_ID_ERROR;
 	struct cam_lrme_frame_request *frame_req;
 	struct cam_lrme_device *hw_device;
 
@@ -530,10 +530,10 @@ static int cam_lrme_mgr_cb(void *data,
 
 	if (cb_args->cb_type & CAM_LRME_CB_BUF_DONE) {
 		cb_args->cb_type &= ~CAM_LRME_CB_BUF_DONE;
-		frame_abort = false;
+		evt_id = CAM_CTX_EVT_ID_SUCCESS;
 	} else if (cb_args->cb_type & CAM_LRME_CB_ERROR) {
 		cb_args->cb_type &= ~CAM_LRME_CB_ERROR;
-		frame_abort = true;
+		evt_id = CAM_CTX_EVT_ID_ERROR;
 	} else {
 		CAM_ERR(CAM_LRME, "Wrong cb type %d, req %lld",
 			cb_args->cb_type, frame_req->req_id);
@@ -544,10 +544,10 @@ static int cam_lrme_mgr_cb(void *data,
 		struct cam_hw_done_event_data buf_data;
 
 		buf_data.request_id = frame_req->req_id;
-		CAM_DBG(CAM_LRME, "frame req %llu, frame_abort %d",
-			frame_req->req_id, frame_abort);
+		CAM_DBG(CAM_LRME, "frame req %llu, evt_id %d",
+			frame_req->req_id, evt_id);
 		rc = hw_mgr->event_cb(frame_req->ctxt_to_hw_map,
-			frame_abort, &buf_data);
+			evt_id, &buf_data);
 	} else {
 		CAM_ERR(CAM_LRME, "No cb function");
 	}

+ 5 - 4
drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.c

@@ -1519,7 +1519,7 @@ static void cam_ope_ctx_cdm_callback(uint32_t handle, void *userdata,
 	struct cam_ope_request *ope_req;
 	struct cam_hw_done_event_data buf_data;
 	struct timespec64 ts;
-	bool flag = false;
+	uint32_t evt_id = CAM_CTX_EVT_ID_SUCCESS;
 
 	if (!userdata) {
 		CAM_ERR(CAM_OPE, "Invalid ctx from CDM callback");
@@ -1582,7 +1582,7 @@ static void cam_ope_ctx_cdm_callback(uint32_t handle, void *userdata,
 		if (status != CAM_CDM_CB_STATUS_HW_FLUSH)
 			cam_ope_dump_req_data(ope_req);
 		rc = cam_ope_mgr_reset_hw();
-		flag = true;
+		evt_id = CAM_CTX_EVT_ID_ERROR;
 	}
 
 	ctx->req_cnt--;
@@ -1595,7 +1595,7 @@ static void cam_ope_ctx_cdm_callback(uint32_t handle, void *userdata,
 	kzfree(ctx->req_list[cookie]);
 	ctx->req_list[cookie] = NULL;
 	clear_bit(cookie, ctx->bitmap);
-	ctx->ctxt_event_cb(ctx->context_priv, flag, &buf_data);
+	ctx->ctxt_event_cb(ctx->context_priv, evt_id, &buf_data);
 
 end:
 	mutex_unlock(&ctx->ctx_mutex);
@@ -3203,7 +3203,8 @@ static int cam_ope_mgr_handle_config_err(
 	ope_req = config_args->priv;
 
 	buf_data.request_id = ope_req->request_id;
-	ctx_data->ctxt_event_cb(ctx_data->context_priv, false, &buf_data);
+	ctx_data->ctxt_event_cb(ctx_data->context_priv, CAM_CTX_EVT_ID_ERROR,
+		&buf_data);
 
 	req_idx = ope_req->req_idx;
 	ope_req->request_id = 0;