Skip to content

Commit 7910567

Browse files
Handle missing tag address in getting completion address
rename test fixture to comply one definition rule Related-To: NEO-6643 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
1 parent 9cba46e commit 7910567

File tree

4 files changed

+37
-9
lines changed

4 files changed

+37
-9
lines changed

opencl/test/unit_test/os_interface/linux/drm_command_stream_xehp_and_later_tests.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,9 @@ struct DrmCommandStreamMultiTileMemExecFixture {
7272
using DrmCommandStreamMultiTileMemExecTest = Test<DrmCommandStreamMultiTileMemExecFixture>;
7373

7474
HWCMDTEST_F(IGFX_XE_HP_CORE, DrmCommandStreamMultiTileMemExecTest, GivenDrmSupportsCompletionFenceAndVmBindWhenCallingCsrExecThenMultipleTagAllocationIsPassed) {
75-
auto osContext = std::make_unique<OsContextLinux>(*mock, 0u, EngineDescriptorHelper::getDefaultDescriptor(device->getDeviceBitfield()));
76-
osContext->ensureContextInitialized();
77-
7875
auto *testCsr = new TestedDrmCommandStreamReceiver<FamilyType>(*executionEnvironment, 0, device->getDeviceBitfield());
79-
auto device = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(executionEnvironment, 0));
8076
device->resetCommandStreamReceiver(testCsr);
8177
EXPECT_EQ(2u, testCsr->activePartitions);
82-
testCsr->setupContext(*osContext.get());
8378

8479
mock->completionFenceSupported = true;
8580
mock->isVmBindAvailableCall.callParent = false;

opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5920,4 +5920,27 @@ TEST_F(DrmMemoryManagerTest, givenCompletionFenceEnabledWhenHandlingCompletionOf
59205920
memoryManager->freeGraphicsMemory(allocation);
59215921
}
59225922

5923+
HWTEST_F(DrmMemoryManagerTest, givenCompletionFenceEnabledWhenHandlingCompletionAndTagAddressIsNullThenDoNotCallWaitUserFence) {
5924+
mock->ioctl_expected.total = -1;
5925+
5926+
VariableBackup<bool> backupFenceSupported{&mock->completionFenceSupported, true};
5927+
VariableBackup<bool> backupVmBindCallParent{&mock->isVmBindAvailableCall.callParent, false};
5928+
VariableBackup<bool> backupVmBindReturnValue{&mock->isVmBindAvailableCall.returnValue, true};
5929+
5930+
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{rootDeviceIndex, 1024, AllocationType::COMMAND_BUFFER});
5931+
auto engine = memoryManager->getRegisteredEngines()[0];
5932+
allocation->updateTaskCount(2, engine.osContext->getContextId());
5933+
5934+
auto testCsr = static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(engine.commandStreamReceiver);
5935+
auto backupTagAddress = testCsr->tagAddress;
5936+
testCsr->tagAddress = nullptr;
5937+
5938+
memoryManager->handleFenceCompletion(allocation);
5939+
EXPECT_EQ(0u, mock->waitUserFenceCall.called);
5940+
5941+
testCsr->tagAddress = backupTagAddress;
5942+
5943+
memoryManager->freeGraphicsMemory(allocation);
5944+
}
5945+
59235946
} // namespace NEO

shared/source/os_interface/linux/drm_command_stream.inl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,9 @@ inline bool DrmCommandStreamReceiver<GfxFamily>::isUserFenceWaitActive() {
319319
template <typename GfxFamily>
320320
uint64_t DrmCommandStreamReceiver<GfxFamily>::getCompletionAddress() {
321321
uint64_t completionFenceAddress = castToUint64(const_cast<uint32_t *>(getTagAddress()));
322+
if (completionFenceAddress == 0) {
323+
return 0;
324+
}
322325
completionFenceAddress += Drm::completionFenceOffset;
323326
return completionFenceAddress;
324327
}

shared/test/unit_test/os_interface/linux/drm_command_stream_tests.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extern ApiSpecificConfig::ApiType apiTypeForUlts;
2929
} //namespace NEO
3030
using namespace NEO;
3131

32-
class DrmCommandStreamTest : public ::testing::Test {
32+
class DrmCommandStreamTest2 : public ::testing::Test {
3333
public:
3434
template <typename GfxFamily>
3535
void SetUpT() {
@@ -95,21 +95,28 @@ struct MockDrmCsr : public DrmCommandStreamReceiver<GfxFamily> {
9595
using DrmCommandStreamReceiver<GfxFamily>::dispatchMode;
9696
};
9797

98-
HWTEST_TEMPLATED_F(DrmCommandStreamTest, givenL0ApiConfigWhenCreatingDrmCsrThenEnableImmediateDispatch) {
98+
HWTEST_TEMPLATED_F(DrmCommandStreamTest2, givenL0ApiConfigWhenCreatingDrmCsrThenEnableImmediateDispatch) {
9999
VariableBackup<ApiSpecificConfig::ApiType> backup(&apiTypeForUlts, ApiSpecificConfig::L0);
100100
MockDrmCsr<FamilyType> csr(executionEnvironment, 0, 1, gemCloseWorkerMode::gemCloseWorkerInactive);
101101
EXPECT_EQ(DispatchMode::ImmediateDispatch, csr.dispatchMode);
102102
}
103103

104-
HWTEST_TEMPLATED_F(DrmCommandStreamTest, whenGettingCompletionValueThenTaskCountOfAllocationIsReturned) {
104+
HWTEST_TEMPLATED_F(DrmCommandStreamTest2, whenGettingCompletionValueThenTaskCountOfAllocationIsReturned) {
105105
MockGraphicsAllocation allocation{};
106106
uint32_t expectedValue = 0x1234;
107107
allocation.updateTaskCount(expectedValue, osContext->getContextId());
108108
EXPECT_EQ(expectedValue, csr->getCompletionValue(allocation));
109109
}
110110

111-
HWTEST_TEMPLATED_F(DrmCommandStreamTest, whenGettingCompletionAddressThenOffsettedTagAddressIsReturned) {
111+
HWTEST_TEMPLATED_F(DrmCommandStreamTest2, whenGettingCompletionAddressThenOffsettedTagAddressIsReturned) {
112+
csr->initializeTagAllocation();
113+
EXPECT_NE(nullptr, csr->getTagAddress());
112114
uint64_t tagAddress = castToUint64(const_cast<uint32_t *>(csr->getTagAddress()));
113115
auto expectedAddress = tagAddress + Drm::completionFenceOffset;
114116
EXPECT_EQ(expectedAddress, csr->getCompletionAddress());
115117
}
118+
119+
HWTEST_TEMPLATED_F(DrmCommandStreamTest2, givenNoTagAddressWhenGettingCompletionAddressThenZeroIsReturned) {
120+
EXPECT_EQ(nullptr, csr->getTagAddress());
121+
EXPECT_EQ(0u, csr->getCompletionAddress());
122+
}

0 commit comments

Comments
 (0)