mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 22:12:59 +08:00
fix: Crash on over memory allocation
- Add defer backing flag to gem create ioctl - Make memory resident before lock Related-To: NEO-13403 Signed-off-by: Bellekallu Rajkiran <bellekallu.rajkiran@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
335aa6e8b9
commit
212ccb8bd4
@@ -1518,8 +1518,17 @@ void *DrmMemoryManager::lockResourceImpl(GraphicsAllocation &graphicsAllocation)
|
||||
return cpuPtr;
|
||||
}
|
||||
|
||||
auto bo = static_cast<DrmAllocation &>(graphicsAllocation).getBO();
|
||||
auto rootDeviceIndex = graphicsAllocation.getRootDeviceIndex();
|
||||
auto ioctlHelper = this->getDrm(rootDeviceIndex).getIoctlHelper();
|
||||
|
||||
if (ioctlHelper->makeResidentBeforeLockNeeded()) {
|
||||
auto memoryOperationsInterface = static_cast<DrmMemoryOperationsHandler *>(executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface.get());
|
||||
auto graphicsAllocationPtr = &graphicsAllocation;
|
||||
[[maybe_unused]] auto ret = memoryOperationsInterface->makeResidentWithinOsContext(getDefaultOsContext(rootDeviceIndex), ArrayRef<NEO::GraphicsAllocation *>(&graphicsAllocationPtr, 1), false) == MemoryOperationsStatus::success;
|
||||
DEBUG_BREAK_IF(!ret);
|
||||
}
|
||||
|
||||
auto bo = static_cast<DrmAllocation &>(graphicsAllocation).getBO();
|
||||
if (graphicsAllocation.getAllocationType() == AllocationType::writeCombined) {
|
||||
auto addr = lockBufferObject(bo);
|
||||
auto alignedAddr = alignUp(addr, MemoryConstants::pageSize64k);
|
||||
|
||||
@@ -236,6 +236,8 @@ class IoctlHelper {
|
||||
|
||||
virtual bool isTimestampsRefreshEnabled() { return false; }
|
||||
|
||||
virtual bool makeResidentBeforeLockNeeded() { return false; }
|
||||
|
||||
protected:
|
||||
Drm &drm;
|
||||
ExternalCtx *externalCtx = nullptr;
|
||||
|
||||
@@ -665,6 +665,7 @@ int IoctlHelperXe::createGemExt(const MemRegionsVec &memClassInstances, size_t a
|
||||
}
|
||||
create.placement = static_cast<uint32_t>(memoryInstances.to_ulong());
|
||||
create.cpu_caching = this->getCpuCachingMode(isCoherent, isSysMemOnly);
|
||||
create.flags |= DRM_XE_GEM_CREATE_FLAG_DEFER_BACKING;
|
||||
|
||||
printDebugString(debugManager.flags.PrintBOCreateDestroyResult.get(), stdout, "Performing DRM_IOCTL_XE_GEM_CREATE with {vmid=0x%x size=0x%lx flags=0x%x placement=0x%x caching=%hu }",
|
||||
create.vm_id, create.size, create.flags, create.placement, create.cpu_caching);
|
||||
@@ -707,6 +708,7 @@ uint32_t IoctlHelperXe::createGem(uint64_t size, uint32_t memoryBanks, std::opti
|
||||
}
|
||||
create.placement = static_cast<uint32_t>(memoryInstances.to_ulong());
|
||||
create.cpu_caching = this->getCpuCachingMode(isCoherent, isSysMemOnly);
|
||||
create.flags |= DRM_XE_GEM_CREATE_FLAG_DEFER_BACKING;
|
||||
|
||||
printDebugString(debugManager.flags.PrintBOCreateDestroyResult.get(), stdout, "Performing DRM_IOCTL_XE_GEM_CREATE with {vmid=0x%x size=0x%lx flags=0x%x placement=0x%x caching=%hu }",
|
||||
create.vm_id, create.size, create.flags, create.placement, create.cpu_caching);
|
||||
|
||||
@@ -136,6 +136,7 @@ class IoctlHelperXe : public IoctlHelper {
|
||||
int getTileIdFromGtId(int gtId) const override {
|
||||
return gtIdToTileId[gtId];
|
||||
}
|
||||
bool makeResidentBeforeLockNeeded() override { return true; }
|
||||
|
||||
protected:
|
||||
static constexpr uint32_t maxContextSetProperties = 4;
|
||||
|
||||
Reference in New Issue
Block a user