Files
compute-runtime/shared/source/command_stream/preemption_xehp_plus.inl
Bartosz Dunajski 96d14967ac Partial support for XE_HP_SDV
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
2021-06-24 18:35:54 +02:00

86 lines
3.4 KiB
C++

/*
* Copyright (C) 2016-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
template <>
void PreemptionHelper::programCsrBaseAddress<GfxFamily>(LinearStream &preambleCmdStream, Device &device, const GraphicsAllocation *preemptionCsr) {
}
template <>
void PreemptionHelper::programStateSip<GfxFamily>(LinearStream &preambleCmdStream, Device &device) {
using STATE_SIP = typename GfxFamily::STATE_SIP;
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);
auto sipAllocation = SipKernel::getSipKernel(device).getSipAllocation();
if (hwHelper.isSipWANeeded(device.getHardwareInfo())) {
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(false);
NEO::MemorySynchronizationCommands<GfxFamily>::addPipeControl(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>(const Device &device) {
size_t size = 0;
bool debuggingEnabled = device.getDebugger() != nullptr || device.isDebuggerActive();
if (debuggingEnabled) {
HwHelper &hwHelper = HwHelper::get(device.getHardwareInfo().platform.eRenderCoreFamily);
if (hwHelper.isSipWANeeded(device.getHardwareInfo())) {
size += sizeof(typename GfxFamily::PIPE_CONTROL);
size += 2 * sizeof(typename GfxFamily::MI_LOAD_REGISTER_IMM);
} else {
size += sizeof(typename GfxFamily::STATE_SIP);
}
}
return size;
}