Skip to content

Commit 3597093

Browse files
Update Temperature APIs to get correct temperature
This change updates Temperature APIs to get correct current temperature based on updated PMT interface. Signed-off-by: Jitendra Sharma <[email protected]>
1 parent a6d898a commit 3597093

37 files changed

+981
-541
lines changed

level_zero/tools/source/sysman/fan/linux/os_fan_imp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*
2-
* Copyright (C) 2020 Intel Corporation
2+
* Copyright (C) 2020-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
66
*/
77

88
#include "level_zero/tools/source/sysman/fan/linux/os_fan_imp.h"
99

10-
#include "level_zero/tools/source/sysman/linux/pmt.h"
10+
#include "level_zero/tools/source/sysman/linux/pmt/pmt.h"
1111

1212
#include "sysman/linux/os_sysman_imp.h"
1313

level_zero/tools/source/sysman/linux/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (C) 2019-2020 Intel Corporation
2+
# Copyright (C) 2019-2021 Intel Corporation
33
#
44
# SPDX-License-Identifier: MIT
55
#
@@ -9,8 +9,6 @@ set(L0_SRCS_TOOLS_SYSMAN_LINUX
99
${CMAKE_CURRENT_SOURCE_DIR}/os_sysman_imp.h
1010
${CMAKE_CURRENT_SOURCE_DIR}/os_sysman_imp.cpp
1111
${CMAKE_CURRENT_SOURCE_DIR}/fs_access.cpp
12-
${CMAKE_CURRENT_SOURCE_DIR}/pmt.cpp
13-
${CMAKE_CURRENT_SOURCE_DIR}/pmt.h
1412
)
1513

1614
if(UNIX)

level_zero/tools/source/sysman/linux/os_sysman_imp.cpp

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 Intel Corporation
2+
* Copyright (C) 2019-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -34,9 +34,14 @@ ze_result_t LinuxSysmanImp::init() {
3434
pSysfsAccess = SysfsAccess::create(myDeviceName);
3535
UNRECOVERABLE_IF(nullptr == pSysfsAccess);
3636

37-
pPmt = new PlatformMonitoringTech();
38-
UNRECOVERABLE_IF(nullptr == pPmt);
39-
pPmt->init(myDeviceName, pFsAccess);
37+
std::string realRootPath;
38+
result = pSysfsAccess->getRealPath("device", realRootPath);
39+
if (ZE_RESULT_SUCCESS != result) {
40+
return result;
41+
}
42+
auto rootPciPathOfGpuDevice = getPciRootPortDirectoryPath(realRootPath);
43+
PlatformMonitoringTech::create(pParentSysmanDeviceImp->deviceHandles, pFsAccess, rootPciPathOfGpuDevice, mapOfSubDeviceIdToPmtObject);
44+
4045
pPmuInterface = PmuInterface::create(this);
4146
UNRECOVERABLE_IF(nullptr == pPmuInterface);
4247

@@ -83,9 +88,29 @@ SysmanDeviceImp *LinuxSysmanImp::getSysmanDeviceImp() {
8388
return pParentSysmanDeviceImp;
8489
}
8590

86-
PlatformMonitoringTech &LinuxSysmanImp::getPlatformMonitoringTechAccess() {
87-
UNRECOVERABLE_IF(nullptr == pPmt);
88-
return *pPmt;
91+
std::string LinuxSysmanImp::getPciRootPortDirectoryPath(std::string realPciPath) {
92+
size_t loc;
93+
// we need to change the absolute path to two levels up to get
94+
// the Discrete card's root port.
95+
// the root port is always at a fixed distance as defined in HW
96+
uint8_t nLevel = 2;
97+
while (nLevel > 0) {
98+
loc = realPciPath.find_last_of('/');
99+
if (loc == std::string::npos) {
100+
break;
101+
}
102+
realPciPath = realPciPath.substr(0, loc);
103+
nLevel--;
104+
}
105+
return realPciPath;
106+
}
107+
108+
PlatformMonitoringTech *LinuxSysmanImp::getPlatformMonitoringTechAccess(uint32_t subDeviceId) {
109+
auto subDeviceIdToPmtEntry = mapOfSubDeviceIdToPmtObject.find(subDeviceId);
110+
if (subDeviceIdToPmtEntry == mapOfSubDeviceIdToPmtObject.end()) {
111+
return nullptr;
112+
}
113+
return subDeviceIdToPmtEntry->second;
89114
}
90115

91116
LinuxSysmanImp::LinuxSysmanImp(SysmanDeviceImp *pParentSysmanDeviceImp) {
@@ -113,14 +138,13 @@ LinuxSysmanImp::~LinuxSysmanImp() {
113138
delete pFwUtilInterface;
114139
pFwUtilInterface = nullptr;
115140
}
116-
if (nullptr != pPmt) {
117-
delete pPmt;
118-
pPmt = nullptr;
119-
}
120141
if (nullptr != pPmuInterface) {
121142
delete pPmuInterface;
122143
pPmuInterface = nullptr;
123144
}
145+
for (auto &subDeviceIdToPmtEntry : mapOfSubDeviceIdToPmtObject) {
146+
delete subDeviceIdToPmtEntry.second;
147+
}
124148
}
125149

126150
OsSysman *OsSysman::create(SysmanDeviceImp *pParentSysmanDeviceImp) {

level_zero/tools/source/sysman/linux/os_sysman_imp.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 Intel Corporation
2+
* Copyright (C) 2019-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -13,11 +13,13 @@
1313
#include "level_zero/core/source/device/device.h"
1414
#include "level_zero/tools/source/sysman/linux/firmware_util/firmware_util.h"
1515
#include "level_zero/tools/source/sysman/linux/fs_access.h"
16-
#include "level_zero/tools/source/sysman/linux/pmt.h"
16+
#include "level_zero/tools/source/sysman/linux/pmt/pmt.h"
1717
#include "level_zero/tools/source/sysman/linux/pmu/pmu_imp.h"
1818
#include "level_zero/tools/source/sysman/linux/xml_parser/xml_parser.h"
1919
#include "level_zero/tools/source/sysman/sysman_imp.h"
2020

21+
#include <map>
22+
2123
namespace L0 {
2224
class PmuInterface;
2325

@@ -35,20 +37,21 @@ class LinuxSysmanImp : public OsSysman, NEO::NonCopyableOrMovableClass {
3537
ProcfsAccess &getProcfsAccess();
3638
SysfsAccess &getSysfsAccess();
3739
NEO::Drm &getDrm();
38-
PlatformMonitoringTech &getPlatformMonitoringTechAccess();
40+
PlatformMonitoringTech *getPlatformMonitoringTechAccess(uint32_t subDeviceId);
3941
Device *getDeviceHandle();
4042
SysmanDeviceImp *getSysmanDeviceImp();
43+
std::string getPciRootPortDirectoryPath(std::string realPciPath);
4144

4245
protected:
4346
XmlParser *pXmlParser = nullptr;
4447
FsAccess *pFsAccess = nullptr;
4548
ProcfsAccess *pProcfsAccess = nullptr;
4649
SysfsAccess *pSysfsAccess = nullptr;
47-
PlatformMonitoringTech *pPmt = nullptr;
4850
NEO::Drm *pDrm = nullptr;
4951
Device *pDevice = nullptr;
5052
PmuInterface *pPmuInterface = nullptr;
5153
FirmwareUtil *pFwUtilInterface = nullptr;
54+
std::map<uint32_t, L0::PlatformMonitoringTech *> mapOfSubDeviceIdToPmtObject;
5255

5356
private:
5457
LinuxSysmanImp() = delete;

level_zero/tools/source/sysman/linux/pmt.cpp

Lines changed: 0 additions & 89 deletions
This file was deleted.

level_zero/tools/source/sysman/linux/pmt.h

Lines changed: 0 additions & 57 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#
2+
# Copyright (C) 2020-2021 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: MIT
5+
#
6+
7+
set(L0_SRCS_TOOLS_SYSMAN_LINUX_PMT
8+
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/pmt.cpp
9+
${CMAKE_CURRENT_SOURCE_DIR}/pmt.h
10+
)
11+
if(UNIX)
12+
target_sources(${L0_STATIC_LIB_NAME}
13+
PRIVATE
14+
${L0_SRCS_TOOLS_SYSMAN_LINUX_PMT}
15+
)
16+
endif()
17+
# Make our source files visible to parent
18+
set_property(GLOBAL PROPERTY L0_SRCS_TOOLS_SYSMAN_PMT_LINUX ${L0_SRCS_TOOLS_SYSMAN_PMT_LINUX})

0 commit comments

Comments
 (0)