Skip to content

Commit 5f41e00

Browse files
In PMT telem directory ignore entry whose suffix is not "telem"
Signed-off-by: Jitendra Sharma <[email protected]>
1 parent a2a3dae commit 5f41e00

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ ze_result_t PlatformMonitoringTech::enumerateRootTelemIndex(FsAccess *pFsAccess,
6262
return result;
6363
}
6464

65+
// listOfTelemNodes vector could contain non "telem" entries which are not interested to us.
66+
// Lets refactor listOfTelemNodes vector as below
67+
for (auto iterator = listOfTelemNodes.begin(); iterator != listOfTelemNodes.end(); iterator++) {
68+
if (iterator->compare(0, telem.size(), telem) != 0) {
69+
listOfTelemNodes.erase(iterator--); // Remove entry if its suffix is not "telem"
70+
}
71+
}
72+
6573
// Exmaple: For below directory
6674
// # /sys/class/intel_pmt$ ls
6775
// telem1 telem2 telem3
@@ -73,12 +81,13 @@ ze_result_t PlatformMonitoringTech::enumerateRootTelemIndex(FsAccess *pFsAccess,
7381
if (result != ZE_RESULT_SUCCESS) {
7482
return result;
7583
}
84+
7685
// Check if Telemetry node(say telem1) and rootPciPathOfGpuDevice share same PCI Root port
86+
// Example: If
87+
// rootPciPathOfGpuDevice = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0";
88+
// realPathOfTelemNode = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0/0000:8b:02.0/0000:8e:00.1/pmt_telemetry.1.auto/intel_pmt/telem1";
89+
// Thus As realPathOfTelemNode consists of rootPciPathOfGpuDevice, hence both telemNode and GPU device share same PCI Root.
7790
if (realPathOfTelemNode.compare(0, rootPciPathOfGpuDevice.size(), rootPciPathOfGpuDevice) == 0) {
78-
// Example: If
79-
// rootPciPathOfGpuDevice = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0";
80-
// realPathOfTelemNode = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0/0000:8b:02.0/0000:8e:00.1/pmt_telemetry.1.auto/intel_pmt/telem1";
81-
// Thus As realPathOfTelemNode consists of rootPciPathOfGpuDevice, hence both telemNode and GPU device share same PCI Root.
8291
auto indexString = telemNode.substr(telem.size(), telemNode.size());
8392
rootDeviceTelemNodeIndex = stoi(indexString); // if telemNode is telemN, then rootDeviceTelemNodeIndex = N
8493
return ZE_RESULT_SUCCESS;

level_zero/tools/test/unit_tests/sources/sysman/linux/pmt/mock_pmt.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,27 @@ struct Mock<PmtFsAccess> : public PmtFsAccess {
9292

9393
ze_result_t listDirectorySuccess(const std::string directory, std::vector<std::string> &listOfTelemNodes) {
9494
if (directory.compare(baseTelemSysFS) == 0) {
95-
listOfTelemNodes.push_back("telem1");
96-
listOfTelemNodes.push_back("telem2");
95+
listOfTelemNodes.push_back("crashlog2");
96+
listOfTelemNodes.push_back("crashlog1");
9797
listOfTelemNodes.push_back("telem3");
98+
listOfTelemNodes.push_back("telem2");
99+
listOfTelemNodes.push_back("telem1");
98100
listOfTelemNodes.push_back("telem4");
99101
listOfTelemNodes.push_back("telem5");
100102
return ZE_RESULT_SUCCESS;
101103
}
102104
return ZE_RESULT_ERROR_NOT_AVAILABLE;
103105
}
104106

107+
ze_result_t listDirectoryNoTelemNode(const std::string directory, std::vector<std::string> &listOfTelemNodes) {
108+
if (directory.compare(baseTelemSysFS) == 0) {
109+
listOfTelemNodes.push_back("crashlog2");
110+
listOfTelemNodes.push_back("crashlog1");
111+
return ZE_RESULT_SUCCESS;
112+
}
113+
return ZE_RESULT_ERROR_NOT_AVAILABLE;
114+
}
115+
105116
MOCK_METHOD(ze_result_t, read, (const std::string file, std::string &val), (override));
106117
MOCK_METHOD(ze_result_t, read, (const std::string file, uint64_t &val), (override));
107118
MOCK_METHOD(ze_result_t, getRealPath, (const std::string path, std::string &buf), (override));

level_zero/tools/test/unit_tests/sources/sysman/linux/pmt/test_pmt.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ TEST_F(ZesPmtFixtureMultiDevice, GivenWhenenumerateRootTelemIndexThenCheckForErr
7474
EXPECT_EQ(ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE, PlatformMonitoringTech::enumerateRootTelemIndex(pTestFsAccess.get(), rootPciPathOfGpuDeviceInPmt));
7575
}
7676

77+
TEST_F(ZesPmtFixtureMultiDevice, GivenTelemDirectoryContainNowTelemEntryWhenenumerateRootTelemIndexThenCheckForError) {
78+
ON_CALL(*pTestFsAccess.get(), listDirectory(_, _))
79+
.WillByDefault(::testing::Invoke(pTestFsAccess.get(), &Mock<PmtFsAccess>::listDirectoryNoTelemNode));
80+
EXPECT_EQ(ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE, PlatformMonitoringTech::enumerateRootTelemIndex(pTestFsAccess.get(), rootPciPathOfGpuDeviceInPmt));
81+
}
82+
7783
TEST_F(ZesPmtFixtureMultiDevice, GivenValidDeviceHandlesWhenCreatingPMTHandlesThenCheckForErrorThatCouldHappenDuringGUIDRead) {
7884
EXPECT_CALL(*pTestFsAccess.get(), read(_, Matcher<std::string &>(_)))
7985
.WillOnce(Return(ZE_RESULT_ERROR_NOT_AVAILABLE));

0 commit comments

Comments
 (0)