|
5 | 5 | * |
6 | 6 | */ |
7 | 7 |
|
8 | | -#include "shared/source/command_stream/preemption.h" |
9 | 8 | #include "shared/source/helpers/api_specific_config.h" |
10 | | -#include "shared/source/os_interface/linux/drm_command_stream.h" |
11 | | -#include "shared/source/os_interface/linux/drm_memory_operations_handler.h" |
12 | | -#include "shared/source/os_interface/linux/os_context_linux.h" |
13 | | -#include "shared/test/common/helpers/debug_manager_state_restore.h" |
14 | | -#include "shared/test/common/helpers/default_hw_info.h" |
15 | | -#include "shared/test/common/helpers/engine_descriptor_helper.h" |
16 | | -#include "shared/test/common/helpers/variable_backup.h" |
17 | | -#include "shared/test/common/libult/linux/drm_mock.h" |
18 | | -#include "shared/test/common/mocks/linux/mock_drm_command_stream_receiver.h" |
19 | | -#include "shared/test/common/mocks/mock_execution_environment.h" |
20 | 9 | #include "shared/test/common/mocks/mock_graphics_allocation.h" |
21 | | -#include "shared/test/common/os_interface/linux/device_command_stream_fixture.h" |
| 10 | +#include "shared/test/common/os_interface/linux/drm_command_stream_fixture.h" |
22 | 11 | #include "shared/test/common/test_macros/test.h" |
23 | 12 |
|
24 | | -#include "drm/i915_drm.h" |
25 | | -#include "gtest/gtest.h" |
26 | | - |
27 | 13 | namespace NEO { |
28 | 14 | extern ApiSpecificConfig::ApiType apiTypeForUlts; |
29 | 15 | } //namespace NEO |
30 | 16 | using namespace NEO; |
31 | 17 |
|
32 | | -class DrmCommandStreamTest2 : public ::testing::Test { |
33 | | - public: |
34 | | - template <typename GfxFamily> |
35 | | - void SetUpT() { |
36 | | - |
37 | | - //make sure this is disabled, we don't want to test this now |
38 | | - DebugManager.flags.EnableForcePin.set(false); |
39 | | - auto hwInfo = executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo(); |
40 | | - |
41 | | - mock = new DrmMock(mockFd, *executionEnvironment.rootDeviceEnvironments[0]); |
42 | | - mock->setupIoctlHelper(hwInfo->platform.eProductFamily); |
43 | | - |
44 | | - executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>(); |
45 | | - executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock)); |
46 | | - executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u); |
47 | | - |
48 | | - mock->createVirtualMemoryAddressSpace(HwHelper::getSubDevicesCount(hwInfo)); |
49 | | - osContext = std::make_unique<OsContextLinux>(*mock, 0u, |
50 | | - EngineDescriptorHelper::getDefaultDescriptor(HwHelper::get(hwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[0], |
51 | | - PreemptionHelper::getDefaultPreemptionMode(*hwInfo))); |
52 | | - osContext->ensureContextInitialized(); |
53 | | - |
54 | | - csr = new DrmCommandStreamReceiver<GfxFamily>(executionEnvironment, 0, 1, gemCloseWorkerMode::gemCloseWorkerActive); |
55 | | - ASSERT_NE(nullptr, csr); |
56 | | - csr->setupContext(*osContext); |
57 | | - |
58 | | - mock->ioctlCallsCount = 0u; |
59 | | - memoryManager = new DrmMemoryManager(gemCloseWorkerMode::gemCloseWorkerActive, |
60 | | - DebugManager.flags.EnableForcePin.get(), |
61 | | - true, |
62 | | - executionEnvironment); |
63 | | - executionEnvironment.memoryManager.reset(memoryManager); |
64 | | - // Memory manager creates pinBB with ioctl, expect one call |
65 | | - EXPECT_EQ(1u, mock->ioctlCallsCount); |
66 | | - |
67 | | - //assert we have memory manager |
68 | | - ASSERT_NE(nullptr, memoryManager); |
69 | | - } |
70 | | - |
71 | | - template <typename GfxFamily> |
72 | | - void TearDownT() { |
73 | | - memoryManager->waitForDeletions(); |
74 | | - memoryManager->peekGemCloseWorker()->close(true); |
75 | | - delete csr; |
76 | | - // Expect 1 call with DRM_IOCTL_I915_GEM_CONTEXT_DESTROY request on destroyDrmContext |
77 | | - // Expect 1 call with DRM_IOCTL_GEM_CLOSE request on BufferObject close |
78 | | - mock->expectedIoctlCallsOnDestruction = mock->ioctlCallsCount + 2; |
79 | | - mock->expectIoctlCallsOnDestruction = true; |
80 | | - } |
81 | | - |
82 | | - CommandStreamReceiver *csr = nullptr; |
83 | | - DrmMemoryManager *memoryManager = nullptr; |
84 | | - DrmMock *mock = nullptr; |
85 | | - const int mockFd = 33; |
86 | | - static const uint64_t alignment = MemoryConstants::allocationAlignment; |
87 | | - DebugManagerStateRestore dbgState; |
88 | | - MockExecutionEnvironment executionEnvironment; |
89 | | - std::unique_ptr<OsContextLinux> osContext; |
90 | | -}; |
91 | | - |
92 | 18 | template <typename GfxFamily> |
93 | 19 | struct MockDrmCsr : public DrmCommandStreamReceiver<GfxFamily> { |
94 | 20 | using DrmCommandStreamReceiver<GfxFamily>::DrmCommandStreamReceiver; |
95 | 21 | using DrmCommandStreamReceiver<GfxFamily>::dispatchMode; |
96 | 22 | }; |
97 | 23 |
|
98 | | -HWTEST_TEMPLATED_F(DrmCommandStreamTest2, givenL0ApiConfigWhenCreatingDrmCsrThenEnableImmediateDispatch) { |
| 24 | +HWTEST_TEMPLATED_F(DrmCommandStreamTest, givenL0ApiConfigWhenCreatingDrmCsrThenEnableImmediateDispatch) { |
99 | 25 | VariableBackup<ApiSpecificConfig::ApiType> backup(&apiTypeForUlts, ApiSpecificConfig::L0); |
100 | 26 | MockDrmCsr<FamilyType> csr(executionEnvironment, 0, 1, gemCloseWorkerMode::gemCloseWorkerInactive); |
101 | 27 | EXPECT_EQ(DispatchMode::ImmediateDispatch, csr.dispatchMode); |
102 | 28 | } |
103 | 29 |
|
104 | | -HWTEST_TEMPLATED_F(DrmCommandStreamTest2, whenGettingCompletionValueThenTaskCountOfAllocationIsReturned) { |
| 30 | +HWTEST_TEMPLATED_F(DrmCommandStreamTest, whenGettingCompletionValueThenTaskCountOfAllocationIsReturned) { |
105 | 31 | MockGraphicsAllocation allocation{}; |
106 | 32 | uint32_t expectedValue = 0x1234; |
107 | 33 | allocation.updateTaskCount(expectedValue, osContext->getContextId()); |
108 | 34 | EXPECT_EQ(expectedValue, csr->getCompletionValue(allocation)); |
109 | 35 | } |
110 | 36 |
|
111 | | -HWTEST_TEMPLATED_F(DrmCommandStreamTest2, whenGettingCompletionAddressThenOffsettedTagAddressIsReturned) { |
| 37 | +HWTEST_TEMPLATED_F(DrmCommandStreamTest, whenGettingCompletionAddressThenOffsettedTagAddressIsReturned) { |
112 | 38 | csr->initializeTagAllocation(); |
113 | 39 | EXPECT_NE(nullptr, csr->getTagAddress()); |
114 | 40 | uint64_t tagAddress = castToUint64(const_cast<uint32_t *>(csr->getTagAddress())); |
115 | 41 | auto expectedAddress = tagAddress + Drm::completionFenceOffset; |
116 | 42 | EXPECT_EQ(expectedAddress, csr->getCompletionAddress()); |
117 | 43 | } |
118 | 44 |
|
119 | | -HWTEST_TEMPLATED_F(DrmCommandStreamTest2, givenNoTagAddressWhenGettingCompletionAddressThenZeroIsReturned) { |
| 45 | +HWTEST_TEMPLATED_F(DrmCommandStreamTest, givenNoTagAddressWhenGettingCompletionAddressThenZeroIsReturned) { |
120 | 46 | EXPECT_EQ(nullptr, csr->getTagAddress()); |
121 | 47 | EXPECT_EQ(0u, csr->getCompletionAddress()); |
122 | 48 | } |
0 commit comments