Skip to content

Commit

Permalink
[Decode] Add RESET status for media reset
Browse files Browse the repository at this point in the history
* [Decode] Add RESET status for media reset
  • Loading branch information
pengxin99 authored and intel-mediadev committed Jul 6, 2023
1 parent 95ed35b commit 98192be
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 85 deletions.
5 changes: 3 additions & 2 deletions media_common/agnostic/common/codec/shared/codec_def_common.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2022, Intel Corporation
* Copyright (c) 2017-2023, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -408,7 +408,8 @@ typedef enum _CODECHAL_STATUS
* Only error reporting parameters in the status reporting structure will be valid. This status will be returned if the workload(s) for the picture in question resulted in a HW hang or HW status indicators indicate a failure.
*/
CODECHAL_STATUS_ERROR = 2,
CODECHAL_STATUS_UNAVAILABLE = 3 //!< Indicates that the entry in the status reporting array was not used
CODECHAL_STATUS_UNAVAILABLE = 3, //!< Indicates that the entry in the status reporting array was not used
CODECHAL_STATUS_RESET = 4 //!< Indicates that Media Reset happend
} CODECHAL_STATUS, *PCODECHAL_STATUS;

typedef enum _CODECHAL_CHROMA_SITING_TYPE
Expand Down
4 changes: 2 additions & 2 deletions media_driver/agnostic/common/codec/hal/codechal_decoder.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2021, Intel Corporation
* Copyright (c) 2011-2023, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -1909,7 +1909,7 @@ MOS_STATUS CodechalDecode::GetStatusReport(
{
// BB_END data not written. Media reset might have occurred.
CODECHAL_DECODE_NORMALMESSAGE("Media reset may have occured.");
codecStatus[j].m_codecStatus = CODECHAL_STATUS_ERROR;
codecStatus[j].m_codecStatus = CODECHAL_STATUS_RESET;
}

if (m_standard == CODECHAL_HEVC)
Expand Down
85 changes: 51 additions & 34 deletions media_driver/linux/common/codec/ddi/media_libva_decoder.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2021, Intel Corporation
* Copyright (c) 2009-2023, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -403,7 +403,10 @@ VAStatus DdiDecode_StatusReport(PDDI_MEDIA_CONTEXT mediaCtx, CodechalDecode *dec
bo = (tempNewReport.m_deblockedPicResOlp.bo) ? tempNewReport.m_deblockedPicResOlp.bo : bo;
}

if ((tempNewReport.m_codecStatus == CODECHAL_STATUS_SUCCESSFUL) || (tempNewReport.m_codecStatus == CODECHAL_STATUS_ERROR) || (tempNewReport.m_codecStatus == CODECHAL_STATUS_INCOMPLETE))
if ((tempNewReport.m_codecStatus == CODECHAL_STATUS_SUCCESSFUL) ||
(tempNewReport.m_codecStatus == CODECHAL_STATUS_ERROR) ||
(tempNewReport.m_codecStatus == CODECHAL_STATUS_INCOMPLETE) ||
(tempNewReport.m_codecStatus == CODECHAL_STATUS_RESET))
{
PDDI_MEDIA_SURFACE_HEAP_ELEMENT mediaSurfaceHeapElmt = (PDDI_MEDIA_SURFACE_HEAP_ELEMENT)mediaCtx->pSurfaceHeap->pHeapBase;

Expand Down Expand Up @@ -451,7 +454,9 @@ VAStatus DdiDecode_StatusReport(PDDI_MEDIA_CONTEXT mediaCtx, CodechalDecode *dec
{
return VA_STATUS_ERROR_DECODING_ERROR;
}
else if (surface->curStatusReport.decode.status == CODECHAL_STATUS_INCOMPLETE || surface->curStatusReport.decode.status == CODECHAL_STATUS_UNAVAILABLE)
else if (surface->curStatusReport.decode.status == CODECHAL_STATUS_INCOMPLETE ||
surface->curStatusReport.decode.status == CODECHAL_STATUS_RESET ||
surface->curStatusReport.decode.status == CODECHAL_STATUS_UNAVAILABLE)
{
return mediaCtx->bMediaResetEnable ? VA_STATUS_SUCCESS : VA_STATUS_ERROR_HW_BUSY;
}
Expand All @@ -474,47 +479,57 @@ VAStatus DdiDecode_StatusReport(PDDI_MEDIA_CONTEXT mediaCtx, DecodePipelineAdapt
if (surface->curStatusReportQueryState == DDI_MEDIA_STATUS_REPORT_QUERY_STATE_PENDING)
{
uint32_t uNumCompletedReport = decoder->GetCompletedReport();
DDI_CHK_CONDITION((uNumCompletedReport == 0),
"No report available at all", VA_STATUS_ERROR_OPERATION_FAILED);

for (uint32_t i = 0; i < uNumCompletedReport; i++)
if (uNumCompletedReport != 0)
{
decode::DecodeStatusReportData tempNewReport;
MOS_ZeroMemory(&tempNewReport, sizeof(CodechalDecodeStatusReport));
MOS_STATUS eStatus = decoder->GetStatusReport(&tempNewReport, 1);
DDI_CHK_CONDITION(MOS_STATUS_SUCCESS != eStatus, "Get status report fail", VA_STATUS_ERROR_OPERATION_FAILED);

MOS_LINUX_BO *bo = tempNewReport.currDecodedPicRes.bo;

if ((tempNewReport.codecStatus == CODECHAL_STATUS_SUCCESSFUL) || (tempNewReport.codecStatus == CODECHAL_STATUS_ERROR) || (tempNewReport.codecStatus == CODECHAL_STATUS_INCOMPLETE))
for (uint32_t i = 0; i < uNumCompletedReport; i++)
{
PDDI_MEDIA_SURFACE_HEAP_ELEMENT mediaSurfaceHeapElmt = (PDDI_MEDIA_SURFACE_HEAP_ELEMENT)mediaCtx->pSurfaceHeap->pHeapBase;
decode::DecodeStatusReportData tempNewReport;
MOS_ZeroMemory(&tempNewReport, sizeof(CodechalDecodeStatusReport));
MOS_STATUS eStatus = decoder->GetStatusReport(&tempNewReport, 1);
DDI_CHK_CONDITION(MOS_STATUS_SUCCESS != eStatus, "Get status report fail", VA_STATUS_ERROR_OPERATION_FAILED);

uint32_t j = 0;
for (j = 0; j < mediaCtx->pSurfaceHeap->uiAllocatedHeapElements; j++, mediaSurfaceHeapElmt++)
MOS_LINUX_BO *bo = tempNewReport.currDecodedPicRes.bo;

if ((tempNewReport.codecStatus == CODECHAL_STATUS_SUCCESSFUL) ||
(tempNewReport.codecStatus == CODECHAL_STATUS_ERROR) ||
(tempNewReport.codecStatus == CODECHAL_STATUS_INCOMPLETE) ||
(tempNewReport.codecStatus == CODECHAL_STATUS_RESET))
{
if (mediaSurfaceHeapElmt != nullptr &&
mediaSurfaceHeapElmt->pSurface != nullptr &&
bo == mediaSurfaceHeapElmt->pSurface->bo)
PDDI_MEDIA_SURFACE_HEAP_ELEMENT mediaSurfaceHeapElmt = (PDDI_MEDIA_SURFACE_HEAP_ELEMENT)mediaCtx->pSurfaceHeap->pHeapBase;

uint32_t j = 0;
for (j = 0; j < mediaCtx->pSurfaceHeap->uiAllocatedHeapElements; j++, mediaSurfaceHeapElmt++)
{
mediaSurfaceHeapElmt->pSurface->curStatusReport.decode.status = (uint32_t)tempNewReport.codecStatus;
mediaSurfaceHeapElmt->pSurface->curStatusReport.decode.errMbNum = (uint32_t)tempNewReport.numMbsAffected;
mediaSurfaceHeapElmt->pSurface->curStatusReport.decode.crcValue = (uint32_t)tempNewReport.frameCrc;
mediaSurfaceHeapElmt->pSurface->curStatusReportQueryState = DDI_MEDIA_STATUS_REPORT_QUERY_STATE_COMPLETED;
break;
if (mediaSurfaceHeapElmt != nullptr &&
mediaSurfaceHeapElmt->pSurface != nullptr &&
bo == mediaSurfaceHeapElmt->pSurface->bo)
{
mediaSurfaceHeapElmt->pSurface->curStatusReport.decode.status = (uint32_t)tempNewReport.codecStatus;
mediaSurfaceHeapElmt->pSurface->curStatusReport.decode.errMbNum = (uint32_t)tempNewReport.numMbsAffected;
mediaSurfaceHeapElmt->pSurface->curStatusReport.decode.crcValue = (uint32_t)tempNewReport.frameCrc;
mediaSurfaceHeapElmt->pSurface->curStatusReportQueryState = DDI_MEDIA_STATUS_REPORT_QUERY_STATE_COMPLETED;
break;
}
}
}

if (j == mediaCtx->pSurfaceHeap->uiAllocatedHeapElements)
if (j == mediaCtx->pSurfaceHeap->uiAllocatedHeapElements)
{
return VA_STATUS_ERROR_OPERATION_FAILED;
}
}
else
{
// return failed if queried INCOMPLETE or UNAVAILABLE report.
return VA_STATUS_ERROR_OPERATION_FAILED;
}
}
else
{
// return failed if queried INCOMPLETE or UNAVAILABLE report.
return VA_STATUS_ERROR_OPERATION_FAILED;
}
}
// The surface is not busy in HW, but uNumCompletedReport is 0, treat as engine reset
else
{
surface->curStatusReport.decode.status == CODECHAL_STATUS_INCOMPLETE;
surface->curStatusReportQueryState = DDI_MEDIA_STATUS_REPORT_QUERY_STATE_COMPLETED;
DDI_ASSERTMESSAGE("No report available at all! Engine reset may have occured.");
}
}

Expand All @@ -534,7 +549,9 @@ VAStatus DdiDecode_StatusReport(PDDI_MEDIA_CONTEXT mediaCtx, DecodePipelineAdapt
{
return VA_STATUS_ERROR_DECODING_ERROR;
}
else if (surface->curStatusReport.decode.status == CODECHAL_STATUS_INCOMPLETE || surface->curStatusReport.decode.status == CODECHAL_STATUS_UNAVAILABLE)
else if (surface->curStatusReport.decode.status == CODECHAL_STATUS_INCOMPLETE ||
surface->curStatusReport.decode.status == CODECHAL_STATUS_RESET ||
surface->curStatusReport.decode.status == CODECHAL_STATUS_UNAVAILABLE)
{
return mediaCtx->bMediaResetEnable ? VA_STATUS_SUCCESS : VA_STATUS_ERROR_HW_BUSY;
}
Expand Down
11 changes: 6 additions & 5 deletions media_driver/linux/common/ddi/media_libva.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2022, Intel Corporation
* Copyright (c) 2009-2023, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -4426,10 +4426,11 @@ VAStatus DdiMedia_QuerySurfaceError(
{
if (error_status != -1 && surface->curCtxType == DDI_MEDIA_CONTEXT_TYPE_DECODER)
{
if (surface->curStatusReport.decode.status == CODECHAL_STATUS_ERROR)
if (surface->curStatusReport.decode.status == CODECHAL_STATUS_ERROR ||
surface->curStatusReport.decode.status == CODECHAL_STATUS_RESET)
{
surfaceErrors[1].status = -1;
surfaceErrors[0].status = 2;
surfaceErrors[0].status = (surface->curStatusReport.decode.status == CODECHAL_STATUS_RESET) ? VA_STATUS_ERROR_HW_BUSY : 2;
surfaceErrors[0].start_mb = 0;
surfaceErrors[0].end_mb = 0;
surfaceErrors[0].num_mb = surface->curStatusReport.decode.errMbNum;
Expand All @@ -4438,8 +4439,8 @@ VAStatus DdiMedia_QuerySurfaceError(
DdiMediaUtil_UnLockMutex(&mediaCtx->SurfaceMutex);
return VA_STATUS_SUCCESS;
}
else if (surface->curStatusReport.decode.status == CODECHAL_STATUS_INCOMPLETE ||
surface->curStatusReport.decode.status == CODECHAL_STATUS_UNAVAILABLE)
else if (surface->curStatusReport.decode.status == CODECHAL_STATUS_INCOMPLETE ||
surface->curStatusReport.decode.status == CODECHAL_STATUS_UNAVAILABLE)
{
MOS_ZeroMemory(&surfaceErrors[0], sizeof(VASurfaceDecodeMBErrors));
surfaceErrors[1].status = -1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2021, Intel Corporation
* Copyright (c) 2019-2023, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -242,7 +242,7 @@ namespace decode {
}
else if (!completed)
{
statusReportData->codecStatus = CODECHAL_STATUS_ERROR;
statusReportData->codecStatus = CODECHAL_STATUS_RESET;
DECODE_ASSERTMESSAGE("Media reset may have occured.");
}
else
Expand Down
Loading

0 comments on commit 98192be

Please sign in to comment.