1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
/*
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
template <>
void PreemptionHelper::programCsrBaseAddress<GfxFamily>(LinearStream &preambleCmdStream, Device &device, const GraphicsAllocation *preemptionCsr, LogicalStateHelper *logicalStateHelper) {
}
template <>
void PreemptionHelper::programStateSip<GfxFamily>(LinearStream &preambleCmdStream, Device &device, LogicalStateHelper *logicalStateHelper) {
using STATE_SIP = typename GfxFamily::STATE_SIP;
using MI_LOAD_REGISTER_IMM = typename GfxFamily::MI_LOAD_REGISTER_IMM;
auto &hwInfo = device.getHardwareInfo();
bool debuggingEnabled = device.getDebugger() != nullptr;
if (debuggingEnabled) {
HwHelper &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
auto sipAllocation = SipKernel::getSipKernel(device).getSipAllocation();
if (hwHelper.isSipWANeeded(hwInfo)) {
auto mmio = reinterpret_cast<MI_LOAD_REGISTER_IMM *>(preambleCmdStream.getSpace(sizeof(MI_LOAD_REGISTER_IMM)));
MI_LOAD_REGISTER_IMM cmd = GfxFamily::cmdInitLoadRegisterImm;
UNRECOVERABLE_IF((sipAllocation->getGpuAddressToPatch() & uint64_t(0xffffffff00000000)) != 0);
uint32_t globalSip = static_cast<uint32_t>(sipAllocation->getGpuAddressToPatch() & uint32_t(-1));
globalSip &= 0xfffffff8;
globalSip |= 1;
cmd.setDataDword(globalSip);
cmd.setRegisterOffset(GlobalSipRegister<GfxFamily>::registerOffset);
*mmio = cmd;
} else {
auto sip = reinterpret_cast<STATE_SIP *>(preambleCmdStream.getSpace(sizeof(STATE_SIP)));
STATE_SIP cmd = GfxFamily::cmdInitStateSip;
cmd.setSystemInstructionPointer(sipAllocation->getGpuAddressToPatch());
*sip = cmd;
}
}
}
template <>
void PreemptionHelper::programStateSipEndWa<GfxFamily>(LinearStream &cmdStream, Device &device) {
using MI_LOAD_REGISTER_IMM = typename GfxFamily::MI_LOAD_REGISTER_IMM;
bool debuggingEnabled = device.getDebugger() != nullptr;
if (debuggingEnabled) {
HwHelper &hwHelper = HwHelper::get(device.getHardwareInfo().platform.eRenderCoreFamily);
if (hwHelper.isSipWANeeded(device.getHardwareInfo())) {
NEO::PipeControlArgs args;
NEO::MemorySynchronizationCommands<GfxFamily>::addSingleBarrier(cmdStream, args);
auto mmio = reinterpret_cast<MI_LOAD_REGISTER_IMM *>(cmdStream.getSpace(sizeof(MI_LOAD_REGISTER_IMM)));
MI_LOAD_REGISTER_IMM cmd = GfxFamily::cmdInitLoadRegisterImm;
uint32_t globalSip = 0;
cmd.setDataDword(globalSip);
cmd.setRegisterOffset(GlobalSipRegister<GfxFamily>::registerOffset);
*mmio = cmd;
}
}
}
template <>
size_t PreemptionHelper::getRequiredPreambleSize<GfxFamily>(const Device &device) {
return 0u;
}
template <>
size_t PreemptionHelper::getRequiredStateSipCmdSize<GfxFamily>(Device &device, bool isRcs) {
size_t size = 0;
bool debuggingEnabled = device.getDebugger() != nullptr || device.isDebuggerActive();
auto &hwInfo = device.getHardwareInfo();
if (debuggingEnabled) {
HwHelper &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
if (hwHelper.isSipWANeeded(hwInfo)) {
size += MemorySynchronizationCommands<GfxFamily>::getSizeForSingleBarrier(false);
size += 2 * sizeof(typename GfxFamily::MI_LOAD_REGISTER_IMM);
} else {
auto hwInfoConfig = HwInfoConfig::get(hwInfo.platform.eProductFamily);
const auto &[isBasicWARequired, isExtendedWARequired] = hwInfoConfig->isPipeControlPriorToNonPipelinedStateCommandsWARequired(hwInfo, isRcs);
const auto isWARequired = isBasicWARequired || isExtendedWARequired;
if (isWARequired) {
size += MemorySynchronizationCommands<GfxFamily>::getSizeForSingleBarrier(false);
}
size += sizeof(typename GfxFamily::STATE_SIP);
}
}
return size;
}
|