2019-09-19 01:32:33 +08:00
|
|
|
/*
|
2022-02-11 07:33:40 +08:00
|
|
|
* Copyright (C) 2019-2022 Intel Corporation
|
2019-09-19 01:32:33 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/command_stream/preemption.h"
|
2021-05-18 10:46:21 +08:00
|
|
|
#include "shared/source/command_stream/stream_properties.h"
|
2022-12-06 19:19:36 +08:00
|
|
|
#include "shared/source/helpers/hw_helper.h"
|
2022-08-11 23:58:56 +08:00
|
|
|
#include "shared/test/common/fixtures/preamble_fixture.h"
|
2021-01-21 20:10:13 +08:00
|
|
|
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
2019-09-19 01:32:33 +08:00
|
|
|
|
|
|
|
#include "reg_configs_common.h"
|
|
|
|
|
|
|
|
using namespace NEO;
|
|
|
|
|
2022-08-11 07:26:05 +08:00
|
|
|
using TglLpSlm = PreambleFixture;
|
2019-09-19 01:32:33 +08:00
|
|
|
|
2020-07-11 00:30:33 +08:00
|
|
|
HWTEST2_F(TglLpSlm, givenTglLpWhenPreambleIsBeingProgrammedThenThreadArbitrationPolicyIsIgnored, IsTGLLP) {
|
2020-06-18 20:24:59 +08:00
|
|
|
DebugManagerStateRestore dbgRestore;
|
|
|
|
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::Disabled));
|
2022-07-25 23:30:11 +08:00
|
|
|
typedef Gen12LpFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
|
2019-09-19 01:32:33 +08:00
|
|
|
LinearStream &cs = linearStream;
|
2022-07-25 23:30:11 +08:00
|
|
|
uint32_t l3Config = PreambleHelper<Gen12LpFamily>::getL3Config(pDevice->getHardwareInfo(), true);
|
2019-09-19 01:32:33 +08:00
|
|
|
MockDevice mockDevice;
|
2022-07-25 23:30:11 +08:00
|
|
|
PreambleHelper<Gen12LpFamily>::programPreamble(&linearStream, mockDevice, l3Config,
|
|
|
|
nullptr, nullptr);
|
2019-09-19 01:32:33 +08:00
|
|
|
|
2022-07-25 23:30:11 +08:00
|
|
|
parseCommands<Gen12LpFamily>(cs);
|
2019-09-19 01:32:33 +08:00
|
|
|
|
|
|
|
// parse through commands and ensure that 0xE404 is not being programmed
|
|
|
|
EXPECT_EQ(0U, countMmio<FamilyType>(cmdList.begin(), cmdList.end(), 0xE404));
|
|
|
|
}
|
|
|
|
|
2020-10-21 15:49:11 +08:00
|
|
|
HWTEST2_F(TglLpSlm, WhenPreambleIsCreatedThenSlmIsDisabled, IsTGLLP) {
|
2022-07-25 23:30:11 +08:00
|
|
|
typedef Gen12LpFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
|
2019-09-19 01:32:33 +08:00
|
|
|
LinearStream &cs = linearStream;
|
|
|
|
uint32_t l3Config = PreambleHelper<FamilyType>::getL3Config(pDevice->getHardwareInfo(), true);
|
|
|
|
PreambleHelper<FamilyType>::programL3(&cs, l3Config);
|
|
|
|
|
2022-07-25 23:30:11 +08:00
|
|
|
parseCommands<Gen12LpFamily>(cs);
|
2019-09-19 01:32:33 +08:00
|
|
|
|
|
|
|
auto itorLRI = find<MI_LOAD_REGISTER_IMM *>(cmdList.begin(), cmdList.end());
|
|
|
|
ASSERT_EQ(cmdList.end(), itorLRI);
|
|
|
|
}
|
|
|
|
|
2022-08-11 07:26:05 +08:00
|
|
|
using Gen12LpUrbEntryAllocationSize = PreambleFixture;
|
2020-10-21 15:49:11 +08:00
|
|
|
HWTEST2_F(Gen12LpUrbEntryAllocationSize, WhenPreambleIsCreatedThenUrbEntryAllocationSizeIsCorrect, IsTGLLP) {
|
2019-09-19 01:32:33 +08:00
|
|
|
uint32_t actualVal = PreambleHelper<FamilyType>::getUrbEntryAllocationSize();
|
|
|
|
EXPECT_EQ(1024u, actualVal);
|
|
|
|
}
|
|
|
|
|
2022-08-11 07:26:05 +08:00
|
|
|
using Gen12LpPreambleVfeState = PreambleVfeState;
|
2020-10-21 15:49:11 +08:00
|
|
|
HWTEST2_F(Gen12LpPreambleVfeState, GivenWaOffWhenProgrammingVfeStateThenProgrammingIsCorrect, IsTGLLP) {
|
2019-09-19 01:32:33 +08:00
|
|
|
typedef typename FamilyType::PIPE_CONTROL PIPE_CONTROL;
|
2021-11-25 17:31:14 +08:00
|
|
|
testWaTable->flags.waSendMIFLUSHBeforeVFE = 0;
|
2019-09-19 01:32:33 +08:00
|
|
|
LinearStream &cs = linearStream;
|
2022-08-11 07:26:05 +08:00
|
|
|
auto vfeCmd = PreambleHelper<FamilyType>::getSpaceForVfeState(&linearStream, pDevice->getHardwareInfo(), EngineGroupType::RenderCompute);
|
2021-04-02 02:26:29 +08:00
|
|
|
StreamProperties emptyProperties{};
|
2022-08-11 07:26:05 +08:00
|
|
|
PreambleHelper<FamilyType>::programVfeState(vfeCmd, pDevice->getHardwareInfo(), 0u, 0, 672u, emptyProperties, nullptr);
|
2019-09-19 01:32:33 +08:00
|
|
|
|
|
|
|
parseCommands<FamilyType>(cs);
|
|
|
|
|
|
|
|
auto itorPC = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
|
|
|
|
ASSERT_NE(cmdList.end(), itorPC);
|
|
|
|
|
|
|
|
const auto &pc = *reinterpret_cast<PIPE_CONTROL *>(*itorPC);
|
|
|
|
EXPECT_FALSE(pc.getRenderTargetCacheFlushEnable());
|
|
|
|
EXPECT_FALSE(pc.getDepthCacheFlushEnable());
|
2020-05-26 21:09:50 +08:00
|
|
|
EXPECT_FALSE(pc.getDepthStallEnable());
|
2019-09-19 01:32:33 +08:00
|
|
|
EXPECT_FALSE(pc.getDcFlushEnable());
|
|
|
|
EXPECT_EQ(1u, pc.getCommandStreamerStallEnable());
|
|
|
|
}
|
|
|
|
|
2020-07-11 00:30:33 +08:00
|
|
|
HWTEST2_F(Gen12LpPreambleVfeState, givenCcsEngineWhenWaIsSetThenAppropriatePipeControlFlushesAreSet, IsTGLLP) {
|
2019-09-19 01:32:33 +08:00
|
|
|
typedef typename FamilyType::PIPE_CONTROL PIPE_CONTROL;
|
2021-11-25 17:31:14 +08:00
|
|
|
testWaTable->flags.waSendMIFLUSHBeforeVFE = 1;
|
2019-09-19 01:32:33 +08:00
|
|
|
LinearStream &cs = linearStream;
|
|
|
|
|
2022-08-11 07:26:05 +08:00
|
|
|
auto vfeCmd = PreambleHelper<FamilyType>::getSpaceForVfeState(&linearStream, pDevice->getHardwareInfo(), EngineGroupType::Compute);
|
2021-04-02 02:26:29 +08:00
|
|
|
StreamProperties emptyProperties{};
|
2022-08-11 07:26:05 +08:00
|
|
|
PreambleHelper<FamilyType>::programVfeState(vfeCmd, pDevice->getHardwareInfo(), 0u, 0, 672u, emptyProperties, nullptr);
|
2019-09-19 01:32:33 +08:00
|
|
|
|
|
|
|
parseCommands<FamilyType>(cs);
|
|
|
|
|
|
|
|
auto itorPC = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
|
|
|
|
ASSERT_NE(cmdList.end(), itorPC);
|
|
|
|
|
|
|
|
const auto &pc = *reinterpret_cast<PIPE_CONTROL *>(*itorPC);
|
|
|
|
EXPECT_FALSE(pc.getRenderTargetCacheFlushEnable());
|
|
|
|
EXPECT_FALSE(pc.getDepthCacheFlushEnable());
|
|
|
|
EXPECT_TRUE(pc.getDcFlushEnable());
|
|
|
|
EXPECT_EQ(1u, pc.getCommandStreamerStallEnable());
|
|
|
|
}
|
|
|
|
|
2020-07-11 00:30:33 +08:00
|
|
|
HWTEST2_F(Gen12LpPreambleVfeState, givenRcsEngineWhenWaIsSetThenAppropriatePipeControlFlushesAreSet, IsTGLLP) {
|
2019-09-19 01:32:33 +08:00
|
|
|
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
|
2021-11-25 17:31:14 +08:00
|
|
|
testWaTable->flags.waSendMIFLUSHBeforeVFE = 1;
|
2019-09-19 01:32:33 +08:00
|
|
|
LinearStream &cs = linearStream;
|
|
|
|
|
2022-08-11 07:26:05 +08:00
|
|
|
auto vfeCmd = PreambleHelper<FamilyType>::getSpaceForVfeState(&linearStream, pDevice->getHardwareInfo(), EngineGroupType::RenderCompute);
|
2021-04-02 02:26:29 +08:00
|
|
|
StreamProperties emptyProperties{};
|
2022-08-11 07:26:05 +08:00
|
|
|
PreambleHelper<FamilyType>::programVfeState(vfeCmd, pDevice->getHardwareInfo(), 0u, 0, 672u, emptyProperties, nullptr);
|
2019-09-19 01:32:33 +08:00
|
|
|
|
|
|
|
parseCommands<FamilyType>(cs);
|
|
|
|
|
|
|
|
auto itorPC = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
|
|
|
|
ASSERT_NE(cmdList.end(), itorPC);
|
|
|
|
|
|
|
|
const auto &pc = *reinterpret_cast<PIPE_CONTROL *>(*itorPC);
|
|
|
|
EXPECT_TRUE(pc.getRenderTargetCacheFlushEnable());
|
|
|
|
EXPECT_TRUE(pc.getDepthCacheFlushEnable());
|
2020-05-26 21:09:50 +08:00
|
|
|
EXPECT_TRUE(pc.getDepthStallEnable());
|
2019-09-19 01:32:33 +08:00
|
|
|
EXPECT_TRUE(pc.getDcFlushEnable());
|
|
|
|
EXPECT_EQ(1u, pc.getCommandStreamerStallEnable());
|
|
|
|
}
|
|
|
|
|
2020-07-11 00:30:33 +08:00
|
|
|
HWTEST2_F(Gen12LpPreambleVfeState, givenDefaultPipeControlWhenItIsProgrammedThenCsStallBitIsSet, IsTGLLP) {
|
2019-09-19 01:32:33 +08:00
|
|
|
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
|
|
|
|
|
|
|
|
PIPE_CONTROL *pipeControl = static_cast<PIPE_CONTROL *>(linearStream.getSpace(sizeof(PIPE_CONTROL)));
|
|
|
|
*pipeControl = FamilyType::cmdInitPipeControl;
|
|
|
|
|
|
|
|
EXPECT_EQ(1u, pipeControl->getCommandStreamerStallEnable());
|
|
|
|
}
|
|
|
|
|
2020-07-11 00:30:33 +08:00
|
|
|
HWTEST2_F(Gen12LpPreambleVfeState, givenCfeFusedEuDispatchFlagsWhenprogramAdditionalFieldsInVfeStateIsCalledThenGetDisableSlice0Subslice2ReturnsCorrectValues, IsTGLLP) {
|
2019-10-01 17:51:31 +08:00
|
|
|
using MEDIA_VFE_STATE = typename FamilyType::MEDIA_VFE_STATE;
|
|
|
|
|
2019-10-07 19:11:12 +08:00
|
|
|
DebugManagerStateRestore restorer;
|
2022-08-11 07:26:05 +08:00
|
|
|
|
|
|
|
auto hwInfo = pDevice->getRootDeviceEnvironment().getMutableHardwareInfo();
|
|
|
|
auto &waTable = hwInfo->workaroundTable;
|
|
|
|
|
|
|
|
void *cmdSpace = linearStream.getSpace(sizeof(MEDIA_VFE_STATE));
|
|
|
|
auto mediaVfeState = reinterpret_cast<MEDIA_VFE_STATE *>(cmdSpace);
|
|
|
|
*mediaVfeState = FamilyType::cmdInitMediaVfeState;
|
2019-10-07 19:11:12 +08:00
|
|
|
|
2020-12-17 20:32:47 +08:00
|
|
|
std::tuple<bool, bool, int32_t> testParams[]{
|
|
|
|
{false, false, 0},
|
|
|
|
{false, true, 0},
|
|
|
|
{false, false, -1},
|
|
|
|
{true, false, 1},
|
|
|
|
{true, true, -1},
|
|
|
|
{true, true, 1}};
|
|
|
|
|
2022-08-11 07:26:05 +08:00
|
|
|
StreamProperties streamProperties = {};
|
|
|
|
streamProperties.frontEndState.disableEUFusion.value = 0;
|
|
|
|
|
2020-12-17 20:32:47 +08:00
|
|
|
for (auto &[expectedValue, waDisableFusedThreadScheduling, debugKeyValue] : testParams) {
|
2021-11-25 17:31:14 +08:00
|
|
|
waTable.flags.waDisableFusedThreadScheduling = waDisableFusedThreadScheduling;
|
2022-08-11 07:26:05 +08:00
|
|
|
|
|
|
|
DebugManager.flags.CFEFusedEUDispatch.set(debugKeyValue);
|
|
|
|
|
|
|
|
PreambleHelper<FamilyType>::appendProgramVFEState(*hwInfo, streamProperties, cmdSpace);
|
|
|
|
EXPECT_EQ(expectedValue, mediaVfeState->getDisableSlice0Subslice2());
|
2019-10-01 17:51:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-21 17:57:13 +08:00
|
|
|
HWTEST2_F(Gen12LpPreambleVfeState, givenMaxNumberOfDssDebugVariableWhenMediaVfeStateIsProgrammedThenFieldIsSet, IsTGLLP) {
|
|
|
|
using MEDIA_VFE_STATE = typename FamilyType::MEDIA_VFE_STATE;
|
|
|
|
|
|
|
|
DebugManagerStateRestore restorer;
|
|
|
|
DebugManager.flags.MediaVfeStateMaxSubSlices.set(2);
|
2022-08-11 07:26:05 +08:00
|
|
|
|
|
|
|
auto hwInfo = pDevice->getRootDeviceEnvironment().getMutableHardwareInfo();
|
|
|
|
|
|
|
|
void *cmdSpace = linearStream.getSpace(sizeof(MEDIA_VFE_STATE));
|
|
|
|
auto mediaVfeState = reinterpret_cast<MEDIA_VFE_STATE *>(cmdSpace);
|
|
|
|
*mediaVfeState = FamilyType::cmdInitMediaVfeState;
|
|
|
|
|
|
|
|
StreamProperties streamProperties = {};
|
|
|
|
streamProperties.frontEndState.disableEUFusion.value = 0;
|
|
|
|
|
|
|
|
PreambleHelper<FamilyType>::appendProgramVFEState(*hwInfo, streamProperties, cmdSpace);
|
|
|
|
EXPECT_EQ(2u, mediaVfeState->getMaximumNumberOfDualSubslices());
|
2020-10-21 17:57:13 +08:00
|
|
|
}
|
|
|
|
|
2022-02-11 07:33:40 +08:00
|
|
|
HWTEST2_F(Gen12LpPreambleVfeState, givenDisableEUFusionWhenProgramAdditionalFieldsInVfeStateThenCorrectFieldIsSet, IsTGLLP) {
|
|
|
|
using MEDIA_VFE_STATE = typename FamilyType::MEDIA_VFE_STATE;
|
|
|
|
|
2022-08-11 07:26:05 +08:00
|
|
|
auto hwInfo = pDevice->getRootDeviceEnvironment().getMutableHardwareInfo();
|
|
|
|
|
|
|
|
void *cmdSpace = linearStream.getSpace(sizeof(MEDIA_VFE_STATE));
|
|
|
|
auto mediaVfeState = reinterpret_cast<MEDIA_VFE_STATE *>(cmdSpace);
|
|
|
|
*mediaVfeState = FamilyType::cmdInitMediaVfeState;
|
|
|
|
|
|
|
|
StreamProperties streamProperties = {};
|
|
|
|
streamProperties.frontEndState.disableEUFusion.value = 1;
|
|
|
|
|
|
|
|
PreambleHelper<FamilyType>::appendProgramVFEState(*hwInfo, streamProperties, cmdSpace);
|
|
|
|
EXPECT_TRUE(mediaVfeState->getDisableSlice0Subslice2());
|
2022-02-11 07:33:40 +08:00
|
|
|
}
|
|
|
|
|
2022-03-17 23:53:21 +08:00
|
|
|
HWTEST2_F(Gen12LpPreambleVfeState, givenDisableEUFusionAndCFEFusedEUDispatchWhenProgramAdditionalFieldsInVfeStateThenCorrectFieldIsSet, IsTGLLP) {
|
|
|
|
using MEDIA_VFE_STATE = typename FamilyType::MEDIA_VFE_STATE;
|
|
|
|
|
|
|
|
DebugManagerStateRestore dbgRestorer;
|
|
|
|
DebugManager.flags.CFEFusedEUDispatch.set(0);
|
|
|
|
|
2022-08-11 07:26:05 +08:00
|
|
|
auto hwInfo = pDevice->getRootDeviceEnvironment().getMutableHardwareInfo();
|
|
|
|
|
|
|
|
void *cmdSpace = linearStream.getSpace(sizeof(MEDIA_VFE_STATE));
|
|
|
|
auto mediaVfeState = reinterpret_cast<MEDIA_VFE_STATE *>(cmdSpace);
|
|
|
|
*mediaVfeState = FamilyType::cmdInitMediaVfeState;
|
|
|
|
|
|
|
|
StreamProperties streamProperties = {};
|
|
|
|
streamProperties.frontEndState.disableEUFusion.value = 1;
|
|
|
|
|
|
|
|
PreambleHelper<FamilyType>::appendProgramVFEState(*hwInfo, streamProperties, cmdSpace);
|
|
|
|
EXPECT_FALSE(mediaVfeState->getDisableSlice0Subslice2());
|
2022-03-17 23:53:21 +08:00
|
|
|
}
|
|
|
|
|
2022-08-11 07:26:05 +08:00
|
|
|
using ThreadArbitrationGen12Lp = PreambleFixture;
|
2022-03-08 22:18:31 +08:00
|
|
|
GEN12LPTEST_F(ThreadArbitrationGen12Lp, whenGetDefaultThreadArbitrationPolicyIsCalledThenCorrectPolicyIsReturned) {
|
2022-03-08 01:00:26 +08:00
|
|
|
EXPECT_EQ(ThreadArbitrationPolicy::AgeBased, HwHelperHw<FamilyType>::get().getDefaultThreadArbitrationPolicy());
|
2019-09-19 01:32:33 +08:00
|
|
|
}
|
|
|
|
|
2021-09-09 16:32:45 +08:00
|
|
|
GEN12LPTEST_F(ThreadArbitrationGen12Lp, whenGetSupportThreadArbitrationPoliciesIsCalledThenEmptyVectorIsReturned) {
|
|
|
|
auto supportedPolicies = PreambleHelper<FamilyType>::getSupportedThreadArbitrationPolicies();
|
|
|
|
|
|
|
|
EXPECT_EQ(0u, supportedPolicies.size());
|
|
|
|
}
|
|
|
|
|
2022-08-11 07:26:05 +08:00
|
|
|
using PreemptionWatermarkGen12Lp = PreambleFixture;
|
|
|
|
GEN12LPTEST_F(PreemptionWatermarkGen12Lp, WhenPreambleIsCreatedThenPreambleWorkAroundsIsNotProgrammed) {
|
2019-09-19 01:32:33 +08:00
|
|
|
PreambleHelper<FamilyType>::programGenSpecificPreambleWorkArounds(&linearStream, pDevice->getHardwareInfo());
|
|
|
|
|
|
|
|
parseCommands<FamilyType>(linearStream);
|
|
|
|
|
|
|
|
auto cmd = findMmioCmd<FamilyType>(cmdList.begin(), cmdList.end(), FfSliceCsChknReg2::address);
|
|
|
|
ASSERT_EQ(nullptr, cmd);
|
|
|
|
|
2020-02-17 20:10:01 +08:00
|
|
|
MockDevice mockDevice;
|
|
|
|
mockDevice.setDebuggerActive(false);
|
|
|
|
size_t expectedSize = PreemptionHelper::getRequiredPreambleSize<FamilyType>(mockDevice);
|
|
|
|
EXPECT_EQ(expectedSize, PreambleHelper<FamilyType>::getAdditionalCommandsSize(mockDevice));
|
|
|
|
|
|
|
|
mockDevice.setDebuggerActive(true);
|
|
|
|
expectedSize += PreambleHelper<FamilyType>::getKernelDebuggingCommandsSize(mockDevice.isDebuggerActive());
|
|
|
|
EXPECT_EQ(expectedSize, PreambleHelper<FamilyType>::getAdditionalCommandsSize(mockDevice));
|
2019-09-19 01:32:33 +08:00
|
|
|
}
|
2021-09-24 00:46:42 +08:00
|
|
|
|
|
|
|
using PreambleFixtureGen12lp = PreambleFixture;
|
|
|
|
GEN12LPTEST_F(PreambleFixtureGen12lp, whenKernelDebuggingCommandsAreProgrammedThenCorrectRegisterAddressesAndValuesAreSet) {
|
|
|
|
typedef typename FamilyType::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
|
|
|
|
|
|
|
|
auto bufferSize = PreambleHelper<FamilyType>::getKernelDebuggingCommandsSize(true);
|
|
|
|
auto buffer = std::unique_ptr<char[]>(new char[bufferSize]);
|
|
|
|
|
|
|
|
LinearStream stream(buffer.get(), bufferSize);
|
|
|
|
PreambleHelper<FamilyType>::programKernelDebugging(&stream);
|
|
|
|
|
|
|
|
HardwareParse hwParser;
|
|
|
|
hwParser.parseCommands<FamilyType>(stream);
|
|
|
|
auto cmdList = hwParser.getCommandsList<MI_LOAD_REGISTER_IMM>();
|
|
|
|
|
|
|
|
ASSERT_EQ(2u, cmdList.size());
|
|
|
|
|
|
|
|
auto it = cmdList.begin();
|
|
|
|
|
2022-08-11 07:26:05 +08:00
|
|
|
MI_LOAD_REGISTER_IMM *cmd = reinterpret_cast<MI_LOAD_REGISTER_IMM *>(*it);
|
|
|
|
EXPECT_EQ(0x20d8u, cmd->getRegisterOffset());
|
|
|
|
EXPECT_EQ((1u << 5) | (1u << 21), cmd->getDataDword());
|
2021-09-24 00:46:42 +08:00
|
|
|
it++;
|
|
|
|
|
2022-08-11 07:26:05 +08:00
|
|
|
cmd = reinterpret_cast<MI_LOAD_REGISTER_IMM *>(*it);
|
|
|
|
EXPECT_EQ(0xe400u, cmd->getRegisterOffset());
|
|
|
|
EXPECT_EQ((1u << 7) | (1u << 4), cmd->getDataDword());
|
|
|
|
}
|