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>
This commit is contained in:
Mateusz Jablonski
2022-04-01 09:40:06 +00:00
committed by Compute-Runtime-Automation
parent 9cba46e5bf
commit 7910567a76
4 changed files with 37 additions and 9 deletions

View File

@ -72,14 +72,9 @@ struct DrmCommandStreamMultiTileMemExecFixture {
using DrmCommandStreamMultiTileMemExecTest = Test<DrmCommandStreamMultiTileMemExecFixture>;
HWCMDTEST_F(IGFX_XE_HP_CORE, DrmCommandStreamMultiTileMemExecTest, GivenDrmSupportsCompletionFenceAndVmBindWhenCallingCsrExecThenMultipleTagAllocationIsPassed) {
auto osContext = std::make_unique<OsContextLinux>(*mock, 0u, EngineDescriptorHelper::getDefaultDescriptor(device->getDeviceBitfield()));
osContext->ensureContextInitialized();
auto *testCsr = new TestedDrmCommandStreamReceiver<FamilyType>(*executionEnvironment, 0, device->getDeviceBitfield());
auto device = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(executionEnvironment, 0));
device->resetCommandStreamReceiver(testCsr);
EXPECT_EQ(2u, testCsr->activePartitions);
testCsr->setupContext(*osContext.get());
mock->completionFenceSupported = true;
mock->isVmBindAvailableCall.callParent = false;

View File

@ -5920,4 +5920,27 @@ TEST_F(DrmMemoryManagerTest, givenCompletionFenceEnabledWhenHandlingCompletionOf
memoryManager->freeGraphicsMemory(allocation);
}
HWTEST_F(DrmMemoryManagerTest, givenCompletionFenceEnabledWhenHandlingCompletionAndTagAddressIsNullThenDoNotCallWaitUserFence) {
mock->ioctl_expected.total = -1;
VariableBackup<bool> backupFenceSupported{&mock->completionFenceSupported, true};
VariableBackup<bool> backupVmBindCallParent{&mock->isVmBindAvailableCall.callParent, false};
VariableBackup<bool> backupVmBindReturnValue{&mock->isVmBindAvailableCall.returnValue, true};
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{rootDeviceIndex, 1024, AllocationType::COMMAND_BUFFER});
auto engine = memoryManager->getRegisteredEngines()[0];
allocation->updateTaskCount(2, engine.osContext->getContextId());
auto testCsr = static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(engine.commandStreamReceiver);
auto backupTagAddress = testCsr->tagAddress;
testCsr->tagAddress = nullptr;
memoryManager->handleFenceCompletion(allocation);
EXPECT_EQ(0u, mock->waitUserFenceCall.called);
testCsr->tagAddress = backupTagAddress;
memoryManager->freeGraphicsMemory(allocation);
}
} // namespace NEO

View File

@ -319,6 +319,9 @@ inline bool DrmCommandStreamReceiver<GfxFamily>::isUserFenceWaitActive() {
template <typename GfxFamily>
uint64_t DrmCommandStreamReceiver<GfxFamily>::getCompletionAddress() {
uint64_t completionFenceAddress = castToUint64(const_cast<uint32_t *>(getTagAddress()));
if (completionFenceAddress == 0) {
return 0;
}
completionFenceAddress += Drm::completionFenceOffset;
return completionFenceAddress;
}

View File

@ -29,7 +29,7 @@ extern ApiSpecificConfig::ApiType apiTypeForUlts;
} //namespace NEO
using namespace NEO;
class DrmCommandStreamTest : public ::testing::Test {
class DrmCommandStreamTest2 : public ::testing::Test {
public:
template <typename GfxFamily>
void SetUpT() {
@ -95,21 +95,28 @@ struct MockDrmCsr : public DrmCommandStreamReceiver<GfxFamily> {
using DrmCommandStreamReceiver<GfxFamily>::dispatchMode;
};
HWTEST_TEMPLATED_F(DrmCommandStreamTest, givenL0ApiConfigWhenCreatingDrmCsrThenEnableImmediateDispatch) {
HWTEST_TEMPLATED_F(DrmCommandStreamTest2, givenL0ApiConfigWhenCreatingDrmCsrThenEnableImmediateDispatch) {
VariableBackup<ApiSpecificConfig::ApiType> backup(&apiTypeForUlts, ApiSpecificConfig::L0);
MockDrmCsr<FamilyType> csr(executionEnvironment, 0, 1, gemCloseWorkerMode::gemCloseWorkerInactive);
EXPECT_EQ(DispatchMode::ImmediateDispatch, csr.dispatchMode);
}
HWTEST_TEMPLATED_F(DrmCommandStreamTest, whenGettingCompletionValueThenTaskCountOfAllocationIsReturned) {
HWTEST_TEMPLATED_F(DrmCommandStreamTest2, whenGettingCompletionValueThenTaskCountOfAllocationIsReturned) {
MockGraphicsAllocation allocation{};
uint32_t expectedValue = 0x1234;
allocation.updateTaskCount(expectedValue, osContext->getContextId());
EXPECT_EQ(expectedValue, csr->getCompletionValue(allocation));
}
HWTEST_TEMPLATED_F(DrmCommandStreamTest, whenGettingCompletionAddressThenOffsettedTagAddressIsReturned) {
HWTEST_TEMPLATED_F(DrmCommandStreamTest2, whenGettingCompletionAddressThenOffsettedTagAddressIsReturned) {
csr->initializeTagAllocation();
EXPECT_NE(nullptr, csr->getTagAddress());
uint64_t tagAddress = castToUint64(const_cast<uint32_t *>(csr->getTagAddress()));
auto expectedAddress = tagAddress + Drm::completionFenceOffset;
EXPECT_EQ(expectedAddress, csr->getCompletionAddress());
}
HWTEST_TEMPLATED_F(DrmCommandStreamTest2, givenNoTagAddressWhenGettingCompletionAddressThenZeroIsReturned) {
EXPECT_EQ(nullptr, csr->getTagAddress());
EXPECT_EQ(0u, csr->getCompletionAddress());
}