2020-03-06 18:09:57 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2019-2020 Intel Corporation
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "level_zero/tools/source/sysman/sysman_imp.h"
|
|
|
|
|
2020-03-19 13:21:57 +08:00
|
|
|
#include "level_zero/core/source/driver/driver.h"
|
|
|
|
#include "level_zero/core/source/driver/driver_handle_imp.h"
|
2020-07-03 22:35:35 +08:00
|
|
|
#include "level_zero/tools/source/sysman/global_operations/global_operations_imp.h"
|
2020-03-22 15:52:57 +08:00
|
|
|
#include "level_zero/tools/source/sysman/pci/pci_imp.h"
|
2020-04-09 18:19:35 +08:00
|
|
|
#include "level_zero/tools/source/sysman/scheduler/scheduler_imp.h"
|
2020-03-06 18:09:57 +08:00
|
|
|
#include "level_zero/tools/source/sysman/sysman.h"
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace L0 {
|
|
|
|
|
2020-07-03 22:35:35 +08:00
|
|
|
SysmanDeviceImp::SysmanDeviceImp(ze_device_handle_t hDevice) {
|
|
|
|
hCoreDevice = hDevice;
|
|
|
|
pOsSysman = OsSysman::create(this);
|
|
|
|
UNRECOVERABLE_IF(nullptr == pOsSysman);
|
2020-07-17 18:19:21 +08:00
|
|
|
pPowerHandleContext = new PowerHandleContext(pOsSysman);
|
2020-07-24 19:09:09 +08:00
|
|
|
pFrequencyHandleContext = new FrequencyHandleContext(pOsSysman);
|
2020-07-21 04:06:42 +08:00
|
|
|
pFabricPortHandleContext = new FabricPortHandleContext(pOsSysman);
|
2020-07-03 22:35:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SysmanDeviceImp::~SysmanDeviceImp() {
|
2020-07-21 04:06:42 +08:00
|
|
|
freeResource(pFabricPortHandleContext);
|
2020-07-03 22:35:35 +08:00
|
|
|
freeResource(pOsSysman);
|
2020-07-17 18:19:21 +08:00
|
|
|
freeResource(pPowerHandleContext);
|
2020-07-24 19:09:09 +08:00
|
|
|
freeResource(pFrequencyHandleContext);
|
2020-07-03 22:35:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SysmanDeviceImp::init() {
|
|
|
|
pOsSysman->init();
|
2020-07-17 18:19:21 +08:00
|
|
|
if (pPowerHandleContext) {
|
|
|
|
pPowerHandleContext->init();
|
|
|
|
}
|
2020-07-24 19:09:09 +08:00
|
|
|
if (pFrequencyHandleContext) {
|
|
|
|
pFrequencyHandleContext->init();
|
|
|
|
}
|
2020-07-21 04:06:42 +08:00
|
|
|
if (pFabricPortHandleContext) {
|
|
|
|
pFabricPortHandleContext->init();
|
|
|
|
}
|
2020-07-03 22:35:35 +08:00
|
|
|
}
|
|
|
|
|
2020-03-06 18:09:57 +08:00
|
|
|
SysmanImp::SysmanImp(ze_device_handle_t hDevice) {
|
|
|
|
hCoreDevice = hDevice;
|
|
|
|
pOsSysman = OsSysman::create(this);
|
2020-03-13 18:01:09 +08:00
|
|
|
UNRECOVERABLE_IF(nullptr == pOsSysman);
|
2020-07-03 13:41:51 +08:00
|
|
|
pPci = new PciImp(pOsSysman, hCoreDevice);
|
2020-04-09 18:19:35 +08:00
|
|
|
pSched = new SchedulerImp(pOsSysman);
|
2020-07-03 22:35:35 +08:00
|
|
|
pGlobalOperations = new GlobalOperationsImp(pOsSysman, hCoreDevice);
|
2020-03-06 18:09:57 +08:00
|
|
|
pFrequencyHandleContext = new FrequencyHandleContext(pOsSysman);
|
|
|
|
pStandbyHandleContext = new StandbyHandleContext(pOsSysman);
|
2020-03-13 18:01:09 +08:00
|
|
|
pMemoryHandleContext = new MemoryHandleContext(pOsSysman, hCoreDevice);
|
2020-04-07 19:02:52 +08:00
|
|
|
pEngineHandleContext = new EngineHandleContext(pOsSysman);
|
2020-04-06 17:56:25 +08:00
|
|
|
pRasHandleContext = new RasHandleContext(pOsSysman);
|
2020-04-24 19:17:09 +08:00
|
|
|
pTempHandleContext = new TemperatureHandleContext(pOsSysman);
|
2020-04-28 14:40:46 +08:00
|
|
|
pPowerHandleContext = new PowerHandleContext(pOsSysman);
|
2020-06-12 03:33:34 +08:00
|
|
|
pFabricPortHandleContext = new FabricPortHandleContext(pOsSysman);
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SysmanImp::~SysmanImp() {
|
2020-06-12 03:33:34 +08:00
|
|
|
freeResource(pFabricPortHandleContext);
|
2020-04-28 14:40:46 +08:00
|
|
|
freeResource(pPowerHandleContext);
|
2020-04-24 19:17:09 +08:00
|
|
|
freeResource(pTempHandleContext);
|
|
|
|
freeResource(pRasHandleContext);
|
|
|
|
freeResource(pEngineHandleContext);
|
|
|
|
freeResource(pMemoryHandleContext);
|
|
|
|
freeResource(pStandbyHandleContext);
|
|
|
|
freeResource(pFrequencyHandleContext);
|
2020-07-03 22:35:35 +08:00
|
|
|
freeResource(pGlobalOperations);
|
2020-04-24 19:17:09 +08:00
|
|
|
freeResource(pPci);
|
|
|
|
freeResource(pSched);
|
|
|
|
freeResource(pOsSysman);
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SysmanImp::init() {
|
|
|
|
pOsSysman->init();
|
2020-03-13 18:01:09 +08:00
|
|
|
if (pFrequencyHandleContext) {
|
|
|
|
pFrequencyHandleContext->init();
|
|
|
|
}
|
|
|
|
if (pStandbyHandleContext) {
|
|
|
|
pStandbyHandleContext->init();
|
|
|
|
}
|
|
|
|
if (pMemoryHandleContext) {
|
|
|
|
pMemoryHandleContext->init();
|
|
|
|
}
|
2020-04-07 19:02:52 +08:00
|
|
|
if (pEngineHandleContext) {
|
|
|
|
pEngineHandleContext->init();
|
|
|
|
}
|
2020-04-06 17:56:25 +08:00
|
|
|
if (pRasHandleContext) {
|
|
|
|
pRasHandleContext->init();
|
|
|
|
}
|
2020-04-24 19:17:09 +08:00
|
|
|
if (pTempHandleContext) {
|
|
|
|
pTempHandleContext->init();
|
|
|
|
}
|
2020-04-28 14:40:46 +08:00
|
|
|
if (pPowerHandleContext) {
|
|
|
|
pPowerHandleContext->init();
|
|
|
|
}
|
2020-06-12 03:33:34 +08:00
|
|
|
if (pFabricPortHandleContext) {
|
|
|
|
pFabricPortHandleContext->init();
|
|
|
|
}
|
2020-03-13 18:01:09 +08:00
|
|
|
if (pPci) {
|
|
|
|
pPci->init();
|
|
|
|
}
|
2020-04-09 18:19:35 +08:00
|
|
|
if (pSched) {
|
2020-06-10 10:29:07 +08:00
|
|
|
pSched->init();
|
2020-04-09 18:19:35 +08:00
|
|
|
}
|
2020-07-03 22:35:35 +08:00
|
|
|
if (pGlobalOperations) {
|
|
|
|
pGlobalOperations->init();
|
2020-03-13 18:01:09 +08:00
|
|
|
}
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ze_result_t SysmanImp::deviceGetProperties(zet_sysman_properties_t *pProperties) {
|
2020-07-03 22:35:35 +08:00
|
|
|
return pGlobalOperations->deviceGetProperties(pProperties);
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ze_result_t SysmanImp::schedulerGetCurrentMode(zet_sched_mode_t *pMode) {
|
2020-04-15 15:46:36 +08:00
|
|
|
if (pSched) {
|
|
|
|
return pSched->getCurrentMode(pMode);
|
|
|
|
}
|
|
|
|
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ze_result_t SysmanImp::schedulerGetTimeoutModeProperties(ze_bool_t getDefaults, zet_sched_timeout_properties_t *pConfig) {
|
2020-04-15 15:46:36 +08:00
|
|
|
if (pSched) {
|
|
|
|
return pSched->getTimeoutModeProperties(getDefaults, pConfig);
|
|
|
|
}
|
|
|
|
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ze_result_t SysmanImp::schedulerGetTimesliceModeProperties(ze_bool_t getDefaults, zet_sched_timeslice_properties_t *pConfig) {
|
2020-04-15 15:46:36 +08:00
|
|
|
if (pSched) {
|
|
|
|
return pSched->getTimesliceModeProperties(getDefaults, pConfig);
|
|
|
|
}
|
|
|
|
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ze_result_t SysmanImp::schedulerSetTimeoutMode(zet_sched_timeout_properties_t *pProperties, ze_bool_t *pNeedReboot) {
|
2020-04-15 15:46:36 +08:00
|
|
|
if (pSched) {
|
|
|
|
return pSched->setTimeoutMode(pProperties, pNeedReboot);
|
|
|
|
}
|
|
|
|
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ze_result_t SysmanImp::schedulerSetTimesliceMode(zet_sched_timeslice_properties_t *pProperties, ze_bool_t *pNeedReboot) {
|
2020-04-15 15:46:36 +08:00
|
|
|
if (pSched) {
|
|
|
|
return pSched->setTimesliceMode(pProperties, pNeedReboot);
|
|
|
|
}
|
|
|
|
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ze_result_t SysmanImp::schedulerSetExclusiveMode(ze_bool_t *pNeedReboot) {
|
2020-04-15 15:46:36 +08:00
|
|
|
if (pSched) {
|
|
|
|
return pSched->setExclusiveMode(pNeedReboot);
|
|
|
|
}
|
|
|
|
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ze_result_t SysmanImp::schedulerSetComputeUnitDebugMode(ze_bool_t *pNeedReboot) {
|
2020-04-15 15:46:36 +08:00
|
|
|
if (pSched) {
|
|
|
|
return pSched->setComputeUnitDebugMode(pNeedReboot);
|
|
|
|
}
|
|
|
|
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ze_result_t SysmanImp::processesGetState(uint32_t *pCount, zet_process_state_t *pProcesses) {
|
2020-07-03 22:35:35 +08:00
|
|
|
return pGlobalOperations->processesGetState(pCount, pProcesses);
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ze_result_t SysmanImp::deviceReset() {
|
2020-07-03 22:35:35 +08:00
|
|
|
return pGlobalOperations->reset();
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ze_result_t SysmanImp::deviceGetRepairStatus(zet_repair_status_t *pRepairStatus) {
|
|
|
|
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ze_result_t SysmanImp::pciGetProperties(zet_pci_properties_t *pProperties) {
|
|
|
|
return pPci->pciStaticProperties(pProperties);
|
|
|
|
}
|
|
|
|
|
|
|
|
ze_result_t SysmanImp::pciGetState(zet_pci_state_t *pState) {
|
|
|
|
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ze_result_t SysmanImp::pciGetBars(uint32_t *pCount, zet_pci_bar_properties_t *pProperties) {
|
|
|
|
return pPci->pciGetInitializedBars(pCount, pProperties);
|
|
|
|
}
|
|
|
|
|
|
|
|
ze_result_t SysmanImp::pciGetStats(zet_pci_stats_t *pStats) {
|
|
|
|
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ze_result_t SysmanImp::powerGet(uint32_t *pCount, zet_sysman_pwr_handle_t *phPower) {
|
2020-04-28 14:40:46 +08:00
|
|
|
return pPowerHandleContext->powerGet(pCount, phPower);
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
2020-07-03 22:35:35 +08:00
|
|
|
ze_result_t SysmanDeviceImp::powerGet(uint32_t *pCount, zes_pwr_handle_t *phPower) {
|
2020-07-17 18:19:21 +08:00
|
|
|
return pPowerHandleContext->powerGet(pCount, phPower);
|
2020-07-03 22:35:35 +08:00
|
|
|
}
|
|
|
|
|
2020-03-06 18:09:57 +08:00
|
|
|
ze_result_t SysmanImp::frequencyGet(uint32_t *pCount, zet_sysman_freq_handle_t *phFrequency) {
|
|
|
|
return pFrequencyHandleContext->frequencyGet(pCount, phFrequency);
|
|
|
|
}
|
|
|
|
|
2020-07-24 19:09:09 +08:00
|
|
|
ze_result_t SysmanDeviceImp::frequencyGet(uint32_t *pCount, zes_freq_handle_t *phFrequency) {
|
|
|
|
return pFrequencyHandleContext->frequencyGet(pCount, phFrequency);
|
|
|
|
}
|
|
|
|
|
2020-03-06 18:09:57 +08:00
|
|
|
ze_result_t SysmanImp::engineGet(uint32_t *pCount, zet_sysman_engine_handle_t *phEngine) {
|
2020-04-21 18:34:51 +08:00
|
|
|
return pEngineHandleContext->engineGet(pCount, phEngine);
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ze_result_t SysmanImp::standbyGet(uint32_t *pCount, zet_sysman_standby_handle_t *phStandby) {
|
|
|
|
return pStandbyHandleContext->standbyGet(pCount, phStandby);
|
|
|
|
}
|
|
|
|
|
|
|
|
ze_result_t SysmanImp::firmwareGet(uint32_t *pCount, zet_sysman_firmware_handle_t *phFirmware) {
|
|
|
|
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ze_result_t SysmanImp::memoryGet(uint32_t *pCount, zet_sysman_mem_handle_t *phMemory) {
|
2020-03-13 18:01:09 +08:00
|
|
|
return pMemoryHandleContext->memoryGet(pCount, phMemory);
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
2020-07-21 04:06:42 +08:00
|
|
|
ze_result_t SysmanDeviceImp::fabricPortGet(uint32_t *pCount, zes_fabric_port_handle_t *phPort) {
|
|
|
|
return pFabricPortHandleContext->fabricPortGet(pCount, phPort);
|
|
|
|
}
|
|
|
|
|
2020-03-06 18:09:57 +08:00
|
|
|
ze_result_t SysmanImp::fabricPortGet(uint32_t *pCount, zet_sysman_fabric_port_handle_t *phPort) {
|
2020-06-12 03:33:34 +08:00
|
|
|
return pFabricPortHandleContext->fabricPortGet(pCount, phPort);
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ze_result_t SysmanImp::temperatureGet(uint32_t *pCount, zet_sysman_temp_handle_t *phTemperature) {
|
2020-04-24 19:17:09 +08:00
|
|
|
return pTempHandleContext->temperatureGet(pCount, phTemperature);
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ze_result_t SysmanImp::psuGet(uint32_t *pCount, zet_sysman_psu_handle_t *phPsu) {
|
|
|
|
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ze_result_t SysmanImp::fanGet(uint32_t *pCount, zet_sysman_fan_handle_t *phFan) {
|
|
|
|
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ze_result_t SysmanImp::ledGet(uint32_t *pCount, zet_sysman_led_handle_t *phLed) {
|
|
|
|
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ze_result_t SysmanImp::rasGet(uint32_t *pCount, zet_sysman_ras_handle_t *phRas) {
|
2020-04-06 17:56:25 +08:00
|
|
|
return pRasHandleContext->rasGet(pCount, phRas);
|
2020-03-06 18:09:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ze_result_t SysmanImp::eventGet(zet_sysman_event_handle_t *phEvent) {
|
|
|
|
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ze_result_t SysmanImp::diagnosticsGet(uint32_t *pCount, zet_sysman_diag_handle_t *phDiagnostics) {
|
|
|
|
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace L0
|