summaryrefslogtreecommitdiffstats
path: root/recipes-multimedia/libva/files/0001-Media-Common-Fix-the-user-setting-memory-free.patch
blob: e513e0aaab9a79e320a58bc7cc09828cb2d1fcda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
From 437e63b6c35eb5d12aac18d7f76ce1a702ad16e0 Mon Sep 17 00:00:00 2001
From: Lim Siew Hoon <siew.hoon.lim@intel.com>
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" <pingli.wang@intel.com>
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 <pingli.wang@intel.com>

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 <siew.hoon.lim@intel.com>
---
 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<std::string, std::map<std::string, std::string>> 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<std::string, std::map<std::string, std::string>> m_regBuffer;
+private:
+    static MosMutex             m_userSettingMutex;
 };
 #endif // __MOS_UTILITIES_SPECIFIC_NEXT_H__
-- 
2.31.1