2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2023-01-20 14:30:59 +00:00
|
|
|
* Copyright (C) 2018-2023 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-18 09:11:08 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/command_stream/preemption.h"
|
|
|
|
|
#include "shared/source/debug_settings/debug_settings_manager.h"
|
2022-11-14 14:52:40 +00:00
|
|
|
#include "shared/source/execution_environment/root_device_environment.h"
|
2023-02-02 14:25:08 +00:00
|
|
|
#include "shared/source/helpers/compiler_product_helper.h"
|
2020-04-02 11:28:38 +02:00
|
|
|
#include "shared/source/helpers/constants.h"
|
2023-02-01 16:23:01 +00:00
|
|
|
#include "shared/source/helpers/gfx_core_helper.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/helpers/hw_info.h"
|
2021-05-24 21:06:15 +02:00
|
|
|
#include "shared/source/os_interface/hw_info_config.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/os_interface/linux/drm_neo.h"
|
2021-05-21 01:17:57 +02:00
|
|
|
#include "shared/source/os_interface/os_interface.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/utilities/cpu_info.h"
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
uint32_t bitExact(uint32_t value, uint32_t highBit, uint32_t lowBit) {
|
2019-11-27 18:00:52 +01:00
|
|
|
uint32_t bitVal = static_cast<uint32_t>((value >> lowBit) & maxNBitValue(highBit - lowBit + 1));
|
2017-12-21 00:45:38 +01:00
|
|
|
return bitVal;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int configureCacheInfo(HardwareInfo *hwInfo) {
|
2019-05-08 16:00:24 +02:00
|
|
|
GT_SYSTEM_INFO *gtSystemInfo = &hwInfo->gtSystemInfo;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
uint32_t type = 0;
|
|
|
|
|
uint32_t subleaf = 0;
|
|
|
|
|
uint32_t eax, ebx, ecx;
|
|
|
|
|
uint32_t cachelevel, linesize, partitions, ways;
|
|
|
|
|
uint64_t sets, size;
|
|
|
|
|
|
|
|
|
|
const CpuInfo &cpuInfo = CpuInfo::getInstance();
|
|
|
|
|
|
|
|
|
|
do {
|
2021-10-14 12:28:53 +02:00
|
|
|
uint32_t cpuRegsInfo[4] = {};
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
cpuInfo.cpuidex(cpuRegsInfo, 4, subleaf);
|
|
|
|
|
eax = cpuRegsInfo[0];
|
|
|
|
|
ebx = cpuRegsInfo[1];
|
|
|
|
|
ecx = cpuRegsInfo[2];
|
|
|
|
|
|
|
|
|
|
type = bitExact(eax, 4, 0);
|
|
|
|
|
if (type != 0) {
|
|
|
|
|
cachelevel = bitExact(eax, 7, 5);
|
|
|
|
|
linesize = bitExact(ebx, 11, 0) + 1;
|
|
|
|
|
partitions = bitExact(ebx, 21, 12) + 1;
|
|
|
|
|
ways = bitExact(ebx, 31, 22) + 1;
|
|
|
|
|
sets = (uint64_t)ecx + 1;
|
|
|
|
|
|
|
|
|
|
size = sets * ways * partitions * linesize / 1024;
|
|
|
|
|
if (cachelevel == 3) {
|
2019-05-08 16:00:24 +02:00
|
|
|
gtSystemInfo->LLCCacheSizeInKb = size;
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
subleaf++;
|
|
|
|
|
}
|
|
|
|
|
} while (type);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-20 14:30:59 +00:00
|
|
|
int ProductHelper::configureHwInfoDrm(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, const RootDeviceEnvironment &rootDeviceEnvironment) {
|
2017-12-21 00:45:38 +01:00
|
|
|
int ret = 0;
|
2023-01-20 14:30:59 +00:00
|
|
|
auto osInterface = rootDeviceEnvironment.osInterface.get();
|
2022-11-14 14:52:40 +00:00
|
|
|
Drm *drm = osInterface->getDriverModel()->as<Drm>();
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-05-06 12:33:44 +02:00
|
|
|
*outHwInfo = *inHwInfo;
|
2019-05-08 16:00:24 +02:00
|
|
|
auto gtSystemInfo = &outHwInfo->gtSystemInfo;
|
|
|
|
|
auto featureTable = &outHwInfo->featureTable;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2021-04-27 14:45:13 +00:00
|
|
|
Drm::QueryTopologyData topologyData = {};
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2021-04-27 14:45:13 +00:00
|
|
|
bool status = drm->queryTopology(*outHwInfo, topologyData);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2020-06-09 15:51:26 +02:00
|
|
|
if (!status) {
|
2020-09-25 11:24:15 +02:00
|
|
|
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Topology query failed!\n");
|
2020-06-09 15:51:26 +02:00
|
|
|
|
2021-04-27 14:45:13 +00:00
|
|
|
topologyData.sliceCount = gtSystemInfo->SliceCount;
|
2020-06-09 15:51:26 +02:00
|
|
|
|
2021-04-27 14:45:13 +00:00
|
|
|
ret = drm->getEuTotal(topologyData.euCount);
|
2020-06-09 15:51:26 +02:00
|
|
|
if (ret != 0) {
|
2020-09-25 11:24:15 +02:00
|
|
|
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query EU total parameter!\n");
|
2020-06-09 15:51:26 +02:00
|
|
|
*outHwInfo = {};
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-27 14:45:13 +00:00
|
|
|
ret = drm->getSubsliceTotal(topologyData.subSliceCount);
|
2020-06-09 15:51:26 +02:00
|
|
|
if (ret != 0) {
|
2020-09-25 11:24:15 +02:00
|
|
|
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query subslice total parameter!\n");
|
2020-06-09 15:51:26 +02:00
|
|
|
*outHwInfo = {};
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
2021-04-27 14:45:13 +00:00
|
|
|
|
2021-05-17 19:48:53 +00:00
|
|
|
topologyData.maxEuCount = topologyData.subSliceCount > 0 ? topologyData.euCount / topologyData.subSliceCount : 0;
|
2021-04-27 14:45:13 +00:00
|
|
|
topologyData.maxSliceCount = topologyData.sliceCount;
|
2021-05-17 19:48:53 +00:00
|
|
|
topologyData.maxSubSliceCount = topologyData.sliceCount > 0 ? topologyData.subSliceCount / topologyData.sliceCount : 0;
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
2020-06-09 15:51:26 +02:00
|
|
|
|
2023-03-08 09:30:38 +00:00
|
|
|
auto &compilerProductHelper = rootDeviceEnvironment.getHelper<CompilerProductHelper>();
|
|
|
|
|
|
2021-04-27 14:45:13 +00:00
|
|
|
gtSystemInfo->SliceCount = static_cast<uint32_t>(topologyData.sliceCount);
|
|
|
|
|
gtSystemInfo->SubSliceCount = static_cast<uint32_t>(topologyData.subSliceCount);
|
2021-06-01 13:07:41 +00:00
|
|
|
gtSystemInfo->DualSubSliceCount = static_cast<uint32_t>(topologyData.subSliceCount);
|
2021-04-27 14:45:13 +00:00
|
|
|
gtSystemInfo->EUCount = static_cast<uint32_t>(topologyData.euCount);
|
2023-03-08 09:30:38 +00:00
|
|
|
gtSystemInfo->ThreadCount = compilerProductHelper.getNumThreadsPerEu() * gtSystemInfo->EUCount;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2021-07-22 16:20:54 +00:00
|
|
|
gtSystemInfo->MaxEuPerSubSlice = gtSystemInfo->MaxEuPerSubSlice != 0 ? gtSystemInfo->MaxEuPerSubSlice : topologyData.maxEuCount;
|
2021-04-27 14:45:13 +00:00
|
|
|
gtSystemInfo->MaxSubSlicesSupported = std::max(static_cast<uint32_t>(topologyData.maxSubSliceCount * topologyData.maxSliceCount), gtSystemInfo->MaxSubSlicesSupported);
|
2021-05-17 15:04:01 +00:00
|
|
|
gtSystemInfo->MaxSlicesSupported = topologyData.maxSliceCount;
|
2023-01-21 06:51:06 +00:00
|
|
|
gtSystemInfo->MaxDualSubSlicesSupported = gtSystemInfo->MaxSubSlicesSupported;
|
2021-04-27 14:45:13 +00:00
|
|
|
|
2022-09-23 00:29:32 +00:00
|
|
|
gtSystemInfo->IsDynamicallyPopulated = true;
|
2023-03-02 12:55:01 +00:00
|
|
|
for (uint32_t slice = 0; slice < GT_MAX_SLICE; slice++) {
|
|
|
|
|
gtSystemInfo->SliceInfo[slice].Enabled = slice < gtSystemInfo->SliceCount;
|
2021-11-30 10:19:27 +00:00
|
|
|
}
|
|
|
|
|
|
2019-12-17 15:17:52 +01:00
|
|
|
uint64_t gttSizeQuery = 0;
|
2021-11-25 09:31:14 +00:00
|
|
|
featureTable->flags.ftrSVM = true;
|
2019-12-17 15:17:52 +01:00
|
|
|
|
|
|
|
|
ret = drm->queryGttSize(gttSizeQuery);
|
|
|
|
|
|
|
|
|
|
if (ret == 0) {
|
2021-11-25 09:31:14 +00:00
|
|
|
featureTable->flags.ftrSVM = (gttSizeQuery > MemoryConstants::max64BitAppAddress);
|
2019-12-17 15:17:52 +01:00
|
|
|
outHwInfo->capabilityTable.gpuAddressSpace = gttSizeQuery - 1; // gttSizeQuery = (1 << bits)
|
|
|
|
|
}
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
int maxGpuFreq = 0;
|
2020-04-10 13:54:07 +02:00
|
|
|
drm->getMaxGpuFrequency(*outHwInfo, maxGpuFreq);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2022-11-14 14:52:40 +00:00
|
|
|
ret = configureHardwareCustom(outHwInfo, osInterface);
|
2017-12-21 00:45:38 +01:00
|
|
|
if (ret != 0) {
|
2018-06-12 09:42:47 +02:00
|
|
|
*outHwInfo = {};
|
2017-12-21 00:45:38 +01:00
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
configureCacheInfo(outHwInfo);
|
2021-11-25 09:31:14 +00:00
|
|
|
featureTable->flags.ftrEDram = (gtSystemInfo->EdramSizeInKb != 0) ? 1 : 0;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
outHwInfo->capabilityTable.maxRenderFrequency = maxGpuFreq;
|
2021-11-25 09:31:14 +00:00
|
|
|
outHwInfo->capabilityTable.ftrSvm = featureTable->flags.ftrSVM;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2023-01-30 00:53:04 +00:00
|
|
|
auto &gfxCoreHelper = rootDeviceEnvironment.getHelper<GfxCoreHelper>();
|
2018-03-28 19:55:17 +02:00
|
|
|
outHwInfo->capabilityTable.ftrSupportsCoherency = false;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2023-01-30 00:53:04 +00:00
|
|
|
gfxCoreHelper.adjustDefaultEngineType(outHwInfo, *this);
|
2019-03-27 10:06:29 +01:00
|
|
|
outHwInfo->capabilityTable.defaultEngineType = getChosenEngineType(*outHwInfo);
|
2018-02-14 14:52:00 +01:00
|
|
|
|
2019-08-21 03:50:47 -07:00
|
|
|
drm->checkQueueSliceSupport();
|
2020-02-10 08:05:32 -08:00
|
|
|
drm->checkNonPersistentContextsSupport();
|
2018-12-07 15:03:23 +01:00
|
|
|
drm->checkPreemptionSupport();
|
|
|
|
|
bool preemption = drm->isPreemptionSupported();
|
2017-12-21 00:45:38 +01:00
|
|
|
PreemptionHelper::adjustDefaultPreemptionMode(outHwInfo->capabilityTable,
|
2023-01-20 16:09:58 +00:00
|
|
|
compilerProductHelper.isMidThreadPreemptionSupported(*outHwInfo) && preemption,
|
2021-11-25 09:31:14 +00:00
|
|
|
static_cast<bool>(outHwInfo->featureTable.flags.ftrGpGpuThreadGroupLevelPreempt) && preemption,
|
|
|
|
|
static_cast<bool>(outHwInfo->featureTable.flags.ftrGpGpuMidBatchPreempt) && preemption);
|
2021-08-29 23:41:42 +00:00
|
|
|
|
2019-05-08 16:00:24 +02:00
|
|
|
outHwInfo->capabilityTable.requiredPreemptionSurfaceSize = outHwInfo->gtSystemInfo.CsrSizeInMb * MemoryConstants::megaByte;
|
2022-12-08 12:22:35 +00:00
|
|
|
gfxCoreHelper.adjustPreemptionSurfaceSize(outHwInfo->capabilityTable.requiredPreemptionSurfaceSize);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-03-22 09:41:17 +01:00
|
|
|
auto &kmdNotifyProperties = outHwInfo->capabilityTable.kmdNotifyProperties;
|
2018-04-10 10:26:59 +02:00
|
|
|
KmdNotifyHelper::overrideFromDebugVariable(DebugManager.flags.OverrideEnableKmdNotify.get(), kmdNotifyProperties.enableKmdNotify);
|
|
|
|
|
KmdNotifyHelper::overrideFromDebugVariable(DebugManager.flags.OverrideKmdNotifyDelayMicroseconds.get(), kmdNotifyProperties.delayKmdNotifyMicroseconds);
|
|
|
|
|
KmdNotifyHelper::overrideFromDebugVariable(DebugManager.flags.OverrideEnableQuickKmdSleep.get(), kmdNotifyProperties.enableQuickKmdSleep);
|
|
|
|
|
KmdNotifyHelper::overrideFromDebugVariable(DebugManager.flags.OverrideQuickKmdSleepDelayMicroseconds.get(), kmdNotifyProperties.delayQuickKmdSleepMicroseconds);
|
|
|
|
|
KmdNotifyHelper::overrideFromDebugVariable(DebugManager.flags.OverrideEnableQuickKmdSleepForSporadicWaits.get(), kmdNotifyProperties.enableQuickKmdSleepForSporadicWaits);
|
|
|
|
|
KmdNotifyHelper::overrideFromDebugVariable(DebugManager.flags.OverrideDelayQuickKmdSleepForSporadicWaitsMicroseconds.get(), kmdNotifyProperties.delayQuickKmdSleepForSporadicWaitsMicroseconds);
|
2021-12-17 18:42:13 +00:00
|
|
|
KmdNotifyHelper::overrideFromDebugVariable(DebugManager.flags.OverrideEnableQuickKmdSleepForDirectSubmission.get(), kmdNotifyProperties.enableQuickKmdSleepForDirectSubmission);
|
|
|
|
|
KmdNotifyHelper::overrideFromDebugVariable(DebugManager.flags.OverrideDelayQuickKmdSleepForDirectSubmissionMicroseconds.get(), kmdNotifyProperties.delayQuickKmdSleepForDirectSubmissionMicroseconds);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2022-07-26 09:46:40 +00:00
|
|
|
if (DebugManager.flags.ForceImagesSupport.get() != -1) {
|
|
|
|
|
outHwInfo->capabilityTable.supportsImages = DebugManager.flags.ForceImagesSupport.get();
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|