2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2022-01-27 00:25:28 +08:00
|
|
|
* Copyright (C) 2018-2022 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/command_stream/preemption.h"
|
|
|
|
#include "shared/source/debug_settings/debug_settings_manager.h"
|
2021-10-05 21:14:08 +08:00
|
|
|
#include "shared/source/helpers/compiler_hw_info_config.h"
|
2020-04-02 17:28:38 +08:00
|
|
|
#include "shared/source/helpers/constants.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/helpers/hw_helper.h"
|
|
|
|
#include "shared/source/helpers/hw_info.h"
|
2021-05-25 03:06:15 +08:00
|
|
|
#include "shared/source/os_interface/hw_info_config.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/os_interface/linux/drm_neo.h"
|
2021-05-21 07:17:57 +08:00
|
|
|
#include "shared/source/os_interface/os_interface.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/utilities/cpu_info.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
uint32_t bitExact(uint32_t value, uint32_t highBit, uint32_t lowBit) {
|
2019-11-28 01:00:52 +08:00
|
|
|
uint32_t bitVal = static_cast<uint32_t>((value >> lowBit) & maxNBitValue(highBit - lowBit + 1));
|
2017-12-21 07:45:38 +08:00
|
|
|
return bitVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
int configureCacheInfo(HardwareInfo *hwInfo) {
|
2019-05-08 22:00:24 +08:00
|
|
|
GT_SYSTEM_INFO *gtSystemInfo = &hwInfo->gtSystemInfo;
|
2017-12-21 07:45:38 +08: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 18:28:53 +08:00
|
|
|
uint32_t cpuRegsInfo[4] = {};
|
2017-12-21 07:45:38 +08: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 22:00:24 +08:00
|
|
|
gtSystemInfo->LLCCacheSizeInKb = size;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
subleaf++;
|
|
|
|
}
|
|
|
|
} while (type);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-05-25 03:06:15 +08:00
|
|
|
int HwInfoConfig::configureHwInfoDrm(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, OSInterface *osIface) {
|
2017-12-21 07:45:38 +08:00
|
|
|
int ret = 0;
|
2021-05-21 07:17:57 +08:00
|
|
|
Drm *drm = osIface->getDriverModel()->as<Drm>();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-05-06 18:33:44 +08:00
|
|
|
*outHwInfo = *inHwInfo;
|
2019-05-08 22:00:24 +08:00
|
|
|
auto platform = &outHwInfo->platform;
|
|
|
|
auto gtSystemInfo = &outHwInfo->gtSystemInfo;
|
|
|
|
auto featureTable = &outHwInfo->featureTable;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2021-04-27 22:45:13 +08:00
|
|
|
Drm::QueryTopologyData topologyData = {};
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2021-04-27 22:45:13 +08:00
|
|
|
bool status = drm->queryTopology(*outHwInfo, topologyData);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-06-09 21:51:26 +08:00
|
|
|
if (!status) {
|
2020-09-25 17:24:15 +08:00
|
|
|
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Topology query failed!\n");
|
2020-06-09 21:51:26 +08:00
|
|
|
|
2021-04-27 22:45:13 +08:00
|
|
|
topologyData.sliceCount = gtSystemInfo->SliceCount;
|
2020-06-09 21:51:26 +08:00
|
|
|
|
2021-04-27 22:45:13 +08:00
|
|
|
ret = drm->getEuTotal(topologyData.euCount);
|
2020-06-09 21:51:26 +08:00
|
|
|
if (ret != 0) {
|
2020-09-25 17:24:15 +08:00
|
|
|
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query EU total parameter!\n");
|
2020-06-09 21:51:26 +08:00
|
|
|
*outHwInfo = {};
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-04-27 22:45:13 +08:00
|
|
|
ret = drm->getSubsliceTotal(topologyData.subSliceCount);
|
2020-06-09 21:51:26 +08:00
|
|
|
if (ret != 0) {
|
2020-09-25 17:24:15 +08:00
|
|
|
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query subslice total parameter!\n");
|
2020-06-09 21:51:26 +08:00
|
|
|
*outHwInfo = {};
|
|
|
|
return ret;
|
|
|
|
}
|
2021-04-27 22:45:13 +08:00
|
|
|
|
2021-05-18 03:48:53 +08:00
|
|
|
topologyData.maxEuCount = topologyData.subSliceCount > 0 ? topologyData.euCount / topologyData.subSliceCount : 0;
|
2021-04-27 22:45:13 +08:00
|
|
|
topologyData.maxSliceCount = topologyData.sliceCount;
|
2021-05-18 03:48:53 +08:00
|
|
|
topologyData.maxSubSliceCount = topologyData.sliceCount > 0 ? topologyData.subSliceCount / topologyData.sliceCount : 0;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
2020-06-09 21:51:26 +08:00
|
|
|
|
2021-04-27 22:45:13 +08:00
|
|
|
gtSystemInfo->SliceCount = static_cast<uint32_t>(topologyData.sliceCount);
|
|
|
|
gtSystemInfo->SubSliceCount = static_cast<uint32_t>(topologyData.subSliceCount);
|
2021-06-01 21:07:41 +08:00
|
|
|
gtSystemInfo->DualSubSliceCount = static_cast<uint32_t>(topologyData.subSliceCount);
|
2021-04-27 22:45:13 +08:00
|
|
|
gtSystemInfo->EUCount = static_cast<uint32_t>(topologyData.euCount);
|
2020-06-09 21:51:26 +08:00
|
|
|
gtSystemInfo->ThreadCount = this->threadsPerEu * gtSystemInfo->EUCount;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2021-07-23 00:20:54 +08:00
|
|
|
gtSystemInfo->MaxEuPerSubSlice = gtSystemInfo->MaxEuPerSubSlice != 0 ? gtSystemInfo->MaxEuPerSubSlice : topologyData.maxEuCount;
|
2021-04-27 22:45:13 +08:00
|
|
|
gtSystemInfo->MaxSubSlicesSupported = std::max(static_cast<uint32_t>(topologyData.maxSubSliceCount * topologyData.maxSliceCount), gtSystemInfo->MaxSubSlicesSupported);
|
2021-05-17 23:04:01 +08:00
|
|
|
gtSystemInfo->MaxSlicesSupported = topologyData.maxSliceCount;
|
2021-04-27 22:45:13 +08:00
|
|
|
|
2021-11-30 18:19:27 +08:00
|
|
|
for (uint32_t slice = 0; slice < gtSystemInfo->SliceCount; slice++) {
|
|
|
|
gtSystemInfo->SliceInfo[slice].Enabled = true;
|
|
|
|
}
|
|
|
|
|
2019-12-17 22:17:52 +08:00
|
|
|
uint64_t gttSizeQuery = 0;
|
2021-11-25 17:31:14 +08:00
|
|
|
featureTable->flags.ftrSVM = true;
|
2019-12-17 22:17:52 +08:00
|
|
|
|
|
|
|
ret = drm->queryGttSize(gttSizeQuery);
|
|
|
|
|
|
|
|
if (ret == 0) {
|
2021-11-25 17:31:14 +08:00
|
|
|
featureTable->flags.ftrSVM = (gttSizeQuery > MemoryConstants::max64BitAppAddress);
|
2019-12-17 22:17:52 +08:00
|
|
|
outHwInfo->capabilityTable.gpuAddressSpace = gttSizeQuery - 1; // gttSizeQuery = (1 << bits)
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
int maxGpuFreq = 0;
|
2020-04-10 19:54:07 +08:00
|
|
|
drm->getMaxGpuFrequency(*outHwInfo, maxGpuFreq);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
ret = configureHardwareCustom(outHwInfo, osIface);
|
|
|
|
if (ret != 0) {
|
2018-06-12 15:42:47 +08:00
|
|
|
*outHwInfo = {};
|
2017-12-21 07:45:38 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
configureCacheInfo(outHwInfo);
|
2021-11-25 17:31:14 +08:00
|
|
|
featureTable->flags.ftrEDram = (gtSystemInfo->EdramSizeInKb != 0) ? 1 : 0;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
outHwInfo->capabilityTable.maxRenderFrequency = maxGpuFreq;
|
2021-11-25 17:31:14 +08:00
|
|
|
outHwInfo->capabilityTable.ftrSvm = featureTable->flags.ftrSVM;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-05-08 22:00:24 +08:00
|
|
|
HwHelper &hwHelper = HwHelper::get(platform->eRenderCoreFamily);
|
2018-03-29 01:55:17 +08:00
|
|
|
outHwInfo->capabilityTable.ftrSupportsCoherency = false;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-03-29 23:06:02 +08:00
|
|
|
hwHelper.adjustDefaultEngineType(outHwInfo);
|
2019-03-27 17:06:29 +08:00
|
|
|
outHwInfo->capabilityTable.defaultEngineType = getChosenEngineType(*outHwInfo);
|
2018-02-14 21:52:00 +08:00
|
|
|
|
2019-08-21 18:50:47 +08:00
|
|
|
drm->checkQueueSliceSupport();
|
2020-02-11 00:05:32 +08:00
|
|
|
drm->checkNonPersistentContextsSupport();
|
2018-12-07 22:03:23 +08:00
|
|
|
drm->checkPreemptionSupport();
|
|
|
|
bool preemption = drm->isPreemptionSupported();
|
2021-10-05 21:14:08 +08:00
|
|
|
auto compilerHwInfoConfig = CompilerHwInfoConfig::get(outHwInfo->platform.eProductFamily);
|
2017-12-21 07:45:38 +08:00
|
|
|
PreemptionHelper::adjustDefaultPreemptionMode(outHwInfo->capabilityTable,
|
2021-10-05 21:14:08 +08:00
|
|
|
compilerHwInfoConfig->isMidThreadPreemptionSupported(*outHwInfo) && preemption,
|
2021-11-25 17:31:14 +08:00
|
|
|
static_cast<bool>(outHwInfo->featureTable.flags.ftrGpGpuThreadGroupLevelPreempt) && preemption,
|
|
|
|
static_cast<bool>(outHwInfo->featureTable.flags.ftrGpGpuMidBatchPreempt) && preemption);
|
2021-08-30 07:41:42 +08:00
|
|
|
|
2019-05-08 22:00:24 +08:00
|
|
|
outHwInfo->capabilityTable.requiredPreemptionSurfaceSize = outHwInfo->gtSystemInfo.CsrSizeInMb * MemoryConstants::megaByte;
|
2021-08-30 07:41:42 +08:00
|
|
|
hwHelper.adjustPreemptionSurfaceSize(outHwInfo->capabilityTable.requiredPreemptionSurfaceSize);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-03-22 16:41:17 +08:00
|
|
|
auto &kmdNotifyProperties = outHwInfo->capabilityTable.kmdNotifyProperties;
|
2018-04-10 16:26:59 +08: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-18 02:42:13 +08:00
|
|
|
KmdNotifyHelper::overrideFromDebugVariable(DebugManager.flags.OverrideEnableQuickKmdSleepForDirectSubmission.get(), kmdNotifyProperties.enableQuickKmdSleepForDirectSubmission);
|
|
|
|
KmdNotifyHelper::overrideFromDebugVariable(DebugManager.flags.OverrideDelayQuickKmdSleepForDirectSubmissionMicroseconds.get(), kmdNotifyProperties.delayQuickKmdSleepForDirectSubmissionMicroseconds);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2022-07-26 17:46:40 +08:00
|
|
|
if (DebugManager.flags.ForceImagesSupport.get() != -1) {
|
|
|
|
outHwInfo->capabilityTable.supportsImages = DebugManager.flags.ForceImagesSupport.get();
|
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|