Skip to content

Commit 4fd83af

Browse files
fix: Add shared VA surface to ulls light residency
Resolves: GSD-11126 Signed-off-by: Lukasz Jobczyk <[email protected]> Source: cca51ce
1 parent 2d2f21e commit 4fd83af

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

shared/source/os_interface/linux/drm_memory_manager.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,6 +1333,7 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(c
13331333
auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(reinterpret_cast<void *>(bo->peekAddress())));
13341334
auto drmAllocation = new DrmAllocation(properties.rootDeviceIndex, 1u /*num gmms*/, properties.allocationType, bo, reinterpret_cast<void *>(bo->peekAddress()), bo->peekSize(),
13351335
osHandleData.handle, memoryPool, canonizedGpuAddress);
1336+
this->makeAllocationResident(drmAllocation);
13361337

13371338
if (requireSpecificBitness && this->force32bitAllocations) {
13381339
drmAllocation->set32BitAllocation(true);

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,35 @@ HWTEST_TEMPLATED_F(DrmMemoryManagerTest, GivenAllocationWhenClosingSharedHandleT
11491149
memoryManager->freeGraphicsMemory(graphicsAllocation);
11501150
}
11511151

1152+
HWTEST_TEMPLATED_F(DrmMemoryManagerTest, givenUllsLightWhenCreateGraphicsAllocationFromSharedHandleThenAddToResidencyContainer) {
1153+
mock->ioctlExpected.total = -1;
1154+
this->dontTestIoctlInTearDown = true;
1155+
1156+
osHandle handle = 1u;
1157+
this->mock->outputHandle = 2u;
1158+
size_t size = 4096u;
1159+
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::sharedBuffer, false, {});
1160+
TestedDrmMemoryManager::OsHandleData osHandleData{handle};
1161+
1162+
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(false, true, false, *executionEnvironment);
1163+
memoryManager->allRegisteredEngines[this->device->getRootDeviceIndex()] = EngineControlContainer{this->device->allEngines};
1164+
for (auto &engine : memoryManager->getRegisteredEngines(this->device->getRootDeviceIndex())) {
1165+
engine.osContext->incRefInternal();
1166+
engine.osContext->setDirectSubmissionActive();
1167+
}
1168+
1169+
auto drmMemoryOperationsHandler = static_cast<DrmMemoryOperationsHandler *>(executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface.get());
1170+
EXPECT_FALSE(drmMemoryOperationsHandler->obtainAndResetNewResourcesSinceLastRingSubmit());
1171+
1172+
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(osHandleData, properties, false, false, true, nullptr);
1173+
EXPECT_EQ(handle, graphicsAllocation->peekSharedHandle());
1174+
EXPECT_EQ(drmMemoryOperationsHandler->isResident(this->device, *graphicsAllocation), MemoryOperationsStatus::success);
1175+
EXPECT_TRUE(drmMemoryOperationsHandler->obtainAndResetNewResourcesSinceLastRingSubmit());
1176+
1177+
memoryManager->closeSharedHandle(graphicsAllocation);
1178+
memoryManager->freeGraphicsMemory(graphicsAllocation);
1179+
}
1180+
11521181
HWTEST_TEMPLATED_F(DrmMemoryManagerTest, GivenAllocationWhenClosingInternalHandleThenSucceeds) {
11531182
mock->ioctlExpected.primeFdToHandle = 1;
11541183
mock->ioctlExpected.gemWait = 1;

0 commit comments

Comments
 (0)