Skip to content

Commit 17565be

Browse files
Retrieve model name and vendor name for sysman zesDeviceGetProperties
Signed-off-by: Mayank Raghuwanshi <[email protected]>
1 parent ede866c commit 17565be

File tree

4 files changed

+13
-32
lines changed

4 files changed

+13
-32
lines changed

level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.cpp

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
namespace L0 {
2020

2121
const std::string LinuxGlobalOperationsImp::deviceDir("device");
22-
const std::string LinuxGlobalOperationsImp::vendorFile("device/vendor");
23-
const std::string LinuxGlobalOperationsImp::deviceFile("device/device");
2422
const std::string LinuxGlobalOperationsImp::subsystemVendorFile("device/subsystem_vendor");
2523
const std::string LinuxGlobalOperationsImp::driverFile("device/driver");
2624
const std::string LinuxGlobalOperationsImp::functionLevelReset("device/reset");
@@ -67,23 +65,17 @@ void LinuxGlobalOperationsImp::getBrandName(char (&brandName)[ZES_STRING_PROPERT
6765
}
6866

6967
void LinuxGlobalOperationsImp::getModelName(char (&modelName)[ZES_STRING_PROPERTY_SIZE]) {
70-
std::string strVal;
71-
ze_result_t result = pSysfsAccess->read(deviceFile, strVal);
72-
if (ZE_RESULT_SUCCESS != result) {
73-
std::strncpy(modelName, unknown.c_str(), ZES_STRING_PROPERTY_SIZE);
74-
return;
75-
}
76-
std::strncpy(modelName, strVal.c_str(), ZES_STRING_PROPERTY_SIZE);
68+
NEO::Device *neoDevice = pDevice->getNEODevice();
69+
std::string deviceModelName = neoDevice->getDeviceName(neoDevice->getHardwareInfo());
70+
std::strncpy(modelName, deviceModelName.c_str(), ZES_STRING_PROPERTY_SIZE);
7771
}
7872

7973
void LinuxGlobalOperationsImp::getVendorName(char (&vendorName)[ZES_STRING_PROPERTY_SIZE]) {
80-
std::string strVal;
81-
ze_result_t result = pSysfsAccess->read(vendorFile, strVal);
82-
if (ZE_RESULT_SUCCESS != result) {
83-
std::strncpy(vendorName, unknown.c_str(), ZES_STRING_PROPERTY_SIZE);
84-
return;
85-
}
86-
if (strVal.compare(intelPciId) == 0) {
74+
ze_device_properties_t coreDeviceProperties;
75+
pDevice->getProperties(&coreDeviceProperties);
76+
std::stringstream pciId;
77+
pciId << std::hex << coreDeviceProperties.vendorId;
78+
if (("0x" + pciId.str()).compare(intelPciId) == 0) {
8779
std::strncpy(vendorName, vendorIntel.c_str(), ZES_STRING_PROPERTY_SIZE);
8880
} else {
8981
std::strncpy(vendorName, unknown.c_str(), ZES_STRING_PROPERTY_SIZE);

level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ class LinuxGlobalOperationsImp : public OsGlobalOperations, NEO::NonCopyableOrMo
4343

4444
private:
4545
static const std::string deviceDir;
46-
static const std::string vendorFile;
47-
static const std::string deviceFile;
4846
static const std::string subsystemVendorFile;
4947
static const std::string driverFile;
5048
static const std::string functionLevelReset;

level_zero/tools/test/unit_tests/sources/sysman/global_operations/linux/mock_global_operations.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ const std::string vendorIntel("Intel(R) Corporation");
1717
const std::string unknown("unknown");
1818
const std::string intelPciId("0x8086");
1919
const std::string deviceDir("device");
20-
const std::string vendorFile("device/vendor");
21-
const std::string deviceFile("device/device");
2220
const std::string subsystemVendorFile("device/subsystem_vendor");
2321
const std::string driverFile("device/driver");
2422
const std::string agamaVersionFile("/sys/module/i915/agama_version");
@@ -69,10 +67,6 @@ struct Mock<GlobalOperationsSysfsAccess> : public GlobalOperationsSysfsAccess {
6967
ze_result_t getValString(const std::string file, std::string &val) {
7068
if (file.compare(subsystemVendorFile) == 0) {
7169
val = "0x8086";
72-
} else if (file.compare(deviceFile) == 0) {
73-
val = "0x3ea5";
74-
} else if (file.compare(vendorFile) == 0) {
75-
val = "0x8086";
7670
} else if (file.compare("clients/8/pid") == 0) {
7771
val = bPid4;
7872
} else {
@@ -84,10 +78,6 @@ struct Mock<GlobalOperationsSysfsAccess> : public GlobalOperationsSysfsAccess {
8478
ze_result_t getFalseValString(const std::string file, std::string &val) {
8579
if (file.compare(subsystemVendorFile) == 0) {
8680
val = "0xa086";
87-
} else if (file.compare(deviceFile) == 0) {
88-
val = "0xa123";
89-
} else if (file.compare(vendorFile) == 0) {
90-
val = "0xa086";
9181
} else {
9282
return ZE_RESULT_ERROR_NOT_AVAILABLE;
9383
}

level_zero/tools/test/unit_tests/sources/sysman/global_operations/linux/test_zes_global_operations.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ constexpr int64_t engines6 = 1u;
3838
constexpr int64_t engines7 = 1u;
3939
constexpr uint32_t totalProcessStates = 5u; // Three process States for three pids
4040
constexpr uint32_t totalProcessStatesForFaultyClients = 3u;
41-
const std::string expectedModelName("0x3ea5");
4241
class SysmanGlobalOperationsFixture : public SysmanDeviceFixture {
4342
protected:
4443
std::unique_ptr<Mock<GlobalOperationsSysfsAccess>> pSysfsAccess;
@@ -50,6 +49,7 @@ class SysmanGlobalOperationsFixture : public SysmanDeviceFixture {
5049
OsGlobalOperations *pOsGlobalOperationsPrev = nullptr;
5150
L0::GlobalOperations *pGlobalOperationsPrev = nullptr;
5251
L0::GlobalOperationsImp *pGlobalOperationsImp;
52+
std::string expectedModelName;
5353

5454
void SetUp() override {
5555
SysmanDeviceFixture::SetUp();
@@ -74,6 +74,7 @@ class SysmanGlobalOperationsFixture : public SysmanDeviceFixture {
7474
pGlobalOperationsImp = static_cast<L0::GlobalOperationsImp *>(pSysmanDeviceImp->pGlobalOperations);
7575
pOsGlobalOperationsPrev = pGlobalOperationsImp->pOsGlobalOperations;
7676
pGlobalOperationsImp->pOsGlobalOperations = nullptr;
77+
expectedModelName = neoDevice->getDeviceName(neoDevice->getHardwareInfo());
7778
pGlobalOperationsImp->init();
7879
}
7980

@@ -151,12 +152,12 @@ TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzesDevice
151152
EXPECT_TRUE(0 == unknown.compare(properties.driverVersion));
152153
}
153154

154-
TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzesDeviceGetPropertiesForCheckingDevicePropertiesWhenRespectiveFilesAreNotIncorrectThenVerifyzesDeviceGetPropertiesCallSucceeds) {
155-
zes_device_properties_t properties;
155+
TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzesDeviceGetPropertiesForCheckingDevicePropertiesWhenVendorIsUnKnownThenVerifyzesDeviceGetPropertiesCallSucceeds) {
156156
ON_CALL(*pSysfsAccess.get(), read(_, Matcher<std::string &>(_)))
157157
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<GlobalOperationsSysfsAccess>::getFalseValString));
158+
neoDevice->deviceInfo.vendorId = 1806; //Unknown Vendor id
158159
pGlobalOperationsImp->init();
159-
160+
zes_device_properties_t properties;
160161
ze_result_t result = zesDeviceGetProperties(device, &properties);
161162
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
162163
EXPECT_TRUE(0 == unknown.compare(properties.vendorName));

0 commit comments

Comments
 (0)