mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 22:12:59 +08:00
refactor: Remove duplicate FsAccess class definition
Related-To: NEO-9661 Signed-off-by: Bellekallu Rajkiran <bellekallu.rajkiran@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
b92b5892b8
commit
3349fcaf75
@@ -12,6 +12,7 @@
|
||||
#include "shared/source/helpers/string.h"
|
||||
|
||||
#include "level_zero/sysman/source/shared/firmware_util/sysman_firmware_util.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
|
||||
#include "level_zero/sysman/source/api/diagnostics/sysman_diagnostics_imp.h"
|
||||
#include "level_zero/sysman/source/api/diagnostics/sysman_os_diagnostics.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
class FirmwareUtil;
|
||||
class SysFsAccessInterface;
|
||||
|
||||
class LinuxDiagnosticsImp : public OsDiagnostics, NEO::NonCopyableOrMovableClass {
|
||||
public:
|
||||
@@ -31,8 +31,7 @@ class LinuxDiagnosticsImp : public OsDiagnostics, NEO::NonCopyableOrMovableClass
|
||||
protected:
|
||||
LinuxSysmanImp *pLinuxSysmanImp = nullptr;
|
||||
FirmwareUtil *pFwInterface = nullptr;
|
||||
SysfsAccess *pSysfsAccess = nullptr;
|
||||
FsAccess *pFsAccess = nullptr;
|
||||
SysFsAccessInterface *pSysfsAccess = nullptr;
|
||||
ze_result_t waitForQuiescentCompletion();
|
||||
|
||||
private:
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "level_zero/sysman/source/api/events/sysman_events_imp.h"
|
||||
#include "level_zero/sysman/source/api/memory/linux/sysman_os_memory_imp_prelim.h"
|
||||
#include "level_zero/sysman/source/driver/sysman_driver_handle_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_driver_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h"
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
#pragma once
|
||||
#include "shared/source/helpers/non_copyable_or_moveable.h"
|
||||
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
#include "level_zero/zes_api.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace L0 {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h"
|
||||
|
||||
#include <limits>
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
#include "level_zero/sysman/source/api/fabric_port/sysman_fabric_port_imp.h"
|
||||
#include "level_zero/sysman/source/api/fabric_port/sysman_os_fabric_port.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/helpers/debug_helpers.h"
|
||||
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h"
|
||||
|
||||
#include <cstdio>
|
||||
@@ -45,8 +46,8 @@ ze_result_t LinuxFabricDeviceImp::getThroughput(const zes_fabric_port_id_t portI
|
||||
}
|
||||
|
||||
ze_result_t LinuxFabricDeviceImp::getFabricDevicePath(std::string &fabricDevicePath) {
|
||||
FsAccess *pFsAccess = &pLinuxSysmanImp->getFsAccess();
|
||||
SysfsAccess *pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
|
||||
FsAccessInterface *pFsAccess = &pLinuxSysmanImp->getFsAccess();
|
||||
SysFsAccessInterface *pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
|
||||
std::string devicePciPath("");
|
||||
ze_result_t result = pSysfsAccess->getRealPath("device/", devicePciPath);
|
||||
if (result != ZE_RESULT_SUCCESS) {
|
||||
@@ -81,7 +82,7 @@ ze_result_t LinuxFabricDeviceImp::getFabricDevicePath(std::string &fabricDeviceP
|
||||
}
|
||||
|
||||
void LinuxFabricDeviceImp::getLinkErrorCount(zes_fabric_port_error_counters_t *pErrors, const std::string &fabricDevicePath, const zes_fabric_port_id_t portId) {
|
||||
FsAccess *pFsAccess = &pLinuxSysmanImp->getFsAccess();
|
||||
FsAccessInterface *pFsAccess = &pLinuxSysmanImp->getFsAccess();
|
||||
std::string fabricLinkErrorPath = fabricDevicePath + "/sd." + std::to_string(portId.attachId) + "/port." + std::to_string(portId.portNumber);
|
||||
uint64_t linkErrorCount = 0;
|
||||
std::string linkFailureFile = fabricLinkErrorPath + "/link_failures";
|
||||
@@ -104,7 +105,7 @@ void LinuxFabricDeviceImp::getLinkErrorCount(zes_fabric_port_error_counters_t *p
|
||||
}
|
||||
|
||||
void LinuxFabricDeviceImp::getFwErrorCount(zes_fabric_port_error_counters_t *pErrors, const std::string &fabricDevicePath, const zes_fabric_port_id_t portId) {
|
||||
FsAccess *pFsAccess = &pLinuxSysmanImp->getFsAccess();
|
||||
FsAccessInterface *pFsAccess = &pLinuxSysmanImp->getFsAccess();
|
||||
uint64_t fwErrorCount = 0;
|
||||
std::string fabricFwErrorPath = fabricDevicePath + "/sd." + std::to_string(portId.attachId);
|
||||
std::string fwErrorFile = fabricFwErrorPath + "/fw_error";
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "shared/source/helpers/string.h"
|
||||
|
||||
#include "level_zero/sysman/source/shared/firmware_util/sysman_firmware_util.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/sysman_const.h"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -29,7 +29,7 @@ ze_result_t OsFirmware::getSupportedFwTypes(std::vector<std::string> &supportedF
|
||||
pFwInterface->getDeviceSupportedFwTypes(deviceSupportedFwTypes);
|
||||
}
|
||||
|
||||
FsAccess *pFsAccess = &pLinuxSysmanImp->getFsAccess();
|
||||
FsAccessInterface *pFsAccess = &pLinuxSysmanImp->getFsAccess();
|
||||
std::vector<std::string> mtdDescriptorStrings = {};
|
||||
ze_result_t result = pFsAccess->read(mtdDescriptor, mtdDescriptorStrings);
|
||||
if (result != ZE_RESULT_SUCCESS) {
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace L0 {
|
||||
namespace Sysman {
|
||||
|
||||
class FirmwareUtil;
|
||||
class SysFsAccessInterface;
|
||||
|
||||
class LinuxFirmwareImp : public OsFirmware, NEO::NonCopyableOrMovableClass {
|
||||
public:
|
||||
@@ -28,7 +29,7 @@ class LinuxFirmwareImp : public OsFirmware, NEO::NonCopyableOrMovableClass {
|
||||
|
||||
protected:
|
||||
FirmwareUtil *pFwInterface = nullptr;
|
||||
SysfsAccess *pSysfsAccess = nullptr;
|
||||
SysFsAccessInterface *pSysfsAccess = nullptr;
|
||||
std::string osFwType;
|
||||
};
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "level_zero/sysman/source/api/firmware/linux/sysman_os_firmware_imp.h"
|
||||
#include "level_zero/sysman/source/shared/firmware_util/sysman_firmware_util.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
|
||||
const std::string iafPath = "device/";
|
||||
const std::string iafDirectory = "iaf.";
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
@@ -10,11 +10,12 @@
|
||||
|
||||
#include "level_zero/sysman/source/api/frequency/sysman_frequency_imp.h"
|
||||
#include "level_zero/sysman/source/api/frequency/sysman_os_frequency.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
|
||||
class SysFsAccessInterface;
|
||||
|
||||
class LinuxFrequencyImp : public OsFrequency, NEO::NonCopyableOrMovableClass {
|
||||
public:
|
||||
ze_result_t osFrequencyGetProperties(zes_freq_properties_t &properties) override;
|
||||
@@ -39,7 +40,7 @@ class LinuxFrequencyImp : public OsFrequency, NEO::NonCopyableOrMovableClass {
|
||||
~LinuxFrequencyImp() override = default;
|
||||
|
||||
protected:
|
||||
SysfsAccess *pSysfsAccess = nullptr;
|
||||
SysFsAccessInterface *pSysfsAccess = nullptr;
|
||||
ze_result_t getMin(double &min);
|
||||
ze_result_t setMin(double min);
|
||||
ze_result_t getMax(double &max);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_kmd_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h"
|
||||
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
|
||||
#include "level_zero/sysman/source/api/frequency/sysman_frequency_imp.h"
|
||||
#include "level_zero/sysman/source/api/frequency/sysman_os_frequency.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
|
||||
#include "igfxfmid.h"
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
|
||||
class SysmanKmdInterface;
|
||||
class SysFsAccessInterface;
|
||||
|
||||
class LinuxFrequencyImp : public OsFrequency, NEO::NonCopyableOrMovableClass {
|
||||
public:
|
||||
@@ -43,7 +43,7 @@ class LinuxFrequencyImp : public OsFrequency, NEO::NonCopyableOrMovableClass {
|
||||
|
||||
protected:
|
||||
SysmanKmdInterface *pSysmanKmdInterface = nullptr;
|
||||
SysfsAccess *pSysfsAccess = nullptr;
|
||||
SysFsAccessInterface *pSysfsAccess = nullptr;
|
||||
ze_result_t getMin(double &min);
|
||||
ze_result_t setMin(double min);
|
||||
ze_result_t getMax(double &max);
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "level_zero/sysman/source/api/global_operations/sysman_global_operations_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/pmt/sysman_pmt.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_kmd_interface.h"
|
||||
#include "level_zero/sysman/source/sysman_const.h"
|
||||
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
class SysfsAccess;
|
||||
class SysFsAccessInterface;
|
||||
class FsAccessInterface;
|
||||
class ProcFsAccessInterface;
|
||||
class SysmanKmdInterface;
|
||||
|
||||
class LinuxGlobalOperationsImp : public OsGlobalOperations, NEO::NonCopyableOrMovableClass {
|
||||
@@ -55,9 +57,9 @@ class LinuxGlobalOperationsImp : public OsGlobalOperations, NEO::NonCopyableOrMo
|
||||
DeviceMemStruct deviceMemStructField;
|
||||
};
|
||||
|
||||
FsAccess *pFsAccess = nullptr;
|
||||
ProcfsAccess *pProcfsAccess = nullptr;
|
||||
SysfsAccess *pSysfsAccess = nullptr;
|
||||
FsAccessInterface *pFsAccess = nullptr;
|
||||
ProcFsAccessInterface *pProcfsAccess = nullptr;
|
||||
SysFsAccessInterface *pSysfsAccess = nullptr;
|
||||
LinuxSysmanImp *pLinuxSysmanImp = nullptr;
|
||||
int resetTimeout = 10000; // in milliseconds
|
||||
void releaseSysmanDeviceResources();
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "shared/source/os_interface/linux/system_info.h"
|
||||
|
||||
#include "level_zero/sysman/source/shared/firmware_util/sysman_firmware_util.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_kmd_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h"
|
||||
#include "level_zero/sysman/source/sysman_const.h"
|
||||
|
||||
@@ -12,14 +12,13 @@
|
||||
#include "level_zero/sysman/source/api/memory/sysman_os_memory.h"
|
||||
#include "level_zero/sysman/source/device/sysman_device_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/pmt/sysman_pmt.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
|
||||
class SysfsAccess;
|
||||
class SysFsAccessInterface;
|
||||
struct Device;
|
||||
class PlatformMonitoringTech;
|
||||
class LinuxSysmanImp;
|
||||
@@ -37,7 +36,7 @@ class LinuxMemoryImp : public OsMemory, NEO::NonCopyableOrMovableClass {
|
||||
|
||||
protected:
|
||||
LinuxSysmanImp *pLinuxSysmanImp = nullptr;
|
||||
SysfsAccess *pSysfsAccess = nullptr;
|
||||
SysFsAccessInterface *pSysfsAccess = nullptr;
|
||||
NEO::Drm *pDrm = nullptr;
|
||||
SysmanDeviceImp *pDevice = nullptr;
|
||||
PlatformMonitoringTech *pPmt = nullptr;
|
||||
|
||||
@@ -13,10 +13,12 @@
|
||||
|
||||
#include "level_zero/sysman/source/api/pci/sysman_pci_imp.h"
|
||||
#include "level_zero/sysman/source/api/pci/sysman_pci_utils.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h"
|
||||
#include "level_zero/sysman/source/sysman_const.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
class SysfsAccess;
|
||||
class FsAccess;
|
||||
class SysFsAccessInterface;
|
||||
class LinuxSysmanImp;
|
||||
struct OsSysman;
|
||||
|
||||
@@ -37,7 +36,7 @@ class LinuxPciImp : public OsPci, NEO::NonCopyableOrMovableClass {
|
||||
~LinuxPciImp() override = default;
|
||||
|
||||
protected:
|
||||
L0::Sysman::SysfsAccess *pSysfsAccess = nullptr;
|
||||
L0::Sysman::SysFsAccessInterface *pSysfsAccess = nullptr;
|
||||
L0::Sysman::LinuxSysmanImp *pLinuxSysmanImp = nullptr;
|
||||
bool getPciConfigMemory(std::string pciPath, std::vector<uint8_t> &configMem);
|
||||
decltype(&NEO::SysCalls::pread) preadFunction = NEO::SysCalls::pread;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/sysman_const.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
@@ -10,13 +10,12 @@
|
||||
|
||||
#include "level_zero/sysman/source/api/performance/sysman_os_performance.h"
|
||||
#include "level_zero/sysman/source/api/performance/sysman_performance_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
|
||||
class SysfsAccess;
|
||||
class SysFsAccessInterface;
|
||||
class LinuxPerformanceImp : public OsPerformance, NEO::NonCopyableOrMovableClass {
|
||||
public:
|
||||
ze_result_t osPerformanceGetProperties(zes_perf_properties_t &pProperties) override;
|
||||
@@ -31,7 +30,7 @@ class LinuxPerformanceImp : public OsPerformance, NEO::NonCopyableOrMovableClass
|
||||
~LinuxPerformanceImp() override = default;
|
||||
|
||||
protected:
|
||||
L0::Sysman::SysfsAccess *pSysfsAccess = nullptr;
|
||||
L0::Sysman::SysFsAccessInterface *pSysfsAccess = nullptr;
|
||||
zes_engine_type_flag_t domain = ZES_ENGINE_TYPE_FLAG_OTHER;
|
||||
|
||||
private:
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
|
||||
#include "level_zero/sysman/source/shared/linux/pmt/sysman_pmt.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_kmd_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h"
|
||||
#include "level_zero/sysman/source/sysman_const.h"
|
||||
@@ -19,7 +20,7 @@ namespace Sysman {
|
||||
|
||||
class LinuxPowerImp::PowerLimitRestorer : NEO::NonCopyableOrMovableClass {
|
||||
public:
|
||||
PowerLimitRestorer(L0::Sysman::SysfsAccess *pSysfsAccess, std::string powerLimit) : pSysfsAccess(pSysfsAccess), powerLimit(powerLimit) {
|
||||
PowerLimitRestorer(L0::Sysman::SysFsAccessInterface *pSysfsAccess, std::string powerLimit) : pSysfsAccess(pSysfsAccess), powerLimit(powerLimit) {
|
||||
result = pSysfsAccess->read(powerLimit, powerLimitValue);
|
||||
}
|
||||
|
||||
@@ -35,7 +36,7 @@ class LinuxPowerImp::PowerLimitRestorer : NEO::NonCopyableOrMovableClass {
|
||||
|
||||
protected:
|
||||
ze_result_t result = ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
SysfsAccess *pSysfsAccess = nullptr;
|
||||
SysFsAccessInterface *pSysfsAccess = nullptr;
|
||||
std::string powerLimit = {};
|
||||
uint64_t powerLimitValue = 0;
|
||||
};
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "shared/source/helpers/non_copyable_or_moveable.h"
|
||||
|
||||
#include "level_zero/sysman/source/api/power/sysman_os_power.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
|
||||
#include "igfxfmid.h"
|
||||
|
||||
@@ -20,8 +19,8 @@ namespace L0 {
|
||||
namespace Sysman {
|
||||
|
||||
class SysmanKmdInterface;
|
||||
class SysFsAccessInterface;
|
||||
|
||||
class SysfsAccess;
|
||||
class PlatformMonitoringTech;
|
||||
class LinuxPowerImp : public OsPower, NEO::NonCopyableOrMovableClass {
|
||||
public:
|
||||
@@ -44,7 +43,7 @@ class LinuxPowerImp : public OsPower, NEO::NonCopyableOrMovableClass {
|
||||
|
||||
protected:
|
||||
PlatformMonitoringTech *pPmt = nullptr;
|
||||
SysfsAccess *pSysfsAccess = nullptr;
|
||||
SysFsAccessInterface *pSysfsAccess = nullptr;
|
||||
SysmanKmdInterface *pSysmanKmdInterface = nullptr;
|
||||
|
||||
private:
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "shared/source/helpers/string.h"
|
||||
#include "shared/source/os_interface/linux/system_info.h"
|
||||
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h"
|
||||
|
||||
#include "drm/intel_hwconfig_types.h"
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include "level_zero/sysman/source/api/ras/sysman_os_ras.h"
|
||||
#include "level_zero/sysman/source/device/sysman_device_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/pmu/sysman_pmu_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
#include "level_zero/sysman/source/sysman_const.h"
|
||||
|
||||
#include <map>
|
||||
@@ -24,6 +23,8 @@ namespace Sysman {
|
||||
|
||||
class LinuxSysmanImp;
|
||||
class FirmwareUtil;
|
||||
class FsAccessInterface;
|
||||
class SysFsAccessInterface;
|
||||
|
||||
class LinuxRasSources : NEO::NonCopyableOrMovableClass {
|
||||
public:
|
||||
@@ -43,7 +44,7 @@ class LinuxRasImp : public OsRas, NEO::NonCopyableOrMovableClass {
|
||||
|
||||
protected:
|
||||
zes_ras_error_type_t osRasErrorType = {};
|
||||
FsAccess *pFsAccess = nullptr;
|
||||
FsAccessInterface *pFsAccess = nullptr;
|
||||
LinuxSysmanImp *pLinuxSysmanImp = nullptr;
|
||||
std::vector<std::unique_ptr<L0::Sysman::LinuxRasSources>> rasSources = {};
|
||||
|
||||
@@ -67,8 +68,8 @@ class LinuxRasSourceGt : public LinuxRasSources {
|
||||
LinuxSysmanImp *pLinuxSysmanImp = nullptr;
|
||||
zes_ras_error_type_t osRasErrorType = {};
|
||||
PmuInterface *pPmuInterface = nullptr;
|
||||
FsAccess *pFsAccess = nullptr;
|
||||
SysfsAccess *pSysfsAccess = nullptr;
|
||||
FsAccessInterface *pFsAccess = nullptr;
|
||||
SysFsAccessInterface *pSysfsAccess = nullptr;
|
||||
|
||||
private:
|
||||
void initRasErrors(ze_bool_t clear);
|
||||
|
||||
@@ -8,9 +8,11 @@
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
|
||||
#include "level_zero/sysman/source/api/ras/linux/sysman_os_ras_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
@@ -59,7 +61,7 @@ static ze_result_t readI915EventsDirectory(LinuxSysmanImp *pLinuxSysmanImp, std:
|
||||
// /sys/devices/i915_0000_01_00.0/events/
|
||||
// all events are enumerated in sysfs at /sys/devices/i915_0000_01_00.0/events/
|
||||
// For above example device is in PCI slot 0000:01:00.0:
|
||||
SysfsAccess *pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
|
||||
SysFsAccessInterface *pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
|
||||
const std::string deviceDir("device");
|
||||
const std::string sysDevicesDir("/sys/devices/");
|
||||
std::string bdfDir;
|
||||
@@ -76,7 +78,7 @@ static ze_result_t readI915EventsDirectory(LinuxSysmanImp *pLinuxSysmanImp, std:
|
||||
if (eventDirectory != nullptr) {
|
||||
*eventDirectory = sysfsNode;
|
||||
}
|
||||
FsAccess *pFsAccess = &pLinuxSysmanImp->getFsAccess();
|
||||
FsAccessInterface *pFsAccess = &pLinuxSysmanImp->getFsAccess();
|
||||
result = pFsAccess->listDirectory(sysfsNode, listOfEvents);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Failed to list directories from %s and returning error:0x%x \n", __FUNCTION__, sysfsNode.c_str(), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/os_interface/linux/engine_info.h"
|
||||
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_kmd_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h"
|
||||
#include "level_zero/sysman/source/sysman_const.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
class SysfsAccess;
|
||||
class SysFsAccessInterface;
|
||||
|
||||
// Following below mappings of scheduler properties with sysfs nodes
|
||||
// zes_sched_timeslice_properties_t.interval = timeslice_duration_ms
|
||||
@@ -39,7 +39,7 @@ class LinuxSchedulerImp : public OsScheduler, NEO::NonCopyableOrMovableClass {
|
||||
|
||||
protected:
|
||||
LinuxSysmanImp *pLinuxSysmanImp = nullptr;
|
||||
SysfsAccess *pSysfsAccess = nullptr;
|
||||
SysFsAccessInterface *pSysfsAccess = nullptr;
|
||||
zes_engine_type_flag_t engineType = ZES_ENGINE_TYPE_FLAG_OTHER;
|
||||
ze_bool_t onSubdevice = 0;
|
||||
uint32_t subdeviceId = 0;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "shared/source/os_interface/linux/i915_prelim.h"
|
||||
|
||||
#include "level_zero/sysman/source/api/scheduler/linux/sysman_os_scheduler_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h"
|
||||
#include "level_zero/sysman/source/sysman_const.h"
|
||||
|
||||
@@ -513,7 +513,7 @@ static ze_result_t getNumEngineTypeAndInstancesForSubDevices(std::map<zes_engine
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
static ze_result_t getNumEngineTypeAndInstancesForDevice(std::map<zes_engine_type_flag_t, std::vector<std::string>> &mapOfEngines, SysfsAccess *pSysfsAccess) {
|
||||
static ze_result_t getNumEngineTypeAndInstancesForDevice(std::map<zes_engine_type_flag_t, std::vector<std::string>> &mapOfEngines, SysFsAccessInterface *pSysfsAccess) {
|
||||
std::vector<std::string> localListOfAllEngines = {};
|
||||
auto result = pSysfsAccess->scanDirEntries(LinuxSchedulerImp::engineDir, localListOfAllEngines);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_kmd_interface.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
#include "level_zero/sysman/source/api/standby/sysman_os_standby.h"
|
||||
#include "level_zero/sysman/source/api/standby/sysman_standby_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
#include "level_zero/sysman/source/api/temperature/sysman_os_temperature.h"
|
||||
#include "level_zero/sysman/source/shared/linux/pmt/sysman_pmt.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
|
||||
#include "igfxfmid.h"
|
||||
|
||||
|
||||
@@ -10,8 +10,6 @@ if(UNIX)
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zes_os_sysman_imp.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zes_os_sysman_imp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sysman_fs_access.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sysman_fs_access.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sysman_hw_device_id_linux.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sysman_hw_device_id_linux.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zes_os_sysman_driver_imp.cpp
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "shared/source/os_interface/linux/file_descriptor.h"
|
||||
|
||||
#include "level_zero/sysman/source/device/sysman_device_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -72,7 +73,7 @@ bool compareTelemNodes(std::string &telemNode1, std::string &telemNode2) {
|
||||
}
|
||||
|
||||
// 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) {
|
||||
static bool isValidTelemNode(FsAccessInterface *pFsAccess, const std::string &gpuUpstreamPortPath, const std::string sysfsTelemNode) {
|
||||
std::string realPathOfTelemNode;
|
||||
auto result = pFsAccess->getRealPath(sysfsTelemNode, realPathOfTelemNode);
|
||||
if (result != ZE_RESULT_SUCCESS) {
|
||||
@@ -88,7 +89,7 @@ static bool isValidTelemNode(FsAccess *pFsAccess, const std::string &gpuUpstream
|
||||
return (realPathOfTelemNode.compare(0, gpuUpstreamPortPath.size(), gpuUpstreamPortPath) == 0);
|
||||
}
|
||||
|
||||
ze_result_t PlatformMonitoringTech::enumerateRootTelemIndex(FsAccess *pFsAccess, std::string &gpuUpstreamPortPath) {
|
||||
ze_result_t PlatformMonitoringTech::enumerateRootTelemIndex(FsAccessInterface *pFsAccess, std::string &gpuUpstreamPortPath) {
|
||||
std::vector<std::string> listOfTelemNodes;
|
||||
auto result = pFsAccess->listDirectory(baseTelemSysFS, listOfTelemNodes);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
@@ -118,7 +119,7 @@ ze_result_t PlatformMonitoringTech::enumerateRootTelemIndex(FsAccess *pFsAccess,
|
||||
return ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE;
|
||||
}
|
||||
|
||||
ze_result_t PlatformMonitoringTech::init(FsAccess *pFsAccess, const std::string &gpuUpstreamPortPath, PRODUCT_FAMILY productFamily) {
|
||||
ze_result_t PlatformMonitoringTech::init(FsAccessInterface *pFsAccess, const std::string &gpuUpstreamPortPath, PRODUCT_FAMILY productFamily) {
|
||||
std::string telemNode = telem + std::to_string(rootDeviceTelemNodeIndex);
|
||||
// For XE_HP_SDV and PVC single tile devices, telemetry info is retrieved from
|
||||
// tile's telem node rather from root device telem node.
|
||||
@@ -167,11 +168,11 @@ ze_result_t PlatformMonitoringTech::init(FsAccess *pFsAccess, const std::string
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
PlatformMonitoringTech::PlatformMonitoringTech(FsAccess *pFsAccess, ze_bool_t onSubdevice,
|
||||
PlatformMonitoringTech::PlatformMonitoringTech(FsAccessInterface *pFsAccess, ze_bool_t onSubdevice,
|
||||
uint32_t subdeviceId) : subdeviceId(subdeviceId), isSubdevice(onSubdevice) {
|
||||
}
|
||||
|
||||
void PlatformMonitoringTech::doInitPmtObject(FsAccess *pFsAccess, uint32_t subdeviceId, PlatformMonitoringTech *pPmt,
|
||||
void PlatformMonitoringTech::doInitPmtObject(FsAccessInterface *pFsAccess, uint32_t subdeviceId, PlatformMonitoringTech *pPmt,
|
||||
const std::string &gpuUpstreamPortPath,
|
||||
std::map<uint32_t, L0::Sysman::PlatformMonitoringTech *> &mapOfSubDeviceIdToPmtObject, PRODUCT_FAMILY productFamily) {
|
||||
if (pPmt->init(pFsAccess, gpuUpstreamPortPath, productFamily) == ZE_RESULT_SUCCESS) {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "shared/source/helpers/non_copyable_or_moveable.h"
|
||||
#include "shared/source/os_interface/linux/sys_calls.h"
|
||||
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
#include "level_zero/zes_api.h"
|
||||
|
||||
#include "igfxfmid.h"
|
||||
|
||||
@@ -21,17 +21,18 @@
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
class LinuxSysmanImp;
|
||||
class FsAccessInterface;
|
||||
|
||||
class PlatformMonitoringTech : NEO::NonCopyableOrMovableClass {
|
||||
public:
|
||||
PlatformMonitoringTech() = delete;
|
||||
PlatformMonitoringTech(FsAccess *pFsAccess, ze_bool_t onSubdevice, uint32_t subdeviceId);
|
||||
PlatformMonitoringTech(FsAccessInterface *pFsAccess, ze_bool_t onSubdevice, uint32_t subdeviceId);
|
||||
virtual ~PlatformMonitoringTech();
|
||||
|
||||
virtual ze_result_t readValue(const std::string key, uint32_t &value);
|
||||
virtual ze_result_t readValue(const std::string key, uint64_t &value);
|
||||
std::string getGuid();
|
||||
static ze_result_t enumerateRootTelemIndex(FsAccess *pFsAccess, std::string &gpuUpstreamPortPath);
|
||||
static ze_result_t enumerateRootTelemIndex(FsAccessInterface *pFsAccess, std::string &gpuUpstreamPortPath);
|
||||
static void create(LinuxSysmanImp *pLinuxSysmanImp, std::string &gpuUpstreamPortPath,
|
||||
std::map<uint32_t, L0::Sysman::PlatformMonitoringTech *> &mapOfSubDeviceIdToPmtObject);
|
||||
static ze_result_t getKeyOffsetMap(std::string guid, std::map<std::string, uint64_t> &keyOffsetMap);
|
||||
@@ -41,8 +42,8 @@ class PlatformMonitoringTech : NEO::NonCopyableOrMovableClass {
|
||||
std::string telemetryDeviceEntry{};
|
||||
std::map<std::string, uint64_t> keyOffsetMap;
|
||||
std::string guid;
|
||||
ze_result_t init(FsAccess *pFsAccess, const std::string &gpuUpstreamPortPath, PRODUCT_FAMILY productFamily);
|
||||
static void doInitPmtObject(FsAccess *pFsAccess, uint32_t subdeviceId, PlatformMonitoringTech *pPmt, const std::string &gpuUpstreamPortPath,
|
||||
ze_result_t init(FsAccessInterface *pFsAccess, const std::string &gpuUpstreamPortPath, PRODUCT_FAMILY productFamily);
|
||||
static void doInitPmtObject(FsAccessInterface *pFsAccess, uint32_t subdeviceId, PlatformMonitoringTech *pPmt, const std::string &gpuUpstreamPortPath,
|
||||
std::map<uint32_t, L0::Sysman::PlatformMonitoringTech *> &mapOfSubDeviceIdToPmtObject, PRODUCT_FAMILY productFamily);
|
||||
decltype(&NEO::SysCalls::pread) preadFunction = NEO::SysCalls::pread;
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
#pragma once
|
||||
#include "level_zero/sysman/source/shared/linux/pmu/sysman_pmu.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h"
|
||||
|
||||
#include <linux/perf_event.h>
|
||||
|
||||
@@ -1,548 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
|
||||
#include <climits>
|
||||
|
||||
#include <array>
|
||||
#include <cerrno>
|
||||
#include <csignal>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
|
||||
static ze_result_t getResult(int err) {
|
||||
if ((EPERM == err) || (EACCES == err)) {
|
||||
return ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS;
|
||||
} else if (ENOENT == err) {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
} else if (EBUSY == err) {
|
||||
return ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE;
|
||||
} else {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
void FdCache::eraseLeastUsedEntryFromCache() {
|
||||
auto it = fdMap.begin();
|
||||
uint32_t fdCountRef = it->second.second;
|
||||
std::map<std::string, std::pair<int, uint32_t>>::iterator leastUsedIterator = it;
|
||||
while (++it != fdMap.end()) {
|
||||
if (it->second.second < fdCountRef) {
|
||||
fdCountRef = it->second.second;
|
||||
leastUsedIterator = it;
|
||||
}
|
||||
}
|
||||
NEO::SysCalls::close(leastUsedIterator->second.first);
|
||||
fdMap.erase(leastUsedIterator);
|
||||
}
|
||||
|
||||
int FdCache::getFd(std::string file) {
|
||||
int fd = -1;
|
||||
if (fdMap.find(file) == fdMap.end()) {
|
||||
fd = NEO::SysCalls::open(file.c_str(), O_RDONLY);
|
||||
if (fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
if (fdMap.size() == maxSize) {
|
||||
eraseLeastUsedEntryFromCache();
|
||||
}
|
||||
fdMap[file] = std::make_pair(fd, 1);
|
||||
} else {
|
||||
auto &fdPair = fdMap[file];
|
||||
fdPair.second++;
|
||||
}
|
||||
return fdMap[file].first;
|
||||
}
|
||||
|
||||
FdCache::~FdCache() {
|
||||
for (auto it = fdMap.begin(); it != fdMap.end(); ++it) {
|
||||
NEO::SysCalls::close(it->second.first);
|
||||
}
|
||||
fdMap.clear();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
ze_result_t FsAccess::readValue(const std::string file, T &val) {
|
||||
|
||||
std::string readVal(64, '\0');
|
||||
int fd = pFdCache->getFd(file);
|
||||
if (fd < 0) {
|
||||
return getResult(errno);
|
||||
}
|
||||
|
||||
ssize_t bytesRead = NEO::SysCalls::pread(fd, readVal.data(), readVal.size(), 0);
|
||||
if (bytesRead < 0) {
|
||||
return getResult(errno);
|
||||
}
|
||||
|
||||
std::istringstream stream(readVal);
|
||||
stream >> val;
|
||||
if (stream.fail()) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
// Generic Filesystem Access
|
||||
FsAccess::FsAccess() {
|
||||
pFdCache = std::make_unique<FdCache>();
|
||||
}
|
||||
|
||||
FsAccess::FsAccess(const FsAccess &fsAccess) : pFdCache(std::unique_ptr<FdCache>(new FdCache())) {}
|
||||
|
||||
FsAccess *FsAccess::create() {
|
||||
return new FsAccess();
|
||||
}
|
||||
|
||||
ze_result_t FsAccess::read(const std::string file, uint64_t &val) {
|
||||
return readValue<uint64_t>(file, val);
|
||||
}
|
||||
|
||||
ze_result_t FsAccess::read(const std::string file, double &val) {
|
||||
return readValue<double>(file, val);
|
||||
}
|
||||
|
||||
ze_result_t FsAccess::read(const std::string file, int32_t &val) {
|
||||
return readValue<int32_t>(file, val);
|
||||
}
|
||||
|
||||
ze_result_t FsAccess::read(const std::string file, uint32_t &val) {
|
||||
return readValue<uint32_t>(file, val);
|
||||
}
|
||||
|
||||
ze_result_t FsAccess::read(const std::string file, std::string &val) {
|
||||
// Read a single line from text file without trailing newline
|
||||
std::ifstream fs;
|
||||
val.clear();
|
||||
|
||||
fs.open(file.c_str());
|
||||
if (fs.fail()) {
|
||||
return getResult(errno);
|
||||
}
|
||||
fs >> val;
|
||||
if (fs.fail()) {
|
||||
fs.close();
|
||||
return getResult(errno);
|
||||
}
|
||||
fs.close();
|
||||
// Strip trailing newline
|
||||
if (val.back() == '\n') {
|
||||
val.pop_back();
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t FsAccess::read(const std::string file, std::vector<std::string> &val) {
|
||||
// Read a entire text file, one line per vector entry
|
||||
std::string line;
|
||||
std::ifstream fs;
|
||||
val.clear();
|
||||
|
||||
fs.open(file.c_str());
|
||||
if (fs.fail()) {
|
||||
return getResult(errno);
|
||||
}
|
||||
while (std::getline(fs, line)) {
|
||||
if (fs.fail()) {
|
||||
fs.close();
|
||||
return getResult(errno);
|
||||
}
|
||||
if (line.back() == '\n') {
|
||||
line.pop_back();
|
||||
}
|
||||
val.push_back(line);
|
||||
}
|
||||
fs.close();
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t FsAccess::write(const std::string file, const std::string val) {
|
||||
std::ofstream sysfs;
|
||||
|
||||
sysfs.open(file.c_str());
|
||||
if (sysfs.fail()) {
|
||||
return getResult(errno);
|
||||
}
|
||||
sysfs << val << std::endl;
|
||||
if (sysfs.fail()) {
|
||||
sysfs.close();
|
||||
return getResult(errno);
|
||||
}
|
||||
sysfs.close();
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t FsAccess::canRead(const std::string file) {
|
||||
struct stat sb;
|
||||
if (statSyscall(file.c_str(), &sb) != 0) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
if (sb.st_mode & S_IRUSR) {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
return ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS;
|
||||
}
|
||||
|
||||
ze_result_t FsAccess::canWrite(const std::string file) {
|
||||
struct stat sb;
|
||||
if (statSyscall(file.c_str(), &sb) != 0) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
if (sb.st_mode & S_IWUSR) {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
return ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS;
|
||||
}
|
||||
|
||||
bool FsAccess::fileExists(const std::string file) {
|
||||
if (NEO::SysCalls::access(file.c_str(), F_OK)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
ze_result_t FsAccess::getFileMode(const std::string file, ::mode_t &mode) {
|
||||
struct stat sb;
|
||||
if (0 != stat(file.c_str(), &sb)) {
|
||||
return getResult(errno);
|
||||
}
|
||||
mode = sb.st_mode;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t FsAccess::readSymLink(const std::string path, std::string &val) {
|
||||
// returns the value of symlink at path
|
||||
char buf[PATH_MAX];
|
||||
ssize_t len = NEO::SysCalls::readlink(path.c_str(), buf, PATH_MAX - 1);
|
||||
if (len < 0) {
|
||||
return getResult(errno);
|
||||
}
|
||||
buf[len] = '\0';
|
||||
val = std::string(buf);
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t FsAccess::getRealPath(const std::string path, std::string &val) {
|
||||
// returns the real file path after resolving all symlinks in path
|
||||
char buf[PATH_MAX];
|
||||
char *realPath = NEO::SysCalls::realpath(path.c_str(), buf);
|
||||
if (!realPath) {
|
||||
return getResult(errno);
|
||||
}
|
||||
val = std::string(buf);
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t FsAccess::listDirectory(const std::string path, std::vector<std::string> &list) {
|
||||
list.clear();
|
||||
::DIR *procDir = ::opendir(path.c_str());
|
||||
if (!procDir) {
|
||||
return getResult(errno);
|
||||
}
|
||||
struct ::dirent *ent;
|
||||
int err = 0;
|
||||
// readdir doesn't clear errno, so make sure it is clear
|
||||
errno = 0;
|
||||
while (NULL != (ent = ::readdir(procDir))) {
|
||||
// Ignore . and ..
|
||||
std::string name = std::string(ent->d_name);
|
||||
if (!name.compare(".") || !name.compare("..")) {
|
||||
errno = 0;
|
||||
continue;
|
||||
}
|
||||
list.push_back(std::string(ent->d_name));
|
||||
errno = 0;
|
||||
}
|
||||
err = errno;
|
||||
::closedir(procDir);
|
||||
// Check if in above while loop, readdir encountered any error.
|
||||
if ((err != 0) && (err != ENOENT)) {
|
||||
list.clear();
|
||||
return getResult(err);
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
std::string FsAccess::getBaseName(const std::string path) {
|
||||
size_t pos = path.rfind("/");
|
||||
if (std::string::npos == pos) {
|
||||
return path;
|
||||
}
|
||||
return path.substr(pos + 1, std::string::npos);
|
||||
}
|
||||
|
||||
std::string FsAccess::getDirName(const std::string path) {
|
||||
size_t pos = path.rfind("/");
|
||||
if (std::string::npos == pos) {
|
||||
return std::string("");
|
||||
}
|
||||
// Include trailing slash
|
||||
return path.substr(0, pos);
|
||||
}
|
||||
|
||||
bool FsAccess::isRootUser() {
|
||||
return (geteuid() == 0);
|
||||
}
|
||||
|
||||
bool FsAccess::directoryExists(const std::string path) {
|
||||
if (accessSyscall(path.c_str(), F_OK)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Procfs Access
|
||||
const std::string ProcfsAccess::procDir = "/proc/";
|
||||
const std::string ProcfsAccess::fdDir = "/fd/";
|
||||
|
||||
std::string ProcfsAccess::fullPath(const ::pid_t pid) {
|
||||
// Returns the full path for proc entry for process pid
|
||||
return std::string(procDir + std::to_string(pid));
|
||||
}
|
||||
|
||||
std::string ProcfsAccess::fdDirPath(const ::pid_t pid) {
|
||||
// Returns the full path to file descritpor directory
|
||||
// for process pid
|
||||
return std::string(fullPath(pid) + fdDir);
|
||||
}
|
||||
|
||||
std::string ProcfsAccess::fullFdPath(const ::pid_t pid, const int fd) {
|
||||
// Returns the full path for filedescriptor fd
|
||||
// for process pid
|
||||
return std::string(fdDirPath(pid) + std::to_string(fd));
|
||||
}
|
||||
|
||||
ProcfsAccess *ProcfsAccess::create() {
|
||||
return new ProcfsAccess();
|
||||
}
|
||||
|
||||
ze_result_t ProcfsAccess::listProcesses(std::vector<::pid_t> &list) {
|
||||
// Returns a vector with all the active process ids in the system
|
||||
list.clear();
|
||||
std::vector<std::string> dir;
|
||||
ze_result_t result = FsAccess::listDirectory(procDir, dir);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
return result;
|
||||
}
|
||||
for (auto &&file : dir) {
|
||||
::pid_t pid;
|
||||
std::istringstream stream(file);
|
||||
stream >> pid;
|
||||
if (stream.fail()) {
|
||||
// Non numeric filename, not a process, skip
|
||||
continue;
|
||||
}
|
||||
list.push_back(pid);
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t ProcfsAccess::getFileDescriptors(const ::pid_t pid, std::vector<int> &list) {
|
||||
// Returns a vector with all the filedescriptor numbers opened by a pid
|
||||
list.clear();
|
||||
std::vector<std::string> dir;
|
||||
ze_result_t result = FsAccess::listDirectory(fdDirPath(pid), dir);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
return result;
|
||||
}
|
||||
for (auto &&file : dir) {
|
||||
int fd;
|
||||
std::istringstream stream(file);
|
||||
stream >> fd;
|
||||
if (stream.fail()) {
|
||||
// Non numeric filename, not a file descriptor
|
||||
continue;
|
||||
}
|
||||
list.push_back(fd);
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t ProcfsAccess::getFileName(const ::pid_t pid, const int fd, std::string &val) {
|
||||
// Given a process id and a file descriptor number
|
||||
// return full name of the open file.
|
||||
// NOTE: For sockets, the name will be of the format "socket:[nnnnnnn]"
|
||||
return FsAccess::readSymLink(fullFdPath(pid, fd), val);
|
||||
}
|
||||
|
||||
bool ProcfsAccess::isAlive(const ::pid_t pid) {
|
||||
return FsAccess::fileExists(fullPath(pid));
|
||||
}
|
||||
|
||||
void ProcfsAccess::kill(const ::pid_t pid) {
|
||||
::kill(pid, SIGKILL);
|
||||
}
|
||||
|
||||
::pid_t ProcfsAccess::myProcessId() {
|
||||
return ::getpid();
|
||||
}
|
||||
|
||||
// Sysfs Access
|
||||
const std::string SysfsAccess::drmPath = "/sys/class/drm/";
|
||||
const std::string SysfsAccess::devicesPath = "device/drm/";
|
||||
const std::string SysfsAccess::primaryDevName = "card";
|
||||
const std::string SysfsAccess::drmDriverDevNodeDir = "/dev/dri/";
|
||||
const std::string SysfsAccess::intelGpuBindEntry = "/sys/bus/pci/drivers/i915/bind";
|
||||
const std::string SysfsAccess::intelGpuUnbindEntry = "/sys/bus/pci/drivers/i915/unbind";
|
||||
|
||||
std::string SysfsAccess::fullPath(const std::string file) {
|
||||
// Prepend sysfs directory path for this device
|
||||
return std::string(dirname + file);
|
||||
}
|
||||
|
||||
SysfsAccess::SysfsAccess(const std::string dev) {
|
||||
// dev could be either /dev/dri/cardX or /dev/dri/renderDX
|
||||
std::string fileName = FsAccess::getBaseName(dev);
|
||||
std::string devicesDir = drmPath + fileName + std::string("/") + devicesPath;
|
||||
|
||||
FsAccess::listDirectory(devicesDir, deviceNames);
|
||||
for (auto &&next : deviceNames) {
|
||||
if (!next.compare(0, primaryDevName.length(), primaryDevName)) {
|
||||
dirname = drmPath + next + std::string("/");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SysfsAccess *SysfsAccess::create(const std::string dev) {
|
||||
return new SysfsAccess(dev);
|
||||
}
|
||||
|
||||
ze_result_t SysfsAccess::canRead(const std::string file) {
|
||||
// Prepend sysfs directory path and call the base canRead
|
||||
return FsAccess::canRead(fullPath(file));
|
||||
}
|
||||
|
||||
ze_result_t SysfsAccess::canWrite(const std::string file) {
|
||||
// Prepend sysfs directory path and call the base canWrite
|
||||
return FsAccess::canWrite(fullPath(file));
|
||||
}
|
||||
|
||||
ze_result_t SysfsAccess::getFileMode(const std::string file, ::mode_t &mode) {
|
||||
// Prepend sysfs directory path and call the base getFileMode
|
||||
return FsAccess::getFileMode(fullPath(file), mode);
|
||||
}
|
||||
|
||||
ze_result_t SysfsAccess::read(const std::string file, std::string &val) {
|
||||
// Prepend sysfs directory path and call the base read
|
||||
return FsAccess::read(fullPath(file).c_str(), val);
|
||||
}
|
||||
|
||||
ze_result_t SysfsAccess::read(const std::string file, int32_t &val) {
|
||||
return FsAccess::read(fullPath(file), val);
|
||||
}
|
||||
|
||||
ze_result_t SysfsAccess::read(const std::string file, uint32_t &val) {
|
||||
return FsAccess::read(fullPath(file), val);
|
||||
}
|
||||
|
||||
ze_result_t SysfsAccess::read(const std::string file, double &val) {
|
||||
return FsAccess::read(fullPath(file), val);
|
||||
}
|
||||
|
||||
ze_result_t SysfsAccess::read(const std::string file, uint64_t &val) {
|
||||
return FsAccess::read(fullPath(file), val);
|
||||
}
|
||||
|
||||
ze_result_t SysfsAccess::read(const std::string file, std::vector<std::string> &val) {
|
||||
// Prepend sysfs directory path and call the base read
|
||||
return FsAccess::read(fullPath(file), val);
|
||||
}
|
||||
|
||||
ze_result_t SysfsAccess::write(const std::string file, const std::string val) {
|
||||
// Prepend sysfs directory path and call the base write
|
||||
return FsAccess::write(fullPath(file).c_str(), val);
|
||||
}
|
||||
|
||||
ze_result_t SysfsAccess::write(const std::string file, const int val) {
|
||||
std::ostringstream stream;
|
||||
stream << val;
|
||||
|
||||
if (stream.fail()) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
return FsAccess::write(fullPath(file), stream.str());
|
||||
}
|
||||
|
||||
ze_result_t SysfsAccess::write(const std::string file, const double val) {
|
||||
std::ostringstream stream;
|
||||
stream << val;
|
||||
|
||||
if (stream.fail()) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
return FsAccess::write(fullPath(file), stream.str());
|
||||
}
|
||||
|
||||
ze_result_t SysfsAccess::write(const std::string file, const uint64_t val) {
|
||||
std::ostringstream stream;
|
||||
stream << val;
|
||||
|
||||
if (stream.fail()) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
return FsAccess::write(fullPath(file), stream.str());
|
||||
}
|
||||
|
||||
ze_result_t SysfsAccess::scanDirEntries(const std::string path, std::vector<std::string> &list) {
|
||||
list.clear();
|
||||
return FsAccess::listDirectory(fullPath(path).c_str(), list);
|
||||
}
|
||||
|
||||
ze_result_t SysfsAccess::readSymLink(const std::string path, std::string &val) {
|
||||
// Prepend sysfs directory path and call the base readSymLink
|
||||
return FsAccess::readSymLink(fullPath(path).c_str(), val);
|
||||
}
|
||||
|
||||
ze_result_t SysfsAccess::getRealPath(const std::string path, std::string &val) {
|
||||
// Prepend sysfs directory path and call the base getRealPath
|
||||
return FsAccess::getRealPath(fullPath(path).c_str(), val);
|
||||
}
|
||||
|
||||
ze_result_t SysfsAccess::bindDevice(std::string device) {
|
||||
return FsAccess::write(intelGpuBindEntry, device);
|
||||
}
|
||||
|
||||
ze_result_t SysfsAccess::unbindDevice(std::string device) {
|
||||
return FsAccess::write(intelGpuUnbindEntry, device);
|
||||
}
|
||||
|
||||
bool SysfsAccess::fileExists(const std::string file) {
|
||||
// Prepend sysfs directory path and call the base fileExists
|
||||
return FsAccess::fileExists(fullPath(file).c_str());
|
||||
}
|
||||
|
||||
bool SysfsAccess::directoryExists(const std::string path) {
|
||||
return FsAccess::directoryExists(fullPath(path).c_str());
|
||||
}
|
||||
|
||||
bool SysfsAccess::isMyDeviceFile(const std::string dev) {
|
||||
// dev is a full pathname.
|
||||
if (getDirName(dev).compare(drmDriverDevNodeDir)) {
|
||||
for (auto &&next : deviceNames) {
|
||||
if (!getBaseName(dev).compare(next)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SysfsAccess::isRootUser() {
|
||||
return FsAccess::isRootUser();
|
||||
}
|
||||
|
||||
} // namespace Sysman
|
||||
} // namespace L0
|
||||
@@ -1,160 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/os_interface/linux/sys_calls.h"
|
||||
|
||||
#include "level_zero/ze_api.h"
|
||||
#include "level_zero/zet_api.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/sysmacros.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
|
||||
class FdCache {
|
||||
public:
|
||||
FdCache() = default;
|
||||
~FdCache();
|
||||
|
||||
static const int maxSize = 10;
|
||||
int getFd(std::string file);
|
||||
|
||||
protected:
|
||||
// Map of File name to pair of file descriptor and reference count to file.
|
||||
std::map<std::string, std::pair<int, uint32_t>> fdMap = {};
|
||||
|
||||
private:
|
||||
void eraseLeastUsedEntryFromCache();
|
||||
};
|
||||
|
||||
class FsAccess {
|
||||
public:
|
||||
static FsAccess *create();
|
||||
FsAccess(const FsAccess &fsAccess);
|
||||
FsAccess &operator=(const FsAccess &) = delete;
|
||||
virtual ~FsAccess() = default;
|
||||
|
||||
virtual ze_result_t canRead(const std::string file);
|
||||
virtual ze_result_t canWrite(const std::string file);
|
||||
virtual ze_result_t getFileMode(const std::string file, ::mode_t &mode);
|
||||
|
||||
virtual ze_result_t read(const std::string file, uint64_t &val);
|
||||
virtual ze_result_t read(const std::string file, std::string &val);
|
||||
virtual ze_result_t read(const std::string file, std::vector<std::string> &val);
|
||||
virtual ze_result_t read(const std::string file, double &val);
|
||||
virtual ze_result_t read(const std::string file, uint32_t &val);
|
||||
virtual ze_result_t read(const std::string file, int32_t &val);
|
||||
|
||||
virtual ze_result_t write(const std::string file, const std::string val);
|
||||
|
||||
virtual ze_result_t readSymLink(const std::string path, std::string &buf);
|
||||
virtual ze_result_t getRealPath(const std::string path, std::string &buf);
|
||||
virtual ze_result_t listDirectory(const std::string path, std::vector<std::string> &list);
|
||||
virtual bool isRootUser();
|
||||
std::string getBaseName(const std::string path);
|
||||
std::string getDirName(const std::string path);
|
||||
virtual bool fileExists(const std::string file);
|
||||
virtual bool directoryExists(const std::string path);
|
||||
|
||||
protected:
|
||||
FsAccess();
|
||||
decltype(&NEO::SysCalls::access) accessSyscall = NEO::SysCalls::access;
|
||||
decltype(&stat) statSyscall = stat;
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
ze_result_t readValue(const std::string file, T &val);
|
||||
std::unique_ptr<FdCache> pFdCache = nullptr;
|
||||
};
|
||||
|
||||
class ProcfsAccess : private FsAccess {
|
||||
public:
|
||||
static ProcfsAccess *create();
|
||||
~ProcfsAccess() override = default;
|
||||
|
||||
MOCKABLE_VIRTUAL ze_result_t listProcesses(std::vector<::pid_t> &list);
|
||||
MOCKABLE_VIRTUAL ::pid_t myProcessId();
|
||||
MOCKABLE_VIRTUAL ze_result_t getFileDescriptors(const ::pid_t pid, std::vector<int> &list);
|
||||
MOCKABLE_VIRTUAL ze_result_t getFileName(const ::pid_t pid, const int fd, std::string &val);
|
||||
MOCKABLE_VIRTUAL bool isAlive(const ::pid_t pid);
|
||||
MOCKABLE_VIRTUAL void kill(const ::pid_t pid);
|
||||
|
||||
protected:
|
||||
ProcfsAccess() = default;
|
||||
|
||||
private:
|
||||
std::string fullPath(const ::pid_t pid);
|
||||
std::string fdDirPath(const ::pid_t pid);
|
||||
std::string fullFdPath(const ::pid_t pid, const int fd);
|
||||
static const std::string procDir;
|
||||
static const std::string fdDir;
|
||||
};
|
||||
|
||||
class SysfsAccess : protected FsAccess {
|
||||
public:
|
||||
static SysfsAccess *create(const std::string file);
|
||||
SysfsAccess() = default;
|
||||
~SysfsAccess() override = default;
|
||||
|
||||
ze_result_t canRead(const std::string file) override;
|
||||
ze_result_t canWrite(const std::string file) override;
|
||||
ze_result_t getFileMode(const std::string file, ::mode_t &mode) override;
|
||||
|
||||
ze_result_t read(const std::string file, std::string &val) override;
|
||||
ze_result_t read(const std::string file, int32_t &val) override;
|
||||
ze_result_t read(const std::string file, uint32_t &val) override;
|
||||
ze_result_t read(const std::string file, uint64_t &val) override;
|
||||
ze_result_t read(const std::string file, double &val) override;
|
||||
ze_result_t read(const std::string file, std::vector<std::string> &val) override;
|
||||
|
||||
ze_result_t write(const std::string file, const std::string val) override;
|
||||
MOCKABLE_VIRTUAL ze_result_t write(const std::string file, const int val);
|
||||
MOCKABLE_VIRTUAL ze_result_t write(const std::string file, const uint64_t val);
|
||||
MOCKABLE_VIRTUAL ze_result_t write(const std::string file, const double val);
|
||||
ze_result_t write(const std::string file, std::vector<std::string> val);
|
||||
|
||||
MOCKABLE_VIRTUAL ze_result_t scanDirEntries(const std::string path, std::vector<std::string> &list);
|
||||
ze_result_t readSymLink(const std::string path, std::string &buf) override;
|
||||
ze_result_t getRealPath(const std::string path, std::string &buf) override;
|
||||
MOCKABLE_VIRTUAL ze_result_t bindDevice(const std::string device);
|
||||
MOCKABLE_VIRTUAL ze_result_t unbindDevice(const std::string device);
|
||||
bool fileExists(const std::string file) override;
|
||||
MOCKABLE_VIRTUAL bool isMyDeviceFile(const std::string dev);
|
||||
bool directoryExists(const std::string path) override;
|
||||
bool isRootUser() override;
|
||||
|
||||
protected:
|
||||
std::vector<std::string> deviceNames;
|
||||
|
||||
private:
|
||||
SysfsAccess(const std::string file);
|
||||
|
||||
std::string fullPath(const std::string file);
|
||||
std::string dirname;
|
||||
static const std::string drmPath;
|
||||
static const std::string devicesPath;
|
||||
static const std::string primaryDevName;
|
||||
static const std::string drmDriverDevNodeDir;
|
||||
static const std::string intelGpuBindEntry;
|
||||
static const std::string intelGpuUnbindEntry;
|
||||
};
|
||||
|
||||
} // namespace Sysman
|
||||
} // namespace L0
|
||||
@@ -80,12 +80,17 @@ std::unique_ptr<SysmanKmdInterface> SysmanKmdInterface::create(const NEO::Drm &d
|
||||
return pSysmanKmdInterface;
|
||||
}
|
||||
|
||||
void SysmanKmdInterface::initFsAccessInterface(const NEO::Drm &drm) {
|
||||
ze_result_t SysmanKmdInterface::initFsAccessInterface(const NEO::Drm &drm) {
|
||||
pFsAccess = FsAccessInterface::create();
|
||||
pProcfsAccess = ProcFsAccessInterface::create();
|
||||
std::string deviceName;
|
||||
pProcfsAccess->getFileName(pProcfsAccess->myProcessId(), drm.getFileDescriptor(), deviceName);
|
||||
auto result = pProcfsAccess->getFileName(pProcfsAccess->myProcessId(), drm.getFileDescriptor(), deviceName);
|
||||
if (result != ZE_RESULT_SUCCESS) {
|
||||
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Failed to device name and returning error:0x%x \n", __FUNCTION__, result);
|
||||
return result;
|
||||
}
|
||||
pSysfsAccess = SysFsAccessInterface::create(deviceName);
|
||||
return result;
|
||||
}
|
||||
|
||||
FsAccessInterface *SysmanKmdInterface::getFsAccess() {
|
||||
@@ -306,7 +311,7 @@ static ze_result_t getNumEngineTypeAndInstancesForSubDevices(std::map<zes_engine
|
||||
}
|
||||
|
||||
static ze_result_t getNumEngineTypeAndInstancesForDevice(std::string engineDir, std::map<zes_engine_type_flag_t, std::vector<std::string>> &mapOfEngines,
|
||||
SysfsAccess *pSysfsAccess) {
|
||||
SysFsAccessInterface *pSysfsAccess) {
|
||||
std::vector<std::string> localListOfAllEngines = {};
|
||||
auto result = pSysfsAccess->scanDirEntries(engineDir, localListOfAllEngines);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
@@ -338,7 +343,7 @@ static ze_result_t getNumEngineTypeAndInstancesForDevice(std::string engineDir,
|
||||
|
||||
ze_result_t SysmanKmdInterfaceI915::getNumEngineTypeAndInstances(std::map<zes_engine_type_flag_t, std::vector<std::string>> &mapOfEngines,
|
||||
LinuxSysmanImp *pLinuxSysmanImp,
|
||||
SysfsAccess *pSysfsAccess,
|
||||
SysFsAccessInterface *pSysfsAccess,
|
||||
ze_bool_t onSubdevice,
|
||||
uint32_t subdeviceId) {
|
||||
return getNumEngineTypeAndInstancesForDevice(getEngineBasePath(subdeviceId), mapOfEngines, pSysfsAccess);
|
||||
@@ -346,7 +351,7 @@ ze_result_t SysmanKmdInterfaceI915::getNumEngineTypeAndInstances(std::map<zes_en
|
||||
|
||||
ze_result_t SysmanKmdInterfaceXe::getNumEngineTypeAndInstances(std::map<zes_engine_type_flag_t, std::vector<std::string>> &mapOfEngines,
|
||||
LinuxSysmanImp *pLinuxSysmanImp,
|
||||
SysfsAccess *pSysfsAccess,
|
||||
SysFsAccessInterface *pSysfsAccess,
|
||||
ze_bool_t onSubdevice,
|
||||
uint32_t subdeviceId) {
|
||||
if (onSubdevice) {
|
||||
|
||||
@@ -29,7 +29,6 @@ class ProcFsAccessInterface;
|
||||
class SysFsAccessInterface;
|
||||
class PmuInterface;
|
||||
class LinuxSysmanImp;
|
||||
class SysfsAccess;
|
||||
|
||||
typedef std::pair<std::string, std::string> valuePair;
|
||||
|
||||
@@ -114,7 +113,7 @@ class SysmanKmdInterface {
|
||||
virtual bool isStandbyModeControlAvailable() const = 0;
|
||||
virtual bool clientInfoAvailableInFdInfo() const = 0;
|
||||
virtual bool isGroupEngineInterfaceAvailable() const = 0;
|
||||
void initFsAccessInterface(const NEO::Drm &drm);
|
||||
ze_result_t initFsAccessInterface(const NEO::Drm &drm);
|
||||
virtual bool isBaseFrequencyFactorAvailable() const = 0;
|
||||
virtual bool isSystemPowerBalanceAvailable() const = 0;
|
||||
FsAccessInterface *getFsAccess();
|
||||
@@ -124,7 +123,7 @@ class SysmanKmdInterface {
|
||||
virtual bool useDefaultMaximumWatchdogTimeoutForExclusiveMode() = 0;
|
||||
virtual ze_result_t getNumEngineTypeAndInstances(std::map<zes_engine_type_flag_t, std::vector<std::string>> &mapOfEngines,
|
||||
LinuxSysmanImp *pLinuxSysmanImp,
|
||||
SysfsAccess *pSysfsAccess,
|
||||
SysFsAccessInterface *pSysfsAccess,
|
||||
ze_bool_t onSubdevice,
|
||||
uint32_t subdeviceId) = 0;
|
||||
SysfsValueUnit getNativeUnit(const SysfsName sysfsName);
|
||||
@@ -158,7 +157,7 @@ class SysmanKmdInterfaceI915 : public SysmanKmdInterface {
|
||||
bool useDefaultMaximumWatchdogTimeoutForExclusiveMode() override { return false; };
|
||||
ze_result_t getNumEngineTypeAndInstances(std::map<zes_engine_type_flag_t, std::vector<std::string>> &mapOfEngines,
|
||||
LinuxSysmanImp *pLinuxSysmanImp,
|
||||
SysfsAccess *pSysfsAccess,
|
||||
SysFsAccessInterface *pSysfsAccess,
|
||||
ze_bool_t onSubdevice,
|
||||
uint32_t subdeviceId) override;
|
||||
std::optional<std::string> getEngineClassString(uint16_t engineClass) override;
|
||||
@@ -196,7 +195,7 @@ class SysmanKmdInterfaceXe : public SysmanKmdInterface {
|
||||
bool useDefaultMaximumWatchdogTimeoutForExclusiveMode() override { return true; };
|
||||
ze_result_t getNumEngineTypeAndInstances(std::map<zes_engine_type_flag_t, std::vector<std::string>> &mapOfEngines,
|
||||
LinuxSysmanImp *pLinuxSysmanImp,
|
||||
SysfsAccess *pSysfsAccess,
|
||||
SysFsAccessInterface *pSysfsAccess,
|
||||
ze_bool_t onSubdevice,
|
||||
uint32_t subdeviceId) override;
|
||||
std::optional<std::string> getEngineClassString(uint16_t engineClass) override;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "level_zero/sysman/source/shared/linux/pmt/sysman_pmt.h"
|
||||
#include "level_zero/sysman/source/shared/linux/pmu/sysman_pmu.h"
|
||||
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_kmd_interface.h"
|
||||
|
||||
namespace L0 {
|
||||
@@ -32,44 +32,32 @@ namespace Sysman {
|
||||
const std::string LinuxSysmanImp::deviceDir("device");
|
||||
|
||||
ze_result_t LinuxSysmanImp::init() {
|
||||
pFsAccess = FsAccess::create();
|
||||
DEBUG_BREAK_IF(nullptr == pFsAccess);
|
||||
|
||||
if (pProcfsAccess == nullptr) {
|
||||
pProcfsAccess = ProcfsAccess::create();
|
||||
}
|
||||
DEBUG_BREAK_IF(nullptr == pProcfsAccess);
|
||||
|
||||
ze_result_t result;
|
||||
NEO::OSInterface &osInterface = *pParentSysmanDeviceImp->getRootDeviceEnvironment().osInterface;
|
||||
if (osInterface.getDriverModel()->getDriverModelType() != NEO::DriverModelType::DRM) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
auto sysmanHwDeviceId = getSysmanHwDeviceIdInstance();
|
||||
int myDeviceFd = sysmanHwDeviceId.getFileDescriptor();
|
||||
result = pProcfsAccess->getFileName(pProcfsAccess->myProcessId(), myDeviceFd, deviceName);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (pSysfsAccess == nullptr) {
|
||||
pSysfsAccess = SysfsAccess::create(deviceName);
|
||||
}
|
||||
DEBUG_BREAK_IF(nullptr == pSysfsAccess);
|
||||
|
||||
subDeviceCount = NEO::GfxCoreHelper::getSubDevicesCount(&pParentSysmanDeviceImp->getHardwareInfo());
|
||||
if (subDeviceCount == 1) {
|
||||
subDeviceCount = 0;
|
||||
}
|
||||
|
||||
rootPath = NEO::getPciRootPath(myDeviceFd).value_or("");
|
||||
pSysfsAccess->getRealPath(deviceDir, gtDevicePath);
|
||||
NEO::OSInterface &osInterface = *pParentSysmanDeviceImp->getRootDeviceEnvironment().osInterface;
|
||||
if (osInterface.getDriverModel()->getDriverModelType() != NEO::DriverModelType::DRM) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
pSysmanKmdInterface = SysmanKmdInterface::create(*getDrm());
|
||||
pSysmanKmdInterface->initFsAccessInterface(*getDrm());
|
||||
auto result = pSysmanKmdInterface->initFsAccessInterface(*getDrm());
|
||||
if (result != ZE_RESULT_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
pFsAccess = pSysmanKmdInterface->getFsAccess();
|
||||
pProcfsAccess = pSysmanKmdInterface->getProcFsAccess();
|
||||
pSysfsAccess = pSysmanKmdInterface->getSysFsAccess();
|
||||
pSysmanProductHelper = SysmanProductHelper::create(getProductFamily());
|
||||
DEBUG_BREAK_IF(nullptr == pSysmanProductHelper);
|
||||
|
||||
auto sysmanHwDeviceId = getSysmanHwDeviceIdInstance();
|
||||
int myDeviceFd = sysmanHwDeviceId.getFileDescriptor();
|
||||
rootPath = NEO::getPciRootPath(myDeviceFd).value_or("");
|
||||
pSysfsAccess->getRealPath(deviceDir, gtDevicePath);
|
||||
|
||||
osInterface.getDriverModel()->as<NEO::Drm>()->cleanup();
|
||||
pPmuInterface = PmuInterface::create(this);
|
||||
return createPmtHandles();
|
||||
@@ -167,17 +155,17 @@ void LinuxSysmanImp::releasePmtObject() {
|
||||
mapOfSubDeviceIdToPmtObject.clear();
|
||||
}
|
||||
|
||||
FsAccess &LinuxSysmanImp::getFsAccess() {
|
||||
FsAccessInterface &LinuxSysmanImp::getFsAccess() {
|
||||
UNRECOVERABLE_IF(nullptr == pFsAccess);
|
||||
return *pFsAccess;
|
||||
}
|
||||
|
||||
ProcfsAccess &LinuxSysmanImp::getProcfsAccess() {
|
||||
ProcFsAccessInterface &LinuxSysmanImp::getProcfsAccess() {
|
||||
UNRECOVERABLE_IF(nullptr == pProcfsAccess);
|
||||
return *pProcfsAccess;
|
||||
}
|
||||
|
||||
SysfsAccess &LinuxSysmanImp::getSysfsAccess() {
|
||||
SysFsAccessInterface &LinuxSysmanImp::getSysfsAccess() {
|
||||
UNRECOVERABLE_IF(nullptr == pSysfsAccess);
|
||||
return *pSysfsAccess;
|
||||
}
|
||||
@@ -227,18 +215,6 @@ void LinuxSysmanImp::releaseFwUtilInterface() {
|
||||
}
|
||||
|
||||
LinuxSysmanImp::~LinuxSysmanImp() {
|
||||
if (nullptr != pSysfsAccess) {
|
||||
delete pSysfsAccess;
|
||||
pSysfsAccess = nullptr;
|
||||
}
|
||||
if (nullptr != pProcfsAccess) {
|
||||
delete pProcfsAccess;
|
||||
pProcfsAccess = nullptr;
|
||||
}
|
||||
if (nullptr != pFsAccess) {
|
||||
delete pFsAccess;
|
||||
pFsAccess = nullptr;
|
||||
}
|
||||
if (nullptr != pPmuInterface) {
|
||||
delete pPmuInterface;
|
||||
pPmuInterface = nullptr;
|
||||
|
||||
@@ -29,11 +29,11 @@ namespace Sysman {
|
||||
class SysmanProductHelper;
|
||||
class PlatformMonitoringTech;
|
||||
class PmuInterface;
|
||||
class FsAccess;
|
||||
class ProcfsAccess;
|
||||
class SysfsAccess;
|
||||
class FirmwareUtil;
|
||||
class SysmanKmdInterface;
|
||||
class FsAccessInterface;
|
||||
class SysFsAccessInterface;
|
||||
class ProcFsAccessInterface;
|
||||
|
||||
class LinuxSysmanImp : public OsSysman, NEO::NonCopyableOrMovableClass {
|
||||
public:
|
||||
@@ -44,9 +44,9 @@ class LinuxSysmanImp : public OsSysman, NEO::NonCopyableOrMovableClass {
|
||||
|
||||
FirmwareUtil *getFwUtilInterface();
|
||||
PmuInterface *getPmuInterface() { return pPmuInterface; }
|
||||
FsAccess &getFsAccess();
|
||||
ProcfsAccess &getProcfsAccess();
|
||||
SysfsAccess &getSysfsAccess();
|
||||
FsAccessInterface &getFsAccess();
|
||||
ProcFsAccessInterface &getProcfsAccess();
|
||||
SysFsAccessInterface &getSysfsAccess();
|
||||
SysmanDeviceImp *getSysmanDeviceImp();
|
||||
SysmanProductHelper *getSysmanProductHelper();
|
||||
uint32_t getSubDeviceCount() override;
|
||||
@@ -83,9 +83,9 @@ class LinuxSysmanImp : public OsSysman, NEO::NonCopyableOrMovableClass {
|
||||
protected:
|
||||
std::unique_ptr<SysmanProductHelper> pSysmanProductHelper;
|
||||
std::unique_ptr<SysmanKmdInterface> pSysmanKmdInterface;
|
||||
FsAccess *pFsAccess = nullptr;
|
||||
ProcfsAccess *pProcfsAccess = nullptr;
|
||||
SysfsAccess *pSysfsAccess = nullptr;
|
||||
FsAccessInterface *pFsAccess = nullptr;
|
||||
ProcFsAccessInterface *pProcfsAccess = nullptr;
|
||||
SysFsAccessInterface *pSysfsAccess = nullptr;
|
||||
std::map<uint32_t, L0::Sysman::PlatformMonitoringTech *> mapOfSubDeviceIdToPmtObject;
|
||||
uint32_t subDeviceCount = 0;
|
||||
FirmwareUtil *pFwUtilInterface = nullptr;
|
||||
|
||||
@@ -70,7 +70,7 @@ struct MockGlobalOperationsEngineHandleContext : public L0::Sysman::EngineHandle
|
||||
ADDMETHOD_NOBASE_VOIDRETURN(init, (uint32_t subDeviceCount));
|
||||
};
|
||||
|
||||
struct MockDiagFsAccess : public L0::Sysman::FsAccess {
|
||||
struct MockDiagFsAccess : public L0::Sysman::FsAccessInterface {
|
||||
ze_result_t mockReadError = ZE_RESULT_SUCCESS;
|
||||
ze_result_t mockWriteError = ZE_RESULT_SUCCESS;
|
||||
ze_result_t mockListDirError = ZE_RESULT_SUCCESS;
|
||||
@@ -125,7 +125,7 @@ struct MockDiagFsAccess : public L0::Sysman::FsAccess {
|
||||
MockDiagFsAccess() = default;
|
||||
};
|
||||
|
||||
struct MockDiagSysfsAccess : public L0::Sysman::SysfsAccess {
|
||||
struct MockDiagSysfsAccess : public L0::Sysman::SysFsAccessInterface {
|
||||
ze_result_t mockError = ZE_RESULT_SUCCESS;
|
||||
int checkErrorAfterCount = 0;
|
||||
ze_result_t getRealPath(const std::string file, std::string &val) override {
|
||||
@@ -180,7 +180,7 @@ struct MockDiagSysfsAccess : public L0::Sysman::SysfsAccess {
|
||||
MockDiagSysfsAccess() = default;
|
||||
};
|
||||
|
||||
struct MockDiagProcfsAccess : public L0::Sysman::ProcfsAccess {
|
||||
struct MockDiagProcfsAccess : public L0::Sysman::ProcFsAccessInterface {
|
||||
std::vector<::pid_t> pidList = {1, 2, 3};
|
||||
::pid_t ourDevicePid = 0;
|
||||
ze_result_t mockError = ZE_RESULT_SUCCESS;
|
||||
|
||||
@@ -111,9 +111,9 @@ class ZesDiagnosticsFixture : public SysmanDeviceFixture {
|
||||
std::unique_ptr<MockDiagLinuxSysmanImp> pMockDiagLinuxSysmanImp;
|
||||
|
||||
L0::Sysman::FirmwareUtil *pFwUtilInterfaceOld = nullptr;
|
||||
L0::Sysman::SysfsAccess *pSysfsAccessOld = nullptr;
|
||||
L0::Sysman::FsAccess *pFsAccessOld = nullptr;
|
||||
L0::Sysman::ProcfsAccess *pProcfsAccessOld = nullptr;
|
||||
L0::Sysman::SysFsAccessInterface *pSysfsAccessOld = nullptr;
|
||||
L0::Sysman::FsAccessInterface *pFsAccessOld = nullptr;
|
||||
L0::Sysman::ProcFsAccessInterface *pProcfsAccessOld = nullptr;
|
||||
L0::Sysman::EngineHandleContext *pEngineHandleContextOld = nullptr;
|
||||
L0::Sysman::SysmanDevice *device = nullptr;
|
||||
|
||||
@@ -265,7 +265,7 @@ TEST_F(ZesDiagnosticsFixture, GivenValidDiagnosticsHandleWhenRunningDiagnosticsT
|
||||
pPublicLinuxDiagnosticsImp->pFwInterface = pMockDiagFwInterface.get();
|
||||
pPublicLinuxDiagnosticsImp->pLinuxSysmanImp = pMockDiagLinuxSysmanImp.get();
|
||||
pPublicLinuxDiagnosticsImp->osDiagType = "MEMORY_PPR";
|
||||
VariableBackup<L0::Sysman::ProcfsAccess *> backup(&pMockDiagLinuxSysmanImp->pProcfsAccess);
|
||||
VariableBackup<L0::Sysman::ProcFsAccessInterface *> backup(&pMockDiagLinuxSysmanImp->pProcfsAccess);
|
||||
pMockDiagLinuxSysmanImp->pProcfsAccess = pMockDiagProcfsAccess.get();
|
||||
|
||||
std::unique_ptr<L0::Sysman::DiagnosticsImp> ptestDiagnosticsImp = std::make_unique<L0::Sysman::DiagnosticsImp>(pSysmanDeviceImp->pDiagnosticsHandleContext->pOsSysman, mockSupportedDiagTypes[0]);
|
||||
@@ -288,7 +288,7 @@ TEST_F(ZesDiagnosticsFixture, GivenValidDiagnosticsHandleWhenRunningDiagnosticsT
|
||||
pPublicLinuxDiagnosticsImp->pSysfsAccess = pMockSysfsAccess.get();
|
||||
pPublicLinuxDiagnosticsImp->pFwInterface = pMockDiagFwInterface.get();
|
||||
pPublicLinuxDiagnosticsImp->pLinuxSysmanImp = pMockDiagLinuxSysmanImp.get();
|
||||
VariableBackup<L0::Sysman::ProcfsAccess *> backup(&pMockDiagLinuxSysmanImp->pProcfsAccess);
|
||||
VariableBackup<L0::Sysman::ProcFsAccessInterface *> backup(&pMockDiagLinuxSysmanImp->pProcfsAccess);
|
||||
pMockDiagLinuxSysmanImp->pProcfsAccess = pMockDiagProcfsAccess.get();
|
||||
|
||||
pMockDiagFwInterface->setDiagResult(ZES_DIAG_RESULT_FORCE_UINT32);
|
||||
@@ -313,7 +313,7 @@ TEST_F(ZesDiagnosticsFixture, GivenValidDiagnosticsHandleWhenListProcessFailsThe
|
||||
pPublicLinuxDiagnosticsImp->pSysfsAccess = pMockSysfsAccess.get();
|
||||
pPublicLinuxDiagnosticsImp->pFwInterface = pMockDiagFwInterface.get();
|
||||
pPublicLinuxDiagnosticsImp->pLinuxSysmanImp = pMockDiagLinuxSysmanImp.get();
|
||||
VariableBackup<L0::Sysman::ProcfsAccess *> backup(&pMockDiagLinuxSysmanImp->pProcfsAccess);
|
||||
VariableBackup<L0::Sysman::ProcFsAccessInterface *> backup(&pMockDiagLinuxSysmanImp->pProcfsAccess);
|
||||
pMockDiagLinuxSysmanImp->pProcfsAccess = pMockDiagProcfsAccess.get();
|
||||
pMockDiagProcfsAccess->setMockError(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
std::unique_ptr<L0::Sysman::DiagnosticsImp> ptestDiagnosticsImp = std::make_unique<L0::Sysman::DiagnosticsImp>(pSysmanDeviceImp->pDiagnosticsHandleContext->pOsSysman, mockSupportedDiagTypes[0]);
|
||||
@@ -337,7 +337,7 @@ TEST_F(ZesDiagnosticsFixture, GivenValidDiagnosticsHandleWhenQuiescentingFailsTh
|
||||
pPublicLinuxDiagnosticsImp->pSysfsAccess = pMockSysfsAccess.get();
|
||||
pPublicLinuxDiagnosticsImp->pFwInterface = pMockDiagFwInterface.get();
|
||||
pPublicLinuxDiagnosticsImp->pLinuxSysmanImp = pMockDiagLinuxSysmanImp.get();
|
||||
VariableBackup<L0::Sysman::ProcfsAccess *> backup(&pMockDiagLinuxSysmanImp->pProcfsAccess);
|
||||
VariableBackup<L0::Sysman::ProcFsAccessInterface *> backup(&pMockDiagLinuxSysmanImp->pProcfsAccess);
|
||||
pMockDiagLinuxSysmanImp->pProcfsAccess = pMockDiagProcfsAccess.get();
|
||||
pMockSysfsAccess->setMockError(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
std::unique_ptr<L0::Sysman::DiagnosticsImp> ptestDiagnosticsImp = std::make_unique<L0::Sysman::DiagnosticsImp>(pSysmanDeviceImp->pDiagnosticsHandleContext->pOsSysman, mockSupportedDiagTypes[0]);
|
||||
@@ -361,7 +361,7 @@ TEST_F(ZesDiagnosticsFixture, GivenValidDiagnosticsHandleWhenInvalidateLmemFails
|
||||
pPublicLinuxDiagnosticsImp->pSysfsAccess = pMockSysfsAccess.get();
|
||||
pPublicLinuxDiagnosticsImp->pFwInterface = pMockDiagFwInterface.get();
|
||||
pPublicLinuxDiagnosticsImp->pLinuxSysmanImp = pMockDiagLinuxSysmanImp.get();
|
||||
VariableBackup<L0::Sysman::ProcfsAccess *> backup(&pMockDiagLinuxSysmanImp->pProcfsAccess);
|
||||
VariableBackup<L0::Sysman::ProcFsAccessInterface *> backup(&pMockDiagLinuxSysmanImp->pProcfsAccess);
|
||||
pMockDiagLinuxSysmanImp->pProcfsAccess = pMockDiagProcfsAccess.get();
|
||||
pMockSysfsAccess->setMockError(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
std::unique_ptr<L0::Sysman::DiagnosticsImp> ptestDiagnosticsImp = std::make_unique<L0::Sysman::DiagnosticsImp>(pSysmanDeviceImp->pDiagnosticsHandleContext->pOsSysman, mockSupportedDiagTypes[0]);
|
||||
@@ -385,7 +385,7 @@ TEST_F(ZesDiagnosticsFixture, GivenValidDiagnosticsHandleWhenColdResetFailsThenC
|
||||
pPublicLinuxDiagnosticsImp->pSysfsAccess = pMockSysfsAccess.get();
|
||||
pPublicLinuxDiagnosticsImp->pFwInterface = pMockDiagFwInterface.get();
|
||||
pPublicLinuxDiagnosticsImp->pLinuxSysmanImp = pMockDiagLinuxSysmanImp.get();
|
||||
VariableBackup<L0::Sysman::ProcfsAccess *> backup(&pMockDiagLinuxSysmanImp->pProcfsAccess);
|
||||
VariableBackup<L0::Sysman::ProcFsAccessInterface *> backup(&pMockDiagLinuxSysmanImp->pProcfsAccess);
|
||||
pMockDiagLinuxSysmanImp->pProcfsAccess = pMockDiagProcfsAccess.get();
|
||||
pMockDiagFwInterface->setDiagResult(ZES_DIAG_RESULT_REBOOT_FOR_REPAIR);
|
||||
pMockDiagLinuxSysmanImp->setMockError(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
@@ -410,7 +410,7 @@ TEST_F(ZesDiagnosticsFixture, GivenValidDiagnosticsHandleWhenWarmResetFailsThenC
|
||||
pPublicLinuxDiagnosticsImp->pSysfsAccess = pMockSysfsAccess.get();
|
||||
pPublicLinuxDiagnosticsImp->pFwInterface = pMockDiagFwInterface.get();
|
||||
pPublicLinuxDiagnosticsImp->pLinuxSysmanImp = pMockDiagLinuxSysmanImp.get();
|
||||
VariableBackup<L0::Sysman::ProcfsAccess *> backup(&pMockDiagLinuxSysmanImp->pProcfsAccess);
|
||||
VariableBackup<L0::Sysman::ProcFsAccessInterface *> backup(&pMockDiagLinuxSysmanImp->pProcfsAccess);
|
||||
pMockDiagLinuxSysmanImp->pProcfsAccess = pMockDiagProcfsAccess.get();
|
||||
pMockDiagLinuxSysmanImp->setMockError(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
std::unique_ptr<L0::Sysman::DiagnosticsImp> ptestDiagnosticsImp = std::make_unique<L0::Sysman::DiagnosticsImp>(pSysmanDeviceImp->pDiagnosticsHandleContext->pOsSysman, mockSupportedDiagTypes[0]);
|
||||
@@ -434,7 +434,7 @@ TEST_F(ZesDiagnosticsFixture, GivenValidDiagnosticsHandleWhenWarmResetSucceedsAn
|
||||
pPublicLinuxDiagnosticsImp->pSysfsAccess = pMockSysfsAccess.get();
|
||||
pPublicLinuxDiagnosticsImp->pFwInterface = pMockDiagFwInterface.get();
|
||||
pPublicLinuxDiagnosticsImp->pLinuxSysmanImp = pMockDiagLinuxSysmanImp.get();
|
||||
VariableBackup<L0::Sysman::ProcfsAccess *> backup(&pMockDiagLinuxSysmanImp->pProcfsAccess);
|
||||
VariableBackup<L0::Sysman::ProcFsAccessInterface *> backup(&pMockDiagLinuxSysmanImp->pProcfsAccess);
|
||||
pMockDiagLinuxSysmanImp->pProcfsAccess = pMockDiagProcfsAccess.get();
|
||||
pMockDiagLinuxSysmanImp->setMockReInitSysmanDeviceError(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
std::unique_ptr<L0::Sysman::DiagnosticsImp> ptestDiagnosticsImp = std::make_unique<L0::Sysman::DiagnosticsImp>(pSysmanDeviceImp->pDiagnosticsHandleContext->pOsSysman, mockSupportedDiagTypes[0]);
|
||||
@@ -458,7 +458,7 @@ TEST_F(ZesDiagnosticsFixture, GivenValidDiagnosticsHandleWhenColdResetSucceedsAn
|
||||
pPublicLinuxDiagnosticsImp->pSysfsAccess = pMockSysfsAccess.get();
|
||||
pPublicLinuxDiagnosticsImp->pFwInterface = pMockDiagFwInterface.get();
|
||||
pPublicLinuxDiagnosticsImp->pLinuxSysmanImp = pMockDiagLinuxSysmanImp.get();
|
||||
VariableBackup<L0::Sysman::ProcfsAccess *> backup(&pMockDiagLinuxSysmanImp->pProcfsAccess);
|
||||
VariableBackup<L0::Sysman::ProcFsAccessInterface *> backup(&pMockDiagLinuxSysmanImp->pProcfsAccess);
|
||||
pMockDiagLinuxSysmanImp->pProcfsAccess = pMockDiagProcfsAccess.get();
|
||||
pMockDiagFwInterface->setDiagResult(ZES_DIAG_RESULT_REBOOT_FOR_REPAIR);
|
||||
pMockDiagLinuxSysmanImp->setMockReInitSysmanDeviceError(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
@@ -482,7 +482,7 @@ TEST_F(ZesDiagnosticsFixture, GivenValidDiagnosticsHandleWhenGPUProcessCleanupSu
|
||||
|
||||
pPublicLinuxDiagnosticsImp->pSysfsAccess = pMockSysfsAccess.get();
|
||||
pPublicLinuxDiagnosticsImp->pFwInterface = pMockDiagFwInterface.get();
|
||||
VariableBackup<L0::Sysman::ProcfsAccess *> backup(&pMockDiagLinuxSysmanImp->pProcfsAccess);
|
||||
VariableBackup<L0::Sysman::ProcFsAccessInterface *> backup(&pMockDiagLinuxSysmanImp->pProcfsAccess);
|
||||
pMockDiagLinuxSysmanImp->pProcfsAccess = pMockDiagProcfsAccess.get();
|
||||
pPublicLinuxDiagnosticsImp->pLinuxSysmanImp = pMockDiagLinuxSysmanImp.get();
|
||||
pMockDiagProcfsAccess->ourDevicePid = getpid();
|
||||
@@ -499,7 +499,7 @@ TEST_F(ZesDiagnosticsFixture, GivenValidDiagnosticsHandleWhenGPUProcessCleanupFa
|
||||
pPublicLinuxDiagnosticsImp->pSysfsAccess = pMockSysfsAccess.get();
|
||||
pPublicLinuxDiagnosticsImp->pFwInterface = pMockDiagFwInterface.get();
|
||||
pPublicLinuxDiagnosticsImp->pLinuxSysmanImp = pMockDiagLinuxSysmanImp.get();
|
||||
VariableBackup<L0::Sysman::ProcfsAccess *> backup(&pMockDiagLinuxSysmanImp->pProcfsAccess);
|
||||
VariableBackup<L0::Sysman::ProcFsAccessInterface *> backup(&pMockDiagLinuxSysmanImp->pProcfsAccess);
|
||||
pMockDiagLinuxSysmanImp->pProcfsAccess = pMockDiagProcfsAccess.get();
|
||||
pMockSysfsAccess->setMockError(ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE);
|
||||
pMockDiagProcfsAccess->setMockError(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
@@ -514,7 +514,7 @@ TEST_F(ZesDiagnosticsFixture, GivenValidDiagnosticsHandleWhenQuiescentFailsConti
|
||||
pPublicLinuxDiagnosticsImp->pSysfsAccess = pMockSysfsAccess.get();
|
||||
pPublicLinuxDiagnosticsImp->pFwInterface = pMockDiagFwInterface.get();
|
||||
pPublicLinuxDiagnosticsImp->pLinuxSysmanImp = pMockDiagLinuxSysmanImp.get();
|
||||
VariableBackup<L0::Sysman::ProcfsAccess *> backup(&pMockDiagLinuxSysmanImp->pProcfsAccess);
|
||||
VariableBackup<L0::Sysman::ProcFsAccessInterface *> backup(&pMockDiagLinuxSysmanImp->pProcfsAccess);
|
||||
pMockDiagLinuxSysmanImp->pProcfsAccess = pMockDiagProcfsAccess.get();
|
||||
|
||||
pMockSysfsAccess->setErrorAfterCount(12, ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE);
|
||||
@@ -529,7 +529,7 @@ TEST_F(ZesDiagnosticsFixture, GivenValidDiagnosticsHandleWhenInvalidateLmemFails
|
||||
pPublicLinuxDiagnosticsImp->pSysfsAccess = pMockSysfsAccess.get();
|
||||
pPublicLinuxDiagnosticsImp->pFwInterface = pMockDiagFwInterface.get();
|
||||
pPublicLinuxDiagnosticsImp->pLinuxSysmanImp = pMockDiagLinuxSysmanImp.get();
|
||||
VariableBackup<L0::Sysman::ProcfsAccess *> backup(&pMockDiagLinuxSysmanImp->pProcfsAccess);
|
||||
VariableBackup<L0::Sysman::ProcFsAccessInterface *> backup(&pMockDiagLinuxSysmanImp->pProcfsAccess);
|
||||
pMockDiagLinuxSysmanImp->pProcfsAccess = pMockDiagProcfsAccess.get();
|
||||
pMockSysfsAccess->setErrorAfterCount(1, ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, pPublicLinuxDiagnosticsImp->waitForQuiescentCompletion());
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "level_zero/sysman/source/api/engine/linux/sysman_os_engine_imp.h"
|
||||
#include "level_zero/sysman/source/api/engine/sysman_engine_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/pmu/sysman_pmu_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h"
|
||||
#include "level_zero/sysman/test/unit_tests/sources/linux/mock_sysman_hw_device_id.h"
|
||||
|
||||
@@ -137,7 +138,7 @@ struct MockEnginePmuInterfaceImp : public L0::Sysman::PmuInterfaceImp {
|
||||
}
|
||||
};
|
||||
|
||||
struct MockEngineFsAccess : public L0::Sysman::FsAccess {
|
||||
struct MockEngineFsAccess : public L0::Sysman::FsAccessInterface {
|
||||
|
||||
bool mockReadVal = false;
|
||||
|
||||
@@ -157,7 +158,7 @@ struct MockEngineFsAccess : public L0::Sysman::FsAccess {
|
||||
}
|
||||
};
|
||||
|
||||
struct MockEngineSysfsAccess : public L0::Sysman::SysfsAccess {
|
||||
struct MockEngineSysfsAccess : public L0::Sysman::SysFsAccessInterface {
|
||||
|
||||
bool mockReadSymLinkFailure = false;
|
||||
bool mockReadSymLinkSuccess = false;
|
||||
|
||||
@@ -25,9 +25,9 @@ class ZesEngineFixture : public SysmanDeviceFixture {
|
||||
Drm *pOriginalDrm = nullptr;
|
||||
L0::Sysman::PmuInterface *pOriginalPmuInterface = nullptr;
|
||||
std::unique_ptr<MockEngineSysfsAccess> pSysfsAccess;
|
||||
L0::Sysman::SysfsAccess *pSysfsAccessOriginal = nullptr;
|
||||
L0::Sysman::SysFsAccessInterface *pSysfsAccessOriginal = nullptr;
|
||||
std::unique_ptr<MockEngineFsAccess> pFsAccess;
|
||||
L0::Sysman::FsAccess *pFsAccessOriginal = nullptr;
|
||||
L0::Sysman::FsAccessInterface *pFsAccessOriginal = nullptr;
|
||||
|
||||
L0::Sysman::SysmanDevice *device = nullptr;
|
||||
|
||||
@@ -315,9 +315,9 @@ class ZesEngineMultiFixture : public SysmanMultiDeviceFixture {
|
||||
std::unique_ptr<MockEnginePmuInterfaceImp> pPmuInterface;
|
||||
L0::Sysman::PmuInterface *pOriginalPmuInterface = nullptr;
|
||||
std::unique_ptr<MockEngineSysfsAccess> pSysfsAccess;
|
||||
L0::Sysman::SysfsAccess *pSysfsAccessOriginal = nullptr;
|
||||
L0::Sysman::SysFsAccessInterface *pSysfsAccessOriginal = nullptr;
|
||||
std::unique_ptr<MockEngineFsAccess> pFsAccess;
|
||||
L0::Sysman::FsAccess *pFsAccessOriginal = nullptr;
|
||||
L0::Sysman::FsAccessInterface *pFsAccessOriginal = nullptr;
|
||||
L0::Sysman::SysmanDevice *device = nullptr;
|
||||
|
||||
void SetUp() override {
|
||||
|
||||
@@ -27,6 +27,11 @@ class ZesEngineFixtureXe : public SysmanDeviceFixture {
|
||||
|
||||
void SetUp() override {
|
||||
SysmanDeviceFixture::SetUp();
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsReadlink)> mockReadLink(&NEO::SysCalls::sysCallsReadlink, [](const char *path, char *buf, size_t bufsize) -> int {
|
||||
std::string str = "../../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:01.0/0000:3a:00.0/drm/renderD128";
|
||||
std::memcpy(buf, str.c_str(), str.size());
|
||||
return static_cast<int>(str.size());
|
||||
});
|
||||
device = pSysmanDevice;
|
||||
MockNeoDrm *pDrm = new MockNeoDrm(const_cast<NEO::RootDeviceEnvironment &>(pSysmanDeviceImp->getRootDeviceEnvironment()));
|
||||
pDrm->ioctlHelper = std::make_unique<NEO::IoctlHelperXe>(*pDrm);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "level_zero/sysman/source/api/events/sysman_events_imp.h"
|
||||
#include "level_zero/sysman/source/shared/firmware_util/sysman_firmware_util.h"
|
||||
#include "level_zero/sysman/source/shared/linux/pmu/sysman_pmu_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_driver_imp.h"
|
||||
#include "level_zero/sysman/test/unit_tests/sources/linux/mock_sysman_hw_device_id.h"
|
||||
|
||||
@@ -67,7 +68,7 @@ struct MockPmuInterfaceImpForEvents : public L0::Sysman::PmuInterfaceImp {
|
||||
}
|
||||
};
|
||||
|
||||
struct MockEventsFsAccess : public L0::Sysman::FsAccess {
|
||||
struct MockEventsFsAccess : public L0::Sysman::FsAccessInterface {
|
||||
|
||||
bool mockReadValSuccess = false;
|
||||
bool mockReadValOne = false;
|
||||
@@ -174,7 +175,7 @@ struct MockEventsFsAccess : public L0::Sysman::FsAccess {
|
||||
MockEventsFsAccess() = default;
|
||||
};
|
||||
|
||||
struct MockEventsSysfsAccess : public L0::Sysman::SysfsAccess {
|
||||
struct MockEventsSysfsAccess : public L0::Sysman::SysFsAccessInterface {
|
||||
ze_result_t getRealPathResult = ZE_RESULT_SUCCESS;
|
||||
std::string realPath = "/sys/devices/pci0000:97/0000:97:02.0/0000:98:00.0/0000:99:01.0/0000:9a:00.0";
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@ class SysmanEventsFixture : public SysmanDeviceFixture {
|
||||
std::unique_ptr<MockEventsFsAccess> pFsAccess;
|
||||
MockEventNeoDrm *pDrm = nullptr;
|
||||
Drm *pOriginalDrm = nullptr;
|
||||
FsAccess *pFsAccessOriginal = nullptr;
|
||||
FsAccessInterface *pFsAccessOriginal = nullptr;
|
||||
OsEvents *pOsEventsPrev = nullptr;
|
||||
L0::Sysman::EventsImp *pEventsImp;
|
||||
std::unique_ptr<MockEventsSysfsAccess> pSysfsAccess;
|
||||
SysfsAccess *pSysfsAccessOriginal = nullptr;
|
||||
SysFsAccessInterface *pSysfsAccessOriginal = nullptr;
|
||||
std::unique_ptr<MockPmuInterfaceImpForEvents> pPmuInterface;
|
||||
PmuInterface *pOriginalPmuInterface = nullptr;
|
||||
PublicLinuxEventsImp *pLinuxEventsImp = nullptr;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "shared/test/common/test_macros/mock_method_macros.h"
|
||||
|
||||
#include "level_zero/sysman/source/api/fabric_port/sysman_fabric_port.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h"
|
||||
|
||||
namespace L0 {
|
||||
@@ -27,7 +27,7 @@ struct MockFabricDevice : public L0::Sysman::FabricDevice {
|
||||
MockFabricDevice() = default;
|
||||
};
|
||||
|
||||
class MockFabricFsAccess : public L0::Sysman::FsAccess {
|
||||
class MockFabricFsAccess : public L0::Sysman::FsAccessInterface {
|
||||
public:
|
||||
ze_result_t mockListDirectory = ZE_RESULT_SUCCESS;
|
||||
ze_result_t canRead(const std::string file) override {
|
||||
@@ -65,7 +65,7 @@ class MockFabricFsAccess : public L0::Sysman::FsAccess {
|
||||
std::vector<std::string> accessibleDirectories = {};
|
||||
};
|
||||
|
||||
class MockFabricSysFsAccess : public L0::Sysman::SysfsAccess {
|
||||
class MockFabricSysFsAccess : public L0::Sysman::SysFsAccessInterface {
|
||||
public:
|
||||
ze_result_t getRealPath(const std::string path, std::string &buf) override {
|
||||
buf.append("/mockRealPath");
|
||||
|
||||
@@ -651,8 +651,8 @@ TEST_F(ZesFabricPortFixture, GivenValidFabricPortHandleWhenCallingZesFabricPortG
|
||||
}
|
||||
|
||||
TEST_F(ZesFabricPortFixture, GivenValidFabricPortHandleWhenCallingzesFabricPortGetFabricErrorCountersWithLegacyPathAndCallSucceeds) {
|
||||
VariableBackup<FsAccess *> backupFsAccess(&pLinuxSysmanImp->pFsAccess);
|
||||
VariableBackup<SysfsAccess *> backupSysfsAccess(&pLinuxSysmanImp->pSysfsAccess);
|
||||
VariableBackup<FsAccessInterface *> backupFsAccess(&pLinuxSysmanImp->pFsAccess);
|
||||
VariableBackup<SysFsAccessInterface *> backupSysfsAccess(&pLinuxSysmanImp->pSysfsAccess);
|
||||
auto pFsAccess = new MockFabricFsAccess;
|
||||
auto pSysfsAccess = new MockFabricSysFsAccess;
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccess;
|
||||
@@ -699,8 +699,8 @@ TEST_F(ZesFabricPortFixture, GivenValidFabricPortHandleWhenCallingzesFabricPortG
|
||||
}
|
||||
|
||||
TEST_F(ZesFabricPortFixture, GivenValidFabricPortHandleWhenCallingzesFabricPortGetFabricErrorCountersCallSucceeds) {
|
||||
VariableBackup<FsAccess *> backupFsAccess(&pLinuxSysmanImp->pFsAccess);
|
||||
VariableBackup<SysfsAccess *> backupSysfsAccess(&pLinuxSysmanImp->pSysfsAccess);
|
||||
VariableBackup<FsAccessInterface *> backupFsAccess(&pLinuxSysmanImp->pFsAccess);
|
||||
VariableBackup<SysFsAccessInterface *> backupSysfsAccess(&pLinuxSysmanImp->pSysfsAccess);
|
||||
auto pFsAccess = new MockFabricFsAccess;
|
||||
auto pSysfsAccess = new MockFabricSysFsAccess;
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccess;
|
||||
@@ -748,8 +748,8 @@ TEST_F(ZesFabricPortFixture, GivenValidFabricPortHandleWhenCallingzesFabricPortG
|
||||
}
|
||||
|
||||
TEST_F(ZesFabricPortFixture, GivenValidFabricPortHandleWhenCallingzesFabricPortGetFabricErrorCountersAndGetRealPathFailsThenFailureIsReturned) {
|
||||
VariableBackup<FsAccess *> backupFsAccess(&pLinuxSysmanImp->pFsAccess);
|
||||
VariableBackup<SysfsAccess *> backupSysfsAccess(&pLinuxSysmanImp->pSysfsAccess);
|
||||
VariableBackup<FsAccessInterface *> backupFsAccess(&pLinuxSysmanImp->pFsAccess);
|
||||
VariableBackup<SysFsAccessInterface *> backupSysfsAccess(&pLinuxSysmanImp->pSysfsAccess);
|
||||
auto pFsAccess = new MockFabricFsAccess;
|
||||
auto pSysfsAccess = new MockFabricSysFsAccess;
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccess;
|
||||
@@ -774,8 +774,8 @@ TEST_F(ZesFabricPortFixture, GivenValidFabricPortHandleWhenCallingzesFabricPortG
|
||||
}
|
||||
|
||||
TEST_F(ZesFabricPortFixture, GivenValidFabricPortHandleWhenCallingzesFabricPortGetFabricErrorCountersAndListDirectoryFailsThenFailureIsReturned) {
|
||||
VariableBackup<FsAccess *> backupFsAccess(&pLinuxSysmanImp->pFsAccess);
|
||||
VariableBackup<SysfsAccess *> backupSysfsAccess(&pLinuxSysmanImp->pSysfsAccess);
|
||||
VariableBackup<FsAccessInterface *> backupFsAccess(&pLinuxSysmanImp->pFsAccess);
|
||||
VariableBackup<SysFsAccessInterface *> backupSysfsAccess(&pLinuxSysmanImp->pSysfsAccess);
|
||||
auto pFsAccess = new MockFabricFsAccess;
|
||||
auto pSysfsAccess = new MockFabricSysFsAccess;
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccess;
|
||||
@@ -800,8 +800,8 @@ TEST_F(ZesFabricPortFixture, GivenValidFabricPortHandleWhenCallingzesFabricPortG
|
||||
}
|
||||
|
||||
TEST_F(ZesFabricPortFixture, GivenValidFabricPortHandleWhenCallingzesFabricPortGetFabricErrorCountersAndIafSysfsFilesAreNotPresentThenFailureIsReturned) {
|
||||
VariableBackup<FsAccess *> backupFsAccess(&pLinuxSysmanImp->pFsAccess);
|
||||
VariableBackup<SysfsAccess *> backupSysfsAccess(&pLinuxSysmanImp->pSysfsAccess);
|
||||
VariableBackup<FsAccessInterface *> backupFsAccess(&pLinuxSysmanImp->pFsAccess);
|
||||
VariableBackup<SysFsAccessInterface *> backupSysfsAccess(&pLinuxSysmanImp->pSysfsAccess);
|
||||
auto pFsAccess = new MockFabricFsAccess;
|
||||
auto pSysfsAccess = new MockFabricSysFsAccess;
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccess;
|
||||
@@ -827,8 +827,8 @@ TEST_F(ZesFabricPortFixture, GivenValidFabricPortHandleWhenCallingzesFabricPortG
|
||||
}
|
||||
|
||||
TEST_F(ZesFabricPortFixture, GivenValidFabricPortHandleWhenCallingzesFabricPortGetFabricErrorCountersAndLinkFailureSysfsNodeIsAbsentThenZeroLinkFailuresAreReturned) {
|
||||
VariableBackup<FsAccess *> backupFsAccess(&pLinuxSysmanImp->pFsAccess);
|
||||
VariableBackup<SysfsAccess *> backupSysfsAccess(&pLinuxSysmanImp->pSysfsAccess);
|
||||
VariableBackup<FsAccessInterface *> backupFsAccess(&pLinuxSysmanImp->pFsAccess);
|
||||
VariableBackup<SysFsAccessInterface *> backupSysfsAccess(&pLinuxSysmanImp->pSysfsAccess);
|
||||
auto pFsAccess = new MockFabricFsAccess;
|
||||
auto pSysfsAccess = new MockFabricSysFsAccess;
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccess;
|
||||
@@ -878,8 +878,8 @@ TEST_F(ZesFabricPortFixture, GivenValidFabricPortHandleWhenCallingzesFabricPortG
|
||||
}
|
||||
|
||||
TEST_F(ZesFabricPortFixture, GivenValidFabricPortHandleWhenCallingzesFabricPortGetFabricErrorCountersAndLinkDegradesSysfsNodeIsAbsentThenZeroLinkDegradesAreReturned) {
|
||||
VariableBackup<FsAccess *> backupFsAccess(&pLinuxSysmanImp->pFsAccess);
|
||||
VariableBackup<SysfsAccess *> backupSysfsAccess(&pLinuxSysmanImp->pSysfsAccess);
|
||||
VariableBackup<FsAccessInterface *> backupFsAccess(&pLinuxSysmanImp->pFsAccess);
|
||||
VariableBackup<SysFsAccessInterface *> backupSysfsAccess(&pLinuxSysmanImp->pSysfsAccess);
|
||||
auto pFsAccess = new MockFabricFsAccess;
|
||||
auto pSysfsAccess = new MockFabricSysFsAccess;
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccess;
|
||||
@@ -930,8 +930,8 @@ TEST_F(ZesFabricPortFixture, GivenValidFabricPortHandleWhenCallingzesFabricPortG
|
||||
}
|
||||
|
||||
TEST_F(ZesFabricPortFixture, GivenValidFabricPortHandleWhenCallingzesFabricPortGetFabricErrorCountersAndFwErrorSysfsNodeIsAbsentThenZeroFwErrorsAreReturned) {
|
||||
VariableBackup<FsAccess *> backupFsAccess(&pLinuxSysmanImp->pFsAccess);
|
||||
VariableBackup<SysfsAccess *> backupSysfsAccess(&pLinuxSysmanImp->pSysfsAccess);
|
||||
VariableBackup<FsAccessInterface *> backupFsAccess(&pLinuxSysmanImp->pFsAccess);
|
||||
VariableBackup<SysFsAccessInterface *> backupSysfsAccess(&pLinuxSysmanImp->pSysfsAccess);
|
||||
auto pFsAccess = new MockFabricFsAccess;
|
||||
auto pSysfsAccess = new MockFabricSysFsAccess;
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccess;
|
||||
@@ -982,8 +982,8 @@ TEST_F(ZesFabricPortFixture, GivenValidFabricPortHandleWhenCallingzesFabricPortG
|
||||
}
|
||||
|
||||
TEST_F(ZesFabricPortFixture, GivenValidFabricPortHandleWhenCallingzesFabricPortGetFabricErrorCountersAndFwCommErrorSysfsNodeIsAbsentThenZeroFwCommErrorsAreReturned) {
|
||||
VariableBackup<FsAccess *> backupFsAccess(&pLinuxSysmanImp->pFsAccess);
|
||||
VariableBackup<SysfsAccess *> backupSysfsAccess(&pLinuxSysmanImp->pSysfsAccess);
|
||||
VariableBackup<FsAccessInterface *> backupFsAccess(&pLinuxSysmanImp->pFsAccess);
|
||||
VariableBackup<SysFsAccessInterface *> backupSysfsAccess(&pLinuxSysmanImp->pSysfsAccess);
|
||||
auto pFsAccess = new MockFabricFsAccess;
|
||||
auto pSysfsAccess = new MockFabricSysFsAccess;
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccess;
|
||||
|
||||
@@ -21,7 +21,7 @@ std::vector<std::string> mockSupportedFwTypes = {"GSC", "OptionROM"};
|
||||
std::vector<std::string> mockUnsupportedFwTypes = {"unknown"};
|
||||
std::string mockEmpty = {};
|
||||
class FirmwareInterface : public L0::Sysman::FirmwareUtil {};
|
||||
class FirmwareFsAccess : public L0::Sysman::FsAccess {};
|
||||
class FirmwareFsAccess : public L0::Sysman::FsAccessInterface {};
|
||||
|
||||
struct MockFirmwareFsAccess : public FirmwareFsAccess {
|
||||
ze_bool_t isReadFwTypes = true;
|
||||
|
||||
@@ -23,8 +23,8 @@ std::vector<std::string> mockSupportedFirmwareTypes = {"GSC", "OptionROM", "PSC"
|
||||
std::vector<std::string> mockUnsupportedFwTypes = {"unknown"};
|
||||
std::string mockEmpty = {};
|
||||
class FirmwareInterface : public L0::Sysman::FirmwareUtil {};
|
||||
class FirmwareFsAccess : public L0::Sysman::FsAccess {};
|
||||
class FirmwareSysfsAccess : public L0::Sysman::SysfsAccess {};
|
||||
class FirmwareFsAccess : public L0::Sysman::FsAccessInterface {};
|
||||
class FirmwareSysfsAccess : public L0::Sysman::SysFsAccessInterface {};
|
||||
|
||||
struct MockFirmwareFsAccess : public FirmwareFsAccess {
|
||||
ze_bool_t isReadFwTypes = true;
|
||||
@@ -41,7 +41,7 @@ struct MockFirmwareFsAccess : public FirmwareFsAccess {
|
||||
}
|
||||
};
|
||||
|
||||
struct MockFirmwareSysfsAccess : public L0::Sysman::SysfsAccess {
|
||||
struct MockFirmwareSysfsAccess : public L0::Sysman::SysFsAccessInterface {
|
||||
|
||||
ze_result_t readResult = ZE_RESULT_SUCCESS;
|
||||
ze_result_t scanDirEntriesResult = ZE_RESULT_SUCCESS;
|
||||
|
||||
@@ -18,7 +18,7 @@ class ZesFirmwareFixture : public SysmanDeviceFixture {
|
||||
std::unique_ptr<MockFirmwareInterface> pMockFwInterface;
|
||||
L0::Sysman::FirmwareUtil *pFwUtilInterfaceOld = nullptr;
|
||||
std::unique_ptr<MockFirmwareFsAccess> pFsAccess;
|
||||
L0::Sysman::FsAccess *pFsAccessOriginal = nullptr;
|
||||
L0::Sysman::FsAccessInterface *pFsAccessOriginal = nullptr;
|
||||
L0::Sysman::SysmanDevice *device = nullptr;
|
||||
|
||||
void SetUp() override {
|
||||
@@ -237,7 +237,7 @@ class ZesFirmwareUninitializedFixture : public SysmanDeviceFixture {
|
||||
std::unique_ptr<MockFirmwareInterface> pMockFwInterface;
|
||||
L0::Sysman::FirmwareUtil *pFwUtilInterfaceOld = nullptr;
|
||||
std::unique_ptr<MockFirmwareFsAccess> pFsAccess;
|
||||
L0::Sysman::FsAccess *pFsAccessOriginal = nullptr;
|
||||
L0::Sysman::FsAccessInterface *pFsAccessOriginal = nullptr;
|
||||
|
||||
void SetUp() override {
|
||||
SysmanDeviceFixture::SetUp();
|
||||
|
||||
@@ -18,8 +18,9 @@ class ZesSysmanFirmwareFixture : public SysmanDeviceFixture {
|
||||
std::unique_ptr<MockFirmwareInterface> pMockFwInterface;
|
||||
L0::Sysman::FirmwareUtil *pFwUtilInterfaceOld = nullptr;
|
||||
std::unique_ptr<MockFirmwareFsAccess> pFsAccess;
|
||||
L0::Sysman::FsAccess *pFsAccessOriginal = nullptr;
|
||||
MockFirmwareSysfsAccess *pMockSysfsAccess = nullptr;
|
||||
L0::Sysman::FsAccessInterface *pFsAccessOriginal = nullptr;
|
||||
L0::Sysman::SysFsAccessInterface *pSysFsAccessOriginal = nullptr;
|
||||
std::unique_ptr<MockFirmwareSysfsAccess> pMockSysfsAccess;
|
||||
L0::Sysman::SysmanDevice *device = nullptr;
|
||||
|
||||
void SetUp() override {
|
||||
@@ -28,9 +29,9 @@ class ZesSysmanFirmwareFixture : public SysmanDeviceFixture {
|
||||
pFsAccess = std::make_unique<MockFirmwareFsAccess>();
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccess.get();
|
||||
|
||||
pMockSysfsAccess = new MockFirmwareSysfsAccess();
|
||||
delete pLinuxSysmanImp->pSysfsAccess;
|
||||
pLinuxSysmanImp->pSysfsAccess = pMockSysfsAccess;
|
||||
pSysFsAccessOriginal = pLinuxSysmanImp->pSysfsAccess;
|
||||
pMockSysfsAccess = std::make_unique<MockFirmwareSysfsAccess>();
|
||||
pLinuxSysmanImp->pSysfsAccess = pMockSysfsAccess.get();
|
||||
|
||||
pFwUtilInterfaceOld = pLinuxSysmanImp->pFwUtilInterface;
|
||||
pMockFwInterface = std::make_unique<MockFirmwareInterface>();
|
||||
@@ -50,6 +51,7 @@ class ZesSysmanFirmwareFixture : public SysmanDeviceFixture {
|
||||
void TearDown() override {
|
||||
pLinuxSysmanImp->pFwUtilInterface = pFwUtilInterfaceOld;
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccessOriginal;
|
||||
pLinuxSysmanImp->pSysfsAccess = pSysFsAccessOriginal;
|
||||
SysmanDeviceFixture::TearDown();
|
||||
}
|
||||
|
||||
@@ -298,7 +300,7 @@ class ZesFirmwareUninitializedFixture : public SysmanDeviceFixture {
|
||||
std::unique_ptr<MockFirmwareInterface> pMockFwInterface;
|
||||
L0::Sysman::FirmwareUtil *pFwUtilInterfaceOld = nullptr;
|
||||
std::unique_ptr<MockFirmwareFsAccess> pFsAccess;
|
||||
L0::Sysman::FsAccess *pFsAccessOriginal = nullptr;
|
||||
L0::Sysman::FsAccessInterface *pFsAccessOriginal = nullptr;
|
||||
|
||||
void SetUp() override {
|
||||
SysmanDeviceFixture::SetUp();
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "shared/test/common/test_macros/mock_method_macros.h"
|
||||
|
||||
#include "level_zero/sysman/source/api/frequency/linux/sysman_os_frequency_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
@@ -49,7 +50,7 @@ const std::string throttleReasonPL2FileLegacy("gt_throttle_reason_status_pl2");
|
||||
const std::string throttleReasonPL4FileLegacy("gt_throttle_reason_status_pl4");
|
||||
const std::string throttleReasonThermalFileLegacy("gt_throttle_reason_status_thermal");
|
||||
|
||||
struct MockFrequencySysfsAccess : public L0::Sysman::SysfsAccess {
|
||||
struct MockFrequencySysfsAccess : public L0::Sysman::SysFsAccessInterface {
|
||||
double mockMin = 0;
|
||||
double mockMax = 0;
|
||||
double mockBoost = 0;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "shared/test/common/test_macros/mock_method_macros.h"
|
||||
|
||||
#include "level_zero/sysman/source/api/frequency/linux/sysman_os_frequency_imp_prelim.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "igfxfmid.h"
|
||||
@@ -52,7 +53,7 @@ const std::string throttleReasonPL2FileLegacy("gt_throttle_reason_status_pl2");
|
||||
const std::string throttleReasonPL4FileLegacy("gt_throttle_reason_status_pl4");
|
||||
const std::string throttleReasonThermalFileLegacy("gt_throttle_reason_status_thermal");
|
||||
|
||||
struct MockFrequencySysfsAccess : public L0::Sysman::SysfsAccess {
|
||||
struct MockFrequencySysfsAccess : public L0::Sysman::SysFsAccessInterface {
|
||||
double mockMin = 0;
|
||||
double mockMax = 0;
|
||||
double mockBoost = 0;
|
||||
|
||||
@@ -31,7 +31,7 @@ class SysmanDeviceFrequencyFixture : public SysmanDeviceFixture {
|
||||
protected:
|
||||
L0::Sysman::SysmanDevice *device = nullptr;
|
||||
std::unique_ptr<MockFrequencySysfsAccess> pSysfsAccess;
|
||||
L0::Sysman::SysfsAccess *pSysfsAccessOld = nullptr;
|
||||
L0::Sysman::SysFsAccessInterface *pSysfsAccessOld = nullptr;
|
||||
|
||||
void SetUp() override {
|
||||
SysmanDeviceFixture::SetUp();
|
||||
@@ -874,7 +874,7 @@ class FreqMultiDeviceFixture : public SysmanMultiDeviceFixture {
|
||||
protected:
|
||||
L0::Sysman::SysmanDevice *device = nullptr;
|
||||
std::unique_ptr<MockFrequencySysfsAccess> pSysfsAccess;
|
||||
L0::Sysman::SysfsAccess *pSysfsAccessOld = nullptr;
|
||||
L0::Sysman::SysFsAccessInterface *pSysfsAccessOld = nullptr;
|
||||
|
||||
void SetUp() override {
|
||||
SysmanMultiDeviceFixture::SetUp();
|
||||
|
||||
@@ -30,7 +30,7 @@ class SysmanDeviceFrequencyFixture : public SysmanDeviceFixture {
|
||||
protected:
|
||||
L0::Sysman::SysmanDevice *device = nullptr;
|
||||
std::unique_ptr<MockFrequencySysfsAccess> pSysfsAccess;
|
||||
L0::Sysman::SysfsAccess *pSysfsAccessOld = nullptr;
|
||||
L0::Sysman::SysFsAccessInterface *pSysfsAccessOld = nullptr;
|
||||
std::unique_ptr<ProductHelper> pProductHelper;
|
||||
std::unique_ptr<ProductHelper> pProductHelperOld;
|
||||
uint32_t numClocks = 0;
|
||||
@@ -927,7 +927,7 @@ class FreqMultiDeviceFixture : public SysmanMultiDeviceFixture {
|
||||
protected:
|
||||
L0::Sysman::SysmanDevice *device = nullptr;
|
||||
std::unique_ptr<MockFrequencySysfsAccess> pSysfsAccess;
|
||||
L0::Sysman::SysfsAccess *pSysfsAccessOld = nullptr;
|
||||
L0::Sysman::SysFsAccessInterface *pSysfsAccessOld = nullptr;
|
||||
std::unique_ptr<ProductHelper> pProductHelper;
|
||||
|
||||
void SetUp() override {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "level_zero/sysman/source/api/global_operations/linux/sysman_os_global_operations_imp.h"
|
||||
#include "level_zero/sysman/source/api/global_operations/sysman_global_operations_imp.h"
|
||||
#include "level_zero/sysman/source/shared/firmware_util/sysman_firmware_util.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/test/unit_tests/sources/linux/mock_sysman_hw_device_id.h"
|
||||
|
||||
namespace L0 {
|
||||
@@ -91,7 +91,7 @@ struct MockGlobalOperationsFirmwareHandleContext : public L0::Sysman::FirmwareHa
|
||||
ADDMETHOD_NOBASE_VOIDRETURN(init, ());
|
||||
};
|
||||
|
||||
struct MockGlobalOperationsSysfsAccess : public L0::Sysman::SysfsAccess {
|
||||
struct MockGlobalOperationsSysfsAccess : public L0::Sysman::SysFsAccessInterface {
|
||||
|
||||
ze_result_t mockScanDirEntriesError = ZE_RESULT_SUCCESS;
|
||||
ze_result_t mockReadError = ZE_RESULT_SUCCESS;
|
||||
@@ -363,7 +363,7 @@ struct MockGlobalOperationsSysfsAccess : public L0::Sysman::SysfsAccess {
|
||||
ADDMETHOD_NOBASE(fileExists, bool, true, (const std::string file));
|
||||
};
|
||||
|
||||
struct MockGlobalOperationsProcfsAccess : public L0::Sysman::ProcfsAccess {
|
||||
struct MockGlobalOperationsProcfsAccess : public L0::Sysman::ProcFsAccessInterface {
|
||||
|
||||
const ::pid_t extraPid = 4;
|
||||
const int extraFd = 5;
|
||||
@@ -466,7 +466,7 @@ struct MockGlobalOperationsProcfsAccess : public L0::Sysman::ProcfsAccess {
|
||||
MockGlobalOperationsProcfsAccess() = default;
|
||||
};
|
||||
|
||||
struct MockGlobalOperationsFsAccess : public L0::Sysman::FsAccess {
|
||||
struct MockGlobalOperationsFsAccess : public L0::Sysman::FsAccessInterface {
|
||||
ze_result_t mockReadError = ZE_RESULT_SUCCESS;
|
||||
ze_result_t readResult = ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
std::string mockReadVal = "";
|
||||
|
||||
@@ -58,9 +58,9 @@ class SysmanGlobalOperationsFixture : public SysmanDeviceFixture {
|
||||
L0::Sysman::DiagnosticsHandleContext *pDiagnosticsHandleContextOld = nullptr;
|
||||
L0::Sysman::FirmwareHandleContext *pFirmwareHandleContextOld = nullptr;
|
||||
L0::Sysman::RasHandleContext *pRasHandleContextOld = nullptr;
|
||||
L0::Sysman::SysfsAccess *pSysfsAccessOld = nullptr;
|
||||
L0::Sysman::ProcfsAccess *pProcfsAccessOld = nullptr;
|
||||
L0::Sysman::FsAccess *pFsAccessOld = nullptr;
|
||||
L0::Sysman::SysFsAccessInterface *pSysfsAccessOld = nullptr;
|
||||
L0::Sysman::ProcFsAccessInterface *pProcfsAccessOld = nullptr;
|
||||
L0::Sysman::FsAccessInterface *pFsAccessOld = nullptr;
|
||||
L0::Sysman::LinuxSysmanImp *pLinuxSysmanImpOld = nullptr;
|
||||
L0::Sysman::OsGlobalOperations *pOsGlobalOperationsPrev = nullptr;
|
||||
L0::Sysman::GlobalOperations *pGlobalOperationsPrev = nullptr;
|
||||
|
||||
@@ -19,9 +19,9 @@ class SysmanGlobalOperationsHelperFixture : public SysmanDeviceFixture {
|
||||
std::unique_ptr<MockGlobalOperationsFsAccess> pFsAccess;
|
||||
std::unique_ptr<MockGlobalOpsFwInterface> pMockFwInterface;
|
||||
L0::Sysman::FirmwareUtil *pFwUtilInterfaceOld = nullptr;
|
||||
L0::Sysman::SysfsAccess *pSysfsAccessOld = nullptr;
|
||||
L0::Sysman::ProcfsAccess *pProcfsAccessOld = nullptr;
|
||||
L0::Sysman::FsAccess *pFsAccessOld = nullptr;
|
||||
L0::Sysman::SysFsAccessInterface *pSysfsAccessOld = nullptr;
|
||||
L0::Sysman::ProcFsAccessInterface *pProcfsAccessOld = nullptr;
|
||||
L0::Sysman::FsAccessInterface *pFsAccessOld = nullptr;
|
||||
L0::Sysman::OsGlobalOperations *pOsGlobalOperationsPrev = nullptr;
|
||||
L0::Sysman::GlobalOperations *pGlobalOperationsPrev = nullptr;
|
||||
L0::Sysman::GlobalOperationsImp *pGlobalOperationsImp;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "level_zero/sysman/source/device/sysman_device.h"
|
||||
#include "level_zero/sysman/source/driver/sysman_driver.h"
|
||||
#include "level_zero/sysman/source/driver/sysman_driver_handle_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_driver_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h"
|
||||
#include "level_zero/sysman/test/unit_tests/sources/firmware_util/mock_fw_util_fixture.h"
|
||||
@@ -148,16 +148,9 @@ class SysmanMultiDeviceFixture : public ::testing::Test {
|
||||
DebugManagerStateRestore restorer;
|
||||
};
|
||||
|
||||
class PublicFsAccess : public L0::Sysman::FsAccess {
|
||||
public:
|
||||
using FsAccess::accessSyscall;
|
||||
using FsAccess::statSyscall;
|
||||
};
|
||||
class PublicFsAccess : public L0::Sysman::FsAccessInterface {};
|
||||
|
||||
class PublicSysfsAccess : public L0::Sysman::SysfsAccess {
|
||||
public:
|
||||
using SysfsAccess::accessSyscall;
|
||||
};
|
||||
class PublicSysfsAccess : public L0::Sysman::SysFsAccessInterface {};
|
||||
|
||||
class PublicLinuxSysmanDriverImp : public L0::Sysman::LinuxSysmanDriverImp {
|
||||
public:
|
||||
|
||||
@@ -30,7 +30,7 @@ const std::string sysfsPahTelem3 = "/sys/class/intel_pmt/telem3";
|
||||
const std::string sysfsPahTelem4 = "/sys/class/intel_pmt/telem4";
|
||||
const std::string sysfsPahTelem5 = "/sys/class/intel_pmt/telem5";
|
||||
|
||||
struct MockPmtFsAccess : public L0::Sysman::FsAccess {
|
||||
struct MockPmtFsAccess : public L0::Sysman::FsAccessInterface {
|
||||
|
||||
ze_result_t listDirectoryResult = ZE_RESULT_SUCCESS;
|
||||
ze_result_t getRealPathResult = ZE_RESULT_SUCCESS;
|
||||
@@ -145,7 +145,7 @@ struct MockPmtFsAccess : public L0::Sysman::FsAccess {
|
||||
|
||||
class PublicPlatformMonitoringTech : public L0::Sysman::PlatformMonitoringTech {
|
||||
public:
|
||||
PublicPlatformMonitoringTech(L0::Sysman::FsAccess *pFsAccess, ze_bool_t onSubdevice, uint32_t subdeviceId) : PlatformMonitoringTech(pFsAccess, onSubdevice, subdeviceId) {}
|
||||
PublicPlatformMonitoringTech(L0::Sysman::FsAccessInterface *pFsAccess, ze_bool_t onSubdevice, uint32_t subdeviceId) : PlatformMonitoringTech(pFsAccess, onSubdevice, subdeviceId) {}
|
||||
using PlatformMonitoringTech::doInitPmtObject;
|
||||
using PlatformMonitoringTech::init;
|
||||
using PlatformMonitoringTech::keyOffsetMap;
|
||||
|
||||
@@ -29,25 +29,17 @@ struct dirent mockEntries[] = {
|
||||
{0, 0, 0, 0, "mockDir2"},
|
||||
};
|
||||
|
||||
inline static int mockAccessFailure(const char *pathname, int mode) {
|
||||
inline static int mockStatFailure(const std::string &filePath, struct stat *statbuf) noexcept {
|
||||
return -1;
|
||||
}
|
||||
|
||||
inline static int mockAccessSuccess(const char *pathname, int mode) {
|
||||
inline static int mockStatSuccess(const std::string &filePath, struct stat *statbuf) noexcept {
|
||||
statbuf->st_mode = S_IWUSR | S_IRUSR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline static int mockStatFailure(const char *pathname, struct stat *sb) noexcept {
|
||||
return -1;
|
||||
}
|
||||
|
||||
inline static int mockStatSuccess(const char *pathname, struct stat *sb) noexcept {
|
||||
sb->st_mode = S_IWUSR | S_IRUSR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline static int mockStatNoPermissions(const char *pathname, struct stat *sb) noexcept {
|
||||
sb->st_mode = 0;
|
||||
inline static int mockStatNoPermissions(const std::string &filePath, struct stat *statbuf) noexcept {
|
||||
statbuf->st_mode = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -79,23 +71,13 @@ TEST_F(SysmanDeviceFixture, GivenValidSysmanKmdInterfaceWhenCallingListDirectori
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, pFsAccess->listDirectory("MockDir", listFiles));
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenCreateFsAccessHandleWhenCallinggetFsAccessThenCreatedFsAccessHandleWillBeRetrieved) {
|
||||
if (pLinuxSysmanImp->pFsAccess != nullptr) {
|
||||
// delete previously allocated pFsAccess
|
||||
delete pLinuxSysmanImp->pFsAccess;
|
||||
pLinuxSysmanImp->pFsAccess = nullptr;
|
||||
}
|
||||
pLinuxSysmanImp->pFsAccess = L0::Sysman::FsAccess::create();
|
||||
EXPECT_EQ(&pLinuxSysmanImp->getFsAccess(), pLinuxSysmanImp->pFsAccess);
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenPublicFsAccessClassWhenCallingDirectoryExistsWithValidAndInvalidPathThenSuccessAndFailureAreReturnedRespectively) {
|
||||
PublicFsAccess *tempFsAccess = new PublicFsAccess();
|
||||
tempFsAccess->accessSyscall = mockAccessSuccess;
|
||||
NEO::SysCalls::allowFakeDevicePath = true;
|
||||
char cwd[PATH_MAX];
|
||||
std::string path = getcwd(cwd, PATH_MAX);
|
||||
EXPECT_TRUE(tempFsAccess->directoryExists(path));
|
||||
tempFsAccess->accessSyscall = mockAccessFailure;
|
||||
NEO::SysCalls::allowFakeDevicePath = false;
|
||||
path = "invalidDiretory";
|
||||
EXPECT_FALSE(tempFsAccess->directoryExists(path));
|
||||
delete tempFsAccess;
|
||||
@@ -103,7 +85,6 @@ TEST_F(SysmanDeviceFixture, GivenPublicFsAccessClassWhenCallingDirectoryExistsWi
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenPublicSysfsAccessClassWhenCallingDirectoryExistsWithInvalidPathThenFalseIsRetured) {
|
||||
PublicFsAccess *tempSysfsAccess = new PublicFsAccess();
|
||||
tempSysfsAccess->accessSyscall = mockAccessFailure;
|
||||
std::string path = "invalidDiretory";
|
||||
EXPECT_FALSE(tempSysfsAccess->directoryExists(path));
|
||||
delete tempSysfsAccess;
|
||||
@@ -111,7 +92,7 @@ TEST_F(SysmanDeviceFixture, GivenPublicSysfsAccessClassWhenCallingDirectoryExist
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenPublicFsAccessClassWhenCallingCanWriteWithUserHavingWritePermissionsThenSuccessIsReturned) {
|
||||
PublicFsAccess *tempFsAccess = new PublicFsAccess();
|
||||
tempFsAccess->statSyscall = mockStatSuccess;
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsStat)> mockStat(&NEO::SysCalls::sysCallsStat, &mockStatSuccess);
|
||||
char cwd[PATH_MAX];
|
||||
std::string path = getcwd(cwd, PATH_MAX);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, tempFsAccess->canWrite(path));
|
||||
@@ -120,7 +101,7 @@ TEST_F(SysmanDeviceFixture, GivenPublicFsAccessClassWhenCallingCanWriteWithUserH
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenPublicFsAccessClassWhenCallingCanReadWithUserHavingReadPermissionsThenSuccessIsReturned) {
|
||||
PublicFsAccess *tempFsAccess = new PublicFsAccess();
|
||||
tempFsAccess->statSyscall = mockStatSuccess;
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsStat)> mockStat(&NEO::SysCalls::sysCallsStat, &mockStatSuccess);
|
||||
char cwd[PATH_MAX];
|
||||
std::string path = getcwd(cwd, PATH_MAX);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, tempFsAccess->canRead(path));
|
||||
@@ -129,7 +110,7 @@ TEST_F(SysmanDeviceFixture, GivenPublicFsAccessClassWhenCallingCanReadWithUserHa
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenPublicFsAccessClassWhenCallingCanWriteWithUserNotHavingWritePermissionsThenInsufficientIsReturned) {
|
||||
PublicFsAccess *tempFsAccess = new PublicFsAccess();
|
||||
tempFsAccess->statSyscall = mockStatNoPermissions;
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsStat)> mockStat(&NEO::SysCalls::sysCallsStat, &mockStatNoPermissions);
|
||||
char cwd[PATH_MAX];
|
||||
std::string path = getcwd(cwd, PATH_MAX);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS, tempFsAccess->canWrite(path));
|
||||
@@ -138,7 +119,7 @@ TEST_F(SysmanDeviceFixture, GivenPublicFsAccessClassWhenCallingCanWriteWithUserN
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenPublicFsAccessClassWhenCallingCanReadWithUserNotHavingReadPermissionsThenInsufficientIsReturned) {
|
||||
PublicFsAccess *tempFsAccess = new PublicFsAccess();
|
||||
tempFsAccess->statSyscall = mockStatNoPermissions;
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsStat)> mockStat(&NEO::SysCalls::sysCallsStat, &mockStatNoPermissions);
|
||||
char cwd[PATH_MAX];
|
||||
std::string path = getcwd(cwd, PATH_MAX);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS, tempFsAccess->canRead(path));
|
||||
@@ -147,7 +128,7 @@ TEST_F(SysmanDeviceFixture, GivenPublicFsAccessClassWhenCallingCanReadWithUserNo
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenPublicFsAccessClassWhenCallingCanReadWithInvalidPathThenErrorIsReturned) {
|
||||
PublicFsAccess *tempFsAccess = new PublicFsAccess();
|
||||
tempFsAccess->statSyscall = mockStatFailure;
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsStat)> mockStat(&NEO::SysCalls::sysCallsStat, &mockStatFailure);
|
||||
std::string path = "invalidPath";
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, tempFsAccess->canRead(path));
|
||||
delete tempFsAccess;
|
||||
@@ -155,7 +136,7 @@ TEST_F(SysmanDeviceFixture, GivenPublicFsAccessClassWhenCallingCanReadWithInvali
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenPublicFsAccessClassWhenCallingCanWriteWithInvalidPathThenErrorIsReturned) {
|
||||
PublicFsAccess *tempFsAccess = new PublicFsAccess();
|
||||
tempFsAccess->statSyscall = mockStatFailure;
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsStat)> mockStat(&NEO::SysCalls::sysCallsStat, &mockStatFailure);
|
||||
std::string path = "invalidPath";
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, tempFsAccess->canRead(path));
|
||||
delete tempFsAccess;
|
||||
@@ -163,38 +144,18 @@ TEST_F(SysmanDeviceFixture, GivenPublicFsAccessClassWhenCallingCanWriteWithInval
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenValidPathnameWhenCallingFsAccessExistsThenSuccessIsReturned) {
|
||||
VariableBackup<bool> allowFakeDevicePathBackup(&SysCalls::allowFakeDevicePath, true);
|
||||
auto fsAccess = pLinuxSysmanImp->getFsAccess();
|
||||
auto fsAccess = &pLinuxSysmanImp->getFsAccess();
|
||||
|
||||
char cwd[PATH_MAX];
|
||||
std::string path = getcwd(cwd, PATH_MAX);
|
||||
EXPECT_TRUE(fsAccess.fileExists(path));
|
||||
EXPECT_TRUE(fsAccess->fileExists(path));
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenInvalidPathnameWhenCallingFsAccessExistsThenErrorIsReturned) {
|
||||
auto fsAccess = pLinuxSysmanImp->getFsAccess();
|
||||
auto fsAccess = &pLinuxSysmanImp->getFsAccess();
|
||||
|
||||
std::string path = "noSuchFileOrDirectory";
|
||||
EXPECT_FALSE(fsAccess.fileExists(path));
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenCreateSysfsAccessHandleWhenCallinggetSysfsAccessThenCreatedSysfsAccessHandleHandleWillBeRetrieved) {
|
||||
if (pLinuxSysmanImp->pSysfsAccess != nullptr) {
|
||||
// delete previously allocated pSysfsAccess
|
||||
delete pLinuxSysmanImp->pSysfsAccess;
|
||||
pLinuxSysmanImp->pSysfsAccess = nullptr;
|
||||
}
|
||||
pLinuxSysmanImp->pSysfsAccess = L0::Sysman::SysfsAccess::create("");
|
||||
EXPECT_EQ(&pLinuxSysmanImp->getSysfsAccess(), pLinuxSysmanImp->pSysfsAccess);
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenCreateProcfsAccessHandleWhenCallinggetProcfsAccessThenCreatedProcfsAccessHandleWillBeRetrieved) {
|
||||
if (pLinuxSysmanImp->pProcfsAccess != nullptr) {
|
||||
// delete previously allocated pProcfsAccess
|
||||
delete pLinuxSysmanImp->pProcfsAccess;
|
||||
pLinuxSysmanImp->pProcfsAccess = nullptr;
|
||||
}
|
||||
pLinuxSysmanImp->pProcfsAccess = L0::Sysman::ProcfsAccess::create();
|
||||
EXPECT_EQ(&pLinuxSysmanImp->getProcfsAccess(), pLinuxSysmanImp->pProcfsAccess);
|
||||
EXPECT_FALSE(fsAccess->fileExists(path));
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenSysfsAccessClassAndIntegerWhenCallingReadOnMultipleFilesThenSuccessIsReturned) {
|
||||
@@ -212,7 +173,7 @@ TEST_F(SysmanDeviceFixture, GivenSysfsAccessClassAndIntegerWhenCallingReadOnMult
|
||||
PublicSysfsAccess *tempSysfsAccess = new PublicSysfsAccess();
|
||||
std::string fileName = {};
|
||||
int iVal32;
|
||||
for (auto i = 0; i < L0::Sysman::FdCache::maxSize + 2; i++) {
|
||||
for (auto i = 0; i < L0::Sysman::FdCacheInterface::maxSize + 2; i++) {
|
||||
fileName = "mockfile" + std::to_string(i) + ".txt";
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, tempSysfsAccess->read(fileName, iVal32));
|
||||
}
|
||||
@@ -221,9 +182,9 @@ TEST_F(SysmanDeviceFixture, GivenSysfsAccessClassAndIntegerWhenCallingReadOnMult
|
||||
|
||||
TEST(FdCacheTest, GivenValidFdCacheWhenCallingGetFdOnSameFileThenVerifyCacheIsUpdatedProperly) {
|
||||
|
||||
class MockFdCache : public FdCache {
|
||||
class MockFdCache : public FdCacheInterface {
|
||||
public:
|
||||
using FdCache::fdMap;
|
||||
using FdCacheInterface::fdMap;
|
||||
};
|
||||
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsOpen)> mockOpen(&NEO::SysCalls::sysCallsOpen, [](const char *pathname, int flags) -> int {
|
||||
@@ -232,7 +193,7 @@ TEST(FdCacheTest, GivenValidFdCacheWhenCallingGetFdOnSameFileThenVerifyCacheIsUp
|
||||
|
||||
std::unique_ptr<MockFdCache> pFdCache = std::make_unique<MockFdCache>();
|
||||
std::string fileName = {};
|
||||
for (auto i = 0; i < L0::Sysman::FdCache::maxSize; i++) {
|
||||
for (auto i = 0; i < L0::Sysman::FdCacheInterface::maxSize; i++) {
|
||||
fileName = "mockfile" + std::to_string(i) + ".txt";
|
||||
EXPECT_LE(0, pFdCache->getFd(fileName));
|
||||
}
|
||||
@@ -242,7 +203,7 @@ TEST(FdCacheTest, GivenValidFdCacheWhenCallingGetFdOnSameFileThenVerifyCacheIsUp
|
||||
EXPECT_LE(0, pFdCache->getFd(fileName));
|
||||
}
|
||||
|
||||
for (auto i = 1; i < L0::Sysman::FdCache::maxSize - 1; i++) {
|
||||
for (auto i = 1; i < L0::Sysman::FdCacheInterface::maxSize - 1; i++) {
|
||||
fileName = "mockfile" + std::to_string(i) + ".txt";
|
||||
EXPECT_LE(0, pFdCache->getFd(fileName));
|
||||
}
|
||||
@@ -259,9 +220,9 @@ TEST(FdCacheTest, GivenValidFdCacheWhenCallingGetFdOnSameFileThenVerifyCacheIsUp
|
||||
|
||||
TEST(FdCacheTest, GivenValidFdCacheWhenClearingCacheThenVerifyProperFdsAreClosedAndCacheIsUpdatedProperly) {
|
||||
|
||||
class MockFdCache : public FdCache {
|
||||
class MockFdCache : public FdCacheInterface {
|
||||
public:
|
||||
using FdCache::fdMap;
|
||||
using FdCacheInterface::fdMap;
|
||||
};
|
||||
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsOpen)> mockOpen(&NEO::SysCalls::sysCallsOpen, [](const char *pathname, int flags) -> int {
|
||||
@@ -275,7 +236,7 @@ TEST(FdCacheTest, GivenValidFdCacheWhenClearingCacheThenVerifyProperFdsAreClosed
|
||||
|
||||
MockFdCache *pFdCache = new MockFdCache();
|
||||
std::string fileName = {};
|
||||
for (auto i = 0; i < L0::Sysman::FdCache::maxSize; i++) {
|
||||
for (auto i = 0; i < L0::Sysman::FdCacheInterface::maxSize; i++) {
|
||||
fileName = "mockfile" + std::to_string(i) + ".txt";
|
||||
EXPECT_LE(0, pFdCache->getFd(fileName));
|
||||
}
|
||||
@@ -285,7 +246,7 @@ TEST(FdCacheTest, GivenValidFdCacheWhenClearingCacheThenVerifyProperFdsAreClosed
|
||||
EXPECT_LE(0, pFdCache->getFd(fileName));
|
||||
}
|
||||
|
||||
for (auto i = 1; i < L0::Sysman::FdCache::maxSize - 1; i++) {
|
||||
for (auto i = 1; i < L0::Sysman::FdCacheInterface::maxSize - 1; i++) {
|
||||
fileName = "mockfile" + std::to_string(i) + ".txt";
|
||||
EXPECT_LE(0, pFdCache->getFd(fileName));
|
||||
}
|
||||
@@ -325,15 +286,15 @@ TEST_F(SysmanDeviceFixture, GivenSysfsAccessClassAndOpenSysCallFailsWhenCallingR
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenValidPidWhenCallingProcfsAccessIsAliveThenSuccessIsReturned) {
|
||||
VariableBackup<bool> allowFakeDevicePathBackup(&SysCalls::allowFakeDevicePath, true);
|
||||
auto procfsAccess = pLinuxSysmanImp->getProcfsAccess();
|
||||
auto procfsAccess = &pLinuxSysmanImp->getProcfsAccess();
|
||||
|
||||
EXPECT_TRUE(procfsAccess.isAlive(getpid()));
|
||||
EXPECT_TRUE(procfsAccess->isAlive(getpid()));
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenInvalidPidWhenCallingProcfsAccessIsAliveThenErrorIsReturned) {
|
||||
auto procfsAccess = pLinuxSysmanImp->getProcfsAccess();
|
||||
auto procfsAccess = &pLinuxSysmanImp->getProcfsAccess();
|
||||
|
||||
EXPECT_FALSE(procfsAccess.isAlive(reinterpret_cast<::pid_t>(-1)));
|
||||
EXPECT_FALSE(procfsAccess->isAlive(reinterpret_cast<::pid_t>(-1)));
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenValidPciPathWhileGettingCardBusPortThenReturnedPathIs1LevelUpThenTheCurrentPath) {
|
||||
@@ -350,11 +311,11 @@ TEST_F(SysmanDeviceFixture, GivenValidPciPathWhileGettingCardBusPortThenReturned
|
||||
|
||||
TEST_F(SysmanMultiDeviceFixture, GivenValidEffectiveUserIdCheckWhetherPermissionsReturnedByIsRootUserAreCorrect) {
|
||||
int euid = geteuid();
|
||||
auto pFsAccess = pLinuxSysmanImp->getFsAccess();
|
||||
auto pFsAccess = &pLinuxSysmanImp->getFsAccess();
|
||||
if (euid == 0) {
|
||||
EXPECT_EQ(true, pFsAccess.isRootUser());
|
||||
EXPECT_EQ(true, pFsAccess->isRootUser());
|
||||
} else {
|
||||
EXPECT_EQ(false, pFsAccess.isRootUser());
|
||||
EXPECT_EQ(false, pFsAccess->isRootUser());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ const std::string sysfsPahTelem3 = "/sys/class/intel_pmt/telem3";
|
||||
const std::string sysfsPahTelem4 = "/sys/class/intel_pmt/telem4";
|
||||
const std::string sysfsPahTelem5 = "/sys/class/intel_pmt/telem5";
|
||||
|
||||
struct MockMemorySysfsAccess : public L0::Sysman::SysfsAccess {
|
||||
struct MockMemorySysfsAccess : public L0::Sysman::SysFsAccessInterface {
|
||||
|
||||
std::vector<ze_result_t> mockReadReturnStatus{};
|
||||
std::vector<std::string> mockReadStringValue{};
|
||||
@@ -263,7 +263,7 @@ struct MockMemoryPmt : public L0::Sysman::PlatformMonitoringTech {
|
||||
this->guid = guid;
|
||||
}
|
||||
|
||||
MockMemoryPmt(L0::Sysman::FsAccess *pFsAccess, ze_bool_t onSubdevice, uint32_t subdeviceId) : L0::Sysman::PlatformMonitoringTech(pFsAccess, onSubdevice, subdeviceId) {}
|
||||
MockMemoryPmt(L0::Sysman::FsAccessInterface *pFsAccess, ze_bool_t onSubdevice, uint32_t subdeviceId) : L0::Sysman::PlatformMonitoringTech(pFsAccess, onSubdevice, subdeviceId) {}
|
||||
ze_result_t readValue(const std::string key, uint32_t &val) override {
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
|
||||
@@ -438,7 +438,7 @@ struct MockMemoryPmt : public L0::Sysman::PlatformMonitoringTech {
|
||||
}
|
||||
};
|
||||
|
||||
struct MockMemoryFsAccess : public L0::Sysman::FsAccess {
|
||||
struct MockMemoryFsAccess : public L0::Sysman::FsAccessInterface {
|
||||
ze_result_t listDirectory(const std::string directory, std::vector<std::string> &listOfTelemNodes) override {
|
||||
if (directory.compare(baseTelemSysFS) == 0) {
|
||||
listOfTelemNodes.push_back("telem1");
|
||||
|
||||
@@ -44,8 +44,8 @@ class SysmanDeviceMemoryFixture : public SysmanDeviceFixture {
|
||||
protected:
|
||||
std::unique_ptr<MockMemorySysfsAccess> pSysfsAccess;
|
||||
std::unique_ptr<MockMemoryFsAccess> pFsAccess;
|
||||
L0::Sysman::SysfsAccess *pSysfsAccessOld = nullptr;
|
||||
L0::Sysman::FsAccess *pFsAccessOriginal = nullptr;
|
||||
L0::Sysman::SysFsAccessInterface *pSysfsAccessOld = nullptr;
|
||||
L0::Sysman::FsAccessInterface *pFsAccessOriginal = nullptr;
|
||||
MockMemoryNeoDrm *pDrm = nullptr;
|
||||
Drm *pOriginalDrm = nullptr;
|
||||
L0::Sysman::SysmanDevice *device = nullptr;
|
||||
@@ -807,7 +807,7 @@ TEST_F(SysmanMultiDeviceFixture, GivenValidDevicePointerWhenGettingMemoryPropert
|
||||
class SysmanMultiDeviceMemoryFixture : public SysmanMultiDeviceFixture {
|
||||
protected:
|
||||
std::unique_ptr<MockMemorySysfsAccess> pSysfsAccess;
|
||||
L0::Sysman::SysfsAccess *pSysfsAccessOld = nullptr;
|
||||
L0::Sysman::SysFsAccessInterface *pSysfsAccessOld = nullptr;
|
||||
MockMemoryNeoDrm *pDrm = nullptr;
|
||||
Drm *pOriginalDrm = nullptr;
|
||||
L0::Sysman::SysmanDevice *device = nullptr;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "level_zero/sysman/source/api/pci/linux/sysman_os_pci_imp.h"
|
||||
#include "level_zero/sysman/source/api/pci/sysman_pci_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/sysman_const.h"
|
||||
|
||||
namespace L0 {
|
||||
@@ -41,7 +41,7 @@ const std::vector<std::string> mockReadBytes =
|
||||
"0x0000000000000000 0x0000000000000000 0x0000000000000000",
|
||||
};
|
||||
|
||||
struct MockPciSysfsAccess : public L0::Sysman::SysfsAccess {
|
||||
struct MockPciSysfsAccess : public L0::Sysman::SysFsAccessInterface {
|
||||
|
||||
bool isStringSymLinkEmpty = false;
|
||||
|
||||
|
||||
@@ -206,8 +206,8 @@ class ZesPciFixture : public SysmanDeviceFixture {
|
||||
protected:
|
||||
std::unique_ptr<MockPciSysfsAccess> pSysfsAccess;
|
||||
L0::Sysman::SysmanDevice *device = nullptr;
|
||||
L0::Sysman::SysfsAccess *pOriginalSysfsAccess = nullptr;
|
||||
L0::Sysman::FsAccess *pOriginalFsAccess = nullptr;
|
||||
L0::Sysman::SysFsAccessInterface *pOriginalSysfsAccess = nullptr;
|
||||
L0::Sysman::FsAccessInterface *pOriginalFsAccess = nullptr;
|
||||
L0::Sysman::PciImp *pPciImp;
|
||||
L0::Sysman::OsPci *pOsPciPrev;
|
||||
std::unique_ptr<L0::ult::Mock<L0::DriverHandleImp>> driverHandle;
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
#include "level_zero/sysman/source/api/performance/linux/sysman_os_performance_imp_prelim.h"
|
||||
#include "level_zero/sysman/source/api/performance/sysman_performance.h"
|
||||
#include "level_zero/sysman/source/api/performance/sysman_performance_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
|
||||
#include <list>
|
||||
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
@@ -26,7 +28,7 @@ const std::string baseFreqFactorSubDevice1("gt/gt1/base_freq_factor");
|
||||
const std::string baseScaleSubDevice1("gt/gt1/base_freq_factor.scale");
|
||||
const std::string pwrBalance("sys_pwr_balance");
|
||||
|
||||
struct MockPerformanceSysfsAccess : public L0::Sysman::SysfsAccess {
|
||||
struct MockPerformanceSysfsAccess : public L0::Sysman::SysFsAccessInterface {
|
||||
ze_result_t mockReadResult = ZE_RESULT_SUCCESS;
|
||||
ze_result_t mockCanReadResult = ZE_RESULT_SUCCESS;
|
||||
ze_bool_t isComputeInvalid = false;
|
||||
|
||||
@@ -23,7 +23,7 @@ constexpr double minPerformanceFactor = 0;
|
||||
class ZesPerformanceFixture : public SysmanMultiDeviceFixture {
|
||||
protected:
|
||||
std::unique_ptr<MockPerformanceSysfsAccess> ptestSysfsAccess;
|
||||
L0::Sysman::SysfsAccess *pOriginalSysfsAccess = nullptr;
|
||||
L0::Sysman::SysFsAccessInterface *pOriginalSysfsAccess = nullptr;
|
||||
L0::Sysman::SysmanDevice *device = nullptr;
|
||||
void SetUp() override {
|
||||
SysmanMultiDeviceFixture::SetUp();
|
||||
|
||||
@@ -50,7 +50,7 @@ const std::map<std::string, uint64_t> deviceKeyOffsetMapPower = {
|
||||
{"SOC_TEMPERATURES", 0x60},
|
||||
{"CORE_TEMPERATURES", 0x6c}};
|
||||
|
||||
struct MockPowerSysfsAccess : public L0::Sysman::SysfsAccess {
|
||||
struct MockPowerSysfsAccess : public L0::Sysman::SysFsAccessInterface {
|
||||
|
||||
std::vector<ze_result_t> mockReadReturnStatus{};
|
||||
std::vector<ze_result_t> mockWriteReturnStatus{};
|
||||
@@ -525,12 +525,12 @@ struct MockPowerPmt : public L0::Sysman::PlatformMonitoringTech {
|
||||
using L0::Sysman::PlatformMonitoringTech::preadFunction;
|
||||
using L0::Sysman::PlatformMonitoringTech::telemetryDeviceEntry;
|
||||
|
||||
MockPowerPmt(L0::Sysman::FsAccess *pFsAccess, ze_bool_t onSubdevice, uint32_t subdeviceId) : L0::Sysman::PlatformMonitoringTech(pFsAccess, onSubdevice, subdeviceId) {}
|
||||
MockPowerPmt(L0::Sysman::FsAccessInterface *pFsAccess, ze_bool_t onSubdevice, uint32_t subdeviceId) : L0::Sysman::PlatformMonitoringTech(pFsAccess, onSubdevice, subdeviceId) {}
|
||||
~MockPowerPmt() override {
|
||||
rootDeviceTelemNodeIndex = 0;
|
||||
}
|
||||
|
||||
void mockedInit(L0::Sysman::FsAccess *pFsAccess) {
|
||||
void mockedInit(L0::Sysman::FsAccessInterface *pFsAccess) {
|
||||
std::string gpuUpstreamPortPath = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0";
|
||||
if (ZE_RESULT_SUCCESS != L0::Sysman::PlatformMonitoringTech::enumerateRootTelemIndex(pFsAccess, gpuUpstreamPortPath)) {
|
||||
return;
|
||||
@@ -539,7 +539,7 @@ struct MockPowerPmt : public L0::Sysman::PlatformMonitoringTech {
|
||||
}
|
||||
};
|
||||
|
||||
struct MockPowerFsAccess : public L0::Sysman::FsAccess {
|
||||
struct MockPowerFsAccess : public L0::Sysman::FsAccessInterface {
|
||||
|
||||
ze_result_t listDirectory(const std::string directory, std::vector<std::string> &listOfTelemNodes) override {
|
||||
if (directory.compare(baseTelemSysFS) == 0) {
|
||||
@@ -595,8 +595,8 @@ class SysmanDevicePowerFixtureI915 : public SysmanDeviceFixture {
|
||||
std::unique_ptr<MockPowerPmt> pPmt;
|
||||
std::unique_ptr<MockPowerFsAccess> pFsAccess;
|
||||
std::unique_ptr<MockPowerSysfsAccess> pSysfsAccess;
|
||||
L0::Sysman::SysfsAccess *pSysfsAccessOld = nullptr;
|
||||
L0::Sysman::FsAccess *pFsAccessOriginal = nullptr;
|
||||
L0::Sysman::SysFsAccessInterface *pSysfsAccessOld = nullptr;
|
||||
L0::Sysman::FsAccessInterface *pFsAccessOriginal = nullptr;
|
||||
L0::Sysman::OsPower *pOsPowerOriginal = nullptr;
|
||||
std::map<uint32_t, L0::Sysman::PlatformMonitoringTech *> pmtMapOriginal;
|
||||
|
||||
@@ -660,8 +660,8 @@ class SysmanDevicePowerMultiDeviceFixture : public SysmanMultiDeviceFixture {
|
||||
std::unique_ptr<MockPowerPmt> pPmt;
|
||||
std::unique_ptr<MockPowerFsAccess> pFsAccess;
|
||||
std::unique_ptr<MockPowerSysfsAccess> pSysfsAccess;
|
||||
L0::Sysman::SysfsAccess *pSysfsAccessOld = nullptr;
|
||||
L0::Sysman::FsAccess *pFsAccessOriginal = nullptr;
|
||||
L0::Sysman::SysFsAccessInterface *pSysfsAccessOld = nullptr;
|
||||
L0::Sysman::FsAccessInterface *pFsAccessOriginal = nullptr;
|
||||
L0::Sysman::OsPower *pOsPowerOriginal = nullptr;
|
||||
std::map<uint32_t, L0::Sysman::PlatformMonitoringTech *> mapOriginal;
|
||||
void SetUp() override {
|
||||
|
||||
@@ -49,7 +49,7 @@ const std::map<std::string, uint64_t> deviceKeyOffsetMapPower = {
|
||||
{"SOC_TEMPERATURES", 0x60},
|
||||
{"CORE_TEMPERATURES", 0x6c}};
|
||||
|
||||
struct MockPowerSysfsAccess : public L0::Sysman::SysfsAccess {
|
||||
struct MockPowerSysfsAccess : public L0::Sysman::SysFsAccessInterface {
|
||||
ze_result_t mockReadResult = ZE_RESULT_SUCCESS;
|
||||
ze_result_t mockReadPeakResult = ZE_RESULT_SUCCESS;
|
||||
ze_result_t mockWriteResult = ZE_RESULT_SUCCESS;
|
||||
@@ -236,7 +236,7 @@ struct MockPowerSysfsAccess : public L0::Sysman::SysfsAccess {
|
||||
|
||||
struct MockPowerPmt : public L0::Sysman::PlatformMonitoringTech {
|
||||
|
||||
MockPowerPmt(L0::Sysman::FsAccess *pFsAccess, ze_bool_t onSubdevice, uint32_t subdeviceId) : L0::Sysman::PlatformMonitoringTech(pFsAccess, onSubdevice, subdeviceId) {}
|
||||
MockPowerPmt(L0::Sysman::FsAccessInterface *pFsAccess, ze_bool_t onSubdevice, uint32_t subdeviceId) : L0::Sysman::PlatformMonitoringTech(pFsAccess, onSubdevice, subdeviceId) {}
|
||||
using L0::Sysman::PlatformMonitoringTech::keyOffsetMap;
|
||||
using L0::Sysman::PlatformMonitoringTech::preadFunction;
|
||||
using L0::Sysman::PlatformMonitoringTech::telemetryDeviceEntry;
|
||||
@@ -244,7 +244,7 @@ struct MockPowerPmt : public L0::Sysman::PlatformMonitoringTech {
|
||||
rootDeviceTelemNodeIndex = 0;
|
||||
}
|
||||
|
||||
void mockedInit(L0::Sysman::FsAccess *pFsAccess) {
|
||||
void mockedInit(L0::Sysman::FsAccessInterface *pFsAccess) {
|
||||
std::string gpuUpstreamPortPath = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0";
|
||||
if (ZE_RESULT_SUCCESS != L0::Sysman::PlatformMonitoringTech::enumerateRootTelemIndex(pFsAccess, gpuUpstreamPortPath)) {
|
||||
return;
|
||||
@@ -254,7 +254,7 @@ struct MockPowerPmt : public L0::Sysman::PlatformMonitoringTech {
|
||||
}
|
||||
};
|
||||
|
||||
struct MockPowerFsAccess : public L0::Sysman::FsAccess {
|
||||
struct MockPowerFsAccess : public L0::Sysman::FsAccessInterface {
|
||||
|
||||
ze_result_t listDirectory(const std::string directory, std::vector<std::string> &listOfTelemNodes) override {
|
||||
if (directory.compare(baseTelemSysFS) == 0) {
|
||||
@@ -304,8 +304,8 @@ class SysmanDevicePowerFixture : public SysmanDeviceFixture {
|
||||
std::unique_ptr<MockPowerPmt> pPmt;
|
||||
std::unique_ptr<MockPowerFsAccess> pFsAccess;
|
||||
std::unique_ptr<MockPowerSysfsAccess> pSysfsAccess;
|
||||
L0::Sysman::SysfsAccess *pSysfsAccessOld = nullptr;
|
||||
L0::Sysman::FsAccess *pFsAccessOriginal = nullptr;
|
||||
L0::Sysman::SysFsAccessInterface *pSysfsAccessOld = nullptr;
|
||||
L0::Sysman::FsAccessInterface *pFsAccessOriginal = nullptr;
|
||||
L0::Sysman::OsPower *pOsPowerOriginal = nullptr;
|
||||
std::map<uint32_t, L0::Sysman::PlatformMonitoringTech *> pmtMapOriginal;
|
||||
void SetUp() override {
|
||||
@@ -354,8 +354,8 @@ class SysmanDevicePowerMultiDeviceFixture : public SysmanMultiDeviceFixture {
|
||||
std::unique_ptr<MockPowerPmt> pPmt;
|
||||
std::unique_ptr<MockPowerFsAccess> pFsAccess;
|
||||
std::unique_ptr<MockPowerSysfsAccess> pSysfsAccess;
|
||||
L0::Sysman::SysfsAccess *pSysfsAccessOld = nullptr;
|
||||
L0::Sysman::FsAccess *pFsAccessOriginal = nullptr;
|
||||
L0::Sysman::SysFsAccessInterface *pSysfsAccessOld = nullptr;
|
||||
L0::Sysman::FsAccessInterface *pFsAccessOriginal = nullptr;
|
||||
L0::Sysman::OsPower *pOsPowerOriginal = nullptr;
|
||||
std::map<uint32_t, L0::Sysman::PlatformMonitoringTech *> mapOriginal;
|
||||
void SetUp() override {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "level_zero/sysman/source/api/ras/sysman_ras.h"
|
||||
#include "level_zero/sysman/source/api/ras/sysman_ras_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/pmu/sysman_pmu_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h"
|
||||
#include "level_zero/sysman/test/unit_tests/sources/linux/mock_sysman_hw_device_id.h"
|
||||
|
||||
@@ -264,7 +264,7 @@ struct MockRasPmuInterfaceImp : public L0::Sysman::PmuInterfaceImp {
|
||||
}
|
||||
};
|
||||
|
||||
struct MockRasSysfsAccess : public L0::Sysman::SysfsAccess {
|
||||
struct MockRasSysfsAccess : public L0::Sysman::SysFsAccessInterface {
|
||||
|
||||
ze_result_t mockReadSymLinkStatus = ZE_RESULT_SUCCESS;
|
||||
bool mockReadSymLinkResult = false;
|
||||
@@ -461,7 +461,7 @@ struct MockRasSysfsAccess : public L0::Sysman::SysfsAccess {
|
||||
}
|
||||
};
|
||||
|
||||
struct MockRasFsAccess : public L0::Sysman::FsAccess {
|
||||
struct MockRasFsAccess : public L0::Sysman::FsAccessInterface {
|
||||
|
||||
ze_result_t mockListDirectoryStatus = ZE_RESULT_SUCCESS;
|
||||
bool mockReadDirectoryFailure = false;
|
||||
|
||||
@@ -26,8 +26,8 @@ struct SysmanRasFixture : public SysmanDeviceFixture {
|
||||
std::unique_ptr<MockRasPmuInterfaceImp> pPmuInterface;
|
||||
std::unique_ptr<MockRasFwInterface> pRasFwUtilInterface;
|
||||
MockRasNeoDrm *pDrm = nullptr;
|
||||
L0::Sysman::FsAccess *pFsAccessOriginal = nullptr;
|
||||
L0::Sysman::SysfsAccess *pSysfsAccessOriginal = nullptr;
|
||||
L0::Sysman::FsAccessInterface *pFsAccessOriginal = nullptr;
|
||||
L0::Sysman::SysFsAccessInterface *pSysfsAccessOriginal = nullptr;
|
||||
L0::Sysman::PmuInterface *pOriginalPmuInterface = nullptr;
|
||||
L0::Sysman::FirmwareUtil *pFwUtilOriginal = nullptr;
|
||||
L0::Sysman::SysmanDevice *device = nullptr;
|
||||
@@ -537,8 +537,8 @@ struct SysmanRasMultiDeviceFixture : public SysmanMultiDeviceFixture {
|
||||
std::unique_ptr<MockRasPmuInterfaceImp> pPmuInterface;
|
||||
std::unique_ptr<MockRasFwInterface> pRasFwUtilInterface;
|
||||
MockRasNeoDrm *pDrm = nullptr;
|
||||
L0::Sysman::FsAccess *pFsAccessOriginal = nullptr;
|
||||
L0::Sysman::SysfsAccess *pSysfsAccessOriginal = nullptr;
|
||||
L0::Sysman::FsAccessInterface *pFsAccessOriginal = nullptr;
|
||||
L0::Sysman::SysFsAccessInterface *pSysfsAccessOriginal = nullptr;
|
||||
L0::Sysman::PmuInterface *pOriginalPmuInterface = nullptr;
|
||||
L0::Sysman::FirmwareUtil *pFwUtilOriginal = nullptr;
|
||||
Drm *pOriginalDrm = nullptr;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "shared/source/os_interface/linux/engine_info.h"
|
||||
|
||||
#include "level_zero/sysman/source/api/scheduler/linux/sysman_os_scheduler_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/test/unit_tests/sources/linux/mock_sysman_hw_device_id.h"
|
||||
|
||||
#include "drm/xe_drm.h"
|
||||
@@ -47,7 +47,7 @@ class SchedulerFileProperties {
|
||||
}
|
||||
};
|
||||
|
||||
struct MockSchedulerSysfsAccess : public L0::Sysman::SysfsAccess {
|
||||
struct MockSchedulerSysfsAccess : public L0::Sysman::SysFsAccessInterface {
|
||||
|
||||
std::string preemptTimeout{};
|
||||
std::string defaultpreemptTimeout{};
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "shared/source/os_interface/linux/ioctl_helper.h"
|
||||
|
||||
#include "level_zero/sysman/source/api/scheduler/linux/sysman_os_scheduler_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/test/unit_tests/sources/linux/mock_sysman_hw_device_id.h"
|
||||
|
||||
namespace L0 {
|
||||
@@ -180,7 +180,7 @@ class SchedulerFileProperties {
|
||||
}
|
||||
};
|
||||
|
||||
class MockSchedulerProcfsAccess : public L0::Sysman::ProcfsAccess {
|
||||
class MockSchedulerProcfsAccess : public L0::Sysman::ProcFsAccessInterface {
|
||||
public:
|
||||
MockSchedulerProcfsAccess() = default;
|
||||
|
||||
@@ -266,8 +266,8 @@ class CalledTimesUpdate {
|
||||
int &calledTimesVar;
|
||||
};
|
||||
|
||||
struct MockSchedulerSysfsAccess : public L0::Sysman::SysfsAccess {
|
||||
using SysfsAccess::deviceNames;
|
||||
struct MockSchedulerSysfsAccess : public L0::Sysman::SysFsAccessInterface {
|
||||
using SysFsAccessInterface::deviceNames;
|
||||
|
||||
ze_result_t mockReadFileFailureError = ZE_RESULT_SUCCESS;
|
||||
ze_result_t mockGetScanDirEntryError = ZE_RESULT_SUCCESS;
|
||||
|
||||
@@ -56,7 +56,7 @@ class SysmanDeviceSchedulerFixtureI915 : public SysmanDeviceSchedulerFixture {
|
||||
|
||||
protected:
|
||||
std::unique_ptr<MockSchedulerSysfsAccessI915> pSysfsAccess;
|
||||
L0::Sysman::SysfsAccess *pSysfsAccessOld = nullptr;
|
||||
L0::Sysman::SysFsAccessInterface *pSysfsAccessOld = nullptr;
|
||||
|
||||
uint64_t defaultTimeout = 650u;
|
||||
uint64_t defaultTimeslice = 1u;
|
||||
@@ -639,7 +639,7 @@ class SysmanDeviceSchedulerFixtureXe : public SysmanDeviceSchedulerFixture {
|
||||
|
||||
protected:
|
||||
std::unique_ptr<MockSchedulerSysfsAccessXe> pSysfsAccess;
|
||||
L0::Sysman::SysfsAccess *pSysfsAccessOld = nullptr;
|
||||
L0::Sysman::SysFsAccessInterface *pSysfsAccessOld = nullptr;
|
||||
|
||||
uint64_t defaultTimeout = 650u;
|
||||
uint64_t defaultTimeslice = 1u;
|
||||
|
||||
@@ -35,7 +35,7 @@ class SysmanDeviceSchedulerFixture : public SysmanDeviceFixture {
|
||||
|
||||
protected:
|
||||
std::unique_ptr<MockSchedulerSysfsAccess> pSysfsAccess;
|
||||
L0::Sysman::SysfsAccess *pSysfsAccessOld = nullptr;
|
||||
L0::Sysman::SysFsAccessInterface *pSysfsAccessOld = nullptr;
|
||||
PublicLinuxSchedulerImp *pLinuxSchedulerImp = nullptr;
|
||||
L0::Sysman::SysmanDevice *device = nullptr;
|
||||
|
||||
@@ -359,7 +359,7 @@ TEST_F(SysmanDeviceSchedulerFixture, GivenValidDeviceHandleWhenCallingzesSchedul
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceSchedulerFixture, GivenCurrentModeIsDebugModeWhenCallingzesSchedulerSetTimeoutModeThenVerifyCallSucceeds) {
|
||||
VariableBackup<L0::Sysman::ProcfsAccess *> backup(&pLinuxSysmanImp->pProcfsAccess);
|
||||
VariableBackup<L0::Sysman::ProcFsAccessInterface *> backup(&pLinuxSysmanImp->pProcfsAccess);
|
||||
auto pMockSchedulerProcfsAccess = new MockSchedulerProcfsAccess;
|
||||
pLinuxSysmanImp->pProcfsAccess = pMockSchedulerProcfsAccess;
|
||||
|
||||
@@ -383,7 +383,7 @@ TEST_F(SysmanDeviceSchedulerFixture, GivenCurrentModeIsDebugModeWhenCallingzesSc
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceSchedulerFixture, GivenCurrentModeIsDebugModeWhenSettingTimeoutModeAndDebugModeCantBeChangedThenVerifyCallFails) {
|
||||
VariableBackup<L0::Sysman::ProcfsAccess *> backup(&pLinuxSysmanImp->pProcfsAccess);
|
||||
VariableBackup<L0::Sysman::ProcFsAccessInterface *> backup(&pLinuxSysmanImp->pProcfsAccess);
|
||||
auto pMockSchedulerProcfsAccess = new MockSchedulerProcfsAccess;
|
||||
pLinuxSysmanImp->pProcfsAccess = pMockSchedulerProcfsAccess;
|
||||
pMockSchedulerProcfsAccess->listProcessesResult = ZE_RESULT_ERROR_NOT_AVAILABLE; // Expect failure when calling gpuProcessCleanup()
|
||||
@@ -514,7 +514,7 @@ TEST_F(SysmanDeviceSchedulerFixture, GivenValidDeviceHandleWhenCallingzesSchedul
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceSchedulerFixture, GivenCurrentModeIsDebugModeWhenCallingzesSchedulerSetTimesliceModeThenVerifyCallSucceeds) {
|
||||
VariableBackup<L0::Sysman::ProcfsAccess *> backup(&pLinuxSysmanImp->pProcfsAccess);
|
||||
VariableBackup<L0::Sysman::ProcFsAccessInterface *> backup(&pLinuxSysmanImp->pProcfsAccess);
|
||||
auto pMockSchedulerProcfsAccess = new MockSchedulerProcfsAccess;
|
||||
pLinuxSysmanImp->pProcfsAccess = pMockSchedulerProcfsAccess;
|
||||
|
||||
@@ -540,7 +540,7 @@ TEST_F(SysmanDeviceSchedulerFixture, GivenCurrentModeIsDebugModeWhenCallingzesSc
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceSchedulerFixture, GivenCurrentModeIsDebugModeWhenSettingTimesliceModeAndDebugModeCantBeChangedThenVerifyCallFails) {
|
||||
VariableBackup<L0::Sysman::ProcfsAccess *> backup(&pLinuxSysmanImp->pProcfsAccess);
|
||||
VariableBackup<L0::Sysman::ProcFsAccessInterface *> backup(&pLinuxSysmanImp->pProcfsAccess);
|
||||
auto pMockSchedulerProcfsAccess = new MockSchedulerProcfsAccess;
|
||||
pLinuxSysmanImp->pProcfsAccess = pMockSchedulerProcfsAccess;
|
||||
pMockSchedulerProcfsAccess->listProcessesResult = ZE_RESULT_ERROR_NOT_AVAILABLE; // Expect failure when calling gpuProcessCleanup()
|
||||
@@ -653,7 +653,7 @@ TEST_F(SysmanDeviceSchedulerFixture, GivenValidDeviceHandleWhenCallingzesSchedul
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceSchedulerFixture, GivenCurrentModeIsDebugModeWhenCallingzesSchedulerSetExclusiveModeThenVerifyCallSucceeds) {
|
||||
VariableBackup<L0::Sysman::ProcfsAccess *> backup(&pLinuxSysmanImp->pProcfsAccess);
|
||||
VariableBackup<L0::Sysman::ProcFsAccessInterface *> backup(&pLinuxSysmanImp->pProcfsAccess);
|
||||
auto pMockSchedulerProcfsAccess = new MockSchedulerProcfsAccess;
|
||||
pLinuxSysmanImp->pProcfsAccess = pMockSchedulerProcfsAccess;
|
||||
|
||||
@@ -672,7 +672,7 @@ TEST_F(SysmanDeviceSchedulerFixture, GivenCurrentModeIsDebugModeWhenCallingzesSc
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceSchedulerFixture, GivenCurrentModeIsDebugModeWhenSettingExclusiveModeAndDebugModeCantBeChangedThenVerifyCallFails) {
|
||||
VariableBackup<L0::Sysman::ProcfsAccess *> backup(&pLinuxSysmanImp->pProcfsAccess);
|
||||
VariableBackup<L0::Sysman::ProcFsAccessInterface *> backup(&pLinuxSysmanImp->pProcfsAccess);
|
||||
auto pMockSchedulerProcfsAccess = new MockSchedulerProcfsAccess;
|
||||
pLinuxSysmanImp->pProcfsAccess = pMockSchedulerProcfsAccess;
|
||||
pMockSchedulerProcfsAccess->listProcessesResult = ZE_RESULT_ERROR_NOT_AVAILABLE; // Expect failure when calling gpuProcessCleanup()
|
||||
@@ -790,7 +790,7 @@ TEST_F(SysmanDeviceSchedulerFixture, GivenValidDeviceHandleWhenCallingzesSchedul
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceSchedulerFixture, GivenValidDeviceHandleWhenCallingzesSchedulerSetComputeUnitDebugModeThenSuccessIsReturned) {
|
||||
VariableBackup<L0::Sysman::ProcfsAccess *> backup(&pLinuxSysmanImp->pProcfsAccess);
|
||||
VariableBackup<L0::Sysman::ProcFsAccessInterface *> backup(&pLinuxSysmanImp->pProcfsAccess);
|
||||
auto pMockSchedulerProcfsAccess = new MockSchedulerProcfsAccess;
|
||||
pLinuxSysmanImp->pProcfsAccess = pMockSchedulerProcfsAccess;
|
||||
|
||||
@@ -811,7 +811,7 @@ TEST_F(SysmanDeviceSchedulerFixture, GivenValidDeviceHandleWhenCallingzesSchedul
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceSchedulerFixture, GivenGpuProcessCleanupFailedWhenCallingzesSchedulerSetComputeUnitDebugModeThenErrorIsReturned) {
|
||||
VariableBackup<L0::Sysman::ProcfsAccess *> backup(&pLinuxSysmanImp->pProcfsAccess);
|
||||
VariableBackup<L0::Sysman::ProcFsAccessInterface *> backup(&pLinuxSysmanImp->pProcfsAccess);
|
||||
auto pMockSchedulerProcfsAccess = new MockSchedulerProcfsAccess;
|
||||
pLinuxSysmanImp->pProcfsAccess = pMockSchedulerProcfsAccess;
|
||||
pMockSchedulerProcfsAccess->listProcessesResult = ZE_RESULT_ERROR_NOT_AVAILABLE; // Expect failure when calling gpuProcessCleanup()
|
||||
@@ -833,7 +833,7 @@ TEST_F(SysmanDeviceSchedulerFixture, GivenGpuProcessCleanupFailedWhenCallingzesS
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceSchedulerFixture, GivenEuDebugNodeWriteFailsWhenCallingzesSchedulerSetComputeUnitDebugModeThenErrorIsReturned) {
|
||||
VariableBackup<L0::Sysman::ProcfsAccess *> backup(&pLinuxSysmanImp->pProcfsAccess);
|
||||
VariableBackup<L0::Sysman::ProcFsAccessInterface *> backup(&pLinuxSysmanImp->pProcfsAccess);
|
||||
auto pMockSchedulerProcfsAccess = new MockSchedulerProcfsAccess;
|
||||
pLinuxSysmanImp->pProcfsAccess = pMockSchedulerProcfsAccess;
|
||||
|
||||
|
||||
@@ -380,7 +380,6 @@ TEST_F(ZesStandbyFixtureXe, GivenKmdInterfaceWhenQueryingSupportForStandbyForXeV
|
||||
}
|
||||
|
||||
class ZesStandbyMultiDeviceFixture : public SysmanMultiDeviceFixture {
|
||||
|
||||
protected:
|
||||
L0::Sysman::SysmanDevice *device = nullptr;
|
||||
uint32_t subDeviceCount;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "level_zero/sysman/source/api/temperature/linux/sysman_os_temperature_imp.h"
|
||||
#include "level_zero/sysman/source/api/temperature/sysman_temperature_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/pmt/sysman_pmt.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
@@ -43,7 +43,7 @@ const std::string sysfsPahTelem4 = "/sys/class/intel_pmt/telem4";
|
||||
const std::string sysfsPahTelem5 = "/sys/class/intel_pmt/telem5";
|
||||
|
||||
struct MockTemperaturePmt : public L0::Sysman::PlatformMonitoringTech {
|
||||
MockTemperaturePmt(L0::Sysman::FsAccess *pFsAccess, ze_bool_t onSubdevice, uint32_t subdeviceId) : L0::Sysman::PlatformMonitoringTech(pFsAccess, onSubdevice, subdeviceId) {}
|
||||
MockTemperaturePmt(L0::Sysman::FsAccessInterface *pFsAccess, ze_bool_t onSubdevice, uint32_t subdeviceId) : L0::Sysman::PlatformMonitoringTech(pFsAccess, onSubdevice, subdeviceId) {}
|
||||
using L0::Sysman::PlatformMonitoringTech::keyOffsetMap;
|
||||
using L0::Sysman::PlatformMonitoringTech::preadFunction;
|
||||
using L0::Sysman::PlatformMonitoringTech::telemetryDeviceEntry;
|
||||
@@ -56,7 +56,7 @@ struct MockTemperaturePmt : public L0::Sysman::PlatformMonitoringTech {
|
||||
rootDeviceTelemNodeIndex = 0;
|
||||
}
|
||||
|
||||
void mockedInit(L0::Sysman::FsAccess *pFsAccess) {
|
||||
void mockedInit(L0::Sysman::FsAccessInterface *pFsAccess) {
|
||||
if (ZE_RESULT_SUCCESS != PlatformMonitoringTech::enumerateRootTelemIndex(pFsAccess, gpuUpstreamPortPathInTemperature)) {
|
||||
return;
|
||||
}
|
||||
@@ -123,7 +123,7 @@ struct MockTemperaturePmt : public L0::Sysman::PlatformMonitoringTech {
|
||||
}
|
||||
};
|
||||
|
||||
struct MockTemperatureFsAccess : public L0::Sysman::FsAccess {
|
||||
struct MockTemperatureFsAccess : public L0::Sysman::FsAccessInterface {
|
||||
ze_result_t mockErrorListDirectory = ZE_RESULT_SUCCESS;
|
||||
ze_result_t mockErrorGetRealPath = ZE_RESULT_SUCCESS;
|
||||
ze_result_t listDirectory(const std::string directory, std::vector<std::string> &listOfTelemNodes) override {
|
||||
|
||||
@@ -25,7 +25,7 @@ class SysmanMultiDeviceTemperatureFixture : public SysmanMultiDeviceFixture {
|
||||
protected:
|
||||
std::unique_ptr<PublicLinuxTemperatureImp> pPublicLinuxTemperatureImp;
|
||||
std::unique_ptr<MockTemperatureFsAccess> pFsAccess;
|
||||
L0::Sysman::FsAccess *pFsAccessOriginal = nullptr;
|
||||
L0::Sysman::FsAccessInterface *pFsAccessOriginal = nullptr;
|
||||
std::map<uint32_t, L0::Sysman::PlatformMonitoringTech *> mapOriginal;
|
||||
L0::Sysman::SysmanDevice *device = nullptr;
|
||||
void SetUp() override {
|
||||
@@ -160,7 +160,7 @@ class SysmanDeviceTemperatureFixture : public SysmanDeviceFixture {
|
||||
protected:
|
||||
std::unique_ptr<PublicLinuxTemperatureImp> pPublicLinuxTemperatureImp;
|
||||
std::unique_ptr<MockTemperatureFsAccess> pFsAccess;
|
||||
L0::Sysman::FsAccess *pFsAccessOriginal = nullptr;
|
||||
L0::Sysman::FsAccessInterface *pFsAccessOriginal = nullptr;
|
||||
std::map<uint32_t, L0::Sysman::PlatformMonitoringTech *> pmtMapOriginal;
|
||||
L0::Sysman::SysmanDevice *device = nullptr;
|
||||
void SetUp() override {
|
||||
|
||||
Reference in New Issue
Block a user