mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 23:03:02 +08:00
Refactor DrmMemoryManager::freeGraphicsMemoryImpl
- remove default value from synchronousDestroy param in DrmMemoryManager::unreference - unreference BufferObject in synchronous mode before release GPU and CPU memory - add ULTs Related-To: NEO-2877 Change-Id: I8065c27923cf4259a0fcd0f6d8d6d5b7c4b810c0 Signed-off-by: Igor Venevtsev <igor.venevtsev@intel.com>
This commit is contained in:
@@ -62,7 +62,7 @@ bool DrmGemCloseWorker::isEmpty() {
|
||||
|
||||
inline void DrmGemCloseWorker::close(BufferObject *bo) {
|
||||
bo->wait(-1);
|
||||
memoryManager.unreference(bo);
|
||||
memoryManager.unreference(bo, false);
|
||||
workCount--;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ DrmMemoryManager::~DrmMemoryManager() {
|
||||
gemCloseWorker->close(false);
|
||||
}
|
||||
if (pinBB) {
|
||||
unreference(pinBB);
|
||||
unreference(pinBB, true);
|
||||
pinBB = nullptr;
|
||||
}
|
||||
if (memoryForPinBB) {
|
||||
@@ -501,32 +501,26 @@ void DrmMemoryManager::removeAllocationFromHostPtrManager(GraphicsAllocation *gf
|
||||
}
|
||||
|
||||
void DrmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) {
|
||||
auto input = static_cast<DrmAllocation *>(gfxAllocation);
|
||||
for (auto handleId = 0u; handleId < maxHandleCount; handleId++) {
|
||||
if (gfxAllocation->getGmm(handleId)) {
|
||||
delete gfxAllocation->getGmm(handleId);
|
||||
}
|
||||
}
|
||||
|
||||
alignedFreeWrapper(gfxAllocation->getDriverAllocatedCpuPtr());
|
||||
|
||||
if (gfxAllocation->fragmentsStorage.fragmentCount) {
|
||||
cleanGraphicsMemoryCreatedFromHostPtr(gfxAllocation);
|
||||
delete gfxAllocation;
|
||||
return;
|
||||
}
|
||||
|
||||
BufferObject *search = input->getBO();
|
||||
|
||||
if (gfxAllocation->peekSharedHandle() != Sharing::nonSharedResource) {
|
||||
closeFunction(gfxAllocation->peekSharedHandle());
|
||||
} else {
|
||||
auto bo = static_cast<DrmAllocation *>(gfxAllocation)->getBO();
|
||||
unreference(bo, bo->isReused ? false : true);
|
||||
if (gfxAllocation->peekSharedHandle() != Sharing::nonSharedResource) {
|
||||
closeFunction(gfxAllocation->peekSharedHandle());
|
||||
}
|
||||
}
|
||||
|
||||
releaseGpuRange(gfxAllocation->getReservedAddressPtr(), gfxAllocation->getReservedAddressSize());
|
||||
alignedFreeWrapper(gfxAllocation->getDriverAllocatedCpuPtr());
|
||||
|
||||
delete gfxAllocation;
|
||||
|
||||
unreference(search);
|
||||
}
|
||||
|
||||
void DrmMemoryManager::handleFenceCompletion(GraphicsAllocation *allocation) {
|
||||
|
||||
@@ -44,7 +44,7 @@ class DrmMemoryManager : public MemoryManager {
|
||||
void cleanOsHandles(OsHandleStorage &handleStorage) override;
|
||||
|
||||
// drm/i915 ioctl wrappers
|
||||
uint32_t unreference(BufferObject *bo, bool synchronousDestroy = false);
|
||||
MOCKABLE_VIRTUAL uint32_t unreference(BufferObject *bo, bool synchronousDestroy);
|
||||
|
||||
bool isValidateHostMemoryEnabled() const {
|
||||
return validateHostPtrMemory;
|
||||
@@ -63,7 +63,7 @@ class DrmMemoryManager : public MemoryManager {
|
||||
BufferObject *allocUserptr(uintptr_t address, size_t size, uint64_t flags);
|
||||
bool setDomainCpu(GraphicsAllocation &graphicsAllocation, bool writeEnable);
|
||||
uint64_t acquireGpuRange(size_t &size, bool requireSpecificBitness);
|
||||
void releaseGpuRange(void *address, size_t size);
|
||||
MOCKABLE_VIRTUAL void releaseGpuRange(void *address, size_t size);
|
||||
void emitPinningRequest(BufferObject *bo, const AllocationData &allocationData) const;
|
||||
uint32_t getDefaultDrmContextId() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user