From 55b89826c0cfb9751b7be8858e2988b6eb657479 Mon Sep 17 00:00:00 2001 From: Zeng_Vicky Date: Thu, 31 Aug 2023 11:50:57 +0800 Subject: [PATCH] [Media Common][VP] Coverity issues clean up For Coverity issues clean up. --- .../common/shared/mediacopy/media_vebox_copy.cpp | 6 ++++++ .../common/vp/hal/vphal_render_vebox_base.cpp | 5 +++++ media_driver/agnostic/gen12/hw/mhw_state_heap_g12.c | 5 ++--- .../gen12/vp/hal/vphal_render_vebox_g12_base.cpp | 1 + .../agnostic/gen12_tgllp/vp/hal/vphal_g12_tgllp.h | 6 +++--- .../media_interfaces_dg2/media_interfaces_dg2.cpp | 4 ++++ .../vp/hal/packet/vp_vebox_cmd_packet_legacy.cpp | 3 +++ .../shared/mmc/media_mem_decompression_next.cpp | 12 ++++++++++-- 8 files changed, 34 insertions(+), 8 deletions(-) diff --git a/media_driver/agnostic/common/shared/mediacopy/media_vebox_copy.cpp b/media_driver/agnostic/common/shared/mediacopy/media_vebox_copy.cpp index 5ed3261553f..52a5ab8a819 100644 --- a/media_driver/agnostic/common/shared/mediacopy/media_vebox_copy.cpp +++ b/media_driver/agnostic/common/shared/mediacopy/media_vebox_copy.cpp @@ -80,6 +80,12 @@ VeboxCopyState::~VeboxCopyState() m_veboxInterface->DestroyHeap(); m_veboxInterface = nullptr; } + + if (m_mhwInterfaces) + { + m_mhwInterfaces->Destroy(); + MOS_Delete(m_mhwInterfaces); + } } MOS_STATUS VeboxCopyState::Initialize() diff --git a/media_driver/agnostic/common/vp/hal/vphal_render_vebox_base.cpp b/media_driver/agnostic/common/vp/hal/vphal_render_vebox_base.cpp index 1d35176e574..9ca28013623 100644 --- a/media_driver/agnostic/common/vp/hal/vphal_render_vebox_base.cpp +++ b/media_driver/agnostic/common/vp/hal/vphal_render_vebox_base.cpp @@ -1823,6 +1823,7 @@ MOS_STATUS VPHAL_VEBOX_STATE::VeboxSendVeboxCmd_Prepare( PVPHAL_VEBOX_STATE pVeboxState = this; PVPHAL_VEBOX_RENDER_DATA pRenderData = GetLastExecRenderData(); + VPHAL_RENDER_CHK_NULL(pRenderData); // Switch GPU context to VEBOX VPHAL_RENDER_CHK_STATUS(pOsInterface->pfnSetGpuContext(pOsInterface, MOS_GPU_CONTEXT_VEBOX)); @@ -2964,6 +2965,7 @@ MOS_STATUS VPHAL_VEBOX_STATE::VeboxCopyAndUpdateVeboxState( MOS_STATUS eStatus = MOS_STATUS_SUCCESS; + VPHAL_RENDER_CHK_NULL(pRenderData); VPHAL_RENDER_ASSERT(pVeboxState); VPHAL_RENDER_ASSERT(pRenderData); VPHAL_RENDER_ASSERT(pSrcSurface); @@ -3392,6 +3394,7 @@ MOS_STATUS VPHAL_VEBOX_STATE::VeboxRenderMode0( PVPHAL_VEBOX_STATE pVeboxState = this; PVPHAL_VEBOX_RENDER_DATA pRenderData = GetLastExecRenderData(); + VPHAL_RENDER_CHK_NULL(pRenderData); VPHAL_RENDER_ASSERT(pVeboxState); VPHAL_RENDER_ASSERT(pRenderData); VPHAL_RENDER_ASSERT(pSrcSurface); @@ -3662,6 +3665,8 @@ MOS_STATUS VPHAL_VEBOX_STATE::Render( bDIVeboxBypass = false; pRenderData = pVeboxState->GetLastExecRenderData(); + VPHAL_RENDER_CHK_NULL(pRenderData); + VPHAL_DBG_STATE_DUMPPER_SET_CURRENT_STAGE(VPHAL_DBG_STAGE_VEBOX); // Check bSameSamples only when reference is avaliable, DI, Variance Query is enabled diff --git a/media_driver/agnostic/gen12/hw/mhw_state_heap_g12.c b/media_driver/agnostic/gen12/hw/mhw_state_heap_g12.c index 986c928ac84..684f8f07113 100644 --- a/media_driver/agnostic/gen12/hw/mhw_state_heap_g12.c +++ b/media_driver/agnostic/gen12/hw/mhw_state_heap_g12.c @@ -495,10 +495,9 @@ MOS_STATUS MHW_STATE_HEAP_INTERFACE_G12_X::SetSurfaceState( pParams->psSurface->dwPitch : pParams->dwPitchToUse[i]; if (pParams->psSurface->MmcState == MOS_MEMCOMP_MC) { - CmdInit.DW7.MemoryCompressionEnable = - (pParams->psSurface->MmcState == MOS_MEMCOMP_RC || pParams->psSurface->MmcState == MOS_MEMCOMP_MC) ? 1 : 0; + CmdInit.DW7.MemoryCompressionEnable = 1; CmdInit.DW7.MemoryCompressionMode = 0; - CmdInit.DW4.DecompressInL3 = (pParams->psSurface->MmcState == MOS_MEMCOMP_MC) ? 1 : 0; + CmdInit.DW4.DecompressInL3 = 1; } else if(pParams->psSurface->MmcState == MOS_MEMCOMP_RC) { diff --git a/media_driver/agnostic/gen12/vp/hal/vphal_render_vebox_g12_base.cpp b/media_driver/agnostic/gen12/vp/hal/vphal_render_vebox_g12_base.cpp index a40acd9a12b..d4489165bbe 100644 --- a/media_driver/agnostic/gen12/vp/hal/vphal_render_vebox_g12_base.cpp +++ b/media_driver/agnostic/gen12/vp/hal/vphal_render_vebox_g12_base.cpp @@ -2582,6 +2582,7 @@ bool VPHAL_VEBOX_STATE_G12_BASE::IsNeeded( pSrcSurface = pRenderPassData->pSrcSurface; VPHAL_RENDER_CHK_NULL(pSrcSurface); + VPHAL_RENDER_CHK_NULL(pRenderData); // Check whether VEBOX is available // VTd doesn't support VEBOX diff --git a/media_driver/agnostic/gen12_tgllp/vp/hal/vphal_g12_tgllp.h b/media_driver/agnostic/gen12_tgllp/vp/hal/vphal_g12_tgllp.h index 2c8dd463bf6..71a13e2272d 100644 --- a/media_driver/agnostic/gen12_tgllp/vp/hal/vphal_g12_tgllp.h +++ b/media_driver/agnostic/gen12_tgllp/vp/hal/vphal_g12_tgllp.h @@ -81,7 +81,6 @@ class VphalStateG12Tgllp : public VphalState { bComputeContextEnabled = computeContextEnabled ? true : false; } -#endif if (!MEDIA_IS_SKU(m_skuTable, FtrCCSNode)) { @@ -90,9 +89,10 @@ class VphalStateG12Tgllp : public VphalState if (bComputeContextEnabled) { - m_renderGpuContext = MOS_GPU_CONTEXT_COMPUTE; - m_renderGpuNode = MOS_GPU_NODE_COMPUTE; + m_renderGpuContext = MOS_GPU_CONTEXT_COMPUTE; + m_renderGpuNode = MOS_GPU_NODE_COMPUTE; } +#endif } //! diff --git a/media_driver/media_interface/media_interfaces_dg2/media_interfaces_dg2.cpp b/media_driver/media_interface/media_interfaces_dg2/media_interfaces_dg2.cpp index 6b0422e1fbc..d16d25983cf 100644 --- a/media_driver/media_interface/media_interfaces_dg2/media_interfaces_dg2.cpp +++ b/media_driver/media_interface/media_interfaces_dg2/media_interfaces_dg2.cpp @@ -857,6 +857,7 @@ MOS_STATUS CodechalInterfacesNextXe_Hpm::Initialize( if (CodecHalIsDecode(CodecFunction)) { CODECHAL_PUBLIC_ASSERTMESSAGE("Decode allocation failed, Decoder with CodechalDeviceNext is not supported!"); + MOS_Delete(hwInterface); return MOS_STATUS_INVALID_PARAMETER; } @@ -876,6 +877,7 @@ MOS_STATUS CodechalInterfacesNextXe_Hpm::Initialize( } else { + MOS_Delete(hwInterface); return MOS_STATUS_INVALID_PARAMETER; } } @@ -883,6 +885,7 @@ MOS_STATUS CodechalInterfacesNextXe_Hpm::Initialize( #endif { CODECHAL_PUBLIC_ASSERTMESSAGE("Unsupported encode function requested."); + MOS_Delete(hwInterface); return MOS_STATUS_INVALID_PARAMETER; } @@ -890,6 +893,7 @@ MOS_STATUS CodechalInterfacesNextXe_Hpm::Initialize( else { CODECHAL_PUBLIC_ASSERTMESSAGE("Unsupported codec function requested."); + MOS_Delete(hwInterface); return MOS_STATUS_INVALID_PARAMETER; } diff --git a/media_driver/media_softlet/agnostic/common/vp/hal/packet/vp_vebox_cmd_packet_legacy.cpp b/media_driver/media_softlet/agnostic/common/vp/hal/packet/vp_vebox_cmd_packet_legacy.cpp index 0ba592bfc48..218c655887e 100644 --- a/media_driver/media_softlet/agnostic/common/vp/hal/packet/vp_vebox_cmd_packet_legacy.cpp +++ b/media_driver/media_softlet/agnostic/common/vp/hal/packet/vp_vebox_cmd_packet_legacy.cpp @@ -2634,6 +2634,9 @@ MOS_STATUS VpVeboxCmdPacketLegacy::SetUpdatedExecuteResource( { VP_FUNC_CALL(); + VP_RENDER_CHK_NULL_RETURN(inputSurface); + VP_RENDER_CHK_NULL_RETURN(outputSurface); + m_allocator->UpdateResourceUsageType(&inputSurface->osSurface->OsResource, MOS_HW_RESOURCE_USAGE_VP_INPUT_PICTURE_FF); m_allocator->UpdateResourceUsageType(&outputSurface->osSurface->OsResource, MOS_HW_RESOURCE_USAGE_VP_OUTPUT_PICTURE_FF); diff --git a/media_softlet/agnostic/common/shared/mmc/media_mem_decompression_next.cpp b/media_softlet/agnostic/common/shared/mmc/media_mem_decompression_next.cpp index cbb432bf612..3ec7fb052e6 100644 --- a/media_softlet/agnostic/common/shared/mmc/media_mem_decompression_next.cpp +++ b/media_softlet/agnostic/common/shared/mmc/media_mem_decompression_next.cpp @@ -109,8 +109,16 @@ MOS_STATUS MediaMemDeCompNext::MemoryDecompress(PMOS_RESOURCE targetResource) { VPHAL_MEMORY_DECOMP_CHK_NULL_RETURN(m_renderMutex); MosUtilities::MosLockMutex(m_renderMutex); - VPHAL_MEMORY_DECOMP_CHK_STATUS_RETURN(RenderDecompCMD(&targetSurface)); - MosUtilities::MosUnlockMutex(m_renderMutex); + eStatus = RenderDecompCMD(&targetSurface); + if (eStatus != MOS_STATUS_SUCCESS) + { + MosUtilities::MosUnlockMutex(m_renderMutex); + VPHAL_MEMORY_DECOMP_CHK_STATUS_RETURN(eStatus); + } + else + { + MosUtilities::MosUnlockMutex(m_renderMutex); + } } } }