Explorar o código

Merge "msm: camera: reqmgr: Propagate hw failures to user" into camera-kernel.lnx.5.0

Camera Software Integration %!s(int64=4) %!d(string=hai) anos
pai
achega
18e3dd6a8e

+ 6 - 2
drivers/cam_isp/cam_isp_context.c

@@ -2628,13 +2628,16 @@ end:
 			if (error_type == CAM_ISP_HW_ERROR_CSID_FATAL)
 				req_msg.u.err_msg.error_type =
 					CAM_REQ_MGR_ERROR_TYPE_FULL_RECOVERY;
-			else
+			else {
 				req_msg.u.err_msg.error_type =
 					CAM_REQ_MGR_ERROR_TYPE_RECOVERY;
+			}
 
 			req_msg.u.err_msg.link_hdl = ctx_isp->base->link_hdl;
 			req_msg.u.err_msg.request_id = error_request_id;
 			req_msg.u.err_msg.resource_size = 0x0;
+			req_msg.u.err_msg.error_code =
+				error_event_data->error_code;
 
 			if (cam_req_mgr_notify_message(&req_msg,
 					V4L_EVENT_CAM_REQ_MGR_ERROR,
@@ -6119,7 +6122,7 @@ static int cam_isp_context_dump_requests(void *data,
 	struct cam_isp_ctx_req *req_isp  = NULL;
 	struct cam_isp_prepare_hw_update_data *hw_update_data = NULL;
 	struct cam_hw_mgr_dump_pf_data *pf_dbg_entry = NULL;
-	struct cam_req_mgr_message       req_msg;
+	struct cam_req_mgr_message       req_msg = {0};
 	struct cam_isp_context          *ctx_isp;
 	uint32_t  resource_type = 0;
 	bool mem_found = false, ctx_found = false, send_error = false;
@@ -6236,6 +6239,7 @@ static int cam_isp_context_dump_requests(void *data,
 		req_msg.u.err_msg.link_hdl = ctx->link_hdl;
 		req_msg.u.err_msg.request_id = 0;
 		req_msg.u.err_msg.resource_size = 0x0;
+		req_msg.u.err_msg.error_code = CAM_REQ_MGR_ISP_UNREPORTED_ERROR;
 
 		if (cam_req_mgr_notify_message(&req_msg,
 				V4L_EVENT_CAM_REQ_MGR_ERROR,

+ 12 - 0
drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c

@@ -10402,6 +10402,7 @@ static int cam_ife_hw_mgr_handle_csid_error(
 		g_ife_hw_mgr.debug_cfg.enable_csid_recovery) {
 
 		error_event_data.error_type = CAM_ISP_HW_ERROR_CSID_FATAL;
+		error_event_data.error_code = CAM_REQ_MGR_CSID_FATAL_ERROR;
 		rc = cam_ife_hw_mgr_find_affected_ctx(&error_event_data,
 			event_info->hw_idx, &recovery_data);
 		goto end;
@@ -10413,6 +10414,15 @@ static int cam_ife_hw_mgr_handle_csid_error(
 
 		cam_ife_hw_mgr_notify_overflow(event_info, ctx);
 		error_event_data.error_type = CAM_ISP_HW_ERROR_OVERFLOW;
+		if (event_info->err_type & CAM_ISP_HW_ERROR_CSID_FIFO_OVERFLOW)
+			error_event_data.error_code |=
+				CAM_REQ_MGR_CSID_FIFO_OVERFLOW_ERROR;
+		if (event_info->err_type & CAM_ISP_HW_ERROR_RECOVERY_OVERFLOW)
+			error_event_data.error_code |=
+				CAM_REQ_MGR_CSID_RECOVERY_OVERFLOW_ERROR;
+		if (event_info->err_type & CAM_ISP_HW_ERROR_CSID_FRAME_SIZE)
+			error_event_data.error_code |=
+				CAM_REQ_MGR_CSID_PIXEL_COUNT_MISMATCH;
 		rc = cam_ife_hw_mgr_find_affected_ctx(&error_event_data,
 			event_info->hw_idx, &recovery_data);
 	}
@@ -10632,6 +10642,8 @@ static int cam_ife_hw_mgr_handle_hw_err(
 	if (g_ife_hw_mgr.debug_cfg.enable_req_dump)
 		error_event_data.enable_req_dump = true;
 
+	error_event_data.error_code = CAM_REQ_MGR_ISP_UNREPORTED_ERROR;
+
 	rc = cam_ife_hw_mgr_find_affected_ctx(&error_event_data,
 		core_idx, &recovery_data);
 

+ 6 - 2
drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.c

@@ -5420,7 +5420,7 @@ static bool cam_tfe_hw_mgr_is_ctx_affected(
 static int  cam_tfe_hw_mgr_find_affected_ctx(
 	struct cam_isp_hw_error_event_data    *error_event_data,
 	uint32_t                               curr_core_idx,
-	struct cam_tfe_hw_event_recovery_data     *recovery_data)
+	struct cam_tfe_hw_event_recovery_data *recovery_data)
 {
 	uint32_t affected_core[CAM_TFE_HW_NUM_MAX] = {0};
 	struct cam_tfe_hw_mgr_ctx   *tfe_hwr_mgr_ctx = NULL;
@@ -5470,7 +5470,8 @@ static int  cam_tfe_hw_mgr_find_affected_ctx(
 		 */
 		if (notify_err_cb) {
 			notify_err_cb(tfe_hwr_mgr_ctx->common.cb_priv,
-			CAM_ISP_HW_EVENT_ERROR, (void *)error_event_data);
+			CAM_ISP_HW_EVENT_ERROR,
+			(void *)error_event_data);
 		} else {
 			CAM_WARN(CAM_ISP, "Error call back is not set");
 			goto end;
@@ -5503,6 +5504,7 @@ static int cam_tfe_hw_mgr_handle_csid_event(
 			break;
 
 		error_event_data.error_type = event_info->err_type;
+		error_event_data.error_code = CAM_REQ_MGR_CSID_FATAL_ERROR;
 		cam_tfe_hw_mgr_find_affected_ctx(&error_event_data,
 			event_info->hw_idx,
 			&recovery_data);
@@ -5545,6 +5547,8 @@ static int cam_tfe_hw_mgr_handle_hw_err(
 	else
 		error_event_data.recovery_enabled = false;
 
+	error_event_data.error_code = CAM_REQ_MGR_ISP_UNREPORTED_ERROR;
+
 	rc = cam_tfe_hw_mgr_find_affected_ctx(&error_event_data,
 		core_idx, &recovery_data);
 	if (rc || !(recovery_data.no_of_context))

+ 2 - 0
drivers/cam_isp/isp_hw_mgr/include/cam_isp_hw_mgr_intf.h

@@ -241,6 +241,7 @@ struct cam_isp_hw_eof_event_data {
  * struct cam_isp_hw_error_event_data - Event payload for CAM_HW_EVENT_ERROR
  *
  * @error_type:            Error type for the error event
+ * @error_code:            HW Error Code that caused to trigger this event
  * @timestamp:             Timestamp for the error event
  * @recovery_enabled:      Identifies if the context needs to recover & reapply
  *                         this request
@@ -248,6 +249,7 @@ struct cam_isp_hw_eof_event_data {
  */
 struct cam_isp_hw_error_event_data {
 	uint32_t             error_type;
+	uint32_t             error_code;
 	uint64_t             timestamp;
 	bool                 recovery_enabled;
 	bool                 enable_req_dump;

+ 4 - 0
drivers/cam_req_mgr/cam_req_mgr_core.c

@@ -352,6 +352,8 @@ static int __cam_req_mgr_notify_error_on_link(
 	msg.u.err_msg.request_id =
 		link->req.apply_data[pd].req_id;
 	msg.u.err_msg.link_hdl   = link->link_hdl;
+	msg.u.err_msg.resource_size = 0;
+	msg.u.err_msg.error_code = CAM_REQ_MGR_LINK_STALLED_ERROR;
 
 	CAM_DBG(CAM_CRM, "Failed for device: %s while applying request: %lld",
 		dev->dev_info.name, link->req.apply_data[pd].req_id);
@@ -2195,6 +2197,8 @@ static int __cam_req_mgr_process_sof_freeze(void *priv, void *data)
 	msg.u.err_msg.error_type = CAM_REQ_MGR_ERROR_TYPE_SOF_FREEZE;
 	msg.u.err_msg.request_id = 0;
 	msg.u.err_msg.link_hdl   = link->link_hdl;
+	msg.u.err_msg.error_code = CAM_REQ_MGR_ISP_UNREPORTED_ERROR;
+	msg.u.err_msg.resource_size = 0;
 
 	rc = cam_req_mgr_notify_message(&msg,
 		V4L_EVENT_CAM_REQ_MGR_ERROR, V4L_EVENT_CAM_REQ_MGR_EVENT);

+ 3 - 2
drivers/cam_req_mgr/cam_req_mgr_dev.c

@@ -242,11 +242,12 @@ static void cam_v4l2_event_queue_notify_error(const struct v4l2_event *old,
 		break;
 	case V4L_EVENT_CAM_REQ_MGR_ERROR:
 		CAM_ERR_RATE_LIMIT(CAM_CRM,
-			"Failed to notify ERROR Sess %X ReqId %d Link %X Type %d",
+			"Failed to notify ERROR Sess %X ReqId %d Link %X Type %d ERR_code: %u",
 			ev_header->session_hdl,
 			ev_header->u.err_msg.request_id,
 			ev_header->u.err_msg.link_hdl,
-			ev_header->u.err_msg.error_type);
+			ev_header->u.err_msg.error_type,
+			ev_header->u.err_msg.error_code);
 		break;
 	default:
 		CAM_ERR(CAM_CRM, "Failed to notify crm event id %d",

+ 20 - 1
include/uapi/camera/media/cam_req_mgr.h

@@ -438,6 +438,22 @@ struct cam_mem_cache_ops_cmd {
 #define CAM_REQ_MGR_ERROR_TYPE_FULL_RECOVERY    5
 #define CAM_REQ_MGR_ERROR_TYPE_PAGE_FAULT       6
 
+/**
+ * Request Manager : Error codes
+ * @CAM_REQ_MGR_ISP_UNREPORTED_ERROR         : No Error Code reported
+ * @CAM_REQ_MGR_LINK_STALLED_ERROR           : Unable to apply requests on link
+ * @CAM_REQ_MGR_CSID_FATAL_ERROR             : CSID FATAL Error
+ * @CAM_REQ_MGR_CSID_FIFO_OVERFLOW_ERROR     : CSID FIFO Overflow
+ * @CAM_REQ_MGR_CSID_RECOVERY_OVERFLOW_ERROR : CSID Recovery Overflow
+ * @CAM_REQ_MGR_CSID_PIXEL_COUNT_MISMATCH    : CSID Pixel Count Mismatch
+ */
+#define CAM_REQ_MGR_ISP_UNREPORTED_ERROR                 0
+#define CAM_REQ_MGR_LINK_STALLED_ERROR                   BIT(0)
+#define CAM_REQ_MGR_CSID_FATAL_ERROR                     BIT(1)
+#define CAM_REQ_MGR_CSID_FIFO_OVERFLOW_ERROR             BIT(2)
+#define CAM_REQ_MGR_CSID_RECOVERY_OVERFLOW_ERROR         BIT(3)
+#define CAM_REQ_MGR_CSID_PIXEL_COUNT_MISMATCH            BIT(5)
+
 /**
  * struct cam_req_mgr_error_msg
  * @error_type: type of error
@@ -445,13 +461,16 @@ struct cam_mem_cache_ops_cmd {
  * @device_hdl: device handle
  * @linke_hdl: link_hdl
  * @resource_size: size of the resource
+ * @error_code: Error code reported by the event.
+ *              Note: This field is a bit field.
  */
 struct cam_req_mgr_error_msg {
 	__u32 error_type;
 	__u32 request_id;
 	__s32 device_hdl;
 	__s32 link_hdl;
-	__u64 resource_size;
+	__u32 resource_size;
+	__u32 error_code;
 };
 
 /**