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 691c94b24d..71a7520047 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 @@ -121,7 +121,6 @@ ze_result_t LinuxGlobalOperationsImp::reset(ze_bool_t force) { result = pProcfsAccess->listProcesses(processes); if (ZE_RESULT_SUCCESS != result) { - return result; } for (auto &&pid : processes) { @@ -137,7 +136,6 @@ ze_result_t LinuxGlobalOperationsImp::reset(ze_bool_t force) { } else { // Device is in use by another process. // Don't reset while in use. - return ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE; } } @@ -149,14 +147,12 @@ ze_result_t LinuxGlobalOperationsImp::reset(ze_bool_t force) { if (!(deviceProperties.flags & ZE_DEVICE_PROPERTY_FLAG_INTEGRATED)) { result = pSysfsAccess->unbindDevice(resetName); if (ZE_RESULT_SUCCESS != result) { - return result; } result = pLinuxSysmanImp->osWarmReset(); if (ZE_RESULT_SUCCESS == result) { return pLinuxSysmanImp->initDevice(); } - return result; } @@ -175,7 +171,6 @@ ze_result_t LinuxGlobalOperationsImp::reset(ze_bool_t force) { // Unbind the device from the kernel driver. result = pSysfsAccess->unbindDevice(resetName); if (ZE_RESULT_SUCCESS != result) { - return result; } @@ -183,7 +178,6 @@ ze_result_t LinuxGlobalOperationsImp::reset(ze_bool_t force) { // after we check, kill them here. result = pProcfsAccess->listProcesses(processes); if (ZE_RESULT_SUCCESS != result) { - return result; } std::vector<::pid_t> deviceUsingPids; @@ -192,7 +186,6 @@ ze_result_t LinuxGlobalOperationsImp::reset(ze_bool_t force) { std::vector fds; pLinuxSysmanImp->getPidFdsForOpenDevice(pProcfsAccess, pSysfsAccess, pid, fds); if (!fds.empty()) { - // Kill all processes that have the device open. pProcfsAccess->kill(pid); deviceUsingPids.push_back(pid); @@ -210,7 +203,6 @@ ze_result_t LinuxGlobalOperationsImp::reset(ze_bool_t force) { return ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE; } - struct ::timespec timeout = {.tv_sec = 0, .tv_nsec = 1000}; ::nanosleep(&timeout, NULL); end = std::chrono::steady_clock::now(); @@ -220,14 +212,12 @@ ze_result_t LinuxGlobalOperationsImp::reset(ze_bool_t force) { // Reset the device. result = pFsAccess->write(resetPath, "1"); if (ZE_RESULT_SUCCESS != result) { - return result; } // Rebind the device to the kernel driver. result = pSysfsAccess->bindDevice(resetName); if (ZE_RESULT_SUCCESS != result) { - return result; } diff --git a/level_zero/tools/source/sysman/linux/os_sysman_imp.cpp b/level_zero/tools/source/sysman/linux/os_sysman_imp.cpp index 6bde9ac1ea..ac6267f86e 100644 --- a/level_zero/tools/source/sysman/linux/os_sysman_imp.cpp +++ b/level_zero/tools/source/sysman/linux/os_sysman_imp.cpp @@ -65,13 +65,13 @@ void LinuxSysmanImp::createFwUtilInterface() { } ze_result_t LinuxSysmanImp::createPmtHandles() { - std::string realRootPath; - auto result = pSysfsAccess->getRealPath("device", realRootPath); + std::string gtDevicePCIPath; + auto result = pSysfsAccess->getRealPath("device", gtDevicePCIPath); if (ZE_RESULT_SUCCESS != result) { return result; } - auto rootPciPathOfGpuDevice = getPciRootPortDirectoryPath(realRootPath); - PlatformMonitoringTech::create(pParentSysmanDeviceImp->deviceHandles, pFsAccess, rootPciPathOfGpuDevice, mapOfSubDeviceIdToPmtObject); + auto gpuUpstreamPortPath = getPciCardBusDirectoryPath(gtDevicePCIPath); + PlatformMonitoringTech::create(pParentSysmanDeviceImp->deviceHandles, pFsAccess, gpuUpstreamPortPath, mapOfSubDeviceIdToPmtObject); return result; } @@ -136,12 +136,9 @@ SysmanDeviceImp *LinuxSysmanImp::getSysmanDeviceImp() { return pParentSysmanDeviceImp; } -std::string LinuxSysmanImp::getPciRootPortDirectoryPath(std::string realPciPath) { +static std::string modifyPathOnLevel(std::string realPciPath, uint8_t nLevel) { size_t loc; - // we need to change the absolute path to two levels up to get - // the Discrete card's root port. - // the root port is always at a fixed distance as defined in HW - uint8_t nLevel = 2; + // we need to change the absolute path to 'nLevel' levels up while (nLevel > 0) { loc = realPciPath.find_last_of('/'); if (loc == std::string::npos) { @@ -152,38 +149,36 @@ std::string LinuxSysmanImp::getPciRootPortDirectoryPath(std::string realPciPath) } return realPciPath; } - -static std::string modifyPathOnLevel(std::string path, uint8_t level) { - size_t loc = 0; - size_t count = 0; - std::string modifiedPath(path); - uint8_t nLevel = level; - do { - loc = path.find_first_of('/'); - count = count + loc; - if (loc == std::string::npos) { - break; - } - path = path.substr(loc + 1, path.size()); - nLevel--; - } while (nLevel > 0); - if (nLevel == 0) { - modifiedPath = modifiedPath.substr(0, (count + level - 1)); // need to adjust for last '/' that the code encounters - } - return modifiedPath; -} -std::string LinuxSysmanImp::getPciRootPortDirectoryPathForReset(std::string realPciPath) { +std::string getPciRootPortDirectoryPath(std::string realPciPath) { // the rootport is always the first pci folder after the pcie slot. + // +-[0000:89]-+-00.0 + // | +-00.1 + // | +-00.2 + // | +-00.4 + // | \-02.0-[8a-8e]----00.0-[8b-8e]--+-01.0-[8c-8d]----00.0 + // | \-02.0-[8e]--+-00.0 + // | +-00.1 + // | \-00.2 // /sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0/0000:8b:01.0/0000:8c:00.0 // '/sys/devices/pci0000:89/0000:89:02.0/' will always be the same distance. - return modifyPathOnLevel(realPciPath, 5); + // from 0000:8c:00.0 i.e the 3rd PCI address from the gt tile + return modifyPathOnLevel(realPciPath, 3); } std::string LinuxSysmanImp::getPciCardBusDirectoryPath(std::string realPciPath) { // the cardbus is always the second pci folder after the pcie slot. + // +-[0000:89]-+-00.0 + // | +-00.1 + // | +-00.2 + // | +-00.4 + // | \-02.0-[8a-8e]----00.0-[8b-8e]--+-01.0-[8c-8d]----00.0 + // | \-02.0-[8e]--+-00.0 + // | +-00.1 + // | \-00.2 // /sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0/0000:8b:01.0/0000:8c:00.0 // '/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0/' will always be the same distance. - return modifyPathOnLevel(realPciPath, 6); + // from 0000:8c:00.0 i.e the 2nd PCI address from the gt tile. + return modifyPathOnLevel(realPciPath, 2); } PlatformMonitoringTech *LinuxSysmanImp::getPlatformMonitoringTechAccess(uint32_t subDeviceId) { @@ -274,7 +269,7 @@ void LinuxSysmanImp::releaseDeviceResources() { executionEnvironment = devicePtr->getNEODevice()->getExecutionEnvironment(); devicePciBdf = devicePtr->getNEODevice()->getRootDeviceEnvironment().osInterface->getDriverModel()->as()->getPciPath(); rootDeviceIndex = devicePtr->getNEODevice()->getRootDeviceIndex(); - + pSysfsAccess->getRealPath(deviceDir, gtDevicePath); releaseSysmanDeviceResources(); auto device = static_cast(getDeviceHandle()); executionEnvironment = device->getNEODevice()->getExecutionEnvironment(); @@ -320,20 +315,14 @@ ze_result_t LinuxSysmanImp::initDevice() { // in the bridge control register in the PCI configuration space of the bridge port upstream of the device. ze_result_t LinuxSysmanImp::osWarmReset() { std::string rootPortPath; - std::string realRootPath; - ze_result_t result = pSysfsAccess->getRealPath(deviceDir, realRootPath); - if (ZE_RESULT_SUCCESS != result) { - return result; - } - - std::string cardBusPath = getPciCardBusDirectoryPath(realRootPath); - result = pFsAccess->write(cardBusPath + '/' + "remove", "1"); + std::string cardBusPath = getPciCardBusDirectoryPath(gtDevicePath); + ze_result_t result = pFsAccess->write(cardBusPath + '/' + "remove", "1"); if (ZE_RESULT_SUCCESS != result) { return result; } this->pSleepFunctionSecs(10); // Sleep for 10seconds to make sure that the config spaces of all devices are saved correctly - rootPortPath = getPciRootPortDirectoryPathForReset(realRootPath); + rootPortPath = getPciRootPortDirectoryPath(gtDevicePath); int fd, ret = 0; unsigned int offset = PCI_BRIDGE_CONTROL; // Bridge control offset in Header of PCI config space @@ -370,19 +359,14 @@ std::string LinuxSysmanImp::getAddressFromPath(std::string &rootPortPath) { } ze_result_t LinuxSysmanImp::osColdReset() { - const std::string slotPath("/sys/bus/pci/slots/"); // holds the directories matching to the number of slots in the PC - std::string cardBusPath; // will hold the PCIe Root port directory path (the address of the PCIe slot). - std::string realRootPath; // will hold the absolute real path (not symlink) to the selected Device - ze_result_t result = pSysfsAccess->getRealPath(deviceDir, realRootPath); // e.g realRootPath=/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0/0000:8b:01.0/0000:8c:00.0 - if (ZE_RESULT_SUCCESS != result) { - return result; - } + const std::string slotPath("/sys/bus/pci/slots/"); // holds the directories matching to the number of slots in the PC + std::string cardBusPath; // will hold the PCIe Root port directory path (the address of the PCIe slot). // will hold the absolute real path (not symlink) to the selected Device - cardBusPath = getPciCardBusDirectoryPath(realRootPath); // e.g cardBusPath=/sys/devices/pci0000:89/0000:89:02.0/ + cardBusPath = getPciCardBusDirectoryPath(gtDevicePath); // e.g cardBusPath=/sys/devices/pci0000:89/0000:89:02.0/ std::string rootAddress = getAddressFromPath(cardBusPath); // e.g rootAddress = 0000:8a:00.0 std::vector dir; - result = pFsAccess->listDirectory(slotPath, dir); // get list of slot directories from /sys/bus/pci/slots/ + ze_result_t result = pFsAccess->listDirectory(slotPath, dir); // get list of slot directories from /sys/bus/pci/slots/ if (ZE_RESULT_SUCCESS != result) { return result; } diff --git a/level_zero/tools/source/sysman/linux/os_sysman_imp.h b/level_zero/tools/source/sysman/linux/os_sysman_imp.h index 4dfdfdbe25..06f2f3b419 100644 --- a/level_zero/tools/source/sysman/linux/os_sysman_imp.h +++ b/level_zero/tools/source/sysman/linux/os_sysman_imp.h @@ -53,8 +53,6 @@ class LinuxSysmanImp : public OsSysman, NEO::NonCopyableOrMovableClass { PlatformMonitoringTech *getPlatformMonitoringTechAccess(uint32_t subDeviceId); Device *getDeviceHandle(); SysmanDeviceImp *getSysmanDeviceImp(); - std::string getPciRootPortDirectoryPath(std::string realPciPath); - std::string getPciRootPortDirectoryPathForReset(std::string realPciPath); std::string getPciCardBusDirectoryPath(std::string realPciPath); void releasePmtObject(); ze_result_t createPmtHandles(); @@ -80,6 +78,7 @@ class LinuxSysmanImp : public OsSysman, NEO::NonCopyableOrMovableClass { NEO::ExecutionEnvironment *executionEnvironment = nullptr; bool diagnosticsReset = false; Device *pDevice = nullptr; + std::string gtDevicePath; protected: FsAccess *pFsAccess = nullptr; diff --git a/level_zero/tools/source/sysman/linux/pmt/pmt.cpp b/level_zero/tools/source/sysman/linux/pmt/pmt.cpp index 9060048d84..a338e765da 100644 --- a/level_zero/tools/source/sysman/linux/pmt/pmt.cpp +++ b/level_zero/tools/source/sysman/linux/pmt/pmt.cpp @@ -74,8 +74,8 @@ bool compareTelemNodes(std::string &telemNode1, std::string &telemNode2) { return indexForTelemNode1 < indexForTelemNode2; } -// Check if Telemetry node(say /sys/class/intel_pmt/telem1) and rootPciPathOfGpuDevice share same PCI Root port -static bool isValidTelemNode(FsAccess *pFsAccess, const std::string &rootPciPathOfGpuDevice, const std::string sysfsTelemNode) { +// Check if Telemetry node(say /sys/class/intel_pmt/telem1) and gpuUpstreamPortPath share same PCI Root port +static bool isValidTelemNode(FsAccess *pFsAccess, const std::string &gpuUpstreamPortPath, const std::string sysfsTelemNode) { std::string realPathOfTelemNode; auto result = pFsAccess->getRealPath(sysfsTelemNode, realPathOfTelemNode); if (result != ZE_RESULT_SUCCESS) { @@ -83,14 +83,15 @@ static bool isValidTelemNode(FsAccess *pFsAccess, const std::string &rootPciPath } // Example: If - // rootPciPathOfGpuDevice = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0"; + // gpuUpstreamPortPath = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0"; // 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"; - // As rootPciPathOfGpuDevice is a substring og realPathOfTelemNode , hence both sysfs telemNode and GPU device share same PCI Root. + // As gpuUpstreamPortPath is a substring of realPathOfTelemNode , hence both sysfs telemNode and GPU device share same PCI Root. + // the PMT is part of the OOBMSM sitting on a switch port 0000:8b:02.0 attached to the upstream port/ Also known as CardBus // Hence this telem node entry is valid for GPU device. - return (realPathOfTelemNode.compare(0, rootPciPathOfGpuDevice.size(), rootPciPathOfGpuDevice) == 0); + return (realPathOfTelemNode.compare(0, gpuUpstreamPortPath.size(), gpuUpstreamPortPath) == 0); } -ze_result_t PlatformMonitoringTech::enumerateRootTelemIndex(FsAccess *pFsAccess, std::string &rootPciPathOfGpuDevice) { +ze_result_t PlatformMonitoringTech::enumerateRootTelemIndex(FsAccess *pFsAccess, std::string &gpuUpstreamPortPath) { std::vector listOfTelemNodes; auto result = pFsAccess->listDirectory(baseTelemSysFS, listOfTelemNodes); if (ZE_RESULT_SUCCESS != result) { @@ -111,7 +112,7 @@ ze_result_t PlatformMonitoringTech::enumerateRootTelemIndex(FsAccess *pFsAccess, // Then listOfTelemNodes would contain telem1, telem2, telem3 std::sort(listOfTelemNodes.begin(), listOfTelemNodes.end(), compareTelemNodes); // sort listOfTelemNodes, to arange telem nodes in ascending order for (const auto &telemNode : listOfTelemNodes) { - if (isValidTelemNode(pFsAccess, rootPciPathOfGpuDevice, baseTelemSysFS + "/" + telemNode)) { + if (isValidTelemNode(pFsAccess, gpuUpstreamPortPath, baseTelemSysFS + "/" + telemNode)) { auto indexString = telemNode.substr(telem.size(), telemNode.size()); rootDeviceTelemNodeIndex = stoi(indexString); // if telemNode is telemN, then rootDeviceTelemNodeIndex = N return ZE_RESULT_SUCCESS; @@ -120,7 +121,7 @@ ze_result_t PlatformMonitoringTech::enumerateRootTelemIndex(FsAccess *pFsAccess, return ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE; } -ze_result_t PlatformMonitoringTech::init(FsAccess *pFsAccess, const std::string &rootPciPathOfGpuDevice) { +ze_result_t PlatformMonitoringTech::init(FsAccess *pFsAccess, const std::string &gpuUpstreamPortPath) { std::string telemNode = telem + std::to_string(rootDeviceTelemNodeIndex); if (isSubdevice) { uint32_t telemNodeIndex = 0; @@ -131,7 +132,7 @@ ze_result_t PlatformMonitoringTech::init(FsAccess *pFsAccess, const std::string telemNode = telem + std::to_string(telemNodeIndex); } std::string baseTelemSysFSNode = baseTelemSysFS + "/" + telemNode; - if (!isValidTelemNode(pFsAccess, rootPciPathOfGpuDevice, baseTelemSysFSNode)) { + if (!isValidTelemNode(pFsAccess, gpuUpstreamPortPath, baseTelemSysFSNode)) { return ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE; } @@ -172,9 +173,9 @@ PlatformMonitoringTech::PlatformMonitoringTech(FsAccess *pFsAccess, ze_bool_t on } void PlatformMonitoringTech::doInitPmtObject(FsAccess *pFsAccess, uint32_t subdeviceId, PlatformMonitoringTech *pPmt, - const std::string &rootPciPathOfGpuDevice, + const std::string &gpuUpstreamPortPath, std::map &mapOfSubDeviceIdToPmtObject) { - if (pPmt->init(pFsAccess, rootPciPathOfGpuDevice) == ZE_RESULT_SUCCESS) { + if (pPmt->init(pFsAccess, gpuUpstreamPortPath) == ZE_RESULT_SUCCESS) { mapOfSubDeviceIdToPmtObject.emplace(subdeviceId, pPmt); return; } @@ -182,9 +183,9 @@ void PlatformMonitoringTech::doInitPmtObject(FsAccess *pFsAccess, uint32_t subde } void PlatformMonitoringTech::create(const std::vector &deviceHandles, - FsAccess *pFsAccess, std::string &rootPciPathOfGpuDevice, + FsAccess *pFsAccess, std::string &gpuUpstreamPortPath, std::map &mapOfSubDeviceIdToPmtObject) { - if (ZE_RESULT_SUCCESS == PlatformMonitoringTech::enumerateRootTelemIndex(pFsAccess, rootPciPathOfGpuDevice)) { + if (ZE_RESULT_SUCCESS == PlatformMonitoringTech::enumerateRootTelemIndex(pFsAccess, gpuUpstreamPortPath)) { for (const auto &deviceHandle : deviceHandles) { uint32_t subdeviceId = 0; ze_bool_t onSubdevice = false; @@ -192,7 +193,7 @@ void PlatformMonitoringTech::create(const std::vector &devic auto pPmt = new PlatformMonitoringTech(pFsAccess, onSubdevice, subdeviceId); UNRECOVERABLE_IF(nullptr == pPmt); PlatformMonitoringTech::doInitPmtObject(pFsAccess, subdeviceId, pPmt, - rootPciPathOfGpuDevice, mapOfSubDeviceIdToPmtObject); + gpuUpstreamPortPath, mapOfSubDeviceIdToPmtObject); } } } diff --git a/level_zero/tools/source/sysman/linux/pmt/pmt.h b/level_zero/tools/source/sysman/linux/pmt/pmt.h index fd273214f1..c5f85820ff 100644 --- a/level_zero/tools/source/sysman/linux/pmt/pmt.h +++ b/level_zero/tools/source/sysman/linux/pmt/pmt.h @@ -27,9 +27,9 @@ class PlatformMonitoringTech : NEO::NonCopyableOrMovableClass { virtual ze_result_t readValue(const std::string key, uint32_t &value); virtual ze_result_t readValue(const std::string key, uint64_t &value); - static ze_result_t enumerateRootTelemIndex(FsAccess *pFsAccess, std::string &rootPciPathOfGpuDevice); + static ze_result_t enumerateRootTelemIndex(FsAccess *pFsAccess, std::string &gpuUpstreamPortPath); static void create(const std::vector &deviceHandles, - FsAccess *pFsAccess, std::string &rootPciPathOfGpuDevice, + FsAccess *pFsAccess, std::string &gpuUpstreamPortPath, std::map &mapOfSubDeviceIdToPmtObject); protected: @@ -37,8 +37,8 @@ class PlatformMonitoringTech : NEO::NonCopyableOrMovableClass { std::string telemetryDeviceEntry{}; std::map keyOffsetMap; ze_result_t getKeyOffsetMap(std::string guid, std::map &keyOffsetMap); - ze_result_t init(FsAccess *pFsAccess, const std::string &rootPciPathOfGpuDevice); - static void doInitPmtObject(FsAccess *pFsAccess, uint32_t subdeviceId, PlatformMonitoringTech *pPmt, const std::string &rootPciPathOfGpuDevice, + ze_result_t init(FsAccess *pFsAccess, const std::string &gpuUpstreamPortPath); + static void doInitPmtObject(FsAccess *pFsAccess, uint32_t subdeviceId, PlatformMonitoringTech *pPmt, const std::string &gpuUpstreamPortPath, std::map &mapOfSubDeviceIdToPmtObject); decltype(&NEO::SysCalls::open) openFunction = NEO::SysCalls::open; decltype(&NEO::SysCalls::close) closeFunction = NEO::SysCalls::close; diff --git a/level_zero/tools/source/sysman/pci/linux/os_pci_imp.cpp b/level_zero/tools/source/sysman/pci/linux/os_pci_imp.cpp index 2cc5017fc2..51d1a88919 100644 --- a/level_zero/tools/source/sysman/pci/linux/os_pci_imp.cpp +++ b/level_zero/tools/source/sysman/pci/linux/os_pci_imp.cpp @@ -274,7 +274,7 @@ void LinuxPciImp::pciCardBusConfigRead() { std::string pciConfigNode; std::string rootPortPath; pSysfsAccess->getRealPath(deviceDir, pciConfigNode); - rootPortPath = pLinuxSysmanImp->getPciRootPortDirectoryPath(pciConfigNode); + rootPortPath = pLinuxSysmanImp->getPciCardBusDirectoryPath(pciConfigNode); pciConfigNode = rootPortPath + "/config"; int fdConfig = -1; fdConfig = this->openFunction(pciConfigNode.c_str(), O_RDONLY); diff --git a/level_zero/tools/test/unit_tests/sources/sysman/diagnostics/linux/test_zes_sysman_diagnostics.cpp b/level_zero/tools/test/unit_tests/sources/sysman/diagnostics/linux/test_zes_sysman_diagnostics.cpp index ffc92efc13..98cd164a28 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/diagnostics/linux/test_zes_sysman_diagnostics.cpp +++ b/level_zero/tools/test/unit_tests/sources/sysman/diagnostics/linux/test_zes_sysman_diagnostics.cpp @@ -537,6 +537,7 @@ TEST_F(ZesDiagnosticsFixture, GivenValidDiagnosticsHandleWhenInvalidateLmemFails } TEST_F(ZesDiagnosticsFixture, GivenValidSysmanImpPointerWhenCallingWarmResetThenCallSucceeds) { + pLinuxSysmanImp->gtDevicePath = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0/0000:8b:01.0/0000:8c:00.0"; pLinuxSysmanImp->openFunction = openMockDiag; pLinuxSysmanImp->closeFunction = closeMockDiag; pLinuxSysmanImp->preadFunction = preadMockDiag; @@ -547,6 +548,7 @@ TEST_F(ZesDiagnosticsFixture, GivenValidSysmanImpPointerWhenCallingWarmResetThen } TEST_F(ZesDiagnosticsFixture, GivenValidSysmanImpPointerWhenCallingWarmResetAndRootPortConfigFileFailsToOpenThenCallFails) { + pLinuxSysmanImp->gtDevicePath = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0/0000:8b:01.0/0000:8c:00.0"; pLinuxSysmanImp->openFunction = openMockDiagFail; pLinuxSysmanImp->closeFunction = closeMockDiag; pLinuxSysmanImp->preadFunction = preadMockDiag; @@ -557,6 +559,7 @@ TEST_F(ZesDiagnosticsFixture, GivenValidSysmanImpPointerWhenCallingWarmResetAndR } TEST_F(ZesDiagnosticsFixture, GivenValidSysmanImpPointerWhenCallingWarmResetAndRootPortConfigFileFailsToCloseThenCallFails) { + pLinuxSysmanImp->gtDevicePath = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0/0000:8b:01.0/0000:8c:00.0"; pLinuxSysmanImp->openFunction = openMockDiag; pLinuxSysmanImp->closeFunction = closeMockDiagFail; pLinuxSysmanImp->preadFunction = preadMockDiag; @@ -566,18 +569,8 @@ TEST_F(ZesDiagnosticsFixture, GivenValidSysmanImpPointerWhenCallingWarmResetAndR EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, pLinuxSysmanImp->osWarmReset()); } -TEST_F(ZesDiagnosticsFixture, GivenValidSysmanImpPointerWhenCallingWarmResetAndGetRealPathFailsThenCallFails) { - pLinuxSysmanImp->openFunction = openMockDiag; - pLinuxSysmanImp->closeFunction = closeMockDiag; - pLinuxSysmanImp->preadFunction = preadMockDiag; - pLinuxSysmanImp->pwriteFunction = pwriteMockDiag; - pLinuxSysmanImp->pSleepFunctionSecs = mockSleepFunctionSecs; - - pMockSysfsAccess->setMockError(ZE_RESULT_ERROR_NOT_AVAILABLE); - EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, pLinuxSysmanImp->osWarmReset()); -} - TEST_F(ZesDiagnosticsFixture, GivenValidSysmanImpPointerWhenCallingWarmResetAndCardbusRemoveFailsThenCallFails) { + pLinuxSysmanImp->gtDevicePath = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0/0000:8b:01.0/0000:8c:00.0"; pLinuxSysmanImp->openFunction = openMockDiag; pLinuxSysmanImp->closeFunction = closeMockDiag; pLinuxSysmanImp->preadFunction = preadMockDiag; @@ -589,6 +582,7 @@ TEST_F(ZesDiagnosticsFixture, GivenValidSysmanImpPointerWhenCallingWarmResetAndC } TEST_F(ZesDiagnosticsFixture, GivenValidSysmanImpPointerWhenCallingWarmResetAndRootPortRescanFailsThenCallFails) { + pLinuxSysmanImp->gtDevicePath = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0/0000:8b:01.0/0000:8c:00.0"; pLinuxSysmanImp->openFunction = openMockDiag; pLinuxSysmanImp->closeFunction = closeMockDiag; pLinuxSysmanImp->preadFunction = preadMockDiag; @@ -601,25 +595,24 @@ TEST_F(ZesDiagnosticsFixture, GivenValidSysmanImpPointerWhenCallingWarmResetAndR } TEST_F(ZesDiagnosticsFixture, GivenValidSysmanImpPointerWhenCallingColdResetThenCallSucceeds) { + pLinuxSysmanImp->gtDevicePath = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0/0000:8b:01.0/0000:8c:00.0"; EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxSysmanImp->osColdReset()); } -TEST_F(ZesDiagnosticsFixture, GivenValidSysmanImpPointerWhenCallingColdResetAndGetRealPathFailsThenCallFails) { - pMockSysfsAccess->setMockError(ZE_RESULT_ERROR_NOT_AVAILABLE); - EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, pLinuxSysmanImp->osColdReset()); -} - TEST_F(ZesDiagnosticsFixture, GivenValidSysmanImpPointerWhenCallingColdResetAndListDirFailsThenCallFails) { + pLinuxSysmanImp->gtDevicePath = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0/0000:8b:01.0/0000:8c:00.0"; pMockFsAccess->mockListDirError = ZE_RESULT_ERROR_NOT_AVAILABLE; EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, pLinuxSysmanImp->osColdReset()); } TEST_F(ZesDiagnosticsFixture, GivenValidSysmanImpPointerWhenCallingColdResetAndReadSlotAddressFailsThenCallFails) { + pLinuxSysmanImp->gtDevicePath = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0/0000:8b:01.0/0000:8c:00.0"; pMockFsAccess->mockReadError = ZE_RESULT_ERROR_NOT_AVAILABLE; EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, pLinuxSysmanImp->osColdReset()); } TEST_F(ZesDiagnosticsFixture, GivenValidSysmanImpPointerWhenCallingColdResetandWriteFailsThenCallFails) { + pLinuxSysmanImp->gtDevicePath = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0/0000:8b:01.0/0000:8c:00.0"; pMockFsAccess->mockWriteError = ZE_RESULT_ERROR_NOT_AVAILABLE; EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, pLinuxSysmanImp->osColdReset()); pMockFsAccess->checkErrorAfterCount = 1; @@ -627,6 +620,7 @@ TEST_F(ZesDiagnosticsFixture, GivenValidSysmanImpPointerWhenCallingColdResetandW } TEST_F(ZesDiagnosticsFixture, GivenValidSysmanImpPointerWhenCallingColdResetandWrongSlotAddressIsReturnedThenCallFails) { + pLinuxSysmanImp->gtDevicePath = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0/0000:8b:01.0/0000:8c:00.0"; pMockFsAccess->setWrongMockAddress(); EXPECT_EQ(ZE_RESULT_ERROR_DEVICE_LOST, pLinuxSysmanImp->osColdReset()); } diff --git a/level_zero/tools/test/unit_tests/sources/sysman/linux/pmt/mock_pmt.h b/level_zero/tools/test/unit_tests/sources/sysman/linux/pmt/mock_pmt.h index 0051ab2d12..9be575dcf7 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/linux/pmt/mock_pmt.h +++ b/level_zero/tools/test/unit_tests/sources/sysman/linux/pmt/mock_pmt.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Intel Corporation + * Copyright (C) 2021-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -17,7 +17,7 @@ const std::string baseTelemSysFS("/sys/class/intel_pmt"); const std::string telem("telem"); const std::string telemNodeForSubdevice0("telem2"); const std::string telemNodeForSubdevice1("telem3"); -std::string rootPciPathOfGpuDeviceInPmt = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0"; +std::string gpuUpstreamPortPathInPmt = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0"; const std::string realPathTelem1 = "/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"; const std::string realPathTelem2 = "/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/telem2"; const std::string realPathTelem3 = "/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/telem3"; diff --git a/level_zero/tools/test/unit_tests/sources/sysman/linux/pmt/test_pmt.cpp b/level_zero/tools/test/unit_tests/sources/sysman/linux/pmt/test_pmt.cpp index 854de47c62..b207284b4f 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/linux/pmt/test_pmt.cpp +++ b/level_zero/tools/test/unit_tests/sources/sysman/linux/pmt/test_pmt.cpp @@ -51,7 +51,7 @@ class ZesPmtFixtureMultiDevice : public SysmanMultiDeviceFixture { .WillByDefault(::testing::Invoke(pTestFsAccess.get(), &Mock::getRealPathSuccess)); ON_CALL(*pTestFsAccess.get(), fileExists(_)) .WillByDefault(::testing::Invoke(pTestFsAccess.get(), &Mock::isFileExists)); - PlatformMonitoringTech::create(deviceHandles, pTestFsAccess.get(), rootPciPathOfGpuDeviceInPmt, mapOfSubDeviceIdToPmtObject); + PlatformMonitoringTech::create(deviceHandles, pTestFsAccess.get(), gpuUpstreamPortPathInPmt, mapOfSubDeviceIdToPmtObject); } void TearDown() override { if (!sysmanUltsEnable) { @@ -70,50 +70,50 @@ TEST_F(ZesPmtFixtureMultiDevice, GivenValidDeviceHandlesWhenCreatingPMTHandlesTh TEST_F(ZesPmtFixtureMultiDevice, GivenValidDeviceHandlesWhenenumerateRootTelemIndexThenCheckForErrorIflistDirectoryFails) { EXPECT_CALL(*pTestFsAccess.get(), listDirectory(_, _)) .WillOnce(Return(ZE_RESULT_ERROR_NOT_AVAILABLE)); - EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, PlatformMonitoringTech::enumerateRootTelemIndex(pTestFsAccess.get(), rootPciPathOfGpuDeviceInPmt)); + EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, PlatformMonitoringTech::enumerateRootTelemIndex(pTestFsAccess.get(), gpuUpstreamPortPathInPmt)); } TEST_F(ZesPmtFixtureMultiDevice, GivenValidDeviceHandlesWhenenumerateRootTelemIndexThenCheckForErrorIfgetRealPathFails) { EXPECT_CALL(*pTestFsAccess.get(), getRealPath(_, _)) .WillRepeatedly(Return(ZE_RESULT_ERROR_NOT_AVAILABLE)); - EXPECT_EQ(ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE, PlatformMonitoringTech::enumerateRootTelemIndex(pTestFsAccess.get(), rootPciPathOfGpuDeviceInPmt)); + EXPECT_EQ(ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE, PlatformMonitoringTech::enumerateRootTelemIndex(pTestFsAccess.get(), gpuUpstreamPortPathInPmt)); } TEST_F(ZesPmtFixtureMultiDevice, GivenWhenenumerateRootTelemIndexThenCheckForErrorIfgetRealPathSuccessButNoTelemetryNodeAndGPUDeviceShareRootPciPort) { EXPECT_CALL(*pTestFsAccess.get(), getRealPath(_, _)) .Times(5) .WillRepeatedly(::testing::DoAll(::testing::SetArgReferee<1>("/sys/devices/pci0000:89/0000:89:02.0/0000:8e:00.0/0000:8b:02.0/0000:8e:00.1/pmt_telemetry.1.auto/intel_pmt/telem1"), Return(ZE_RESULT_SUCCESS))); - EXPECT_EQ(ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE, PlatformMonitoringTech::enumerateRootTelemIndex(pTestFsAccess.get(), rootPciPathOfGpuDeviceInPmt)); + EXPECT_EQ(ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE, PlatformMonitoringTech::enumerateRootTelemIndex(pTestFsAccess.get(), gpuUpstreamPortPathInPmt)); } TEST_F(ZesPmtFixtureMultiDevice, GivenTelemDirectoryContainNowTelemEntryWhenenumerateRootTelemIndexThenCheckForError) { ON_CALL(*pTestFsAccess.get(), listDirectory(_, _)) .WillByDefault(::testing::Invoke(pTestFsAccess.get(), &Mock::listDirectoryNoTelemNode)); - EXPECT_EQ(ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE, PlatformMonitoringTech::enumerateRootTelemIndex(pTestFsAccess.get(), rootPciPathOfGpuDeviceInPmt)); + EXPECT_EQ(ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE, PlatformMonitoringTech::enumerateRootTelemIndex(pTestFsAccess.get(), gpuUpstreamPortPathInPmt)); } TEST_F(ZesPmtFixtureMultiDevice, GivenValidDeviceHandlesWhenCreatingPMTHandlesThenCheckForErrorThatCouldHappenDuringWhileValidatingTelemNode) { EXPECT_CALL(*pTestFsAccess.get(), getRealPath(_, _)) .WillRepeatedly(Return(ZE_RESULT_ERROR_NOT_AVAILABLE)); - PlatformMonitoringTech::enumerateRootTelemIndex(pTestFsAccess.get(), rootPciPathOfGpuDeviceInPmt); + PlatformMonitoringTech::enumerateRootTelemIndex(pTestFsAccess.get(), gpuUpstreamPortPathInPmt); auto pPmt = std::make_unique(pTestFsAccess.get(), 1, 0); - EXPECT_EQ(pPmt->init(pTestFsAccess.get(), rootPciPathOfGpuDeviceInPmt), ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE); + EXPECT_EQ(pPmt->init(pTestFsAccess.get(), gpuUpstreamPortPathInPmt), ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE); } TEST_F(ZesPmtFixtureMultiDevice, GivenValidDeviceHandlesWhenCreatingPMTHandlesThenCheckForErrorThatCouldHappenDuringGUIDRead) { EXPECT_CALL(*pTestFsAccess.get(), read(_, Matcher(_))) .WillOnce(Return(ZE_RESULT_ERROR_NOT_AVAILABLE)); - PlatformMonitoringTech::enumerateRootTelemIndex(pTestFsAccess.get(), rootPciPathOfGpuDeviceInPmt); + PlatformMonitoringTech::enumerateRootTelemIndex(pTestFsAccess.get(), gpuUpstreamPortPathInPmt); auto pPmt = std::make_unique(pTestFsAccess.get(), 1, 0); - EXPECT_EQ(pPmt->init(pTestFsAccess.get(), rootPciPathOfGpuDeviceInPmt), ZE_RESULT_ERROR_NOT_AVAILABLE); + EXPECT_EQ(pPmt->init(pTestFsAccess.get(), gpuUpstreamPortPathInPmt), ZE_RESULT_ERROR_NOT_AVAILABLE); } TEST_F(ZesPmtFixtureMultiDevice, GivenValidDeviceHandlesWhenCreatingPMTHandlesThenCheckForErrorIfGUIDReadValueIsNotSupported) { EXPECT_CALL(*pTestFsAccess.get(), read(_, Matcher(_))) .WillOnce(::testing::DoAll(::testing::SetArgReferee<1>(""), Return(ZE_RESULT_SUCCESS))); - PlatformMonitoringTech::enumerateRootTelemIndex(pTestFsAccess.get(), rootPciPathOfGpuDeviceInPmt); + PlatformMonitoringTech::enumerateRootTelemIndex(pTestFsAccess.get(), gpuUpstreamPortPathInPmt); auto pPmt = std::make_unique(pTestFsAccess.get(), 1, 0); - EXPECT_EQ(pPmt->init(pTestFsAccess.get(), rootPciPathOfGpuDeviceInPmt), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + EXPECT_EQ(pPmt->init(pTestFsAccess.get(), gpuUpstreamPortPathInPmt), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); } TEST_F(ZesPmtFixtureMultiDevice, GivenSomeKeyWhenCallingreadValueWithUint64TypeThenCheckForErrorBranches) { @@ -133,9 +133,9 @@ TEST_F(ZesPmtFixtureMultiDevice, GivenSomeKeyWhenCallingreadValueWithUint32TypeT TEST_F(ZesPmtFixtureMultiDevice, GivenValidDeviceHandlesWhenCreatingPMTHandlesThenCheckForErrorThatCouldHappenDuringbaseOffsetRead) { EXPECT_CALL(*pTestFsAccess.get(), read(_, Matcher(_))) .WillOnce(Return(ZE_RESULT_ERROR_NOT_AVAILABLE)); - PlatformMonitoringTech::enumerateRootTelemIndex(pTestFsAccess.get(), rootPciPathOfGpuDeviceInPmt); + PlatformMonitoringTech::enumerateRootTelemIndex(pTestFsAccess.get(), gpuUpstreamPortPathInPmt); auto pPmt = std::make_unique(pTestFsAccess.get(), 1, 0); - EXPECT_EQ(pPmt->init(pTestFsAccess.get(), rootPciPathOfGpuDeviceInPmt), ZE_RESULT_ERROR_NOT_AVAILABLE); + EXPECT_EQ(pPmt->init(pTestFsAccess.get(), gpuUpstreamPortPathInPmt), ZE_RESULT_ERROR_NOT_AVAILABLE); } inline static int openMock(const char *pathname, int flags) { @@ -246,7 +246,7 @@ TEST_F(ZesPmtFixtureMultiDevice, GivenValidSyscallsWhenDoingPMTInitThenPMTmapOfS deviceProperties.subdeviceId); UNRECOVERABLE_IF(nullptr == pPmt); PublicPlatformMonitoringTech::doInitPmtObject(pTestFsAccess.get(), deviceProperties.subdeviceId, pPmt, - rootPciPathOfGpuDeviceInPmt, mapOfSubDeviceIdToPmtObject); + gpuUpstreamPortPathInPmt, mapOfSubDeviceIdToPmtObject); auto subDeviceIdToPmtEntry = mapOfSubDeviceIdToPmtObject.find(deviceProperties.subdeviceId); EXPECT_EQ(subDeviceIdToPmtEntry->second, pPmt); delete pPmt; @@ -264,7 +264,7 @@ TEST_F(ZesPmtFixtureMultiDevice, GivenBaseOffsetReadFailWhenDoingPMTInitThenPMTm deviceProperties.subdeviceId); UNRECOVERABLE_IF(nullptr == pPmt); PublicPlatformMonitoringTech::doInitPmtObject(pTestFsAccess.get(), deviceProperties.subdeviceId, pPmt, - rootPciPathOfGpuDeviceInPmt, mapOfSubDeviceIdToPmtObject); + gpuUpstreamPortPathInPmt, mapOfSubDeviceIdToPmtObject); EXPECT_TRUE(mapOfSubDeviceIdToPmtObject.empty()); } } @@ -311,7 +311,7 @@ class ZesPmtFixtureNoSubDevice : public SysmanDeviceFixture { .WillByDefault(::testing::Invoke(pTestFsAccess.get(), &Mock::getRealPathSuccess)); ON_CALL(*pTestFsAccess.get(), fileExists(_)) .WillByDefault(::testing::Invoke(pTestFsAccess.get(), &Mock::isFileExists)); - PlatformMonitoringTech::create(deviceHandles, pTestFsAccess.get(), rootPciPathOfGpuDeviceInPmt, mapOfSubDeviceIdToPmtObject); + PlatformMonitoringTech::create(deviceHandles, pTestFsAccess.get(), gpuUpstreamPortPathInPmt, mapOfSubDeviceIdToPmtObject); } void TearDown() override { if (!sysmanUltsEnable) { diff --git a/level_zero/tools/test/unit_tests/sources/sysman/linux/test_sysman.cpp b/level_zero/tools/test/unit_tests/sources/sysman/linux/test_sysman.cpp index 2bbb254543..6a4e41114f 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/linux/test_sysman.cpp +++ b/level_zero/tools/test/unit_tests/sources/sysman/linux/test_sysman.cpp @@ -301,18 +301,6 @@ TEST_F(SysmanDeviceFixture, GivenPmuInterfaceHandleWhenCallinggetPmuInterfaceThe EXPECT_EQ(pLinuxSysmanImp->getPmuInterface(), pLinuxSysmanImp->pPmuInterface); } -TEST_F(SysmanDeviceFixture, GivenValidPciPathWhileGettingRootPciPortThenReturnedPathIs2LevelUpThenTheCurrentPath) { - const std::string mockBdf = "0000:00:02.0"; - const std::string mockRealPath = "/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:01.0/" + mockBdf; - const std::string mockRealPath2LevelsUp = "/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0"; - - std::string pciRootPort1 = pLinuxSysmanImp->getPciRootPortDirectoryPath(mockRealPath); - EXPECT_EQ(pciRootPort1, mockRealPath2LevelsUp); - - std::string pciRootPort2 = pLinuxSysmanImp->getPciRootPortDirectoryPath("device"); - EXPECT_EQ(pciRootPort2, "device"); -} - TEST_F(SysmanDeviceFixture, GivenValidPciPathWhileGettingCardBusPortThenReturnedPathIs1LevelUpThenTheCurrentPath) { const std::string mockBdf = "0000:00:02.0"; const std::string mockRealPath = "/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:01.0/" + mockBdf; @@ -325,18 +313,6 @@ TEST_F(SysmanDeviceFixture, GivenValidPciPathWhileGettingCardBusPortThenReturned EXPECT_EQ(pciRootPort2, "device"); } -TEST_F(SysmanDeviceFixture, GivenValidPciPathWhileGettingRootPciPortThenReturnedPathIs1LevelAfterPCIePath) { - const std::string mockBdf = "0000:00:02.0"; - const std::string mockRealPath = "/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:01.0/" + mockBdf; - const std::string mockRootPortPath = "/sys/devices/pci0000:00/0000:00:01.0"; - - std::string pciRootPort1 = pLinuxSysmanImp->getPciRootPortDirectoryPathForReset(mockRealPath); - EXPECT_EQ(pciRootPort1, mockRootPortPath); - - std::string pciRootPort2 = pLinuxSysmanImp->getPciRootPortDirectoryPathForReset("device"); - EXPECT_EQ(pciRootPort2, "device"); -} - TEST_F(SysmanDeviceFixture, GivenNullDrmHandleWhenGettingDrmHandleThenValidDrmHandleIsReturned) { pLinuxSysmanImp->releaseLocalDrmHandle(); EXPECT_NO_THROW(pLinuxSysmanImp->getDrm()); diff --git a/level_zero/tools/test/unit_tests/sources/sysman/power/linux/mock_sysfs_power.h b/level_zero/tools/test/unit_tests/sources/sysman/power/linux/mock_sysfs_power.h index 20bb93ba86..d5e3223a06 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/power/linux/mock_sysfs_power.h +++ b/level_zero/tools/test/unit_tests/sources/sysman/power/linux/mock_sysfs_power.h @@ -274,8 +274,8 @@ struct Mock : public PowerPmt { Mock(FsAccess *pFsAccess, ze_bool_t onSubdevice, uint32_t subdeviceId) : PowerPmt(pFsAccess, onSubdevice, subdeviceId) {} void mockedInit(FsAccess *pFsAccess) { - std::string rootPciPathOfGpuDevice = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0"; - if (ZE_RESULT_SUCCESS != PlatformMonitoringTech::enumerateRootTelemIndex(pFsAccess, rootPciPathOfGpuDevice)) { + std::string gpuUpstreamPortPath = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0"; + if (ZE_RESULT_SUCCESS != PlatformMonitoringTech::enumerateRootTelemIndex(pFsAccess, gpuUpstreamPortPath)) { return; } diff --git a/level_zero/tools/test/unit_tests/sources/sysman/temperature/linux/mock_sysfs_temperature.h b/level_zero/tools/test/unit_tests/sources/sysman/temperature/linux/mock_sysfs_temperature.h index ecf5e36d81..09e3771c68 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/temperature/linux/mock_sysfs_temperature.h +++ b/level_zero/tools/test/unit_tests/sources/sysman/temperature/linux/mock_sysfs_temperature.h @@ -32,7 +32,7 @@ constexpr uint64_t offsetForNoSubDevices = 0x60; constexpr uint8_t computeIndexForNoSubDevices = 9; constexpr uint8_t globalIndexForNoSubDevices = 3; const std::string baseTelemSysFS("/sys/class/intel_pmt"); -std::string rootPciPathOfGpuDeviceInTemperature = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0"; +std::string gpuUpstreamPortPathInTemperature = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0"; const std::string realPathTelem1 = "/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"; const std::string realPathTelem2 = "/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/telem2"; const std::string realPathTelem3 = "/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/telem3"; @@ -61,7 +61,7 @@ struct Mock : public TemperaturePmt { } void mockedInit(FsAccess *pFsAccess) { - if (ZE_RESULT_SUCCESS != PlatformMonitoringTech::enumerateRootTelemIndex(pFsAccess, rootPciPathOfGpuDeviceInTemperature)) { + if (ZE_RESULT_SUCCESS != PlatformMonitoringTech::enumerateRootTelemIndex(pFsAccess, gpuUpstreamPortPathInTemperature)) { return; } telemetryDeviceEntry = "/sys/class/intel_pmt/telem2/telem"; diff --git a/level_zero/tools/test/unit_tests/sources/sysman/temperature/linux/test_zes_temperature.cpp b/level_zero/tools/test/unit_tests/sources/sysman/temperature/linux/test_zes_temperature.cpp index 1da47dee75..9fe4f16c8c 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/temperature/linux/test_zes_temperature.cpp +++ b/level_zero/tools/test/unit_tests/sources/sysman/temperature/linux/test_zes_temperature.cpp @@ -13,7 +13,7 @@ extern bool sysmanUltsEnable; namespace L0 { namespace ult { const static int fakeFileDescriptor = 123; -std::string rootPciPathOfGpuDevice = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0"; +std::string gpuUpstreamPortPath = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0"; constexpr uint32_t handleComponentCountForSubDevices = 6u; constexpr uint32_t handleComponentCountForNoSubDevices = 2u; constexpr uint32_t invalidMaxTemperature = 125; @@ -185,7 +185,7 @@ TEST_F(SysmanMultiDeviceTemperatureFixture, GivenValidTempHandleWhenSettingTempe TEST_F(SysmanMultiDeviceTemperatureFixture, GivenCreatePmtObjectsWhenRootTileIndexEnumeratesSuccessfulThenValidatePmtObjectsReceivedAndBranches) { std::map mapOfSubDeviceIdToPmtObject; - PlatformMonitoringTech::create(deviceHandles, pFsAccess.get(), rootPciPathOfGpuDevice, mapOfSubDeviceIdToPmtObject); + PlatformMonitoringTech::create(deviceHandles, pFsAccess.get(), gpuUpstreamPortPath, mapOfSubDeviceIdToPmtObject); uint32_t deviceHandlesIndex = 0; for (auto &subDeviceIdToPmtEntry : mapOfSubDeviceIdToPmtObject) { ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; @@ -322,13 +322,13 @@ TEST_F(SysmanDeviceTemperatureFixture, GivenValidTempHandleWhenGettingUnsupporte TEST_F(SysmanDeviceTemperatureFixture, GivenValidateEnumerateRootTelemIndexWhengetRealPathFailsThenFailureReturned) { pFsAccess->mockErrorGetRealPath = ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE; EXPECT_EQ(ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE, - PlatformMonitoringTech::enumerateRootTelemIndex(pFsAccess.get(), rootPciPathOfGpuDevice)); + PlatformMonitoringTech::enumerateRootTelemIndex(pFsAccess.get(), gpuUpstreamPortPath)); pFsAccess->mockErrorListDirectory = ZE_RESULT_ERROR_NOT_AVAILABLE; EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, - PlatformMonitoringTech::enumerateRootTelemIndex(pFsAccess.get(), rootPciPathOfGpuDevice)); + PlatformMonitoringTech::enumerateRootTelemIndex(pFsAccess.get(), gpuUpstreamPortPath)); std::map mapOfSubDeviceIdToPmtObject; - PlatformMonitoringTech::create(deviceHandles, pFsAccess.get(), rootPciPathOfGpuDevice, mapOfSubDeviceIdToPmtObject); + PlatformMonitoringTech::create(deviceHandles, pFsAccess.get(), gpuUpstreamPortPath, mapOfSubDeviceIdToPmtObject); EXPECT_TRUE(mapOfSubDeviceIdToPmtObject.empty()); } @@ -342,7 +342,7 @@ TEST_F(SysmanDeviceTemperatureFixture, GivenValidatePmtReadValueWhenkeyOffsetMap TEST_F(SysmanDeviceTemperatureFixture, GivenCreatePmtObjectsWhenRootTileIndexEnumeratesSuccessfulThenValidatePmtObjectsReceivedAndBranches) { std::map mapOfSubDeviceIdToPmtObject1; - PlatformMonitoringTech::create(deviceHandles, pFsAccess.get(), rootPciPathOfGpuDevice, mapOfSubDeviceIdToPmtObject1); + PlatformMonitoringTech::create(deviceHandles, pFsAccess.get(), gpuUpstreamPortPath, mapOfSubDeviceIdToPmtObject1); for (auto &subDeviceIdToPmtEntry : mapOfSubDeviceIdToPmtObject1) { EXPECT_NE(subDeviceIdToPmtEntry.second, nullptr); EXPECT_EQ(subDeviceIdToPmtEntry.first, 0u); // We know that subdeviceID is zero as core device didnt have any subdevices @@ -352,7 +352,7 @@ TEST_F(SysmanDeviceTemperatureFixture, GivenCreatePmtObjectsWhenRootTileIndexEnu std::map mapOfSubDeviceIdToPmtObject2; std::vector testHandleVector; // If empty device handle vector is provided then empty map is retrieved - PlatformMonitoringTech::create(testHandleVector, pFsAccess.get(), rootPciPathOfGpuDevice, mapOfSubDeviceIdToPmtObject2); + PlatformMonitoringTech::create(testHandleVector, pFsAccess.get(), gpuUpstreamPortPath, mapOfSubDeviceIdToPmtObject2); EXPECT_TRUE(mapOfSubDeviceIdToPmtObject2.empty()); }