Dont close shared handle on imported allocations
Related-To: LOCI-2272 Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
This commit is contained in:
parent
7ec8d8ef91
commit
a010fb3634
|
@ -439,6 +439,7 @@ void *DriverHandleImp::importFdHandle(ze_device_handle_t hDevice, ze_ipc_memory_
|
||||||
allocData.size = alloc->getUnderlyingBufferSize();
|
allocData.size = alloc->getUnderlyingBufferSize();
|
||||||
allocData.memoryType = InternalMemoryType::DEVICE_UNIFIED_MEMORY;
|
allocData.memoryType = InternalMemoryType::DEVICE_UNIFIED_MEMORY;
|
||||||
allocData.device = neoDevice;
|
allocData.device = neoDevice;
|
||||||
|
allocData.isImportedAllocation = true;
|
||||||
if (flags & ZE_DEVICE_MEM_ALLOC_FLAG_BIAS_UNCACHED) {
|
if (flags & ZE_DEVICE_MEM_ALLOC_FLAG_BIAS_UNCACHED) {
|
||||||
allocData.allocationFlagsProperty.flags.locallyUncachedResource = 1;
|
allocData.allocationFlagsProperty.flags.locallyUncachedResource = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -335,6 +335,7 @@ class MemoryManagerIpcMock : public NEO::MemoryManager {
|
||||||
AllocationStatus populateOsHandles(NEO::OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override { return AllocationStatus::Success; };
|
AllocationStatus populateOsHandles(NEO::OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override { return AllocationStatus::Success; };
|
||||||
void cleanOsHandles(NEO::OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override{};
|
void cleanOsHandles(NEO::OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override{};
|
||||||
void freeGraphicsMemoryImpl(NEO::GraphicsAllocation *gfxAllocation) override{};
|
void freeGraphicsMemoryImpl(NEO::GraphicsAllocation *gfxAllocation) override{};
|
||||||
|
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation, bool isImportedAllocation) override{};
|
||||||
uint64_t getSystemSharedMemory(uint32_t rootDeviceIndex) override { return 0; };
|
uint64_t getSystemSharedMemory(uint32_t rootDeviceIndex) override { return 0; };
|
||||||
uint64_t getLocalMemorySize(uint32_t rootDeviceIndex, uint32_t deviceBitfield) override { return 0; };
|
uint64_t getLocalMemorySize(uint32_t rootDeviceIndex, uint32_t deviceBitfield) override { return 0; };
|
||||||
double getPercentOfGlobalMemoryAvailable(uint32_t rootDeviceIndex) override { return 0; }
|
double getPercentOfGlobalMemoryAvailable(uint32_t rootDeviceIndex) override { return 0; }
|
||||||
|
|
|
@ -51,6 +51,7 @@ class MemoryManagerEventPoolFailMock : public NEO::MemoryManager {
|
||||||
AllocationStatus populateOsHandles(NEO::OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override { return AllocationStatus::Success; };
|
AllocationStatus populateOsHandles(NEO::OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override { return AllocationStatus::Success; };
|
||||||
void cleanOsHandles(NEO::OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override{};
|
void cleanOsHandles(NEO::OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override{};
|
||||||
void freeGraphicsMemoryImpl(NEO::GraphicsAllocation *gfxAllocation) override{};
|
void freeGraphicsMemoryImpl(NEO::GraphicsAllocation *gfxAllocation) override{};
|
||||||
|
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation, bool isImportedAllocation) override{};
|
||||||
uint64_t getSystemSharedMemory(uint32_t rootDeviceIndex) override { return 0; };
|
uint64_t getSystemSharedMemory(uint32_t rootDeviceIndex) override { return 0; };
|
||||||
uint64_t getLocalMemorySize(uint32_t rootDeviceIndex, uint32_t deviceBitfield) override { return 0; };
|
uint64_t getLocalMemorySize(uint32_t rootDeviceIndex, uint32_t deviceBitfield) override { return 0; };
|
||||||
double getPercentOfGlobalMemoryAvailable(uint32_t rootDeviceIndex) override { return 0; }
|
double getPercentOfGlobalMemoryAvailable(uint32_t rootDeviceIndex) override { return 0; }
|
||||||
|
|
|
@ -4891,6 +4891,36 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenCopyMemoryToAllocationThen
|
||||||
memoryManager->freeGraphicsMemory(allocation);
|
memoryManager->freeGraphicsMemory(allocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenFreeingImportedMemoryThenCloseSharedHandleIsNotCalled) {
|
||||||
|
mock->ioctl_expected.gemUserptr = 1;
|
||||||
|
mock->ioctl_expected.gemWait = 1;
|
||||||
|
mock->ioctl_expected.gemClose = 1;
|
||||||
|
|
||||||
|
std::vector<uint8_t> dataToCopy(MemoryConstants::pageSize, 1u);
|
||||||
|
|
||||||
|
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties({rootDeviceIndex, dataToCopy.size(), AllocationType::BUFFER, device->getDeviceBitfield()});
|
||||||
|
ASSERT_NE(nullptr, allocation);
|
||||||
|
|
||||||
|
memoryManager->freeGraphicsMemory(allocation, true);
|
||||||
|
|
||||||
|
EXPECT_EQ(memoryManager->callsToCloseSharedHandle, 0u);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenFreeingNonImportedMemoryThenCloseSharedHandleIsCalled) {
|
||||||
|
mock->ioctl_expected.gemUserptr = 1;
|
||||||
|
mock->ioctl_expected.gemWait = 1;
|
||||||
|
mock->ioctl_expected.gemClose = 1;
|
||||||
|
|
||||||
|
std::vector<uint8_t> dataToCopy(MemoryConstants::pageSize, 1u);
|
||||||
|
|
||||||
|
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties({rootDeviceIndex, dataToCopy.size(), AllocationType::BUFFER, device->getDeviceBitfield()});
|
||||||
|
ASSERT_NE(nullptr, allocation);
|
||||||
|
|
||||||
|
memoryManager->freeGraphicsMemory(allocation);
|
||||||
|
|
||||||
|
EXPECT_EQ(memoryManager->callsToCloseSharedHandle, 1u);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenGetLocalMemoryIsCalledThenSizeOfLocalMemoryIsReturned) {
|
TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenGetLocalMemoryIsCalledThenSizeOfLocalMemoryIsReturned) {
|
||||||
EXPECT_EQ(0 * GB, memoryManager->getLocalMemorySize(rootDeviceIndex, 0xF));
|
EXPECT_EQ(0 * GB, memoryManager->getLocalMemorySize(rootDeviceIndex, 0xF));
|
||||||
}
|
}
|
||||||
|
|
|
@ -383,6 +383,22 @@ TEST_F(WddmMemoryManagerSimpleTest, givenAllocateGraphicsMemoryForNonSvmHostPtrI
|
||||||
memoryManager->freeGraphicsMemory(allocation);
|
memoryManager->freeGraphicsMemory(allocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(WddmMemoryManagerSimpleTest, givenAllocateGraphicsMemoryForNonSvmHostPtrIsCalledWhenNotAlignedPtrIsPassedAndImportedAllocationIsFalseThenAlignedGraphicsAllocationIsFreed) {
|
||||||
|
memoryManager.reset(new MockWddmMemoryManager(false, false, *executionEnvironment));
|
||||||
|
auto size = 13u;
|
||||||
|
auto hostPtr = reinterpret_cast<const void *>(0x10001);
|
||||||
|
|
||||||
|
AllocationData allocationData;
|
||||||
|
allocationData.size = size;
|
||||||
|
allocationData.hostPtr = hostPtr;
|
||||||
|
auto allocation = memoryManager->allocateGraphicsMemoryForNonSvmHostPtr(allocationData);
|
||||||
|
EXPECT_NE(nullptr, allocation);
|
||||||
|
EXPECT_EQ(hostPtr, allocation->getUnderlyingBuffer());
|
||||||
|
EXPECT_EQ(size, allocation->getUnderlyingBufferSize());
|
||||||
|
EXPECT_EQ(1u, allocation->getAllocationOffset());
|
||||||
|
memoryManager->freeGraphicsMemoryImpl(allocation, false);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(WddmMemoryManagerTest, givenAllocateGraphicsMemoryForNonSvmHostPtrIsCalledWhencreateWddmAllocationFailsThenGraphicsAllocationIsNotCreated) {
|
TEST_F(WddmMemoryManagerTest, givenAllocateGraphicsMemoryForNonSvmHostPtrIsCalledWhencreateWddmAllocationFailsThenGraphicsAllocationIsNotCreated) {
|
||||||
char hostPtr[64];
|
char hostPtr[64];
|
||||||
memoryManager->setDeferredDeleter(nullptr);
|
memoryManager->setDeferredDeleter(nullptr);
|
||||||
|
|
|
@ -195,6 +195,10 @@ void MemoryManager::freeSystemMemory(void *ptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemoryManager::freeGraphicsMemory(GraphicsAllocation *gfxAllocation) {
|
void MemoryManager::freeGraphicsMemory(GraphicsAllocation *gfxAllocation) {
|
||||||
|
return freeGraphicsMemory(gfxAllocation, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MemoryManager::freeGraphicsMemory(GraphicsAllocation *gfxAllocation, bool isImportedAllocation) {
|
||||||
if (!gfxAllocation) {
|
if (!gfxAllocation) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -213,7 +217,7 @@ void MemoryManager::freeGraphicsMemory(GraphicsAllocation *gfxAllocation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
getLocalMemoryUsageBankSelector(gfxAllocation->getAllocationType(), gfxAllocation->getRootDeviceIndex())->freeOnBanks(gfxAllocation->storageInfo.getMemoryBanks(), gfxAllocation->getUnderlyingBufferSize());
|
getLocalMemoryUsageBankSelector(gfxAllocation->getAllocationType(), gfxAllocation->getRootDeviceIndex())->freeOnBanks(gfxAllocation->storageInfo.getMemoryBanks(), gfxAllocation->getUnderlyingBufferSize());
|
||||||
freeGraphicsMemoryImpl(gfxAllocation);
|
freeGraphicsMemoryImpl(gfxAllocation, isImportedAllocation);
|
||||||
}
|
}
|
||||||
//if not in use destroy in place
|
//if not in use destroy in place
|
||||||
//if in use pass to temporary allocation list that is cleaned on blocking calls
|
//if in use pass to temporary allocation list that is cleaned on blocking calls
|
||||||
|
|
|
@ -128,7 +128,9 @@ class MemoryManager {
|
||||||
void freeSystemMemory(void *ptr);
|
void freeSystemMemory(void *ptr);
|
||||||
|
|
||||||
virtual void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) = 0;
|
virtual void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) = 0;
|
||||||
|
virtual void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation, bool isImportedAllocation) = 0;
|
||||||
MOCKABLE_VIRTUAL void freeGraphicsMemory(GraphicsAllocation *gfxAllocation);
|
MOCKABLE_VIRTUAL void freeGraphicsMemory(GraphicsAllocation *gfxAllocation);
|
||||||
|
MOCKABLE_VIRTUAL void freeGraphicsMemory(GraphicsAllocation *gfxAllocation, bool isImportedAllocation);
|
||||||
virtual void handleFenceCompletion(GraphicsAllocation *allocation){};
|
virtual void handleFenceCompletion(GraphicsAllocation *allocation){};
|
||||||
|
|
||||||
void checkGpuUsageAndDestroyGraphicsAllocations(GraphicsAllocation *gfxAllocation);
|
void checkGpuUsageAndDestroyGraphicsAllocations(GraphicsAllocation *gfxAllocation);
|
||||||
|
|
|
@ -260,6 +260,10 @@ void OsAgnosticMemoryManager::removeAllocationFromHostPtrManager(GraphicsAllocat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OsAgnosticMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation, bool isImportedAllocation) {
|
||||||
|
return freeGraphicsMemoryImpl(gfxAllocation);
|
||||||
|
}
|
||||||
|
|
||||||
void OsAgnosticMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) {
|
void OsAgnosticMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) {
|
||||||
for (auto handleId = 0u; handleId < gfxAllocation->getNumGmms(); handleId++) {
|
for (auto handleId = 0u; handleId < gfxAllocation->getNumGmms(); handleId++) {
|
||||||
delete gfxAllocation->getGmm(handleId);
|
delete gfxAllocation->getGmm(handleId);
|
||||||
|
|
|
@ -75,6 +75,7 @@ class OsAgnosticMemoryManager : public MemoryManager {
|
||||||
void addAllocationToHostPtrManager(GraphicsAllocation *gfxAllocation) override;
|
void addAllocationToHostPtrManager(GraphicsAllocation *gfxAllocation) override;
|
||||||
void removeAllocationFromHostPtrManager(GraphicsAllocation *gfxAllocation) override;
|
void removeAllocationFromHostPtrManager(GraphicsAllocation *gfxAllocation) override;
|
||||||
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) override;
|
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) override;
|
||||||
|
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation, bool isImportedAllocation) override;
|
||||||
|
|
||||||
AllocationStatus populateOsHandles(OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override;
|
AllocationStatus populateOsHandles(OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override;
|
||||||
void cleanOsHandles(OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override;
|
void cleanOsHandles(OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override;
|
||||||
|
|
|
@ -477,12 +477,13 @@ void SVMAllocsManager::freeZeroCopySvmAllocation(SvmAllocationData *svmData) {
|
||||||
void SVMAllocsManager::freeSvmAllocationWithDeviceStorage(SvmAllocationData *svmData) {
|
void SVMAllocsManager::freeSvmAllocationWithDeviceStorage(SvmAllocationData *svmData) {
|
||||||
auto graphicsAllocations = svmData->gpuAllocations.getGraphicsAllocations();
|
auto graphicsAllocations = svmData->gpuAllocations.getGraphicsAllocations();
|
||||||
GraphicsAllocation *cpuAllocation = svmData->cpuAllocation;
|
GraphicsAllocation *cpuAllocation = svmData->cpuAllocation;
|
||||||
|
bool isImportedAllocation = svmData->isImportedAllocation;
|
||||||
SVMAllocs.remove(*svmData);
|
SVMAllocs.remove(*svmData);
|
||||||
|
|
||||||
for (auto gpuAllocation : graphicsAllocations) {
|
for (auto gpuAllocation : graphicsAllocations) {
|
||||||
memoryManager->freeGraphicsMemory(gpuAllocation);
|
memoryManager->freeGraphicsMemory(gpuAllocation, isImportedAllocation);
|
||||||
}
|
}
|
||||||
memoryManager->freeGraphicsMemory(cpuAllocation);
|
memoryManager->freeGraphicsMemory(cpuAllocation, isImportedAllocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SVMAllocsManager::hasHostAllocations() {
|
bool SVMAllocsManager::hasHostAllocations() {
|
||||||
|
|
|
@ -36,6 +36,7 @@ struct SvmAllocationData {
|
||||||
this->memoryType = svmAllocData.memoryType;
|
this->memoryType = svmAllocData.memoryType;
|
||||||
this->allocId = svmAllocData.allocId;
|
this->allocId = svmAllocData.allocId;
|
||||||
this->pageSizeForAlignment = svmAllocData.pageSizeForAlignment;
|
this->pageSizeForAlignment = svmAllocData.pageSizeForAlignment;
|
||||||
|
this->isImportedAllocation = svmAllocData.isImportedAllocation;
|
||||||
for (auto allocation : svmAllocData.gpuAllocations.getGraphicsAllocations()) {
|
for (auto allocation : svmAllocData.gpuAllocations.getGraphicsAllocations()) {
|
||||||
if (allocation) {
|
if (allocation) {
|
||||||
this->gpuAllocations.addAllocation(allocation);
|
this->gpuAllocations.addAllocation(allocation);
|
||||||
|
@ -50,6 +51,7 @@ struct SvmAllocationData {
|
||||||
InternalMemoryType memoryType = InternalMemoryType::SVM;
|
InternalMemoryType memoryType = InternalMemoryType::SVM;
|
||||||
MemoryProperties allocationFlagsProperty;
|
MemoryProperties allocationFlagsProperty;
|
||||||
Device *device = nullptr;
|
Device *device = nullptr;
|
||||||
|
bool isImportedAllocation = false;
|
||||||
void setAllocId(uint32_t id) {
|
void setAllocId(uint32_t id) {
|
||||||
allocId = id;
|
allocId = id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -774,6 +774,10 @@ void DrmMemoryManager::removeAllocationFromHostPtrManager(GraphicsAllocation *gf
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) {
|
void DrmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) {
|
||||||
|
return freeGraphicsMemoryImpl(gfxAllocation, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation, bool isImported) {
|
||||||
if (DebugManager.flags.DoNotFreeResources.get()) {
|
if (DebugManager.flags.DoNotFreeResources.get()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -800,7 +804,9 @@ void DrmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation)
|
||||||
for (auto bo : bos) {
|
for (auto bo : bos) {
|
||||||
unreference(bo, bo && bo->peekIsReusableAllocation() ? false : true);
|
unreference(bo, bo && bo->peekIsReusableAllocation() ? false : true);
|
||||||
}
|
}
|
||||||
closeSharedHandle(gfxAllocation);
|
if (isImported == false) {
|
||||||
|
closeSharedHandle(gfxAllocation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
releaseGpuRange(gfxAllocation->getReservedAddressPtr(), gfxAllocation->getReservedAddressSize(), gfxAllocation->getRootDeviceIndex());
|
releaseGpuRange(gfxAllocation->getReservedAddressPtr(), gfxAllocation->getReservedAddressSize(), gfxAllocation->getRootDeviceIndex());
|
||||||
|
|
|
@ -33,6 +33,7 @@ class DrmMemoryManager : public MemoryManager {
|
||||||
void addAllocationToHostPtrManager(GraphicsAllocation *gfxAllocation) override;
|
void addAllocationToHostPtrManager(GraphicsAllocation *gfxAllocation) override;
|
||||||
void removeAllocationFromHostPtrManager(GraphicsAllocation *gfxAllocation) override;
|
void removeAllocationFromHostPtrManager(GraphicsAllocation *gfxAllocation) override;
|
||||||
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) override;
|
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) override;
|
||||||
|
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation, bool isImportedAllocation) override;
|
||||||
void handleFenceCompletion(GraphicsAllocation *allocation) override;
|
void handleFenceCompletion(GraphicsAllocation *allocation) override;
|
||||||
GraphicsAllocation *createGraphicsAllocationFromExistingStorage(AllocationProperties &properties, void *ptr, MultiGraphicsAllocation &multiGraphicsAllocation) override;
|
GraphicsAllocation *createGraphicsAllocationFromExistingStorage(AllocationProperties &properties, void *ptr, MultiGraphicsAllocation &multiGraphicsAllocation) override;
|
||||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation) override;
|
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation) override;
|
||||||
|
|
|
@ -508,6 +508,10 @@ void WddmMemoryManager::freeAssociatedResourceImpl(GraphicsAllocation &graphicsA
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WddmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation, bool isImportedAllocation) {
|
||||||
|
return freeGraphicsMemoryImpl(gfxAllocation);
|
||||||
|
}
|
||||||
|
|
||||||
void WddmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) {
|
void WddmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) {
|
||||||
WddmAllocation *input = static_cast<WddmAllocation *>(gfxAllocation);
|
WddmAllocation *input = static_cast<WddmAllocation *>(gfxAllocation);
|
||||||
DEBUG_BREAK_IF(!validateAllocation(input));
|
DEBUG_BREAK_IF(!validateAllocation(input));
|
||||||
|
|
|
@ -41,6 +41,7 @@ class WddmMemoryManager : public MemoryManager {
|
||||||
WddmMemoryManager &operator=(const WddmMemoryManager &) = delete;
|
WddmMemoryManager &operator=(const WddmMemoryManager &) = delete;
|
||||||
|
|
||||||
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) override;
|
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) override;
|
||||||
|
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation, bool isImportedAllocation) override;
|
||||||
void handleFenceCompletion(GraphicsAllocation *allocation) override;
|
void handleFenceCompletion(GraphicsAllocation *allocation) override;
|
||||||
|
|
||||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation) override;
|
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation) override;
|
||||||
|
|
|
@ -78,6 +78,13 @@ DrmAllocation *TestedDrmMemoryManager::allocate32BitGraphicsMemory(uint32_t root
|
||||||
bool useLocalMemory = !allocationData.flags.useSystemMemory && this->localMemorySupported[rootDeviceIndex];
|
bool useLocalMemory = !allocationData.flags.useSystemMemory && this->localMemorySupported[rootDeviceIndex];
|
||||||
return allocate32BitGraphicsMemoryImpl(allocationData, useLocalMemory);
|
return allocate32BitGraphicsMemoryImpl(allocationData, useLocalMemory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestedDrmMemoryManager::closeSharedHandle(GraphicsAllocation *gfxAllocation) {
|
||||||
|
std::unique_lock<std::mutex> lock(callsToCloseSharedHandleMtx);
|
||||||
|
DrmMemoryManager::closeSharedHandle(gfxAllocation);
|
||||||
|
callsToCloseSharedHandle++;
|
||||||
|
}
|
||||||
|
|
||||||
TestedDrmMemoryManager::~TestedDrmMemoryManager() {
|
TestedDrmMemoryManager::~TestedDrmMemoryManager() {
|
||||||
DrmMemoryManager::commonCleanup();
|
DrmMemoryManager::commonCleanup();
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,12 +149,15 @@ class TestedDrmMemoryManager : public MemoryManagerCreate<DrmMemoryManager> {
|
||||||
alignedFreeWrapperCalled++;
|
alignedFreeWrapperCalled++;
|
||||||
DrmMemoryManager::alignedFreeWrapper(ptr);
|
DrmMemoryManager::alignedFreeWrapper(ptr);
|
||||||
}
|
}
|
||||||
|
void closeSharedHandle(GraphicsAllocation *gfxAllocation) override;
|
||||||
uint32_t alignedFreeWrapperCalled = 0u;
|
uint32_t alignedFreeWrapperCalled = 0u;
|
||||||
|
uint32_t callsToCloseSharedHandle = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::mutex unreferenceMtx;
|
std::mutex unreferenceMtx;
|
||||||
std::mutex releaseGpuRangeMtx;
|
std::mutex releaseGpuRangeMtx;
|
||||||
std::mutex alignedFreeWrapperMtx;
|
std::mutex alignedFreeWrapperMtx;
|
||||||
|
std::mutex callsToCloseSharedHandleMtx;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MockDrmGemCloseWorker : DrmGemCloseWorker {
|
struct MockDrmGemCloseWorker : DrmGemCloseWorker {
|
||||||
|
|
|
@ -73,6 +73,10 @@ class MockWddmMemoryManager : public MemoryManagerCreate<WddmMemoryManager> {
|
||||||
BaseClass::freeGraphicsMemoryImpl(gfxAllocation);
|
BaseClass::freeGraphicsMemoryImpl(gfxAllocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation, bool isImportedAllocation) override {
|
||||||
|
BaseClass::freeGraphicsMemoryImpl(gfxAllocation, isImportedAllocation);
|
||||||
|
}
|
||||||
|
|
||||||
GraphicsAllocation *allocateHugeGraphicsMemory(const AllocationData &allocationData, bool sharedVirtualAddress) override {
|
GraphicsAllocation *allocateHugeGraphicsMemory(const AllocationData &allocationData, bool sharedVirtualAddress) override {
|
||||||
allocateHugeGraphicsMemoryCalled = true;
|
allocateHugeGraphicsMemoryCalled = true;
|
||||||
return BaseClass::allocateHugeGraphicsMemory(allocationData, sharedVirtualAddress);
|
return BaseClass::allocateHugeGraphicsMemory(allocationData, sharedVirtualAddress);
|
||||||
|
|
|
@ -255,6 +255,7 @@ TEST_F(DeviceGetCapsTest, givenFlagEnabled64kbPagesWhenCallConstructorMemoryMana
|
||||||
AllocationStatus populateOsHandles(OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override { return AllocationStatus::Success; };
|
AllocationStatus populateOsHandles(OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override { return AllocationStatus::Success; };
|
||||||
void cleanOsHandles(OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override{};
|
void cleanOsHandles(OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override{};
|
||||||
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) override{};
|
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) override{};
|
||||||
|
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation, bool isImportedAllocation) override{};
|
||||||
uint64_t getSystemSharedMemory(uint32_t rootDeviceIndex) override {
|
uint64_t getSystemSharedMemory(uint32_t rootDeviceIndex) override {
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue