mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-12 17:33:00 +08:00
fix: handle failure on set cache region
Related-To: NEO-9038 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
bede264d0d
commit
af275ed341
@@ -2442,14 +2442,17 @@ DrmAllocation *DrmMemoryManager::createUSMHostAllocationFromSharedHandle(osHandl
|
||||
|
||||
pushSharedBufferObject(bo);
|
||||
|
||||
DrmAllocation *drmAllocation = nullptr;
|
||||
drmAllocation = new DrmAllocation(properties.rootDeviceIndex, properties.allocationType, bo, cpuPointer, bo->peekAddress(), bo->peekSize(), MemoryPool::System4KBPages);
|
||||
auto drmAllocation = std::make_unique<DrmAllocation>(properties.rootDeviceIndex, properties.allocationType, bo, cpuPointer, bo->peekAddress(), bo->peekSize(), MemoryPool::System4KBPages);
|
||||
drmAllocation->setMmapPtr(cpuPointer);
|
||||
drmAllocation->setMmapSize(size);
|
||||
drmAllocation->setReservedAddressRange(reinterpret_cast<void *>(cpuPointer), size);
|
||||
drmAllocation->setCacheRegion(&drm, static_cast<CacheRegion>(properties.cacheRegion));
|
||||
if (!drmAllocation->setCacheRegion(&drm, static_cast<CacheRegion>(properties.cacheRegion))) {
|
||||
this->munmapFunction(cpuPointer, size);
|
||||
delete bo;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return drmAllocation;
|
||||
return drmAllocation.release();
|
||||
}
|
||||
|
||||
auto gmmHelper = getGmmHelper(properties.rootDeviceIndex);
|
||||
|
||||
@@ -1076,6 +1076,28 @@ TEST_F(DrmMemoryManagerTest, GivenDeviceSharedAllocationWhichRequiresHostMapThen
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTest, GivenDeviceSharedAllocationWhenSetCacheRegionFailsThenNullptrIsReturned) {
|
||||
mock->ioctlExpected.primeFdToHandle = 1;
|
||||
mock->ioctlExpected.gemWait = 0;
|
||||
mock->ioctlExpected.gemClose = 0;
|
||||
mock->ioctlExpected.gemMmapOffset = 1;
|
||||
|
||||
osHandle handle = 1u;
|
||||
this->mock->outputHandle = 2u;
|
||||
size_t size = 4096u;
|
||||
std::vector<MemoryRegion> regionInfo(1);
|
||||
regionInfo[0].region = {drm_i915_gem_memory_class::I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
|
||||
this->mock->memoryInfo.reset(new MemoryInfo(regionInfo, *mock));
|
||||
this->mock->queryEngineInfo();
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER, false, {});
|
||||
properties.cacheRegion = std::numeric_limits<uint32_t>::max();
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, false, nullptr);
|
||||
|
||||
EXPECT_EQ(nullptr, graphicsAllocation);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTest, GivenAllocationWhenFreeingThenSucceeds) {
|
||||
mock->ioctlExpected.gemUserptr = 1;
|
||||
mock->ioctlExpected.gemWait = 1;
|
||||
|
||||
Reference in New Issue
Block a user