diff --git a/shared/source/command_stream/tbx_command_stream_receiver_hw.inl b/shared/source/command_stream/tbx_command_stream_receiver_hw.inl index 82e47b7357..28d6592de7 100644 --- a/shared/source/command_stream/tbx_command_stream_receiver_hw.inl +++ b/shared/source/command_stream/tbx_command_stream_receiver_hw.inl @@ -89,7 +89,7 @@ bool TbxCommandStreamReceiverHw::isAllocTbxFaultable(GraphicsAllocati return false; } auto allocType = gfxAlloc->getAllocationType(); - return AubHelper::isOneTimeAubWritableAllocationType(allocType) && allocType != AllocationType::gpuTimestampDeviceBuffer; + return AubHelper::isOneTimeAubWritableAllocationType(allocType) && GraphicsAllocation::isLockable(allocType); } template diff --git a/shared/source/page_fault_manager/tbx_page_fault_manager.cpp b/shared/source/page_fault_manager/tbx_page_fault_manager.cpp index be8048996d..d0b3a0ee9e 100644 --- a/shared/source/page_fault_manager/tbx_page_fault_manager.cpp +++ b/shared/source/page_fault_manager/tbx_page_fault_manager.cpp @@ -39,7 +39,6 @@ void TbxPageFaultManager::handlePageFault(void *ptr, PageFaultDataTbx &faultData } else { graphicsAllocation.setTbxWritable(true, bank); this->allowCPUMemoryAccess(ptr, size); - this->memoryDataTbx.erase(ptr); } } diff --git a/shared/test/unit_test/command_stream/tbx_command_stream_tests.cpp b/shared/test/unit_test/command_stream/tbx_command_stream_tests.cpp index 7e7fe872a7..f09dd20275 100644 --- a/shared/test/unit_test/command_stream/tbx_command_stream_tests.cpp +++ b/shared/test/unit_test/command_stream/tbx_command_stream_tests.cpp @@ -1547,7 +1547,29 @@ HWTEST_F(TbxCommandStreamTests, givenTbxModeWhenPageFaultManagerIsNotAvailableTh memoryManager->freeGraphicsMemory(gfxAlloc1); } -HWTEST_F(TbxCommandStreamTests, givenTbxModeWhenPageFaultManagerIsAvailableThenTbxFaultableTypesShouldReturnTrue) { +static constexpr std::array onceWritableAllocTypesForTbx{ + AllocationType::pipe, + AllocationType::constantSurface, + AllocationType::globalSurface, + AllocationType::kernelIsa, + AllocationType::kernelIsaInternal, + AllocationType::privateSurface, + AllocationType::scratchSurface, + AllocationType::workPartitionSurface, + AllocationType::buffer, + AllocationType::image, + AllocationType::timestampPacketTagBuffer, + AllocationType::externalHostPtr, + AllocationType::mapAllocation, + AllocationType::svmGpu, + AllocationType::gpuTimestampDeviceBuffer, + AllocationType::assertBuffer, + AllocationType::tagBuffer, + AllocationType::syncDispatchToken, + AllocationType::bufferHostMemory, +}; + +HWTEST_F(TbxCommandStreamTests, givenAubOneTimeWritableAllocWhenTbxFaultManagerIsAvailableAndAllocIsLockableThenTbxFaultableTypesShouldReturnTrue) { DebugManagerStateRestore stateRestore; debugManager.flags.SetCommandStreamReceiver.set(static_cast(CommandStreamReceiverType::tbx)); debugManager.flags.EnableTbxPageFaultManager.set(true); @@ -1564,36 +1586,38 @@ HWTEST_F(TbxCommandStreamTests, givenTbxModeWhenPageFaultManagerIsAvailableThenT auto backupAllocType = gfxAlloc1->getAllocationType(); - std::array onceWritableTypes{ - AllocationType::pipe, - AllocationType::constantSurface, - AllocationType::globalSurface, - AllocationType::kernelIsa, - AllocationType::kernelIsaInternal, - AllocationType::privateSurface, - AllocationType::scratchSurface, - AllocationType::workPartitionSurface, - AllocationType::buffer, - AllocationType::image, - AllocationType::timestampPacketTagBuffer, - AllocationType::externalHostPtr, - AllocationType::mapAllocation, - AllocationType::svmGpu, - AllocationType::gpuTimestampDeviceBuffer, - AllocationType::assertBuffer, - AllocationType::tagBuffer, - AllocationType::syncDispatchToken, - AllocationType::bufferHostMemory, - }; - - std::set unsupportedOnceWritableTypes{AllocationType::gpuTimestampDeviceBuffer}; - - for (const auto &allocType : onceWritableTypes) { + for (const auto &allocType : onceWritableAllocTypesForTbx) { gfxAlloc1->setAllocationType(allocType); - auto isSupportedOnceWritableType = unsupportedOnceWritableTypes.count(allocType) == 0; - if (isSupportedOnceWritableType) { + if (GraphicsAllocation::isLockable(allocType)) { EXPECT_TRUE(tbxCsr->isAllocTbxFaultable(gfxAlloc1)); - } else { + } + } + + gfxAlloc1->setAllocationType(backupAllocType); + + memoryManager->freeGraphicsMemory(gfxAlloc1); +} + +HWTEST_F(TbxCommandStreamTests, givenAubOneTimeWritableAllocWhenTbxFaultManagerIsAvailableAndAllocIsNotLockableThenTbxFaultableTypesShouldReturnFalse) { + DebugManagerStateRestore stateRestore; + debugManager.flags.SetCommandStreamReceiver.set(static_cast(CommandStreamReceiverType::tbx)); + debugManager.flags.EnableTbxPageFaultManager.set(true); + std::unique_ptr> tbxCsr(new MockTbxCsrForPageFaultTests(*pDevice->executionEnvironment, pDevice->getDeviceBitfield())); + tbxCsr->setupContext(*pDevice->getDefaultEngine().osContext); + + auto memoryManager = pDevice->getMemoryManager(); + + NEO::GraphicsAllocation *gfxAlloc1 = memoryManager->allocateGraphicsMemoryWithProperties( + {pDevice->getRootDeviceIndex(), + MemoryConstants::pageSize, + AllocationType::bufferHostMemory, + pDevice->getDeviceBitfield()}); + + auto backupAllocType = gfxAlloc1->getAllocationType(); + + for (const auto &allocType : onceWritableAllocTypesForTbx) { + gfxAlloc1->setAllocationType(allocType); + if (!GraphicsAllocation::isLockable(allocType)) { EXPECT_FALSE(tbxCsr->isAllocTbxFaultable(gfxAlloc1)); } }