From e3cbfcbf825d9d3087c5987fb029fc51b96e25dc Mon Sep 17 00:00:00 2001 From: Chen_Ke Date: Fri, 13 Oct 2023 13:46:43 +0800 Subject: [PATCH] [VP] Fix cm rt leak Fix cm rt leak whhen destroy cm device --- media_driver/agnostic/common/cm/cm_hal.h | 10 ++++++++++ media_driver/agnostic/common/cm/cm_queue_rt.cpp | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/media_driver/agnostic/common/cm/cm_hal.h b/media_driver/agnostic/common/cm/cm_hal.h index 50b8ee45ce4..f97574ff507 100644 --- a/media_driver/agnostic/common/cm/cm_hal.h +++ b/media_driver/agnostic/common/cm/cm_hal.h @@ -1964,6 +1964,12 @@ typedef struct _CM_HAL_STATE uint64_t kernelId); uint32_t (*pfnRegisterStream) (PCM_HAL_STATE state); + + void(*pfnUnRegisterStream) + ( + uint32_t streamIndex, + PCM_HAL_STATE state); + } CM_HAL_STATE, *PCM_HAL_STATE; typedef struct _CM_HAL_MI_REG_OFFSETS @@ -2108,6 +2114,10 @@ MOS_STATUS HalCm_GetGpuTime( uint32_t HalCm_RegisterStream( PCM_HAL_STATE state); +void HalCm_UnRegisterStream( + uint32_t streamIndex, + PCM_HAL_STATE state); + MOS_STATUS HalCm_GetSipBinary( PCM_HAL_STATE state); diff --git a/media_driver/agnostic/common/cm/cm_queue_rt.cpp b/media_driver/agnostic/common/cm/cm_queue_rt.cpp index d190c647b37..50a7cdbecc5 100644 --- a/media_driver/agnostic/common/cm/cm_queue_rt.cpp +++ b/media_driver/agnostic/common/cm/cm_queue_rt.cpp @@ -121,6 +121,13 @@ int32_t CmQueueRT::Destroy(CmQueueRT* &queue ) queue->DestroyComputeGpuContext(); + PCM_HAL_STATE cmHalState = ((PCM_CONTEXT_DATA)queue->m_device->GetAccelData())->cmHalState; + CM_CHK_NULL_RETURN_CMERROR(cmHalState); + if (cmHalState->pfnUnRegisterStream != nullptr && queue->m_streamIndex != cmHalState->osInterface->streamIndex) + { + cmHalState->pfnUnRegisterStream(queue->m_streamIndex, cmHalState); + } + CmSafeDelete( queue ); return result;