mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-27 15:53:13 +08:00
Ensure shared handle be closed once on Linux
Related-To: NEO-5644 Signed-off-by: Slawomir Milczarek <slawomir.milczarek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
d60225d995
commit
693f2ff384
@@ -183,6 +183,7 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
|
||||
void decReuseCount() { sharingInfo.reuseCount--; }
|
||||
uint32_t peekReuseCount() const { return sharingInfo.reuseCount; }
|
||||
osHandle peekSharedHandle() const { return sharingInfo.sharedHandle; }
|
||||
void setSharedHandle(osHandle handle) { sharingInfo.sharedHandle = handle; }
|
||||
|
||||
void setAllocationType(AllocationType allocationType);
|
||||
AllocationType getAllocationType() const { return allocationType; }
|
||||
|
||||
@@ -87,7 +87,7 @@ class MemoryManager {
|
||||
|
||||
virtual bool verifyHandle(osHandle handle, uint32_t rootDeviceIndex, bool) { return true; }
|
||||
virtual GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness) = 0;
|
||||
virtual void closeSharedHandle(osHandle handle){};
|
||||
virtual void closeSharedHandle(GraphicsAllocation *graphicsAllocation){};
|
||||
virtual GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex) = 0;
|
||||
|
||||
virtual bool mapAuxGpuVA(GraphicsAllocation *graphicsAllocation);
|
||||
|
||||
@@ -18,8 +18,6 @@ class MemoryAllocation : public GraphicsAllocation {
|
||||
size_t sizeToFree = 0;
|
||||
const bool uncacheable;
|
||||
|
||||
void setSharedHandle(osHandle handle) { sharingInfo.sharedHandle = handle; }
|
||||
|
||||
MemoryAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, uint64_t gpuAddress, uint64_t baseAddress, size_t sizeIn,
|
||||
MemoryPool::Type pool, size_t maxOsContextCount)
|
||||
: MemoryAllocation(rootDeviceIndex, 1, allocationType, cpuPtrIn, gpuAddress, baseAddress, sizeIn, pool, maxOsContextCount) {}
|
||||
|
||||
@@ -628,8 +628,12 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o
|
||||
return drmAllocation;
|
||||
}
|
||||
|
||||
void DrmMemoryManager::closeSharedHandle(osHandle handle) {
|
||||
closeFunction(handle);
|
||||
void DrmMemoryManager::closeSharedHandle(GraphicsAllocation *gfxAllocation) {
|
||||
DrmAllocation *drmAllocation = static_cast<DrmAllocation *>(gfxAllocation);
|
||||
if (drmAllocation->peekSharedHandle() != Sharing::nonSharedResource) {
|
||||
closeFunction(drmAllocation->peekSharedHandle());
|
||||
drmAllocation->setSharedHandle(Sharing::nonSharedResource);
|
||||
}
|
||||
}
|
||||
|
||||
GraphicsAllocation *DrmMemoryManager::createPaddedAllocation(GraphicsAllocation *inputGraphicsAllocation, size_t sizeWithPadding) {
|
||||
@@ -707,9 +711,7 @@ void DrmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation)
|
||||
for (auto bo : bos) {
|
||||
unreference(bo, bo && bo->isReused ? false : true);
|
||||
}
|
||||
if (gfxAllocation->peekSharedHandle() != Sharing::nonSharedResource) {
|
||||
closeFunction(gfxAllocation->peekSharedHandle());
|
||||
}
|
||||
closeSharedHandle(gfxAllocation);
|
||||
}
|
||||
|
||||
releaseGpuRange(gfxAllocation->getReservedAddressPtr(), gfxAllocation->getReservedAddressSize(), gfxAllocation->getRootDeviceIndex());
|
||||
|
||||
@@ -36,7 +36,7 @@ class DrmMemoryManager : public MemoryManager {
|
||||
void handleFenceCompletion(GraphicsAllocation *allocation) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromExistingStorage(AllocationProperties &properties, void *ptr, MultiGraphicsAllocation &multiGraphicsAllocation) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness) override;
|
||||
void closeSharedHandle(osHandle handle) override;
|
||||
void closeSharedHandle(GraphicsAllocation *gfxAllocation) override;
|
||||
GraphicsAllocation *createPaddedAllocation(GraphicsAllocation *inputGraphicsAllocation, size_t sizeWithPadding) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex) override { return nullptr; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user