Skip to content

Commit

Permalink
[Decode] Add Huc Status Report Critical Error Regkey
Browse files Browse the repository at this point in the history
Check Huc status bit15 none critical error and report to regkey
  • Loading branch information
XuanJessica authored and intel-mediadev committed Feb 8, 2022
1 parent 5dfb72e commit bfb7cb2
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 29 deletions.
1 change: 1 addition & 0 deletions media_common/agnostic/common/os/mos_os_trace_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions media_common/agnostic/common/os/mos_utilities_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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__
4 changes: 3 additions & 1 deletion media_driver/agnostic/common/codec/hal/codechal_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
9 changes: 9 additions & 0 deletions media_driver/agnostic/common/os/mos_utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
56 changes: 36 additions & 20 deletions media_driver/agnostic/gen12/codec/hal/codechal_decode_hevc_g12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit bfb7cb2

Please sign in to comment.