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:
Igor Venevtsev
2019-08-27 15:33:58 +02:00
parent 18982bd016
commit 3371ed12f6
5 changed files with 77 additions and 25 deletions

View File

@@ -62,7 +62,7 @@ bool DrmGemCloseWorker::isEmpty() {
inline void DrmGemCloseWorker::close(BufferObject *bo) {
bo->wait(-1);
memoryManager.unreference(bo);
memoryManager.unreference(bo, false);
workCount--;
}

View File

@@ -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) {

View File

@@ -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;