fix: do not unregister shared allocation

Allocations imported from shared handle are not using registerAlloc in drm
manager but on free, unregister was called.

This could lead to problems with allocation size tracking.

This change will skip the unregisterAllocation call if allocation is
imported from shared handle.

Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
Dominik Dabek
2024-10-02 14:47:22 +00:00
committed by Compute-Runtime-Automation
parent 14c8f1f15d
commit ac8dcdb298
4 changed files with 38 additions and 2 deletions

View File

@@ -1229,7 +1229,9 @@ void DrmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation,
return;
}
DrmAllocation *drmAlloc = static_cast<DrmAllocation *>(gfxAllocation);
this->unregisterAllocation(gfxAllocation);
if (Sharing::nonSharedResource == gfxAllocation->peekSharedHandle()) {
this->unregisterAllocation(gfxAllocation);
}
auto rootDeviceIndex = gfxAllocation->getRootDeviceIndex();
for (auto &engine : getRegisteredEngines(rootDeviceIndex)) {
auto memoryOperationsInterface = static_cast<DrmMemoryOperationsHandler *>(executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface.get());

View File

@@ -93,7 +93,7 @@ class DrmMemoryManager : public MemoryManager {
std::vector<GraphicsAllocation *> &getLocalMemAllocs(uint32_t rootDeviceIndex);
AllocationStatus registerSysMemAlloc(GraphicsAllocation *allocation) override;
AllocationStatus registerLocalMemAlloc(GraphicsAllocation *allocation, uint32_t rootDeviceIndex) override;
void unregisterAllocation(GraphicsAllocation *allocation);
MOCKABLE_VIRTUAL void unregisterAllocation(GraphicsAllocation *allocation);
static std::unique_ptr<MemoryManager> create(ExecutionEnvironment &executionEnvironment);