Skip to content

Commit 3e70b4a

Browse files
bellekalCompute-Runtime-Automation
authored andcommittedNov 26, 2024
fix: Enable immediate binding for make resident on linux
Related-To: NEO-11977 Signed-off-by: Bellekallu Rajkiran <bellekallu.rajkiran@intel.com> Source: 0c3a767
1 parent 4e7b01d commit 3e70b4a

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
 

‎shared/source/os_interface/linux/drm_memory_operations_handler_bind.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ MemoryOperationsStatus DrmMemoryOperationsHandlerBind::makeResidentWithinOsConte
6767

6868
if (!bo->getBindInfo()[bo->getOsContextId(osContext)][drmIterator]) {
6969
bo->requireExplicitLockedMemory(drmAllocation->isLockedMemory());
70+
bo->requireImmediateBinding(true);
7071
int result = drmAllocation->makeBOsResident(osContext, drmIterator, nullptr, true);
7172
if (result) {
7273
return MemoryOperationsStatus::outOfMemory;
@@ -111,6 +112,11 @@ int DrmMemoryOperationsHandlerBind::evictImpl(OsContext *osContext, GraphicsAllo
111112
if (retVal) {
112113
return retVal;
113114
}
115+
auto bo = drmAllocation->storageInfo.getNumBanks() > 1 ? drmAllocation->getBOs()[drmIterator] : drmAllocation->getBO();
116+
if (drmAllocation->storageInfo.isChunked) {
117+
bo = drmAllocation->getBO();
118+
}
119+
bo->requireImmediateBinding(false);
114120
}
115121
}
116122
drmAllocation->updateResidencyTaskCount(GraphicsAllocation::objectNotResident, osContext->getContextId());

‎shared/test/unit_test/os_interface/linux/drm_memory_operations_handler_bind_tests.cpp

100644100755
+23
Original file line numberDiff line numberDiff line change
@@ -1408,6 +1408,29 @@ TEST_F(DrmMemoryOperationsHandlerBindTest, givenLockedAndResidentAllocationsWhen
14081408
memoryManager->freeGraphicsMemory(allocation1);
14091409
}
14101410

1411+
TEST_F(DrmMemoryOperationsHandlerBindTest, whenCallingMakeResidentThenVerifyImmediateBindingIsRequired) {
1412+
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{device->getRootDeviceIndex(), MemoryConstants::pageSize});
1413+
EXPECT_EQ(operationHandler->makeResident(device, ArrayRef<NEO::GraphicsAllocation *>(&allocation, 1), false), MemoryOperationsStatus::success);
1414+
1415+
auto bo = static_cast<DrmAllocation *>(allocation)->getBO();
1416+
EXPECT_TRUE(bo->isImmediateBindingRequired());
1417+
memoryManager->freeGraphicsMemory(allocation);
1418+
}
1419+
1420+
TEST_F(DrmMemoryOperationsHandlerBindTest, givenDrmMemoryOperationBindWhenCallingEvictAfterCallingResidentThenVerifyImmediateBindingIsNotRequired) {
1421+
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{device->getRootDeviceIndex(), MemoryConstants::pageSize});
1422+
1423+
EXPECT_EQ(operationHandler->makeResident(device, ArrayRef<NEO::GraphicsAllocation *>(&allocation, 1), false), MemoryOperationsStatus::success);
1424+
1425+
auto bo = static_cast<DrmAllocation *>(allocation)->getBO();
1426+
EXPECT_TRUE(bo->isImmediateBindingRequired());
1427+
1428+
EXPECT_EQ(operationHandler->evict(device, *allocation), MemoryOperationsStatus::success);
1429+
EXPECT_FALSE(bo->isImmediateBindingRequired());
1430+
1431+
memoryManager->freeGraphicsMemory(allocation);
1432+
}
1433+
14111434
using DrmResidencyHandlerTests = ::testing::Test;
14121435

14131436
HWTEST2_F(DrmResidencyHandlerTests, givenClosIndexAndMemoryTypeWhenAskingForPatIndexThenReturnCorrectValue, IsWithinXeGfxFamily) {

0 commit comments

Comments
 (0)
Please sign in to comment.