| 1 |
/* |
| 2 |
* Copyright (C) 2019-2023 Intel Corporation |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: MIT |
| 5 |
* |
| 6 |
*/ |
| 7 |
|
| 8 |
#include "shared/source/command_stream/aub_command_stream_receiver_hw.h" |
| 9 |
#include "shared/source/command_stream/command_stream_receiver_with_aub_dump.h" |
| 10 |
#include "shared/source/command_stream/linear_stream.h" |
| 11 |
#include "shared/source/execution_environment/execution_environment.h" |
| 12 |
#include "shared/source/execution_environment/root_device_environment.h" |
| 13 |
#include "shared/source/helpers/gfx_core_helper.h" |
| 14 |
#include "shared/source/helpers/windows/gmm_callbacks.h" |
| 15 |
#include "shared/source/os_interface/windows/wddm_device_command_stream.h" |
| 16 |
#include "shared/test/common/cmd_parse/hw_parse.h" |
| 17 |
#include "shared/test/common/fixtures/gmm_callbacks_fixture.h" |
| 18 |
#include "shared/test/common/helpers/debug_manager_state_restore.h" |
| 19 |
#include "shared/test/common/helpers/default_hw_info.h" |
| 20 |
#include "shared/test/common/libult/ult_command_stream_receiver.h" |
| 21 |
#include "shared/test/common/test_macros/hw_test.h" |
| 22 |
|
| 23 |
using namespace NEO; |
| 24 |
|
| 25 |
using Gen12LpGmmCallbacksTests = ::Test<GmmCallbacksFixture>; |
| 26 |
|
| 27 |
template <typename GfxFamily> |
| 28 |
struct MockAubCsrToTestNotifyAubCapture : public AUBCommandStreamReceiverHw<GfxFamily> { |
| 29 |
using AUBCommandStreamReceiverHw<GfxFamily>::AUBCommandStreamReceiverHw; |
| 30 |
using AUBCommandStreamReceiverHw<GfxFamily>::externalAllocations; |
| 31 |
}; |
| 32 |
|
| 33 |
GEN12LPTEST_F(Gen12LpGmmCallbacksTests, givenCsrWithoutAubDumpWhenNotifyAubCaptureCallbackIsCalledThenDoNothing) { |
| 34 |
auto csr = std::make_unique<WddmCommandStreamReceiver<FamilyType>>(*executionEnvironment, 0, 1); |
| 35 |
uint64_t address = 0xFEDCBA9876543210; |
| 36 |
size_t size = 1024; |
| 37 |
|
| 38 |
auto res = DeviceCallbacks<FamilyType>::notifyAubCapture(csr.get(), address, size, true); |
| 39 |
|
| 40 |
EXPECT_EQ(1, res); |
| 41 |
} |
| 42 |
|
| 43 |
GEN12LPTEST_F(Gen12LpGmmCallbacksTests, givenWddmCsrWhenWriteL3CalledThenWriteTwoMmio) { |
| 44 |
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM; |
| 45 |
|
| 46 |
UltCommandStreamReceiver<FamilyType> csr(*executionEnvironment, 0, 1); |
| 47 |
uint8_t buffer[128] = {}; |
| 48 |
csr.commandStream.replaceBuffer(buffer, 128); |
| 49 |
|
| 50 |
uint64_t address = 0x00234564002BCDEC; |
| 51 |
uint64_t value = 0xFEDCBA987654321C; |
| 52 |
|
| 53 |
auto res = TTCallbacks<FamilyType>::writeL3Address(&csr, value, address); |
| 54 |
EXPECT_EQ(1, res); |
| 55 |
EXPECT_EQ(2 * sizeof(MI_LOAD_REGISTER_IMM), csr.commandStream.getUsed()); |
| 56 |
|
| 57 |
HardwareParse hwParse; |
| 58 |
hwParse.parseCommands<FamilyType>(csr.commandStream, 0); |
| 59 |
EXPECT_EQ(2u, hwParse.cmdList.size()); |
| 60 |
|
| 61 |
auto cmd = genCmdCast<MI_LOAD_REGISTER_IMM *>(*hwParse.cmdList.begin()); |
| 62 |
ASSERT_NE(nullptr, cmd); |
| 63 |
EXPECT_EQ(address & 0xFFFFFFFF, cmd->getRegisterOffset()); |
| 64 |
EXPECT_EQ(value & 0xFFFFFFFF, cmd->getDataDword()); |
| 65 |
|
| 66 |
cmd = genCmdCast<MI_LOAD_REGISTER_IMM *>(*(++hwParse.cmdList.begin())); |
| 67 |
ASSERT_NE(nullptr, cmd); |
| 68 |
EXPECT_EQ(address >> 32, cmd->getRegisterOffset()); |
| 69 |
EXPECT_EQ(value >> 32, cmd->getDataDword()); |
| 70 |
} |
| 71 |
|
| 72 |
GEN12LPTEST_F(Gen12LpGmmCallbacksTests, givenCcsEnabledhenWriteL3CalledThenSetRemapBit) { |
| 73 |
typedef typename FamilyType::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM; |
| 74 |
HardwareInfo localHwInfo = *defaultHwInfo; |
| 75 |
localHwInfo.featureTable.flags.ftrCCSNode = true; |
| 76 |
ExecutionEnvironment executionEnvironment; |
| 77 |
executionEnvironment.prepareRootDeviceEnvironments(1u); |
| 78 |
executionEnvironment.rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(&localHwInfo); |
| 79 |
executionEnvironment.initializeMemoryManager(); |
| 80 |
UltCommandStreamReceiver<FamilyType> csr(executionEnvironment, 0, 1); |
| 81 |
uint8_t buffer[128] = {}; |
| 82 |
csr.commandStream.replaceBuffer(buffer, 128); |
| 83 |
|
| 84 |
auto res = TTCallbacks<FamilyType>::writeL3Address(&csr, 1, 1); |
| 85 |
EXPECT_EQ(1, res); |
| 86 |
|
| 87 |
HardwareParse hwParse; |
| 88 |
hwParse.parseCommands<FamilyType>(csr.commandStream, 0); |
| 89 |
EXPECT_EQ(2u, hwParse.cmdList.size()); |
| 90 |
|
| 91 |
auto cmd = genCmdCast<MI_LOAD_REGISTER_IMM *>(*hwParse.cmdList.begin()); |
| 92 |
ASSERT_NE(nullptr, cmd); |
| 93 |
EXPECT_TRUE(cmd->getMmioRemapEnable()); |
| 94 |
|
| 95 |
cmd = genCmdCast<MI_LOAD_REGISTER_IMM *>(*(++hwParse.cmdList.begin())); |
| 96 |
ASSERT_NE(nullptr, cmd); |
| 97 |
EXPECT_TRUE(cmd->getMmioRemapEnable()); |
| 98 |
} |
| 99 |
|
| 100 |
GEN12LPTEST_F(Gen12LpGmmCallbacksTests, givenCcsDisabledhenWriteL3CalledThenSetRemapBitToTrue) { |
| 101 |
typedef typename FamilyType::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM; |
| 102 |
HardwareInfo localHwInfo = *defaultHwInfo; |
| 103 |
localHwInfo.featureTable.flags.ftrCCSNode = false; |
| 104 |
ExecutionEnvironment executionEnvironment; |
| 105 |
executionEnvironment.prepareRootDeviceEnvironments(1u); |
| 106 |
executionEnvironment.rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(&localHwInfo); |
| 107 |
executionEnvironment.initializeMemoryManager(); |
| 108 |
UltCommandStreamReceiver<FamilyType> csr(executionEnvironment, 0, 1); |
| 109 |
uint8_t buffer[128] = {}; |
| 110 |
csr.commandStream.replaceBuffer(buffer, 128); |
| 111 |
|
| 112 |
auto res = TTCallbacks<FamilyType>::writeL3Address(&csr, 1, 1); |
| 113 |
EXPECT_EQ(1, res); |
| 114 |
|
| 115 |
HardwareParse hwParse; |
| 116 |
hwParse.parseCommands<FamilyType>(csr.commandStream, 0); |
| 117 |
EXPECT_EQ(2u, hwParse.cmdList.size()); |
| 118 |
|
| 119 |
auto cmd = genCmdCast<MI_LOAD_REGISTER_IMM *>(*hwParse.cmdList.begin()); |
| 120 |
ASSERT_NE(nullptr, cmd); |
| 121 |
EXPECT_TRUE(cmd->getMmioRemapEnable()); |
| 122 |
|
| 123 |
cmd = genCmdCast<MI_LOAD_REGISTER_IMM *>(*(++hwParse.cmdList.begin())); |
| 124 |
ASSERT_NE(nullptr, cmd); |
| 125 |
EXPECT_TRUE(cmd->getMmioRemapEnable()); |
| 126 |
} |