From 437e63b6c35eb5d12aac18d7f76ce1a702ad16e0 Mon Sep 17 00:00:00 2001 From: Lim Siew Hoon Date: Thu, 2 Dec 2021 15:50:33 +0000 Subject: [PATCH] [Media Common] Fix the user setting memory free From 4b8a411f2b8df112cbb5dbf8562735700cd15cf1 Mon Sep 17 00:00:00 2001 From: "Wang, Pingli" Date: Thu, 2 Dec 2021 17:57:50 +0800 Subject: [PATCH] [Media Common]Fix the user setting memory free This commit fix the #1300 Signed-off-by: Wang, Pingli This patch was imported from iHD media-driver git server (https://github.com/intel/media-driver.git) as of pull request https://github.com/intel/media-driver/pull/1305. Upstream-status: Submitted Signed-off-by: Lim Siew Hoon --- media_softlet/linux/common/os/mos_utilities_specific_next.cpp | 4 ++++ media_softlet/linux/common/os/mos_utilities_specific_next.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/media_softlet/linux/common/os/mos_utilities_specific_next.cpp b/media_softlet/linux/common/os/mos_utilities_specific_next.cpp index 584ba086..c138cb08 100644 --- a/media_softlet/linux/common/os/mos_utilities_specific_next.cpp +++ b/media_softlet/linux/common/os/mos_utilities_specific_next.cpp @@ -70,6 +70,7 @@ double MosUtilities::MosGetTime() //! const char *const MosUtilitiesSpecificNext::m_mosTracePath = "/sys/kernel/debug/tracing/trace_marker_raw"; int32_t MosUtilitiesSpecificNext::m_mosTraceFd = -1; +MosMutex MosUtilitiesSpecificNext::m_userSettingMutex; std::map> MosUtilitiesSpecificNext::m_regBuffer; @@ -612,6 +613,7 @@ MOS_STATUS MosUtilitiesSpecificNext::UserFeatureSet(MOS_PUF_KEYLIST *pKeyList, M MOS_AtomicIncrement(&MosUtilities::m_mosMemAllocFakeCounter); //ulValueBuf does not count it, because it is freed after the MEMNJA final report. MOS_OS_NORMALMESSAGE("ulValueBuf %p for key %s", ulValueBuf, NewKey.pValueArray[0].pcValueName); + m_userSettingMutex.Lock(); if ( (iPos = UserFeatureFindValue(*Key, NewKey.pValueArray[0].pcValueName)) == NOT_FOUND) { //not found, add a new value to key struct. @@ -620,6 +622,7 @@ MOS_STATUS MosUtilitiesSpecificNext::UserFeatureSet(MOS_PUF_KEYLIST *pKeyList, M if (iPos >= UF_CAPABILITY) { MOS_OS_ASSERTMESSAGE("user setting value icount %d must less than UF_CAPABILITY(64)", iPos); + m_userSettingMutex.Unlock(); return MOS_STATUS_USER_FEATURE_KEY_READ_FAILED; } @@ -646,6 +649,7 @@ MOS_STATUS MosUtilitiesSpecificNext::UserFeatureSet(MOS_PUF_KEYLIST *pKeyList, M NewKey.pValueArray[0].ulValueBuf, NewKey.pValueArray[0].ulValueLen); + m_userSettingMutex.Unlock(); return MOS_STATUS_SUCCESS; } diff --git a/media_softlet/linux/common/os/mos_utilities_specific_next.h b/media_softlet/linux/common/os/mos_utilities_specific_next.h index 878ce4e6..57e505d0 100644 --- a/media_softlet/linux/common/os/mos_utilities_specific_next.h +++ b/media_softlet/linux/common/os/mos_utilities_specific_next.h @@ -30,6 +30,8 @@ #include "mos_defs.h" #include "mos_utilities_specific.h" +class MosMutex; + class MosUtilitiesSpecificNext { public: @@ -294,5 +296,7 @@ public: static int32_t m_mosTraceFd; static const char* const m_mosTracePath; static std::map> m_regBuffer; +private: + static MosMutex m_userSettingMutex; }; #endif // __MOS_UTILITIES_SPECIFIC_NEXT_H__ -- 2.31.1