Skip to content

Commit 143694a

Browse files
kgibalaCompute-Runtime-Automation
authored andcommitted
Adjust gmmHelper canonize method accessing point in Drm
Accessing canonize method as a member of GmmHelper class object Related-To: NEO-6523 Signed-off-by: Krzysztof Gibala <[email protected]>
1 parent 17333a0 commit 143694a

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

shared/source/os_interface/linux/drm_buffer_object.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ uint32_t BufferObject::getRefCount() const {
5656
return this->refCount.load();
5757
}
5858

59+
void BufferObject::setAddress(uint64_t address) {
60+
auto gmmHelper = drm->getRootDeviceEnvironment().getGmmHelper();
61+
62+
this->gpuAddress = gmmHelper->canonize(address);
63+
}
64+
5965
bool BufferObject::close() {
6066
drm_gem_close close = {};
6167
close.handle = this->handle;

shared/source/os_interface/linux/drm_buffer_object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class BufferObject {
6969
int peekHandle() const { return handle; }
7070
const Drm *peekDrm() const { return drm; }
7171
uint64_t peekAddress() const { return gpuAddress; }
72-
void setAddress(uint64_t address) { this->gpuAddress = GmmHelper::canonize(address); }
72+
void setAddress(uint64_t address);
7373
void *peekLockedAddress() const { return lockedAddress; }
7474
void setLockedAddress(void *cpuAddress) { this->lockedAddress = cpuAddress; }
7575
void setUnmapSize(uint64_t unmapSize) { this->unmapSize = unmapSize; }

shared/source/os_interface/linux/drm_memory_manager.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,7 @@ void fillGmmsInAllocation(GmmHelper *gmmHelper, DrmAllocation *allocation, const
13811381
}
13821382

13831383
uint64_t getGpuAddress(const AlignmentSelector &alignmentSelector, HeapAssigner &heapAssigner, const HardwareInfo &hwInfo, AllocationType allocType, GfxPartition *gfxPartition,
1384-
size_t &sizeAllocated, const void *hostPtr, bool resource48Bit, bool useFrontWindow) {
1384+
size_t &sizeAllocated, const void *hostPtr, bool resource48Bit, bool useFrontWindow, const GmmHelper &gmmHelper) {
13851385
uint64_t gpuAddress = 0;
13861386
switch (allocType) {
13871387
case AllocationType::SVM_GPU:
@@ -1393,7 +1393,7 @@ uint64_t getGpuAddress(const AlignmentSelector &alignmentSelector, HeapAssigner
13931393
case AllocationType::INTERNAL_HEAP:
13941394
case AllocationType::DEBUG_MODULE_AREA: {
13951395
auto heap = heapAssigner.get32BitHeapIndex(allocType, true, hwInfo, useFrontWindow);
1396-
gpuAddress = GmmHelper::canonize(gfxPartition->heapAllocate(heap, sizeAllocated));
1396+
gpuAddress = gmmHelper.canonize(gfxPartition->heapAllocate(heap, sizeAllocated));
13971397
} break;
13981398
case AllocationType::WRITE_COMBINED:
13991399
sizeAllocated = 0;
@@ -1403,7 +1403,7 @@ uint64_t getGpuAddress(const AlignmentSelector &alignmentSelector, HeapAssigner
14031403
if (gfxPartition->getHeapLimit(HeapIndex::HEAP_EXTENDED) > 0 && !resource48Bit) {
14041404
alignment.heap = HeapIndex::HEAP_EXTENDED;
14051405
}
1406-
gpuAddress = GmmHelper::canonize(gfxPartition->heapAllocateWithCustomAlignment(alignment.heap, sizeAllocated, alignment.alignment));
1406+
gpuAddress = gmmHelper.canonize(gfxPartition->heapAllocateWithCustomAlignment(alignment.heap, sizeAllocated, alignment.alignment));
14071407
break;
14081408
}
14091409
return gpuAddress;
@@ -1441,9 +1441,11 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryInDevicePool(const A
14411441
size_t sizeAligned = 0;
14421442
auto numHandles = allocationData.storageInfo.getNumBanks();
14431443
bool createSingleHandle = 1 == numHandles;
1444+
auto gmmHelper = getGmmHelper(allocationData.rootDeviceIndex);
1445+
14441446
if (allocationData.type == AllocationType::IMAGE) {
14451447
allocationData.imgInfo->useLocalMemory = true;
1446-
gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), *allocationData.imgInfo,
1448+
gmm = std::make_unique<Gmm>(gmmHelper, *allocationData.imgInfo,
14471449
allocationData.storageInfo, allocationData.flags.preferCompressed);
14481450
sizeAligned = alignUp(allocationData.imgInfo->size, MemoryConstants::pageSize64k);
14491451
} else {
@@ -1454,7 +1456,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryInDevicePool(const A
14541456
}
14551457
if (createSingleHandle) {
14561458

1457-
gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(),
1459+
gmm = std::make_unique<Gmm>(gmmHelper,
14581460
nullptr,
14591461
sizeAligned,
14601462
0u,
@@ -1469,7 +1471,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryInDevicePool(const A
14691471
auto gfxPartition = getGfxPartition(allocationData.rootDeviceIndex);
14701472
auto gpuAddress = getGpuAddress(this->alignmentSelector, this->heapAssigner, *hwInfo,
14711473
allocationData.type, gfxPartition, sizeAllocated,
1472-
allocationData.hostPtr, allocationData.flags.resource48Bit, allocationData.flags.use32BitFrontWindow);
1474+
allocationData.hostPtr, allocationData.flags.resource48Bit, allocationData.flags.use32BitFrontWindow, *gmmHelper);
14731475

14741476
auto allocation = std::make_unique<DrmAllocation>(allocationData.rootDeviceIndex, numHandles, allocationData.type, nullptr, nullptr, gpuAddress, sizeAligned, MemoryPool::LocalMemory);
14751477
DrmAllocation *drmAllocation = static_cast<DrmAllocation *>(allocation.get());
@@ -1478,12 +1480,12 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryInDevicePool(const A
14781480
if (createSingleHandle) {
14791481
allocation->setDefaultGmm(gmm.release());
14801482
} else if (allocationData.storageInfo.multiStorage) {
1481-
createColouredGmms(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(),
1483+
createColouredGmms(gmmHelper,
14821484
*allocation,
14831485
allocationData.storageInfo,
14841486
allocationData.flags.preferCompressed);
14851487
} else {
1486-
fillGmmsInAllocation(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), allocation.get(), allocationData.storageInfo);
1488+
fillGmmsInAllocation(gmmHelper, allocation.get(), allocationData.storageInfo);
14871489
}
14881490
allocation->storageInfo = allocationData.storageInfo;
14891491
allocation->setFlushL3Required(allocationData.flags.flushL3);
@@ -1494,7 +1496,6 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryInDevicePool(const A
14941496
for (auto handleId = 0u; handleId < allocationData.storageInfo.getNumBanks(); handleId++) {
14951497
delete allocation->getGmm(handleId);
14961498
}
1497-
auto gmmHelper = getGmmHelper(allocationData.rootDeviceIndex);
14981499
gfxPartition->freeGpuAddressRange(gmmHelper->decanonize(gpuAddress), sizeAllocated);
14991500
status = AllocationStatus::Error;
15001501
return nullptr;
@@ -1523,7 +1524,6 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryInDevicePool(const A
15231524
allocation->setCpuPtrAndGpuAddress(cpuAddress, gpuAddress);
15241525
}
15251526
if (heapAssigner.useInternal32BitHeap(allocationData.type)) {
1526-
auto gmmHelper = getGmmHelper(allocationData.rootDeviceIndex);
15271527
allocation->setGpuBaseAddress(gmmHelper->canonize(getInternalHeapBaseAddress(allocationData.rootDeviceIndex, true)));
15281528
}
15291529
if (!allocation->setCacheRegion(&getDrm(allocationData.rootDeviceIndex), static_cast<CacheRegion>(allocationData.cacheRegion))) {

0 commit comments

Comments
 (0)