Skip to content

Commit

Permalink
Set SysMan DDI to null if SysMan is not enabled
Browse files Browse the repository at this point in the history
Signed-off-by: Jaime Arteaga <[email protected]>
  • Loading branch information
Jaime Arteaga authored and Compute-Runtime-Automation committed Dec 9, 2020
1 parent beb3c5e commit 86e2563
Showing 1 changed file with 152 additions and 0 deletions.
152 changes: 152 additions & 0 deletions level_zero/api/sysman/ze_sysman_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*
*/

#include "shared/source/os_interface/debug_env_reader.h"

#include "level_zero/source/inc/ze_intel_gpu.h"
#include <level_zero/ze_api.h>
#include <level_zero/ze_ddi.h>
Expand All @@ -27,6 +29,14 @@ zesGetDeviceProcAddrTable(
return ZE_RESULT_ERROR_UNKNOWN;
ze_result_t result = ZE_RESULT_SUCCESS;

NEO::EnvironmentVariableReader envReader;
bool isSysManEnabled =
envReader.getSetting("ZES_ENABLE_SYSMAN", false);
if (false == isSysManEnabled) {
*pDdiTable = {};
return result;
}

pDdiTable->pfnGetProperties = zesDeviceGetProperties;
pDdiTable->pfnGetState = zesDeviceGetState;
pDdiTable->pfnReset = zesDeviceReset;
Expand Down Expand Up @@ -63,6 +73,15 @@ zesGetDriverProcAddrTable(
if (driver_ddiTable.version < version)
return ZE_RESULT_ERROR_UNKNOWN;
ze_result_t result = ZE_RESULT_SUCCESS;

NEO::EnvironmentVariableReader envReader;
bool isSysManEnabled =
envReader.getSetting("ZES_ENABLE_SYSMAN", false);
if (false == isSysManEnabled) {
*pDdiTable = {};
return result;
}

pDdiTable->pfnEventListen = zesDriverEventListen;
return result;
}
Expand All @@ -76,6 +95,15 @@ zesGetDiagnosticsProcAddrTable(
if (driver_ddiTable.version < version)
return ZE_RESULT_ERROR_UNKNOWN;
ze_result_t result = ZE_RESULT_SUCCESS;

NEO::EnvironmentVariableReader envReader;
bool isSysManEnabled =
envReader.getSetting("ZES_ENABLE_SYSMAN", false);
if (false == isSysManEnabled) {
*pDdiTable = {};
return result;
}

pDdiTable->pfnGetProperties = zesDiagnosticsGetProperties;
pDdiTable->pfnGetTests = zesDiagnosticsGetTests;
pDdiTable->pfnRunTests = zesDiagnosticsRunTests;
Expand All @@ -93,6 +121,15 @@ zesGetEngineProcAddrTable(
return ZE_RESULT_ERROR_UNKNOWN;

ze_result_t result = ZE_RESULT_SUCCESS;

NEO::EnvironmentVariableReader envReader;
bool isSysManEnabled =
envReader.getSetting("ZES_ENABLE_SYSMAN", false);
if (false == isSysManEnabled) {
*pDdiTable = {};
return result;
}

pDdiTable->pfnGetProperties = zesEngineGetProperties;
pDdiTable->pfnGetActivity = zesEngineGetActivity;

Expand All @@ -109,6 +146,14 @@ zesGetFabricPortProcAddrTable(
return ZE_RESULT_ERROR_UNKNOWN;
ze_result_t result = ZE_RESULT_SUCCESS;

NEO::EnvironmentVariableReader envReader;
bool isSysManEnabled =
envReader.getSetting("ZES_ENABLE_SYSMAN", false);
if (false == isSysManEnabled) {
*pDdiTable = {};
return result;
}

pDdiTable->pfnGetProperties = zesFabricPortGetProperties;
pDdiTable->pfnGetLinkType = zesFabricPortGetLinkType;
pDdiTable->pfnGetConfig = zesFabricPortGetConfig;
Expand All @@ -129,6 +174,14 @@ zesGetFanProcAddrTable(
return ZE_RESULT_ERROR_UNKNOWN;
ze_result_t result = ZE_RESULT_SUCCESS;

NEO::EnvironmentVariableReader envReader;
bool isSysManEnabled =
envReader.getSetting("ZES_ENABLE_SYSMAN", false);
if (false == isSysManEnabled) {
*pDdiTable = {};
return result;
}

pDdiTable->pfnGetProperties = zesFanGetProperties;
pDdiTable->pfnGetConfig = zesFanGetConfig;
pDdiTable->pfnSetDefaultMode = zesFanSetDefaultMode;
Expand All @@ -148,6 +201,15 @@ zesGetFirmwareProcAddrTable(
if (driver_ddiTable.version < version)
return ZE_RESULT_ERROR_UNKNOWN;
ze_result_t result = ZE_RESULT_SUCCESS;

NEO::EnvironmentVariableReader envReader;
bool isSysManEnabled =
envReader.getSetting("ZES_ENABLE_SYSMAN", false);
if (false == isSysManEnabled) {
*pDdiTable = {};
return result;
}

pDdiTable->pfnGetProperties = zesFirmwareGetProperties;
pDdiTable->pfnFlash = zesFirmwareFlash;

Expand All @@ -164,6 +226,15 @@ zesGetFrequencyProcAddrTable(
return ZE_RESULT_ERROR_UNKNOWN;

ze_result_t result = ZE_RESULT_SUCCESS;

NEO::EnvironmentVariableReader envReader;
bool isSysManEnabled =
envReader.getSetting("ZES_ENABLE_SYSMAN", false);
if (false == isSysManEnabled) {
*pDdiTable = {};
return result;
}

pDdiTable->pfnGetProperties = zesFrequencyGetProperties;
pDdiTable->pfnGetAvailableClocks = zesFrequencyGetAvailableClocks;
pDdiTable->pfnGetRange = zesFrequencyGetRange;
Expand Down Expand Up @@ -194,6 +265,15 @@ zesGetLedProcAddrTable(
if (driver_ddiTable.version < version)
return ZE_RESULT_ERROR_UNKNOWN;
ze_result_t result = ZE_RESULT_SUCCESS;

NEO::EnvironmentVariableReader envReader;
bool isSysManEnabled =
envReader.getSetting("ZES_ENABLE_SYSMAN", false);
if (false == isSysManEnabled) {
*pDdiTable = {};
return result;
}

pDdiTable->pfnGetProperties = zesLedGetProperties;
pDdiTable->pfnGetState = zesLedGetState;
pDdiTable->pfnSetState = zesLedSetState;
Expand All @@ -211,6 +291,15 @@ zesGetMemoryProcAddrTable(
if (driver_ddiTable.version < version)
return ZE_RESULT_ERROR_UNKNOWN;
ze_result_t result = ZE_RESULT_SUCCESS;

NEO::EnvironmentVariableReader envReader;
bool isSysManEnabled =
envReader.getSetting("ZES_ENABLE_SYSMAN", false);
if (false == isSysManEnabled) {
*pDdiTable = {};
return result;
}

pDdiTable->pfnGetProperties = zesMemoryGetProperties;
pDdiTable->pfnGetState = zesMemoryGetState;
pDdiTable->pfnGetBandwidth = zesMemoryGetBandwidth;
Expand All @@ -227,6 +316,15 @@ zesGetPerformanceFactorProcAddrTable(
if (driver_ddiTable.version < version)
return ZE_RESULT_ERROR_UNKNOWN;
ze_result_t result = ZE_RESULT_SUCCESS;

NEO::EnvironmentVariableReader envReader;
bool isSysManEnabled =
envReader.getSetting("ZES_ENABLE_SYSMAN", false);
if (false == isSysManEnabled) {
*pDdiTable = {};
return result;
}

pDdiTable->pfnGetProperties = zesPerformanceFactorGetProperties;
pDdiTable->pfnGetConfig = zesPerformanceFactorGetConfig;
pDdiTable->pfnSetConfig = zesPerformanceFactorSetConfig;
Expand All @@ -243,6 +341,15 @@ zesGetPowerProcAddrTable(
if (driver_ddiTable.version < version)
return ZE_RESULT_ERROR_UNKNOWN;
ze_result_t result = ZE_RESULT_SUCCESS;

NEO::EnvironmentVariableReader envReader;
bool isSysManEnabled =
envReader.getSetting("ZES_ENABLE_SYSMAN", false);
if (false == isSysManEnabled) {
*pDdiTable = {};
return result;
}

pDdiTable->pfnGetProperties = zesPowerGetProperties;
pDdiTable->pfnGetEnergyCounter = zesPowerGetEnergyCounter;
pDdiTable->pfnGetLimits = zesPowerGetLimits;
Expand All @@ -262,6 +369,15 @@ zesGetPsuProcAddrTable(
if (driver_ddiTable.version < version)
return ZE_RESULT_ERROR_UNKNOWN;
ze_result_t result = ZE_RESULT_SUCCESS;

NEO::EnvironmentVariableReader envReader;
bool isSysManEnabled =
envReader.getSetting("ZES_ENABLE_SYSMAN", false);
if (false == isSysManEnabled) {
*pDdiTable = {};
return result;
}

pDdiTable->pfnGetProperties = zesPsuGetProperties;
pDdiTable->pfnGetState = zesPsuGetState;

Expand All @@ -277,6 +393,15 @@ zesGetRasProcAddrTable(
if (driver_ddiTable.version < version)
return ZE_RESULT_ERROR_UNKNOWN;
ze_result_t result = ZE_RESULT_SUCCESS;

NEO::EnvironmentVariableReader envReader;
bool isSysManEnabled =
envReader.getSetting("ZES_ENABLE_SYSMAN", false);
if (false == isSysManEnabled) {
*pDdiTable = {};
return result;
}

pDdiTable->pfnGetProperties = zesRasGetProperties;
pDdiTable->pfnGetConfig = zesRasGetConfig;
pDdiTable->pfnSetConfig = zesRasSetConfig;
Expand All @@ -294,6 +419,15 @@ zesGetSchedulerProcAddrTable(
if (driver_ddiTable.version < version)
return ZE_RESULT_ERROR_UNKNOWN;
ze_result_t result = ZE_RESULT_SUCCESS;

NEO::EnvironmentVariableReader envReader;
bool isSysManEnabled =
envReader.getSetting("ZES_ENABLE_SYSMAN", false);
if (false == isSysManEnabled) {
*pDdiTable = {};
return result;
}

pDdiTable->pfnGetProperties = zesSchedulerGetProperties;
pDdiTable->pfnGetCurrentMode = zesSchedulerGetCurrentMode;
pDdiTable->pfnGetTimeoutModeProperties = zesSchedulerGetTimeoutModeProperties;
Expand All @@ -315,6 +449,15 @@ zesGetStandbyProcAddrTable(
if (driver_ddiTable.version < version)
return ZE_RESULT_ERROR_UNKNOWN;
ze_result_t result = ZE_RESULT_SUCCESS;

NEO::EnvironmentVariableReader envReader;
bool isSysManEnabled =
envReader.getSetting("ZES_ENABLE_SYSMAN", false);
if (false == isSysManEnabled) {
*pDdiTable = {};
return result;
}

pDdiTable->pfnGetProperties = zesStandbyGetProperties;
pDdiTable->pfnGetMode = zesStandbyGetMode;
pDdiTable->pfnSetMode = zesStandbySetMode;
Expand All @@ -331,6 +474,15 @@ zesGetTemperatureProcAddrTable(
if (driver_ddiTable.version < version)
return ZE_RESULT_ERROR_UNKNOWN;
ze_result_t result = ZE_RESULT_SUCCESS;

NEO::EnvironmentVariableReader envReader;
bool isSysManEnabled =
envReader.getSetting("ZES_ENABLE_SYSMAN", false);
if (false == isSysManEnabled) {
*pDdiTable = {};
return result;
}

pDdiTable->pfnGetProperties = zesTemperatureGetProperties;
pDdiTable->pfnGetConfig = zesTemperatureGetConfig;
pDdiTable->pfnSetConfig = zesTemperatureSetConfig;
Expand Down

0 comments on commit 86e2563

Please sign in to comment.