2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2020-01-21 22:24:52 +08:00
|
|
|
* Copyright (C) 2017-2020 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/os_interface/hw_info_config.h"
|
2019-02-27 18:39:32 +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"
|
|
|
|
#include "shared/source/helpers/hw_cmds.h"
|
|
|
|
#include "shared/source/helpers/hw_helper.h"
|
|
|
|
#include "shared/source/helpers/hw_info.h"
|
|
|
|
#include "shared/source/memory_manager/memory_constants.h"
|
|
|
|
#include "shared/source/os_interface/linux/drm_neo.h"
|
|
|
|
#include "shared/source/os_interface/linux/os_interface.h"
|
|
|
|
#include "shared/source/utilities/cpu_info.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-08-07 15:19:51 +08:00
|
|
|
#include "instrumentation.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
|
|
|
|
|
|
|
HwInfoConfig *hwInfoConfigFactory[IGFX_MAX_PRODUCT] = {};
|
|
|
|
|
|
|
|
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 {
|
|
|
|
uint32_t cpuRegsInfo[4];
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
int HwInfoConfig::configureHwInfo(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, OSInterface *osIface) {
|
|
|
|
int ret = 0;
|
|
|
|
Drm *drm = osIface->get()->getDrm();
|
|
|
|
|
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
|
|
|
|
|
|
|
int val = 0;
|
|
|
|
ret = drm->getDeviceID(val);
|
|
|
|
if (ret != 0 || val == 0) {
|
2018-06-12 15:42:47 +08:00
|
|
|
*outHwInfo = {};
|
2017-12-21 07:45:38 +08:00
|
|
|
return (ret == 0) ? -1 : ret;
|
|
|
|
}
|
2019-05-08 22:00:24 +08:00
|
|
|
platform->usDeviceID = static_cast<unsigned short>(val);
|
2017-12-21 07:45:38 +08:00
|
|
|
ret = drm->getDeviceRevID(val);
|
|
|
|
if (ret != 0) {
|
2018-06-12 15:42:47 +08:00
|
|
|
*outHwInfo = {};
|
2017-12-21 07:45:38 +08:00
|
|
|
return ret;
|
|
|
|
}
|
2019-05-08 22:00:24 +08:00
|
|
|
platform->usRevId = static_cast<unsigned short>(val);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
int euCount;
|
|
|
|
ret = drm->getEuTotal(euCount);
|
|
|
|
if (ret != 0) {
|
2018-06-12 15:42:47 +08:00
|
|
|
*outHwInfo = {};
|
2017-12-21 07:45:38 +08:00
|
|
|
return ret;
|
|
|
|
}
|
2019-05-08 22:00:24 +08:00
|
|
|
gtSystemInfo->EUCount = static_cast<uint32_t>(euCount);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-05-08 22:00:24 +08:00
|
|
|
gtSystemInfo->ThreadCount = this->threadsPerEu * gtSystemInfo->EUCount;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
int subSliceCount;
|
|
|
|
ret = drm->getSubsliceTotal(subSliceCount);
|
|
|
|
if (ret != 0) {
|
2018-06-12 15:42:47 +08:00
|
|
|
*outHwInfo = {};
|
2017-12-21 07:45:38 +08:00
|
|
|
return ret;
|
|
|
|
}
|
2019-05-08 22:00:24 +08:00
|
|
|
gtSystemInfo->SubSliceCount = static_cast<uint32_t>(subSliceCount);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-12-17 22:17:52 +08:00
|
|
|
uint64_t gttSizeQuery = 0;
|
|
|
|
featureTable->ftrSVM = true;
|
|
|
|
|
|
|
|
ret = drm->queryGttSize(gttSizeQuery);
|
|
|
|
|
|
|
|
if (ret == 0) {
|
|
|
|
featureTable->ftrSVM = (gttSizeQuery > MemoryConstants::max64BitAppAddress);
|
|
|
|
outHwInfo->capabilityTable.gpuAddressSpace = gttSizeQuery - 1; // gttSizeQuery = (1 << bits)
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
int maxGpuFreq = 0;
|
|
|
|
drm->getMaxGpuFrequency(maxGpuFreq);
|
|
|
|
|
|
|
|
GTTYPE gtType = drm->getGtType();
|
|
|
|
if (gtType == GTTYPE_UNDEFINED) {
|
2018-06-12 15:42:47 +08:00
|
|
|
*outHwInfo = {};
|
2017-12-21 07:45:38 +08:00
|
|
|
return -1;
|
|
|
|
}
|
2019-05-08 22:00:24 +08:00
|
|
|
platform->eGTType = gtType;
|
|
|
|
featureTable->ftrGTA = (gtType == GTTYPE_GTA) ? 1 : 0;
|
|
|
|
featureTable->ftrGTC = (gtType == GTTYPE_GTC) ? 1 : 0;
|
|
|
|
featureTable->ftrGTX = (gtType == GTTYPE_GTX) ? 1 : 0;
|
|
|
|
featureTable->ftrGT1 = (gtType == GTTYPE_GT1) ? 1 : 0;
|
|
|
|
featureTable->ftrGT1_5 = (gtType == GTTYPE_GT1_5) ? 1 : 0;
|
|
|
|
featureTable->ftrGT2 = (gtType == GTTYPE_GT2) ? 1 : 0;
|
|
|
|
featureTable->ftrGT2_5 = (gtType == GTTYPE_GT2_5) ? 1 : 0;
|
|
|
|
featureTable->ftrGT3 = (gtType == GTTYPE_GT3) ? 1 : 0;
|
|
|
|
featureTable->ftrGT4 = (gtType == GTTYPE_GT4) ? 1 : 0;
|
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);
|
2019-05-08 22:00:24 +08:00
|
|
|
featureTable->ftrEDram = (gtSystemInfo->EdramSizeInKb != 0) ? 1 : 0;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
outHwInfo->capabilityTable.maxRenderFrequency = maxGpuFreq;
|
2019-05-08 22:00:24 +08:00
|
|
|
outHwInfo->capabilityTable.ftrSvm = featureTable->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-23 21:41:25 +08:00
|
|
|
outHwInfo->capabilityTable.instrumentationEnabled =
|
|
|
|
(outHwInfo->capabilityTable.instrumentationEnabled && haveInstrumentation);
|
2019-08-21 18:50:47 +08:00
|
|
|
|
2018-07-18 20:11:05 +08:00
|
|
|
outHwInfo->capabilityTable.ftrRenderCompressedBuffers = false;
|
|
|
|
outHwInfo->capabilityTable.ftrRenderCompressedImages = false;
|
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();
|
2017-12-21 07:45:38 +08:00
|
|
|
PreemptionHelper::adjustDefaultPreemptionMode(outHwInfo->capabilityTable,
|
2019-05-08 22:00:24 +08:00
|
|
|
static_cast<bool>(outHwInfo->featureTable.ftrGpGpuMidThreadLevelPreempt) && preemption,
|
|
|
|
static_cast<bool>(outHwInfo->featureTable.ftrGpGpuThreadGroupLevelPreempt) && preemption,
|
|
|
|
static_cast<bool>(outHwInfo->featureTable.ftrGpGpuMidBatchPreempt) && preemption);
|
|
|
|
outHwInfo->capabilityTable.requiredPreemptionSurfaceSize = outHwInfo->gtSystemInfo.CsrSizeInMb * MemoryConstants::megaByte;
|
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);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|