From bfb7cb25755077422366c38aaf1f9671281965b4 Mon Sep 17 00:00:00 2001 From: XuanJessica Date: Tue, 8 Feb 2022 20:52:12 +0800 Subject: [PATCH] [Decode] Add Huc Status Report Critical Error Regkey Check Huc status bit15 none critical error and report to regkey --- .../agnostic/common/os/mos_os_trace_event.h | 1 + .../agnostic/common/os/mos_utilities_common.h | 1 + .../common/codec/hal/codechal_decode_hevc.h | 1 + .../common/codec/hal/codechal_decoder.cpp | 4 +- .../agnostic/common/os/mos_utilities.cpp | 9 +++ .../codec/hal/codechal_decode_hevc_g12.cpp | 56 ++++++++++++------- .../hevc/pipeline/decode_hevc_pipeline.cpp | 33 ++++++++--- .../dec/hevc/pipeline/decode_hevc_pipeline.h | 1 + 8 files changed, 77 insertions(+), 29 deletions(-) diff --git a/media_common/agnostic/common/os/mos_os_trace_event.h b/media_common/agnostic/common/os/mos_os_trace_event.h index d4c6cd3de0..0764ce881c 100644 --- a/media_common/agnostic/common/os/mos_os_trace_event.h +++ b/media_common/agnostic/common/os/mos_os_trace_event.h @@ -638,6 +638,7 @@ typedef enum _MT_PARAM_ID MT_PARAM_ID_DEC_BASE = 0x03000000, MT_DEC_HUC_ERROR_STATUS2, MT_CODEC_HAL_MODE, + MT_DEC_HUC_STATUS_CRITICAL_ERROR, MT_PARAM_ID_ENC_BASE = 0x04000000, } MT_PARAM_ID; diff --git a/media_common/agnostic/common/os/mos_utilities_common.h b/media_common/agnostic/common/os/mos_utilities_common.h index 91e1ecf495..0f3aa004ee 100644 --- a/media_common/agnostic/common/os/mos_utilities_common.h +++ b/media_common/agnostic/common/os/mos_utilities_common.h @@ -553,6 +553,7 @@ typedef enum _MOS_USER_FEATURE_VALUE_ID __MEDIA_USER_FEATURE_VALUE_OLP_IN_USE_ID, __MEDIA_USER_FEATURE_VALUE_SKIP_FRAME_IN_USE_ID, __MEDIA_USER_FEATURE_VALUE_HUC_LOAD_STATUS_ID, + __MEDIA_USER_FEATURE_VALUE_HUC_REPORT_CRITICAL_ERROR_ID, __MOS_USER_FEATURE_KEY_MAX_ID, } MOS_USER_FEATURE_VALUE_ID; diff --git a/media_driver/agnostic/common/codec/hal/codechal_decode_hevc.h b/media_driver/agnostic/common/codec/hal/codechal_decode_hevc.h index 2e267db9d8..9b33876a60 100644 --- a/media_driver/agnostic/common/codec/hal/codechal_decode_hevc.h +++ b/media_driver/agnostic/common/codec/hal/codechal_decode_hevc.h @@ -583,6 +583,7 @@ class CodechalDecodeHevc : public CodechalDecode bool m_dummyReferenceSlot[CODECHAL_MAX_CUR_NUM_REF_FRAME_HEVC]; bool m_reportHucStatus = false; + bool m_reportHucCriticalError = false; }; #endif // __CODECHAL_DECODER_HEVC_H__ diff --git a/media_driver/agnostic/common/codec/hal/codechal_decoder.cpp b/media_driver/agnostic/common/codec/hal/codechal_decoder.cpp index 3d9d875a2e..53f1486ff3 100644 --- a/media_driver/agnostic/common/codec/hal/codechal_decoder.cpp +++ b/media_driver/agnostic/common/codec/hal/codechal_decoder.cpp @@ -458,9 +458,11 @@ MOS_STATUS CodechalDecode::Allocate (CodechalSetting * codecHalSettings) m_decodeStatusBuf.m_hucErrorStatusRegOffset = CODECHAL_OFFSETOF(CodechalDecodeStatus, m_hucErrorStatus) + sizeof(uint32_t); // Set IMEM Loaded bit (in DW1) to 1 by default in the first status buffer - // This bit will be changed later after storing register + // Set None Critical Error bit to 1 by default in the first status buffer + // These bits will be changed later after storing register if (m_hucInterface) { + m_decodeStatusBuf.m_decodeStatus->m_hucErrorStatus = (uint64_t)m_hucInterface->GetHucStatusHevcS2lFailureMask() << 32; m_decodeStatusBuf.m_decodeStatus->m_hucErrorStatus2 = (uint64_t)m_hucInterface->GetHucStatus2ImemLoadedMask() << 32; } diff --git a/media_driver/agnostic/common/os/mos_utilities.cpp b/media_driver/agnostic/common/os/mos_utilities.cpp index 555fd4d43f..ac7a9423a5 100644 --- a/media_driver/agnostic/common/os/mos_utilities.cpp +++ b/media_driver/agnostic/common/os/mos_utilities.cpp @@ -4127,6 +4127,15 @@ static MOS_USER_FEATURE_VALUE MOSUserFeatureDescFields[__MOS_USER_FEATURE_KEY_MA MOS_USER_FEATURE_VALUE_TYPE_INT32, "0", "Report out Huc loaded fails."), + MOS_DECLARE_UF_KEY(__MEDIA_USER_FEATURE_VALUE_HUC_REPORT_CRITICAL_ERROR_ID, + "HuC Report Critical Error", + __MEDIA_USER_FEATURE_SUBKEY_INTERNAL, + __MEDIA_USER_FEATURE_SUBKEY_REPORT, + "Report", + MOS_USER_FEATURE_TYPE_USER, + MOS_USER_FEATURE_VALUE_TYPE_INT32, + "0", + "Report out HuC report critical error."), }; PMOS_USER_FEATURE_VALUE const MosUtilities::m_mosUserFeatureDescFields = MOSUserFeatureDescFields; diff --git a/media_driver/agnostic/gen12/codec/hal/codechal_decode_hevc_g12.cpp b/media_driver/agnostic/gen12/codec/hal/codechal_decode_hevc_g12.cpp index 35c50d1e36..db4f6d1685 100644 --- a/media_driver/agnostic/gen12/codec/hal/codechal_decode_hevc_g12.cpp +++ b/media_driver/agnostic/gen12/codec/hal/codechal_decode_hevc_g12.cpp @@ -708,26 +708,42 @@ MOS_STATUS CodechalDecodeHevcG12::SetFrameStates () m_frameIdx++; - // Check HuC_status2 Imem loaded bit, if 0,return error - // As driver doesn't know when can get reg value afer storing HuC_Status2 register, - // Check the reg value here at the beginning of next frame - // Check twice, first entry and second entry - if (m_shortFormatInUse && m_frameIdx < 3 && m_statusQueryReportingEnabled && - (((m_decodeStatusBuf.m_decodeStatus->m_hucErrorStatus2 >> 32) & m_hucInterface->GetHucStatus2ImemLoadedMask()) == 0)) - { - if (!m_reportHucStatus) - { - MOS_USER_FEATURE_VALUE_WRITE_DATA userFeatureWriteData; - MOS_ZeroMemory(&userFeatureWriteData, sizeof(userFeatureWriteData)); - userFeatureWriteData.Value.i32Data = true; - userFeatureWriteData.ValueID = __MEDIA_USER_FEATURE_VALUE_HUC_LOAD_STATUS_ID; - MOS_UserFeature_WriteValues_ID(nullptr, &userFeatureWriteData, 1, m_osInterface->pOsContext); - m_reportHucStatus = true; - } - - CODECHAL_DECODE_ASSERTMESSAGE("HuC IMEM Loaded fails"); - MT_ERR1(MT_DEC_HEVC, MT_DEC_HUC_ERROR_STATUS2, (m_decodeStatusBuf.m_decodeStatus->m_hucErrorStatus2 >> 32)); - return MOS_STATUS_UNKNOWN; + if (m_shortFormatInUse) + { + // Check HuC_status2 Imem loaded bit, if 0,return error + // As driver doesn't know when can get reg value afer storing HuC_Status2 register, + // Check the reg value here at the beginning of next frame + // Check twice, first entry and second entry + if (m_frameIdx < 3 && m_statusQueryReportingEnabled && + (((m_decodeStatusBuf.m_decodeStatus->m_hucErrorStatus2 >> 32) & m_hucInterface->GetHucStatus2ImemLoadedMask()) == 0)) + { + if (!m_reportHucStatus) + { + MOS_USER_FEATURE_VALUE_WRITE_DATA userFeatureWriteData; + MOS_ZeroMemory(&userFeatureWriteData, sizeof(userFeatureWriteData)); + userFeatureWriteData.Value.i32Data = true; + userFeatureWriteData.ValueID = __MEDIA_USER_FEATURE_VALUE_HUC_LOAD_STATUS_ID; + MOS_UserFeature_WriteValues_ID(nullptr, &userFeatureWriteData, 1, m_osInterface->pOsContext); + m_reportHucStatus = true; + } + + CODECHAL_DECODE_ASSERTMESSAGE("HuC IMEM Loaded fails"); + MT_ERR1(MT_DEC_HEVC, MT_DEC_HUC_ERROR_STATUS2, (m_decodeStatusBuf.m_decodeStatus->m_hucErrorStatus2 >> 32)); + return MOS_STATUS_UNKNOWN; + } + + // Check Huc_status None Critical Error bit, bit 15. If 0, return error. + if (((m_decodeStatusBuf.m_decodeStatus->m_hucErrorStatus >> 32) & m_hucInterface->GetHucStatusHevcS2lFailureMask()) == 0) + { + if (!m_reportHucCriticalError) + { + WriteUserFeature(__MEDIA_USER_FEATURE_VALUE_HUC_REPORT_CRITICAL_ERROR_ID, 1, m_osInterface->pOsContext); + m_reportHucCriticalError = true; + } + CODECHAL_DECODE_ASSERTMESSAGE("Huc Report Critical Error!"); + MT_ERR1(MT_DEC_HEVC, MT_DEC_HUC_STATUS_CRITICAL_ERROR, (m_decodeStatusBuf.m_decodeStatus->m_hucErrorStatus >> 32)); + return MOS_STATUS_UNKNOWN; + } } m_cencBuf = m_decodeParams.m_cencBuf; diff --git a/media_softlet/agnostic/common/codec/hal/dec/hevc/pipeline/decode_hevc_pipeline.cpp b/media_softlet/agnostic/common/codec/hal/dec/hevc/pipeline/decode_hevc_pipeline.cpp index d28bf6fd78..baf2756ed5 100644 --- a/media_softlet/agnostic/common/codec/hal/dec/hevc/pipeline/decode_hevc_pipeline.cpp +++ b/media_softlet/agnostic/common/codec/hal/dec/hevc/pipeline/decode_hevc_pipeline.cpp @@ -299,18 +299,35 @@ MOS_STATUS HevcPipeline::HwStatusCheck(const DecodeStatusMfx &status) { DECODE_FUNC_CALL(); - // Check HuC_status2 Imem loaded bit, if 0, return error - if (m_shortFormatInUse && - ((status.m_hucErrorStatus2 >> 32) && (m_hwInterface->GetHucInterface()->GetHucStatus2ImemLoadedMask()) == 0)) + if (m_shortFormatInUse) { - if (!m_reportHucStatus) + // Check HuC_status2 Imem loaded bit, if 0, return error + if (((status.m_hucErrorStatus2 >> 32) && (m_hwInterface->GetHucInterface()->GetHucStatus2ImemLoadedMask())) == 0) { - WriteUserFeature(__MEDIA_USER_FEATURE_VALUE_HUC_LOAD_STATUS_ID, 1, m_osInterface->pOsContext); - m_reportHucStatus = true; + if (!m_reportHucStatus) + { + WriteUserFeature(__MEDIA_USER_FEATURE_VALUE_HUC_LOAD_STATUS_ID, 1, m_osInterface->pOsContext); + m_reportHucStatus = true; + } + DECODE_ASSERTMESSAGE("Huc IMEM Loaded fails"); + MT_ERR1(MT_DEC_HEVC, MT_DEC_HUC_ERROR_STATUS2, (status.m_hucErrorStatus2 >> 32)); + return MOS_STATUS_UNKNOWN; + } + + // Check Huc_status None Critical Error bit, bit 15. If 0, return error. + if (((status.m_hucErrorStatus >> 32) & m_hwInterface->GetHucInterface()->GetHucStatusHevcS2lFailureMask()) == 0) + { + if (!m_reportHucCriticalError) + { + WriteUserFeature(__MEDIA_USER_FEATURE_VALUE_HUC_REPORT_CRITICAL_ERROR_ID, 1, m_osInterface->pOsContext); + m_reportHucCriticalError = true; + } + DECODE_ASSERTMESSAGE("Huc Report Critical Error!"); + MT_ERR1(MT_DEC_HEVC, MT_DEC_HUC_STATUS_CRITICAL_ERROR, (status.m_hucErrorStatus >> 32)); + return MOS_STATUS_UNKNOWN; } - DECODE_ASSERTMESSAGE("Huc IMEM Loaded fails"); - return MOS_STATUS_UNKNOWN; } + return MOS_STATUS_SUCCESS; } #endif diff --git a/media_softlet/agnostic/common/codec/hal/dec/hevc/pipeline/decode_hevc_pipeline.h b/media_softlet/agnostic/common/codec/hal/dec/hevc/pipeline/decode_hevc_pipeline.h index 11b9a03e8f..837e8bdff2 100644 --- a/media_softlet/agnostic/common/codec/hal/dec/hevc/pipeline/decode_hevc_pipeline.h +++ b/media_softlet/agnostic/common/codec/hal/dec/hevc/pipeline/decode_hevc_pipeline.h @@ -299,6 +299,7 @@ class HevcPipeline : public DecodePipeline uint32_t m_vtFrameCount = 0; //!< frame count for virtual tile decoding uint32_t m_spFrameCount = 0; //!< frame count for single pipe decoding bool m_reportHucStatus = false; //!< Flag for reporting huc status to regkey + bool m_reportHucCriticalError = false; //!< Flag for reporting huc critical error to regkey #endif MEDIA_CLASS_DEFINE_END(HevcPipeline)