2020-03-06 11:09:57 +01:00
/*
2022-01-04 09:57:06 +00:00
* Copyright ( C ) 2020 - 2022 Intel Corporation
2020-03-06 11:09:57 +01:00
*
* SPDX - License - Identifier : MIT
*
*/
2020-03-22 08:52:57 +01:00
# include "level_zero/tools/source/sysman/linux/os_sysman_imp.h"
2020-03-06 11:09:57 +01:00
2022-07-06 13:23:03 +00:00
# include "shared/source/memory_manager/memory_manager.h"
2022-01-04 09:57:06 +00:00
# include "shared/source/os_interface/device_factory.h"
# include "level_zero/core/source/device/device_imp.h"
2022-06-02 16:12:23 +00:00
# include "level_zero/core/source/driver/driver_handle_imp.h"
2022-06-17 09:30:19 +00:00
# include "level_zero/tools/source/sysman/firmware_util/firmware_util.h"
2020-03-19 12:36:29 -04:00
# include "level_zero/tools/source/sysman/linux/fs_access.h"
2020-03-06 11:09:57 +01:00
2022-06-17 09:30:19 +00:00
# include "sysman/firmware_util/firmware_util.h"
2021-11-09 14:12:15 +00:00
2020-03-06 11:09:57 +01:00
namespace L0 {
2022-01-04 09:57:06 +00:00
const std : : string LinuxSysmanImp : : deviceDir ( " device " ) ;
2020-03-06 11:09:57 +01:00
ze_result_t LinuxSysmanImp : : init ( ) {
2020-03-19 12:36:29 -04:00
pFsAccess = FsAccess : : create ( ) ;
2021-09-15 17:20:49 +05:30
DEBUG_BREAK_IF ( nullptr = = pFsAccess ) ;
2020-03-19 12:36:29 -04:00
2021-09-15 17:20:49 +05:30
if ( pProcfsAccess = = nullptr ) {
pProcfsAccess = ProcfsAccess : : create ( ) ;
}
DEBUG_BREAK_IF ( nullptr = = pProcfsAccess ) ;
2020-03-19 12:36:29 -04:00
2021-10-11 15:34:03 +00:00
auto result = initLocalDeviceAndDrmHandles ( ) ;
if ( ZE_RESULT_SUCCESS ! = result ) {
return result ;
2021-09-30 12:38:56 +00:00
}
2020-03-19 12:36:29 -04:00
int myDeviceFd = pDrm - > getFileDescriptor ( ) ;
std : : string myDeviceName ;
2021-10-11 15:34:03 +00:00
result = pProcfsAccess - > getFileName ( pProcfsAccess - > myProcessId ( ) , myDeviceFd , myDeviceName ) ;
2020-03-19 12:36:29 -04:00
if ( ZE_RESULT_SUCCESS ! = result ) {
return result ;
}
2020-03-06 11:09:57 +01:00
2021-09-15 17:20:49 +05:30
if ( pSysfsAccess = = nullptr ) {
pSysfsAccess = SysfsAccess : : create ( myDeviceName ) ;
}
DEBUG_BREAK_IF ( nullptr = = pSysfsAccess ) ;
2020-03-19 12:36:29 -04:00
2021-10-11 15:34:03 +00:00
pPmuInterface = PmuInterface : : create ( this ) ;
DEBUG_BREAK_IF ( nullptr = = pPmuInterface ) ;
2021-11-09 14:12:15 +00:00
2021-10-11 15:34:03 +00:00
return createPmtHandles ( ) ;
}
2021-11-09 14:12:15 +00:00
void LinuxSysmanImp : : createFwUtilInterface ( ) {
2022-06-17 09:30:19 +00:00
ze_pci_ext_properties_t pPciProperties ;
if ( ZE_RESULT_SUCCESS ! = pDevice - > getPciProperties ( & pPciProperties ) ) {
2021-11-09 14:12:15 +00:00
return ;
}
2022-06-17 09:30:19 +00:00
uint16_t domain = static_cast < uint16_t > ( pPciProperties . address . domain ) ;
uint8_t bus = static_cast < uint8_t > ( pPciProperties . address . bus ) ;
uint8_t device = static_cast < uint8_t > ( pPciProperties . address . device ) ;
uint8_t function = static_cast < uint8_t > ( pPciProperties . address . function ) ;
pFwUtilInterface = FirmwareUtil : : create ( domain , bus , device , function ) ;
2021-11-09 14:12:15 +00:00
}
2021-10-11 15:34:03 +00:00
ze_result_t LinuxSysmanImp : : createPmtHandles ( ) {
2022-06-16 13:02:42 +00:00
std : : string gtDevicePCIPath ;
auto result = pSysfsAccess - > getRealPath ( " device " , gtDevicePCIPath ) ;
2021-01-20 23:52:47 +05:30
if ( ZE_RESULT_SUCCESS ! = result ) {
return result ;
}
2022-06-16 13:02:42 +00:00
auto gpuUpstreamPortPath = getPciCardBusDirectoryPath ( gtDevicePCIPath ) ;
PlatformMonitoringTech : : create ( pParentSysmanDeviceImp - > deviceHandles , pFsAccess , gpuUpstreamPortPath , mapOfSubDeviceIdToPmtObject ) ;
2021-10-11 15:34:03 +00:00
return result ;
2020-03-06 11:09:57 +01:00
}
2020-08-26 15:32:23 +05:30
PmuInterface * LinuxSysmanImp : : getPmuInterface ( ) {
return pPmuInterface ;
}
2020-11-12 14:26:22 +05:30
FirmwareUtil * LinuxSysmanImp : : getFwUtilInterface ( ) {
2021-11-24 09:25:05 +00:00
if ( pFwUtilInterface = = nullptr ) {
createFwUtilInterface ( ) ;
}
2020-11-12 14:26:22 +05:30
return pFwUtilInterface ;
}
2020-03-19 12:36:29 -04:00
FsAccess & LinuxSysmanImp : : getFsAccess ( ) {
UNRECOVERABLE_IF ( nullptr = = pFsAccess ) ;
return * pFsAccess ;
}
ProcfsAccess & LinuxSysmanImp : : getProcfsAccess ( ) {
UNRECOVERABLE_IF ( nullptr = = pProcfsAccess ) ;
return * pProcfsAccess ;
}
2020-03-06 11:09:57 +01:00
SysfsAccess & LinuxSysmanImp : : getSysfsAccess ( ) {
UNRECOVERABLE_IF ( nullptr = = pSysfsAccess ) ;
return * pSysfsAccess ;
}
2021-10-11 15:34:03 +00:00
ze_result_t LinuxSysmanImp : : initLocalDeviceAndDrmHandles ( ) {
pDevice = Device : : fromHandle ( pParentSysmanDeviceImp - > hCoreDevice ) ;
DEBUG_BREAK_IF ( nullptr = = pDevice ) ;
2022-05-12 14:04:41 +00:00
NEO : : OSInterface & osInterface = pDevice - > getOsInterface ( ) ;
if ( osInterface . getDriverModel ( ) - > getDriverModelType ( ) ! = NEO : : DriverModelType : : DRM ) {
2021-10-11 15:34:03 +00:00
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE ;
}
2022-05-12 14:04:41 +00:00
pDrm = osInterface . getDriverModel ( ) - > as < NEO : : Drm > ( ) ;
2021-10-11 15:34:03 +00:00
return ZE_RESULT_SUCCESS ;
}
2020-06-17 15:17:48 +05:30
NEO : : Drm & LinuxSysmanImp : : getDrm ( ) {
2021-10-11 15:34:03 +00:00
if ( pDrm = = nullptr ) {
initLocalDeviceAndDrmHandles ( ) ;
}
2020-06-17 15:17:48 +05:30
UNRECOVERABLE_IF ( nullptr = = pDrm ) ;
return * pDrm ;
}
2021-10-11 15:34:03 +00:00
void LinuxSysmanImp : : releaseLocalDrmHandle ( ) {
pDrm = nullptr ;
}
2020-08-13 23:33:21 +05:30
Device * LinuxSysmanImp : : getDeviceHandle ( ) {
return pDevice ;
}
2020-09-25 14:04:02 -04:00
SysmanDeviceImp * LinuxSysmanImp : : getSysmanDeviceImp ( ) {
return pParentSysmanDeviceImp ;
}
2022-06-16 13:02:42 +00:00
static std : : string modifyPathOnLevel ( std : : string realPciPath , uint8_t nLevel ) {
2021-01-20 23:52:47 +05:30
size_t loc ;
2022-06-16 13:02:42 +00:00
// we need to change the absolute path to 'nLevel' levels up
2021-01-20 23:52:47 +05:30
while ( nLevel > 0 ) {
loc = realPciPath . find_last_of ( ' / ' ) ;
if ( loc = = std : : string : : npos ) {
break ;
}
realPciPath = realPciPath . substr ( 0 , loc ) ;
nLevel - - ;
}
return realPciPath ;
}
2022-06-16 13:02:42 +00:00
std : : string getPciRootPortDirectoryPath ( std : : string realPciPath ) {
2022-01-04 09:57:06 +00:00
// the rootport is always the first pci folder after the pcie slot.
2022-06-16 13:02:42 +00:00
// +-[0000:89]-+-00.0
// | +-00.1
// | +-00.2
// | +-00.4
// | \-02.0-[8a-8e]----00.0-[8b-8e]--+-01.0-[8c-8d]----00.0
// | \-02.0-[8e]--+-00.0
// | +-00.1
// | \-00.2
2022-01-04 09:57:06 +00:00
// /sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0/0000:8b:01.0/0000:8c:00.0
// '/sys/devices/pci0000:89/0000:89:02.0/' will always be the same distance.
2022-06-16 13:02:42 +00:00
// from 0000:8c:00.0 i.e the 3rd PCI address from the gt tile
return modifyPathOnLevel ( realPciPath , 3 ) ;
2022-01-04 09:57:06 +00:00
}
std : : string LinuxSysmanImp : : getPciCardBusDirectoryPath ( std : : string realPciPath ) {
// the cardbus is always the second pci folder after the pcie slot.
2022-06-16 13:02:42 +00:00
// +-[0000:89]-+-00.0
// | +-00.1
// | +-00.2
// | +-00.4
// | \-02.0-[8a-8e]----00.0-[8b-8e]--+-01.0-[8c-8d]----00.0
// | \-02.0-[8e]--+-00.0
// | +-00.1
// | \-00.2
2022-01-04 09:57:06 +00:00
// /sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0/0000:8b:01.0/0000:8c:00.0
// '/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0/' will always be the same distance.
2022-06-16 13:02:42 +00:00
// from 0000:8c:00.0 i.e the 2nd PCI address from the gt tile.
return modifyPathOnLevel ( realPciPath , 2 ) ;
2022-01-04 09:57:06 +00:00
}
2021-01-20 23:52:47 +05:30
PlatformMonitoringTech * LinuxSysmanImp : : getPlatformMonitoringTechAccess ( uint32_t subDeviceId ) {
auto subDeviceIdToPmtEntry = mapOfSubDeviceIdToPmtObject . find ( subDeviceId ) ;
if ( subDeviceIdToPmtEntry = = mapOfSubDeviceIdToPmtObject . end ( ) ) {
return nullptr ;
}
return subDeviceIdToPmtEntry - > second ;
2020-06-30 17:34:31 -07:00
}
2020-07-03 20:05:35 +05:30
LinuxSysmanImp : : LinuxSysmanImp ( SysmanDeviceImp * pParentSysmanDeviceImp ) {
this - > pParentSysmanDeviceImp = pParentSysmanDeviceImp ;
}
2021-04-14 12:30:33 +00:00
void LinuxSysmanImp : : releasePmtObject ( ) {
for ( auto & subDeviceIdToPmtEntry : mapOfSubDeviceIdToPmtObject ) {
2021-05-17 16:59:16 +00:00
if ( subDeviceIdToPmtEntry . second ) {
delete subDeviceIdToPmtEntry . second ;
subDeviceIdToPmtEntry . second = nullptr ;
}
2021-04-14 12:30:33 +00:00
}
2021-05-17 16:59:16 +00:00
mapOfSubDeviceIdToPmtObject . clear ( ) ;
2021-04-14 12:30:33 +00:00
}
2021-11-09 14:12:15 +00:00
void LinuxSysmanImp : : releaseFwUtilInterface ( ) {
if ( nullptr ! = pFwUtilInterface ) {
delete pFwUtilInterface ;
pFwUtilInterface = nullptr ;
}
}
2021-04-14 12:30:33 +00:00
2020-03-06 11:09:57 +01:00
LinuxSysmanImp : : ~ LinuxSysmanImp ( ) {
if ( nullptr ! = pSysfsAccess ) {
delete pSysfsAccess ;
2020-05-12 17:21:14 -07:00
pSysfsAccess = nullptr ;
2020-03-06 11:09:57 +01:00
}
2020-03-19 12:36:29 -04:00
if ( nullptr ! = pProcfsAccess ) {
delete pProcfsAccess ;
2020-05-12 17:21:14 -07:00
pProcfsAccess = nullptr ;
2020-03-19 12:36:29 -04:00
}
if ( nullptr ! = pFsAccess ) {
delete pFsAccess ;
2020-05-12 17:21:14 -07:00
pFsAccess = nullptr ;
2020-03-19 12:36:29 -04:00
}
2020-08-26 15:32:23 +05:30
if ( nullptr ! = pPmuInterface ) {
delete pPmuInterface ;
pPmuInterface = nullptr ;
}
2021-11-09 14:12:15 +00:00
releaseFwUtilInterface ( ) ;
2021-04-14 12:30:33 +00:00
releasePmtObject ( ) ;
2020-03-06 11:09:57 +01:00
}
2022-01-04 09:57:06 +00:00
void LinuxSysmanImp : : getPidFdsForOpenDevice ( ProcfsAccess * pProcfsAccess , SysfsAccess * pSysfsAccess , const : : pid_t pid , std : : vector < int > & deviceFds ) {
// Return a list of all the file descriptors of this process that point to this device
std : : vector < int > fds ;
deviceFds . clear ( ) ;
if ( ZE_RESULT_SUCCESS ! = pProcfsAccess - > getFileDescriptors ( pid , fds ) ) {
// Process exited. Not an error. Just ignore.
return ;
}
for ( auto & & fd : fds ) {
std : : string file ;
if ( pProcfsAccess - > getFileName ( pid , fd , file ) ! = ZE_RESULT_SUCCESS ) {
// Process closed this file. Not an error. Just ignore.
continue ;
}
if ( pSysfsAccess - > isMyDeviceFile ( file ) ) {
deviceFds . push_back ( fd ) ;
}
}
}
void LinuxSysmanImp : : releaseSysmanDeviceResources ( ) {
getSysmanDeviceImp ( ) - > pEngineHandleContext - > releaseEngines ( ) ;
getSysmanDeviceImp ( ) - > pRasHandleContext - > releaseRasHandles ( ) ;
if ( ! diagnosticsReset ) {
getSysmanDeviceImp ( ) - > pDiagnosticsHandleContext - > releaseDiagnosticsHandles ( ) ;
}
getSysmanDeviceImp ( ) - > pFirmwareHandleContext - > releaseFwHandles ( ) ;
releasePmtObject ( ) ;
if ( ! diagnosticsReset ) {
releaseFwUtilInterface ( ) ;
}
releaseLocalDrmHandle ( ) ;
}
void LinuxSysmanImp : : releaseDeviceResources ( ) {
2022-04-28 08:56:02 +00:00
auto devicePtr = static_cast < DeviceImp * > ( pDevice ) ;
executionEnvironment = devicePtr - > getNEODevice ( ) - > getExecutionEnvironment ( ) ;
devicePciBdf = devicePtr - > getNEODevice ( ) - > getRootDeviceEnvironment ( ) . osInterface - > getDriverModel ( ) - > as < NEO : : Drm > ( ) - > getPciPath ( ) ;
rootDeviceIndex = devicePtr - > getNEODevice ( ) - > getRootDeviceIndex ( ) ;
2022-06-16 13:02:42 +00:00
pSysfsAccess - > getRealPath ( deviceDir , gtDevicePath ) ;
2022-01-04 09:57:06 +00:00
releaseSysmanDeviceResources ( ) ;
auto device = static_cast < DeviceImp * > ( getDeviceHandle ( ) ) ;
executionEnvironment = device - > getNEODevice ( ) - > getExecutionEnvironment ( ) ;
device - > releaseResources ( ) ;
executionEnvironment - > memoryManager - > releaseDeviceSpecificMemResources ( rootDeviceIndex ) ;
executionEnvironment - > releaseRootDeviceEnvironmentResources ( executionEnvironment - > rootDeviceEnvironments [ rootDeviceIndex ] . get ( ) ) ;
executionEnvironment - > rootDeviceEnvironments [ rootDeviceIndex ] . reset ( ) ;
}
void LinuxSysmanImp : : reInitSysmanDeviceResources ( ) {
getSysmanDeviceImp ( ) - > updateSubDeviceHandlesLocally ( ) ;
createPmtHandles ( ) ;
2022-09-06 09:15:54 +00:00
if ( ! diagnosticsReset ) {
createFwUtilInterface ( ) ;
}
2022-08-11 13:42:59 +00:00
if ( getSysmanDeviceImp ( ) - > pRasHandleContext - > isRasInitDone ( ) ) {
getSysmanDeviceImp ( ) - > pRasHandleContext - > init ( getSysmanDeviceImp ( ) - > deviceHandles ) ;
}
if ( getSysmanDeviceImp ( ) - > pEngineHandleContext - > isEngineInitDone ( ) ) {
getSysmanDeviceImp ( ) - > pEngineHandleContext - > init ( ) ;
}
2022-01-04 09:57:06 +00:00
if ( ! diagnosticsReset ) {
2022-08-11 13:42:59 +00:00
if ( getSysmanDeviceImp ( ) - > pDiagnosticsHandleContext - > isDiagnosticsInitDone ( ) ) {
getSysmanDeviceImp ( ) - > pDiagnosticsHandleContext - > init ( ) ;
}
2022-01-04 09:57:06 +00:00
}
2022-04-28 08:56:02 +00:00
this - > diagnosticsReset = false ;
2022-08-11 13:42:59 +00:00
if ( getSysmanDeviceImp ( ) - > pFirmwareHandleContext - > isFirmwareInitDone ( ) ) {
getSysmanDeviceImp ( ) - > pFirmwareHandleContext - > init ( ) ;
}
2022-01-04 09:57:06 +00:00
}
ze_result_t LinuxSysmanImp : : initDevice ( ) {
ze_result_t result = ZE_RESULT_SUCCESS ;
auto device = static_cast < DeviceImp * > ( getDeviceHandle ( ) ) ;
auto neoDevice = NEO : : DeviceFactory : : createDevice ( * executionEnvironment , devicePciBdf , rootDeviceIndex ) ;
if ( neoDevice = = nullptr ) {
return ZE_RESULT_ERROR_DEVICE_LOST ;
}
static_cast < L0 : : DriverHandleImp * > ( device - > getDriverHandle ( ) ) - > updateRootDeviceBitFields ( neoDevice ) ;
static_cast < L0 : : DriverHandleImp * > ( device - > getDriverHandle ( ) ) - > enableRootDeviceDebugger ( neoDevice ) ;
Device : : deviceReinit ( device - > getDriverHandle ( ) , device , neoDevice , & result ) ;
reInitSysmanDeviceResources ( ) ;
2022-04-28 08:56:02 +00:00
2022-01-04 09:57:06 +00:00
return ZE_RESULT_SUCCESS ;
}
// A 'warm reset' is a conventional reset that is triggered across a PCI express link.
// A warm reset is triggered either when a link is forced into electrical idle or
// by sending TS1 and TS2 ordered sets with the hot reset bit set.
// Software can initiate a warm reset by setting and then clearing the secondary bus reset bit
// in the bridge control register in the PCI configuration space of the bridge port upstream of the device.
ze_result_t LinuxSysmanImp : : osWarmReset ( ) {
std : : string rootPortPath ;
2022-06-16 13:02:42 +00:00
std : : string cardBusPath = getPciCardBusDirectoryPath ( gtDevicePath ) ;
ze_result_t result = pFsAccess - > write ( cardBusPath + ' / ' + " remove " , " 1 " ) ;
2022-04-28 08:56:02 +00:00
if ( ZE_RESULT_SUCCESS ! = result ) {
return result ;
}
2022-09-26 14:35:19 +00:00
if ( diagnosticsReset ) {
this - > pSleepFunctionSecs ( 30 ) ; // Sleep for 30seconds to make sure that the config spaces of all devices are saved correctly after IFR
} else {
this - > pSleepFunctionSecs ( 10 ) ; // Sleep for 10seconds to make sure that the config spaces of all devices are saved correctly
}
2022-06-16 13:02:42 +00:00
rootPortPath = getPciRootPortDirectoryPath ( gtDevicePath ) ;
2022-01-04 09:57:06 +00:00
int fd , ret = 0 ;
unsigned int offset = PCI_BRIDGE_CONTROL ; // Bridge control offset in Header of PCI config space
unsigned int value = 0x00 ;
unsigned int resetValue = 0x00 ;
std : : string configFilePath = rootPortPath + ' / ' + " config " ;
fd = this - > openFunction ( configFilePath . c_str ( ) , O_RDWR ) ;
if ( fd < 0 ) {
return ZE_RESULT_ERROR_UNKNOWN ;
}
this - > preadFunction ( fd , & value , 0x01 , offset ) ;
resetValue = value | PCI_BRIDGE_CTL_BUS_RESET ;
this - > pwriteFunction ( fd , & resetValue , 0x01 , offset ) ;
2022-04-28 08:56:02 +00:00
this - > pSleepFunctionSecs ( 10 ) ; // Sleep for 10seconds just to make sure the change is propagated.
2022-01-04 09:57:06 +00:00
this - > pwriteFunction ( fd , & value , 0x01 , offset ) ;
2022-04-28 08:56:02 +00:00
this - > pSleepFunctionSecs ( 10 ) ; // Sleep for 10seconds to make sure the change is propagated. before rescan is done.
2022-01-04 09:57:06 +00:00
ret = this - > closeFunction ( fd ) ;
if ( ret < 0 ) {
return ZE_RESULT_ERROR_UNKNOWN ;
}
2022-04-28 08:56:02 +00:00
result = pFsAccess - > write ( rootPortPath + ' / ' + " rescan " , " 1 " ) ;
2022-01-04 09:57:06 +00:00
if ( ZE_RESULT_SUCCESS ! = result ) {
return result ;
}
2022-09-26 14:35:19 +00:00
if ( diagnosticsReset ) {
this - > pSleepFunctionSecs ( 30 ) ; // Sleep for 30seconds to make sure that the config spaces of all devices are saved correctly after IFR
} else {
this - > pSleepFunctionSecs ( 10 ) ; // Sleep for 10seconds, allows the rescan to complete on all devices attached to the root port.
}
2022-04-28 08:56:02 +00:00
return result ;
2022-01-04 09:57:06 +00:00
}
std : : string LinuxSysmanImp : : getAddressFromPath ( std : : string & rootPortPath ) {
size_t loc ;
loc = rootPortPath . find_last_of ( ' / ' ) ; // we get the pci address of the root port from rootPortPath
return rootPortPath . substr ( loc + 1 , std : : string : : npos ) ;
}
ze_result_t LinuxSysmanImp : : osColdReset ( ) {
2022-06-16 13:02:42 +00:00
const std : : string slotPath ( " /sys/bus/pci/slots/ " ) ; // holds the directories matching to the number of slots in the PC
std : : string cardBusPath ; // will hold the PCIe Root port directory path (the address of the PCIe slot). // will hold the absolute real path (not symlink) to the selected Device
2022-01-04 09:57:06 +00:00
2022-06-16 13:02:42 +00:00
cardBusPath = getPciCardBusDirectoryPath ( gtDevicePath ) ; // e.g cardBusPath=/sys/devices/pci0000:89/0000:89:02.0/
2022-01-04 09:57:06 +00:00
std : : string rootAddress = getAddressFromPath ( cardBusPath ) ; // e.g rootAddress = 0000:8a:00.0
std : : vector < std : : string > dir ;
2022-06-16 13:02:42 +00:00
ze_result_t result = pFsAccess - > listDirectory ( slotPath , dir ) ; // get list of slot directories from /sys/bus/pci/slots/
2022-01-04 09:57:06 +00:00
if ( ZE_RESULT_SUCCESS ! = result ) {
return result ;
}
for ( auto & slot : dir ) {
std : : string slotAddress ;
result = pFsAccess - > read ( ( slotPath + slot + " /address " ) , slotAddress ) ; // extract slot address from the slot directory /sys/bus/pci/slots/<slot num>/address
if ( ZE_RESULT_SUCCESS ! = result ) {
return result ;
}
if ( slotAddress . compare ( rootAddress ) = = 0 ) { // compare slot address to root port address
result = pFsAccess - > write ( ( slotPath + slot + " /power " ) , " 0 " ) ; // turn off power
if ( ZE_RESULT_SUCCESS ! = result ) {
return result ;
}
std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 100 ) ) ; // Sleep for 100 milliseconds just to make sure, 1 ms is defined as part of spec
result = pFsAccess - > write ( ( slotPath + slot + " /power " ) , " 1 " ) ; // turn on power
if ( ZE_RESULT_SUCCESS ! = result ) {
return result ;
}
2022-04-28 08:56:02 +00:00
return ZE_RESULT_SUCCESS ;
2022-01-04 09:57:06 +00:00
}
}
return ZE_RESULT_ERROR_DEVICE_LOST ; // incase the reset fails inform upper layers.
}
2020-07-03 20:05:35 +05:30
OsSysman * OsSysman : : create ( SysmanDeviceImp * pParentSysmanDeviceImp ) {
LinuxSysmanImp * pLinuxSysmanImp = new LinuxSysmanImp ( pParentSysmanDeviceImp ) ;
return static_cast < OsSysman * > ( pLinuxSysmanImp ) ;
}
2022-07-02 10:23:53 +00:00
std : : vector < ze_device_handle_t > & LinuxSysmanImp : : getDeviceHandles ( ) {
return pParentSysmanDeviceImp - > deviceHandles ;
}
2022-07-17 19:12:13 +00:00
ze_device_handle_t LinuxSysmanImp : : getCoreDeviceHandle ( ) {
return pParentSysmanDeviceImp - > hCoreDevice ;
}
2022-07-02 10:23:53 +00:00
2020-03-06 11:09:57 +01:00
} // namespace L0