Move ownership of OsContext to memory manager.

- register OsContext when device is created
- memory manager controls residency so it needs to have control of
OsContexts underneath
- device may be destroyed while OsContexts may be still in use

Change-Id: If08df7686f5448a1e7b0b6ced20b37a1e8ba2cd6
This commit is contained in:
Mrozek, Michal
2018-09-06 09:01:13 +02:00
committed by sys_ocldev
parent b87af2c9e7
commit 75e26f39b1
5 changed files with 30 additions and 5 deletions

View File

@@ -32,6 +32,7 @@
#include "runtime/helpers/options.h"
#include "runtime/helpers/timestamp_packet.h"
#include "runtime/memory_manager/deferred_deleter.h"
#include "runtime/os_interface/os_context.h"
#include "runtime/utilities/stackvec.h"
#include "runtime/utilities/tag_allocator.h"
@@ -76,6 +77,9 @@ MemoryManager::MemoryManager(bool enable64kbpages) : allocator32Bit(nullptr), en
MemoryManager::~MemoryManager() {
freeAllocationsList(-1, graphicsAllocations);
freeAllocationsList(-1, allocationsForReuse);
for (auto osContext : registeredOsContexts) {
osContext->decRefInternal();
}
}
void *MemoryManager::allocateSystemMemory(size_t size, size_t alignment) {
@@ -379,6 +383,11 @@ RequirementsStatus MemoryManager::checkAllocationsForOverlapping(AllocationRequi
return status;
}
void MemoryManager::registerOsContext(OsContext *contextToRegister) {
contextToRegister->incRefInternal();
registeredOsContexts.push_back(contextToRegister);
}
bool MemoryManager::getAllocationData(AllocationData &allocationData, bool allocateMemory, const void *hostPtr, size_t size, GraphicsAllocation::AllocationType type) {
UNRECOVERABLE_IF(hostPtr == nullptr && !allocateMemory);