Skip to content

Commit

Permalink
[Media Common] Optimize PID path reg key read/write for nullhw sw lat…
Browse files Browse the repository at this point in the history
…ency

Optimize sw latency forcodec nullhw test.
  • Loading branch information
LhGu authored and intel-mediadev committed Nov 13, 2024
1 parent 9553d1c commit 788a28d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#define __MEDIA_USER_SETTING_CONFIGURE__H__

#include <string>
#include <set>
#include "media_user_setting_definition.h"
#include "mos_utilities.h"

Expand Down Expand Up @@ -229,6 +230,7 @@ class Configure
std::string m_statedReportPath = "";
#if (_DEBUG || _RELEASE_INTERNAL)
std::string m_pidPath = "";
static std::set<std::string> m_nonPidRegPaths; // Record non-pid reg path which does not have inner pid path
#endif
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ const UFKEY_NEXT Configure::m_rootKey = UFKEY_INTERNAL_NEXT;
const char *Configure::m_configPath = USER_SETTING_CONFIG_PATH;
const char *Configure::m_reportPath = USER_SETTING_REPORT_PATH;

#if (_DEBUG || _RELEASE_INTERNAL)
std::set<std::string> Configure::m_nonPidRegPaths = {};
#endif

Configure::Configure(MOS_USER_FEATURE_KEY_PATH_INFO *keyPathInfo):Configure()
{
m_keyPathInfo = keyPathInfo;
Expand Down Expand Up @@ -134,7 +138,7 @@ MOS_STATUS Configure::Read(Value &value,
uint32_t option)
{
int32_t ret = 0;
MOS_STATUS status = MOS_STATUS_SUCCESS;
MOS_STATUS status = MOS_STATUS_UNKNOWN;
auto &defs = GetDefinitions(group);
auto def = defs[MakeHash(valueName)];
if (def == nullptr)
Expand All @@ -151,17 +155,24 @@ MOS_STATUS Configure::Read(Value &value,
std::string path = GetReadPath(def, option);
#if (_DEBUG || _RELEASE_INTERNAL)
//First, Read pid path user setting. If succeed, return;
std::string pathPidSuffix = path + m_pidPath;
UFKEY_NEXT keyPidSuffix = {};
m_mutexLock.Lock();
status = MosUtilities::MosOpenRegKey(m_rootKey, pathPidSuffix, KEY_READ, &keyPidSuffix, m_regBufferMap);
if (status == MOS_STATUS_SUCCESS)
if (m_nonPidRegPaths.find(path) == m_nonPidRegPaths.end())
{
status = MosUtilities::MosGetRegValue(keyPidSuffix, valueName, defaultType, value, m_regBufferMap);
MosUtilities::MosCloseRegKey(keyPidSuffix);
std::string pathPidSuffix = path + m_pidPath;
UFKEY_NEXT keyPidSuffix = {};
m_mutexLock.Lock();
status = MosUtilities::MosOpenRegKey(m_rootKey, pathPidSuffix, KEY_READ, &keyPidSuffix, m_regBufferMap);
if (status == MOS_STATUS_SUCCESS)
{
status = MosUtilities::MosGetRegValue(keyPidSuffix, valueName, defaultType, value, m_regBufferMap);
MosUtilities::MosCloseRegKey(keyPidSuffix);
}
else
{
// Record the reg path which does not have inner pid reg path.
m_nonPidRegPaths.insert(path);
}
m_mutexLock.Unlock();
}
m_mutexLock.Unlock();

//Second, if reading pid path failed, read non-pid path. If succeed, return;
if (status != MOS_STATUS_SUCCESS)
#endif
Expand Down Expand Up @@ -236,19 +247,27 @@ MOS_STATUS Configure::Write(

MOS_STATUS status = MOS_STATUS_UNKNOWN;
#if (_DEBUG || _RELEASE_INTERNAL)
std::string pathPidSuffix = path + m_pidPath;
UFKEY_NEXT keyPidSuffix = {};
if (m_nonPidRegPaths.find(path) == m_nonPidRegPaths.end())
{
std::string pathPidSuffix = path + m_pidPath;
UFKEY_NEXT keyPidSuffix = {};

m_mutexLock.Lock();
status = MosUtilities::MosOpenRegKey(m_rootKey, pathPidSuffix, KEY_WRITE, &keyPidSuffix, m_regBufferMap);
m_mutexLock.Lock();
status = MosUtilities::MosOpenRegKey(m_rootKey, pathPidSuffix, KEY_WRITE, &keyPidSuffix, m_regBufferMap);

if (status == MOS_STATUS_SUCCESS)
{
status = MosUtilities::MosSetRegValue(keyPidSuffix, valueName, value, m_regBufferMap);
if (status == MOS_STATUS_SUCCESS)
{
status = MosUtilities::MosSetRegValue(keyPidSuffix, valueName, value, m_regBufferMap);

MosUtilities::MosCloseRegKey(keyPidSuffix);
MosUtilities::MosCloseRegKey(keyPidSuffix);
}
else
{
// Record the reg path which does not have inner pid reg path.
m_nonPidRegPaths.insert(path);
}
m_mutexLock.Unlock();
}
m_mutexLock.Unlock();

if (status != MOS_STATUS_SUCCESS)
#endif
Expand Down

0 comments on commit 788a28d

Please sign in to comment.