From c23a3f448c4270ea73eb9c039a60eaa3f5d2ba62 Mon Sep 17 00:00:00 2001 From: Stark Lin Date: Tue, 21 Mar 2023 15:43:12 +0800 Subject: [PATCH] msm: camera: isp: Add support for HWPD debugging HWPD is associated with several modules, but only image size violation displayed in the kernel when an error occur. Now we will pass the error code of HWPD violation to UMD to help UMD to take necessary action and dump relevant info. CRs-Fixed: 3440015 Change-Id: I6483b228a8eeaac3bf54f5f83f8f8deab3da6250 Signed-off-by: Stark Lin --- drivers/cam_isp/cam_isp_context.c | 5 +++ drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c | 7 ++-- .../isp_hw_mgr/include/cam_isp_hw_mgr_intf.h | 1 + .../isp_hw_mgr/isp_hw/include/cam_isp_hw.h | 2 ++ .../isp_hw/include/cam_vfe_hw_intf.h | 4 +++ .../isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver3.c | 34 ++++++++++++++++--- include/uapi/camera/media/cam_req_mgr.h | 6 +++- 7 files changed, 51 insertions(+), 8 deletions(-) diff --git a/drivers/cam_isp/cam_isp_context.c b/drivers/cam_isp/cam_isp_context.c index dd5eb580d8..9b0fa1c283 100644 --- a/drivers/cam_isp/cam_isp_context.c +++ b/drivers/cam_isp/cam_isp_context.c @@ -3579,6 +3579,11 @@ static void __cam_isp_get_notification_evt_params( err_type = CAM_SYNC_ISP_EVENT_VIOLATION; recovery_type_temp |= CAM_REQ_MGR_ERROR_TYPE_RECOVERY; } + if (hw_error & CAM_ISP_HW_ERROR_HWPD_VIOLATION) { + err_code |= CAM_REQ_MGR_ISP_ERR_HWPD_VIOLATION; + err_type = CAM_SYNC_ISP_EVENT_VIOLATION; + recovery_type_temp |= CAM_REQ_MGR_ERROR_TYPE_RECOVERY; + } if (hw_error & CAM_ISP_HW_ERROR_BUSIF_OVERFLOW) { err_code |= CAM_REQ_MGR_ISP_UNREPORTED_ERROR; err_type = CAM_SYNC_ISP_EVENT_BUSIF_OVERFLOW; diff --git a/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c b/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c index b4b0c69a45..dd6a5ce65a 100644 --- a/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c +++ b/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c @@ -14135,9 +14135,12 @@ static int cam_ife_hw_mgr_handle_hw_err( CAM_ISP_HW_VFE_IN_CAMIF) cam_ife_hw_mgr_handle_hw_dump_info(ife_hw_mgr_ctx, event_info); - if (err_type == CAM_VFE_IRQ_STATUS_VIOLATION) + if (err_type == CAM_VFE_IRQ_STATUS_VIOLATION) { error_event_data.error_type = CAM_ISP_HW_ERROR_VIOLATION; - else if (event_info->res_type == CAM_ISP_RESOURCE_VFE_IN) + + if (err_evt_info->err_mask & CAM_VFE_IRQ_ERR_MASK_HWPD_VIOLATION) + error_event_data.error_type |= CAM_ISP_HW_ERROR_HWPD_VIOLATION; + } else if (event_info->res_type == CAM_ISP_RESOURCE_VFE_IN) error_event_data.error_type = CAM_ISP_HW_ERROR_OVERFLOW; else if (event_info->res_type == CAM_ISP_RESOURCE_VFE_OUT) error_event_data.error_type = CAM_ISP_HW_ERROR_BUSIF_OVERFLOW; diff --git a/drivers/cam_isp/isp_hw_mgr/include/cam_isp_hw_mgr_intf.h b/drivers/cam_isp/isp_hw_mgr/include/cam_isp_hw_mgr_intf.h index 0a86f600f0..dd952bad9b 100644 --- a/drivers/cam_isp/isp_hw_mgr/include/cam_isp_hw_mgr_intf.h +++ b/drivers/cam_isp/isp_hw_mgr/include/cam_isp_hw_mgr_intf.h @@ -132,6 +132,7 @@ enum cam_isp_hw_err_type { CAM_ISP_HW_ERROR_CSID_MISSING_EOT = 0x00008000, CAM_ISP_HW_ERROR_CSID_PKT_PAYLOAD_CORRUPTED = 0x00010000, CAM_ISP_HW_ERROR_CSID_CAMIF_FRAME_DROP = 0x00020000, + CAM_ISP_HW_ERROR_HWPD_VIOLATION = 0x00040000, }; /** diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/include/cam_isp_hw.h b/drivers/cam_isp/isp_hw_mgr/isp_hw/include/cam_isp_hw.h index 0fac1a58ee..847fe0d8be 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/include/cam_isp_hw.h +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/include/cam_isp_hw.h @@ -308,10 +308,12 @@ struct cam_isp_blanking_config { * @brief: Structure to pass error event details to hw mgr * * @err_type: Type of error being reported + * @err_mask: Exact error of the err_type * */ struct cam_isp_hw_error_event_info { uint32_t err_type; + uint32_t err_mask; }; /** diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/include/cam_vfe_hw_intf.h b/drivers/cam_isp/isp_hw_mgr/isp_hw/include/cam_vfe_hw_intf.h index 148f6755a5..9559ad8dfb 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/include/cam_vfe_hw_intf.h +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/include/cam_vfe_hw_intf.h @@ -59,6 +59,10 @@ enum cam_vfe_hw_irq_status { CAM_VFE_IRQ_STATUS_MAX, }; +enum cam_vfe_irq_err_mask { + CAM_VFE_IRQ_ERR_MASK_HWPD_VIOLATION = 0x00000001, +}; + enum cam_vfe_hw_irq_regs { CAM_IFE_IRQ_CAMIF_REG_STATUS0 = 0, CAM_IFE_IRQ_CAMIF_REG_STATUS1 = 1, diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver3.c b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver3.c index 83e8aa3f39..f44deedd07 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver3.c +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver3.c @@ -71,6 +71,10 @@ enum cam_vfe_bus_ver3_packer_format { PACKER_FMT_VER3_MAX, }; +struct cam_vfe_bus_irq_violation_type { + bool hwpd_violation; +}; + struct cam_vfe_bus_ver3_comp_grp_acquire_args { enum cam_vfe_bus_ver3_comp_grp_type comp_grp_id; uint64_t composite_mask; @@ -2764,11 +2768,12 @@ static int cam_vfe_bus_ver3_err_irq_top_half(uint32_t evt_id, return rc; } -static void cam_vfe_print_violations( +static void cam_vfe_check_violations( char *error_type, uint32_t status, struct cam_vfe_bus_ver3_priv *bus_priv, - uint64_t *out_port) + uint64_t *out_port, + struct cam_vfe_bus_irq_violation_type *violation_type) { int i, j; struct cam_isp_resource_node *rsrc_node = NULL; @@ -2802,6 +2807,17 @@ static void cam_vfe_print_violations( cam_vfe_bus_ver3_print_wm_info(wm_data, common_data, wm_name); *out_port |= BIT_ULL(rsrc_node->res_id & 0xFF); + + /* check what type of violation it is*/ + switch (wm_data->index) { + case 21: + case 22: + if (!strcmp(error_type, "Image Size")) + violation_type->hwpd_violation = true; + break; + default: + break; + } } } } @@ -2817,6 +2833,7 @@ static int cam_vfe_bus_ver3_err_irq_bottom_half( struct cam_isp_hw_error_event_info err_evt_info; uint32_t status = 0, image_size_violation = 0, ccif_violation = 0, constraint_violation = 0; uint64_t out_port_id = 0; + struct cam_vfe_bus_irq_violation_type violation_type; if (!handler_priv || !evt_payload_priv) return -EINVAL; @@ -2839,20 +2856,27 @@ static int cam_vfe_bus_ver3_err_irq_bottom_half( memset(&evt_info, 0, sizeof(evt_info)); memset(&err_evt_info, 0, sizeof(err_evt_info)); + memset(&violation_type, 0, sizeof(violation_type)); if (image_size_violation || constraint_violation) { status = evt_payload->image_size_violation_status; if (!status) cam_vfe_bus_ver3_get_constraint_errors(bus_priv); else { - cam_vfe_print_violations("Image Size", status, - bus_priv, &out_port_id); + cam_vfe_check_violations("Image Size", status, bus_priv, + &out_port_id, &violation_type); } } if (ccif_violation) { status = evt_payload->ccif_violation_status; - cam_vfe_print_violations("CCIF", status, bus_priv, &out_port_id); + cam_vfe_check_violations("CCIF", status, bus_priv, + &out_port_id, &violation_type); + } + + if (image_size_violation && violation_type.hwpd_violation) { + err_evt_info.err_mask |= CAM_VFE_IRQ_ERR_MASK_HWPD_VIOLATION; + CAM_DBG(CAM_ISP, "HWPD image size violation"); } cam_vfe_bus_ver3_put_evt_payload(common_data, &evt_payload); diff --git a/include/uapi/camera/media/cam_req_mgr.h b/include/uapi/camera/media/cam_req_mgr.h index 0be0b04060..29e6739aa8 100644 --- a/include/uapi/camera/media/cam_req_mgr.h +++ b/include/uapi/camera/media/cam_req_mgr.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ /* * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. - * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef __UAPI_LINUX_CAM_REQ_MGR_H @@ -660,6 +660,8 @@ struct cam_mem_cpu_access_op { * @CAM_REQ_MGR_CSID_MISSING_EOT : CSID is missing EOT on one or more lanes * @CAM_REQ_MGR_CSID_RX_PKT_PAYLOAD_CORRUPTION : CSID long packet payload CRC mismatch * @CAM_REQ_MGR_SENSOR_STREAM_OFF_FAILED : Failed to stream off sensor + * @CAM_REQ_MGR_VALID_SHUTTER_DROPPED : Valid shutter dropped + * @CAM_REQ_MGR_ISP_ERR_HWPD_VIOLATION : HWPD image size violation */ #define CAM_REQ_MGR_ISP_UNREPORTED_ERROR 0 #define CAM_REQ_MGR_LINK_STALLED_ERROR BIT(0) @@ -677,6 +679,8 @@ struct cam_mem_cpu_access_op { #define CAM_REQ_MGR_CSID_MISSING_EOT BIT(12) #define CAM_REQ_MGR_CSID_RX_PKT_PAYLOAD_CORRUPTION BIT(13) #define CAM_REQ_MGR_SENSOR_STREAM_OFF_FAILED BIT(14) +#define CAM_REQ_MGR_VALID_SHUTTER_DROPPED BIT(15) +#define CAM_REQ_MGR_ISP_ERR_HWPD_VIOLATION BIT(16) /** * struct cam_req_mgr_error_msg