Skip to content

Commit

Permalink
[Media Common] [VP] fix ocartlogmgr destroy reentry
Browse files Browse the repository at this point in the history
fix ocartlogmgr destroy reentry!
  • Loading branch information
Dylan-debug authored and intel-mediadev committed Aug 30, 2023
1 parent 0738e88 commit 26e0436
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 14 deletions.
22 changes: 14 additions & 8 deletions media_softlet/agnostic/common/os/mos_oca_rtlog_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ MosOcaRTLogMgr::~MosOcaRTLogMgr()
{
m_globleIndex = -1;
m_isMgrInitialized = false;
s_isOcaRtlogMgrDestoryed = true;
}


Expand All @@ -156,24 +157,24 @@ MosOcaRTLogMgr& MosOcaRTLogMgr::operator= (MosOcaRTLogMgr&)
return *this;
}

MosOcaRTLogMgr &MosOcaRTLogMgr::GetInstance()
MosOcaRTLogMgr *MosOcaRTLogMgr::GetInstance()
{
static MosOcaRTLogMgr mgr;
return mgr;
return &mgr;
}

void MosOcaRTLogMgr::RegisterContext(OsContextNext *osDriverContext, MOS_CONTEXT *osContext)
{
if (!m_enableOcaRTLog)
if (!s_enableOcaRTLog)
{
return;
}
if (!osContext)
{
return;
}
MosOcaRTLogMgr &ocaRTLogMgr = GetInstance();
MOS_STATUS status = ocaRTLogMgr.RegisterCtx(osDriverContext, osContext);
MosOcaRTLogMgr *ocaRTLogMgr = GetInstance();
MOS_STATUS status = ocaRTLogMgr->RegisterCtx(osDriverContext, osContext);
if (status != MOS_STATUS_SUCCESS)
{
MOS_OS_NORMALMESSAGE("MosOcaRTLogMgr RegisterContext failed!");
Expand All @@ -182,12 +183,17 @@ void MosOcaRTLogMgr::RegisterContext(OsContextNext *osDriverContext, MOS_CONTEXT

void MosOcaRTLogMgr::UnRegisterContext(OsContextNext *osDriverContext)
{
if (!m_enableOcaRTLog)
if (!s_enableOcaRTLog)
{
return;
}
MosOcaRTLogMgr &ocaRTLogMgr = GetInstance();
MOS_STATUS status = ocaRTLogMgr.UnRegisterCtx(osDriverContext);
if (s_isOcaRtlogMgrDestoryed)
{
MOS_OS_NORMALMESSAGE("MosOcaRTLogMgr have be destroyed!");
return;
}
MosOcaRTLogMgr *ocaRTLogMgr = GetInstance();
MOS_STATUS status = ocaRTLogMgr->UnRegisterCtx(osDriverContext);
if (status != MOS_STATUS_SUCCESS)
{
MOS_OS_NORMALMESSAGE("MosOcaRTLogMgr UnRegisterContext failed!");
Expand Down
2 changes: 1 addition & 1 deletion media_softlet/agnostic/common/os/mos_oca_rtlog_mgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class MosOcaRTLogMgr : public MosOcaRTLogMgrBase
MosOcaRTLogMgr(MosOcaRTLogMgr &);
virtual ~MosOcaRTLogMgr();
MosOcaRTLogMgr &operator=(MosOcaRTLogMgr &);
static MosOcaRTLogMgr &GetInstance();
static MosOcaRTLogMgr *GetInstance();

protected:
virtual MOS_STATUS RegisterCtx(OsContextNext *osDriverContext, MOS_CONTEXT *osContext);
Expand Down
3 changes: 2 additions & 1 deletion media_softlet/agnostic/common/os/mos_oca_rtlog_mgr_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
#include "oca_rtlog_section_mgr.h"
#include "mos_context_specific_next.h"

bool MosOcaRTLogMgrBase::m_enableOcaRTLog = true;
bool MosOcaRTLogMgrBase::s_enableOcaRTLog = true;
MosMutex MosOcaRTLogMgrBase::s_ocaMutex;
bool MosOcaRTLogMgrBase::s_isOcaRtlogMgrDestoryed = false;

/****************************************************************************************************/
/* MosOcaRTLogMgrBase */
Expand Down
5 changes: 3 additions & 2 deletions media_softlet/agnostic/common/os/mos_oca_rtlog_mgr_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class MosOcaRTLogMgrBase

uint32_t GetRtlogHeapSize() { return m_heapSize; };

static bool IsOcaRTLogEnabled() { return m_enableOcaRTLog; };
static bool IsOcaRTLogEnabled() { return s_enableOcaRTLog; };

protected:
int32_t GetGlobleIndex();
Expand All @@ -64,8 +64,9 @@ class MosOcaRTLogMgrBase
uint32_t m_heapSize = MAX_OCA_RT_SIZE;
uint8_t *m_heapAddr = nullptr;

static bool m_enableOcaRTLog;
static bool s_enableOcaRTLog;
static MosMutex s_ocaMutex;
static bool s_isOcaRtlogMgrDestoryed;

MEDIA_CLASS_DEFINE_END(MosOcaRTLogMgrBase)
};
Expand Down
5 changes: 3 additions & 2 deletions media_softlet/linux/common/os/mos_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3813,12 +3813,13 @@ void MosInterface::GetRtLogResourceInfo(
size = 0;
if (osInterface->osStreamState && osInterface->osStreamState->osDeviceContext)
{
MosOcaRTLogMgr &ocaRTLogMgr = MosOcaRTLogMgr::GetInstance();
MosOcaRTLogMgr *ocaRTLogMgr = MosOcaRTLogMgr::GetInstance();
MOS_OS_CHK_NULL_NO_STATUS_RETURN(ocaRTLogMgr);
GpuContextSpecificNext *gpuContext = dynamic_cast<GpuContextSpecificNext*>(osInterface->osStreamState->osDeviceContext->GetGpuContextMgr()->GetGpuContext(osInterface->osStreamState->currentGpuContextHandle));
if (gpuContext != nullptr)
{
osResource = gpuContext->GetOcaRTLogResource(osInterface->osStreamState->osDeviceContext->GetOcaRTLogResource());
size = ocaRTLogMgr.GetRtlogHeapSize();
size = ocaRTLogMgr->GetRtlogHeapSize();
}
}
}
Expand Down

0 comments on commit 26e0436

Please sign in to comment.