diff --git a/level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.cpp b/level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.cpp index a377965f61..d97ec5c696 100644 --- a/level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.cpp +++ b/level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.cpp @@ -19,8 +19,6 @@ namespace L0 { const std::string LinuxGlobalOperationsImp::deviceDir("device"); -const std::string LinuxGlobalOperationsImp::vendorFile("device/vendor"); -const std::string LinuxGlobalOperationsImp::deviceFile("device/device"); const std::string LinuxGlobalOperationsImp::subsystemVendorFile("device/subsystem_vendor"); const std::string LinuxGlobalOperationsImp::driverFile("device/driver"); const std::string LinuxGlobalOperationsImp::functionLevelReset("device/reset"); @@ -67,23 +65,17 @@ void LinuxGlobalOperationsImp::getBrandName(char (&brandName)[ZES_STRING_PROPERT } void LinuxGlobalOperationsImp::getModelName(char (&modelName)[ZES_STRING_PROPERTY_SIZE]) { - std::string strVal; - ze_result_t result = pSysfsAccess->read(deviceFile, strVal); - if (ZE_RESULT_SUCCESS != result) { - std::strncpy(modelName, unknown.c_str(), ZES_STRING_PROPERTY_SIZE); - return; - } - std::strncpy(modelName, strVal.c_str(), ZES_STRING_PROPERTY_SIZE); + NEO::Device *neoDevice = pDevice->getNEODevice(); + std::string deviceModelName = neoDevice->getDeviceName(neoDevice->getHardwareInfo()); + std::strncpy(modelName, deviceModelName.c_str(), ZES_STRING_PROPERTY_SIZE); } void LinuxGlobalOperationsImp::getVendorName(char (&vendorName)[ZES_STRING_PROPERTY_SIZE]) { - std::string strVal; - ze_result_t result = pSysfsAccess->read(vendorFile, strVal); - if (ZE_RESULT_SUCCESS != result) { - std::strncpy(vendorName, unknown.c_str(), ZES_STRING_PROPERTY_SIZE); - return; - } - if (strVal.compare(intelPciId) == 0) { + ze_device_properties_t coreDeviceProperties; + pDevice->getProperties(&coreDeviceProperties); + std::stringstream pciId; + pciId << std::hex << coreDeviceProperties.vendorId; + if (("0x" + pciId.str()).compare(intelPciId) == 0) { std::strncpy(vendorName, vendorIntel.c_str(), ZES_STRING_PROPERTY_SIZE); } else { std::strncpy(vendorName, unknown.c_str(), ZES_STRING_PROPERTY_SIZE); diff --git a/level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.h b/level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.h index 7062a1b5a4..b400b7c8b7 100644 --- a/level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.h +++ b/level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.h @@ -43,8 +43,6 @@ class LinuxGlobalOperationsImp : public OsGlobalOperations, NEO::NonCopyableOrMo private: static const std::string deviceDir; - static const std::string vendorFile; - static const std::string deviceFile; static const std::string subsystemVendorFile; static const std::string driverFile; static const std::string functionLevelReset; diff --git a/level_zero/tools/test/unit_tests/sources/sysman/global_operations/linux/mock_global_operations.h b/level_zero/tools/test/unit_tests/sources/sysman/global_operations/linux/mock_global_operations.h index ec2ee088f6..fe83a4480e 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/global_operations/linux/mock_global_operations.h +++ b/level_zero/tools/test/unit_tests/sources/sysman/global_operations/linux/mock_global_operations.h @@ -17,8 +17,6 @@ const std::string vendorIntel("Intel(R) Corporation"); const std::string unknown("unknown"); const std::string intelPciId("0x8086"); const std::string deviceDir("device"); -const std::string vendorFile("device/vendor"); -const std::string deviceFile("device/device"); const std::string subsystemVendorFile("device/subsystem_vendor"); const std::string driverFile("device/driver"); const std::string agamaVersionFile("/sys/module/i915/agama_version"); @@ -69,10 +67,6 @@ struct Mock : public GlobalOperationsSysfsAccess { ze_result_t getValString(const std::string file, std::string &val) { if (file.compare(subsystemVendorFile) == 0) { val = "0x8086"; - } else if (file.compare(deviceFile) == 0) { - val = "0x3ea5"; - } else if (file.compare(vendorFile) == 0) { - val = "0x8086"; } else if (file.compare("clients/8/pid") == 0) { val = bPid4; } else { @@ -84,10 +78,6 @@ struct Mock : public GlobalOperationsSysfsAccess { ze_result_t getFalseValString(const std::string file, std::string &val) { if (file.compare(subsystemVendorFile) == 0) { val = "0xa086"; - } else if (file.compare(deviceFile) == 0) { - val = "0xa123"; - } else if (file.compare(vendorFile) == 0) { - val = "0xa086"; } else { return ZE_RESULT_ERROR_NOT_AVAILABLE; } diff --git a/level_zero/tools/test/unit_tests/sources/sysman/global_operations/linux/test_zes_global_operations.cpp b/level_zero/tools/test/unit_tests/sources/sysman/global_operations/linux/test_zes_global_operations.cpp index 61e7bd5d10..32e2186c98 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/global_operations/linux/test_zes_global_operations.cpp +++ b/level_zero/tools/test/unit_tests/sources/sysman/global_operations/linux/test_zes_global_operations.cpp @@ -38,7 +38,6 @@ constexpr int64_t engines6 = 1u; constexpr int64_t engines7 = 1u; constexpr uint32_t totalProcessStates = 5u; // Three process States for three pids constexpr uint32_t totalProcessStatesForFaultyClients = 3u; -const std::string expectedModelName("0x3ea5"); class SysmanGlobalOperationsFixture : public SysmanDeviceFixture { protected: std::unique_ptr> pSysfsAccess; @@ -50,6 +49,7 @@ class SysmanGlobalOperationsFixture : public SysmanDeviceFixture { OsGlobalOperations *pOsGlobalOperationsPrev = nullptr; L0::GlobalOperations *pGlobalOperationsPrev = nullptr; L0::GlobalOperationsImp *pGlobalOperationsImp; + std::string expectedModelName; void SetUp() override { SysmanDeviceFixture::SetUp(); @@ -74,6 +74,7 @@ class SysmanGlobalOperationsFixture : public SysmanDeviceFixture { pGlobalOperationsImp = static_cast(pSysmanDeviceImp->pGlobalOperations); pOsGlobalOperationsPrev = pGlobalOperationsImp->pOsGlobalOperations; pGlobalOperationsImp->pOsGlobalOperations = nullptr; + expectedModelName = neoDevice->getDeviceName(neoDevice->getHardwareInfo()); pGlobalOperationsImp->init(); } @@ -151,12 +152,12 @@ TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzesDevice EXPECT_TRUE(0 == unknown.compare(properties.driverVersion)); } -TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzesDeviceGetPropertiesForCheckingDevicePropertiesWhenRespectiveFilesAreNotIncorrectThenVerifyzesDeviceGetPropertiesCallSucceeds) { - zes_device_properties_t properties; +TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzesDeviceGetPropertiesForCheckingDevicePropertiesWhenVendorIsUnKnownThenVerifyzesDeviceGetPropertiesCallSucceeds) { ON_CALL(*pSysfsAccess.get(), read(_, Matcher(_))) .WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock::getFalseValString)); + neoDevice->deviceInfo.vendorId = 1806; //Unknown Vendor id pGlobalOperationsImp->init(); - + zes_device_properties_t properties; ze_result_t result = zesDeviceGetProperties(device, &properties); EXPECT_EQ(ZE_RESULT_SUCCESS, result); EXPECT_TRUE(0 == unknown.compare(properties.vendorName));