diff --git a/shared/source/os_interface/linux/drm_memory_operations_handler_bind.cpp b/shared/source/os_interface/linux/drm_memory_operations_handler_bind.cpp index ad6ff9b392..44c68a8a10 100644 --- a/shared/source/os_interface/linux/drm_memory_operations_handler_bind.cpp +++ b/shared/source/os_interface/linux/drm_memory_operations_handler_bind.cpp @@ -17,7 +17,7 @@ #include "shared/source/os_interface/linux/drm_allocation.h" #include "shared/source/os_interface/linux/drm_buffer_object.h" #include "shared/source/os_interface/linux/drm_memory_manager.h" -#include "shared/source/os_interface/os_context.h" +#include "shared/source/os_interface/linux/os_context_linux.h" namespace NEO { @@ -36,6 +36,10 @@ MemoryOperationsStatus DrmMemoryOperationsHandlerBind::makeResident(Device *devi break; } } + + for (const auto &engine : engines) { + static_cast(engine.osContext)->waitForPagingFence(); + } return result; } diff --git a/shared/source/os_interface/linux/os_context_linux.h b/shared/source/os_interface/linux/os_context_linux.h index a9769b2bb9..07ef01448d 100644 --- a/shared/source/os_interface/linux/os_context_linux.h +++ b/shared/source/os_interface/linux/os_context_linux.h @@ -29,7 +29,7 @@ class OsContextLinux : public OsContext { const std::vector &getDrmVmIds() const { return drmVmIds; } bool isDirectSubmissionSupported() const override; Drm &getDrm() const; - virtual void waitForPagingFence(); + MOCKABLE_VIRTUAL void waitForPagingFence(); static OsContext *create(OSInterface *osInterface, uint32_t rootDeviceIndex, uint32_t contextId, const EngineDescriptor &engineDescriptor); void reInitializeContext() override; void setHangDetected() { diff --git a/shared/test/unit_test/os_interface/linux/drm_memory_operations_handler_bind_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_memory_operations_handler_bind_tests.cpp index 6c573f7a41..6d6586fdbb 100644 --- a/shared/test/unit_test/os_interface/linux/drm_memory_operations_handler_bind_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_memory_operations_handler_bind_tests.cpp @@ -1409,6 +1409,15 @@ TEST_F(DrmMemoryOperationsHandlerBindTest, givenLockedAndResidentAllocationsWhen memoryManager->freeGraphicsMemory(allocation1); } +TEST_F(DrmMemoryOperationsHandlerBindTest, whenCallMakeResidentThenWaitUntilResidencyCompleted) { + auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{device->getRootDeviceIndex(), MemoryConstants::pageSize}); + + mock->fenceVal[0]++; + EXPECT_EQ(operationHandler->makeResident(device, ArrayRef(&allocation, 1)), MemoryOperationsStatus::success); + EXPECT_EQ(mock->context.waitUserFenceCalled, 1u); + memoryManager->freeGraphicsMemory(allocation); +} + using DrmResidencyHandlerTests = ::testing::Test; HWTEST2_F(DrmResidencyHandlerTests, givenClosIndexAndMemoryTypeWhenAskingForPatIndexThenReturnCorrectValue, IsWithinXeGfxFamily) {