From 08435a265fcbd19471d22f3cdb33741d784f8fa8 Mon Sep 17 00:00:00 2001 From: gta Date: Thu, 5 Dec 2024 22:10:10 +0000 Subject: [PATCH 1/2] feature: System Allocator support for Level Zero Related-To: NEO-12988 Signed-off-by: John Falkowski john.falkowski@intel.com --- level_zero/core/source/cmdlist/cmdlist_hw.inl | 46 ++++++++----- level_zero/core/source/device/device_imp.cpp | 10 +++ level_zero/core/source/device/device_imp.h | 1 + .../debug_settings/debug_variables_base.inl | 1 + shared/source/os_interface/linux/drm_neo.cpp | 28 ++++++++ shared/source/os_interface/linux/drm_neo.h | 9 +++ .../os_interface/linux/xe/ioctl_helper_xe.cpp | 69 +++++++++++++++---- 7 files changed, 134 insertions(+), 30 deletions(-) diff --git a/level_zero/core/source/cmdlist/cmdlist_hw.inl b/level_zero/core/source/cmdlist/cmdlist_hw.inl index 37ea875b234c6..0ff5ba6677f33 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw.inl @@ -59,6 +59,7 @@ #include #include + namespace L0 { inline ze_result_t parseErrorCode(NEO::CommandContainer::ErrorCode returnValue) { @@ -514,18 +515,28 @@ ze_result_t CommandListCoreFamily::appendLaunchMultipleKernelsInd appendEventForProfiling(event, nullptr, true, false, false, false); auto allocData = device->getDriverHandle()->getSvmAllocsManager()->getSVMAlloc(static_cast(pNumLaunchArguments)); - auto alloc = allocData->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex()); - commandContainer.addToResidencyContainer(alloc); - + if (allocData) { + auto alloc = allocData->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex()); + commandContainer.addToResidencyContainer(alloc); + + for (uint32_t i = 0; i < numKernels; i++) { + NEO::EncodeMathMMIO::encodeGreaterThanPredicate(commandContainer, alloc->getGpuAddress(), i, isCopyOnly(false)); + ret = appendLaunchKernelWithParams(Kernel::fromHandle(kernelHandles[i]), + pLaunchArgumentsBuffer[i], + nullptr, launchParams); + if (ret) { + return ret; + } + } + } else { for (uint32_t i = 0; i < numKernels; i++) { - NEO::EncodeMathMMIO::encodeGreaterThanPredicate(commandContainer, alloc->getGpuAddress(), i, isCopyOnly(false)); - ret = appendLaunchKernelWithParams(Kernel::fromHandle(kernelHandles[i]), pLaunchArgumentsBuffer[i], nullptr, launchParams); if (ret) { return ret; } + } } addToMappedEventList(event); appendSignalEventPostWalker(event, nullptr, nullptr, false, false, false); @@ -2012,18 +2023,21 @@ ze_result_t CommandListCoreFamily::appendMemoryFill(void *ptr, bool hostPointerNeedsFlush = false; - NEO::SvmAllocationData *allocData = nullptr; - bool dstAllocFound = device->getDriverHandle()->findAllocationDataForRange(ptr, size, allocData); - if (dstAllocFound) { - if (allocData->memoryType == InternalMemoryType::hostUnifiedMemory || - allocData->memoryType == InternalMemoryType::sharedUnifiedMemory) { - hostPointerNeedsFlush = true; - } - } else { - if (device->getDriverHandle()->getHostPointerBaseAddress(ptr, nullptr) != ZE_RESULT_SUCCESS) { - return ZE_RESULT_ERROR_INVALID_ARGUMENT; + DeviceImp *deviceImp = static_cast(device); + if (!deviceImp->isSystemAllocEnabled()) { + NEO::SvmAllocationData *allocData = nullptr; + bool dstAllocFound = device->getDriverHandle()->findAllocationDataForRange(ptr, size, allocData); + if (dstAllocFound) { + if (allocData->memoryType == InternalMemoryType::hostUnifiedMemory || + allocData->memoryType == InternalMemoryType::sharedUnifiedMemory) { + hostPointerNeedsFlush = true; + } } else { - hostPointerNeedsFlush = true; + if (device->getDriverHandle()->getHostPointerBaseAddress(ptr, nullptr) != ZE_RESULT_SUCCESS) { + return ZE_RESULT_ERROR_INVALID_ARGUMENT; + } else { + hostPointerNeedsFlush = true; + } } } diff --git a/level_zero/core/source/device/device_imp.cpp b/level_zero/core/source/device/device_imp.cpp index 5db31a65dbc84..43114b7b1ebe0 100644 --- a/level_zero/core/source/device/device_imp.cpp +++ b/level_zero/core/source/device/device_imp.cpp @@ -62,6 +62,7 @@ #include "level_zero/tools/source/sysman/sysman.h" #include "encode_surface_state_args.h" +#include "shared/source/os_interface/linux/drm_neo.h" #include #include @@ -2003,4 +2004,13 @@ uint32_t DeviceImp::getEventMaxKernelCount() const { return l0GfxCoreHelper.getEventMaxKernelCount(hardwareInfo); } +bool DeviceImp::isSystemAllocEnabled() const { + auto &osInterface = this->getNEODevice()->getRootDeviceEnvironment().osInterface; + if (osInterface->getDriverModel()->getDriverModelType() == NEO::DriverModelType::drm) { + auto pDrm = osInterface->getDriverModel()->as(); + return pDrm->isSystemAllocEnabled(); + } + return false; +} + } // namespace L0 diff --git a/level_zero/core/source/device/device_imp.h b/level_zero/core/source/device/device_imp.h index fca9f433a1a30..407813d75b2e8 100644 --- a/level_zero/core/source/device/device_imp.h +++ b/level_zero/core/source/device/device_imp.h @@ -173,6 +173,7 @@ struct DeviceImp : public Device, NEO::NonCopyableOrMovableClass { ze_result_t setDeviceLuid(ze_device_luid_ext_properties_t *deviceLuidProperties); uint32_t getEventMaxPacketCount() const override; uint32_t getEventMaxKernelCount() const override; + bool isSystemAllocEnabled() const; uint32_t queryDeviceNodeMask(); NEO::EngineGroupType getInternalEngineGroupType(); uint32_t getCopyEngineOrdinal() const; diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index 859c96827d036..58f236d4caac7 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -210,6 +210,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, ForceExtendedUSMBufferSize, -1, "-1: default, 0: DECLARE_DEBUG_VARIABLE(int32_t, ForceExtendedKernelIsaSize, -1, "-1: default, 0: disabled, >=1: Forces extended kernel isa size by specified pageSize number") DECLARE_DEBUG_VARIABLE(int32_t, ForceSimdMessageSizeInWalker, -1, "-1: default, >=0 Program given value in Walker command for SIMD size") DECLARE_DEBUG_VARIABLE(int32_t, EnableRecoverablePageFaults, -1, "-1: default - ignore, 0: disable, 1: enable recoverable page faults on all VMs (on faultable hardware)") +DECLARE_DEBUG_VARIABLE(int32_t, EnableSystemAllocator, -1, "-1: default - ignore, 0: disable, 1: enable use of system-allocated memory for GPU access") DECLARE_DEBUG_VARIABLE(int32_t, EnableImplicitMigrationOnFaultableHardware, -1, "-1: default - ignore, 0: disable, 1: enable implicit migration on faultable hardware (for all allocations)") DECLARE_DEBUG_VARIABLE(int32_t, UseDrmVirtualEnginesForCcs, -1, "-1: default, 0: disable, 1: enable, Combine all CCS nodes to single VE (per context)") DECLARE_DEBUG_VARIABLE(int32_t, UseDrmVirtualEnginesForBcs, -1, "-1: default, 0: disable, 1: enable, Combine all BCS nodes to single VE (per context)") diff --git a/shared/source/os_interface/linux/drm_neo.cpp b/shared/source/os_interface/linux/drm_neo.cpp index e7171b23c63b7..727ae2a76712f 100644 --- a/shared/source/os_interface/linux/drm_neo.cpp +++ b/shared/source/os_interface/linux/drm_neo.cpp @@ -54,6 +54,10 @@ #include #include +#ifndef DRM_XE_VM_BIND_FLAG_SYSTEM_ALLOCATOR +#define DRM_XE_VM_BIND_FLAG_SYSTEM_ALLOCATOR (1 << 4) +#endif + namespace NEO { Drm::Drm(std::unique_ptr &&hwDeviceIdIn, RootDeviceEnvironment &rootDeviceEnvironment) @@ -1140,6 +1144,16 @@ bool Drm::hasPageFaultSupport() const { return pageFaultSupported; } +void Drm::checkSystemAllocEnabled() { + auto drmVersion = Drm::getDrmVersion(getFileDescriptor()); + bool systemAllocSupported = false; + //For now, this can only be enabled with debug variable + if (("xe" == drmVersion) && (debugManager.flags.EnableSystemAllocator.get() != -1)) { + systemAllocSupported = !!debugManager.flags.EnableSystemAllocator.get(); + } + setSystemAllocEnable(systemAllocSupported); +} + bool Drm::hasKmdMigrationSupport() const { const auto &productHelper = this->getRootDeviceEnvironment().getHelper(); auto kmdMigrationSupported = hasPageFaultSupport() && productHelper.isKmdMigrationSupported(); @@ -1570,6 +1584,20 @@ int Drm::createDrmVirtualMemory(uint32_t &drmVmId) { if (ret == 0) { drmVmId = ctl.vmId; + checkSystemAllocEnabled(); + if (isSystemAllocEnabled()) { + VmBindParams vmBind{}; + vmBind.vmId = static_cast(ctl.vmId); + vmBind.flags = DRM_XE_VM_BIND_FLAG_SYSTEM_ALLOCATOR; + vmBind.handle = 0; + vmBind.length = (0x1ull << 48); + vmBind.offset = 0; + vmBind.start = 0; + vmBind.userptr = 0; + setVmBindSystemAlloc(true); + ret = ioctlHelper->vmBind(vmBind); + setVmBindSystemAlloc(false); + } if (ctl.vmId == 0) { // 0 is reserved for invalid/unassigned ppgtt return -1; diff --git a/shared/source/os_interface/linux/drm_neo.h b/shared/source/os_interface/linux/drm_neo.h index 789cf28d3bce3..f41199a740b73 100644 --- a/shared/source/os_interface/linux/drm_neo.h +++ b/shared/source/os_interface/linux/drm_neo.h @@ -152,6 +152,12 @@ class Drm : public DriverModel { void setDirectSubmissionActive(bool value) { this->directSubmissionActive = value; } bool isDirectSubmissionActive() const { return this->directSubmissionActive; } + void setVmBindSystemAlloc(bool value) { this->vmBindSystemAlloc = value; } + bool isVmBindSystemAlloc() const { return this->vmBindSystemAlloc; } + void checkSystemAllocEnabled(); + void setSystemAllocEnable(bool value) { this->systemAllocEnable = value; } + bool isSystemAllocEnabled() const { return this->systemAllocEnable; } + MOCKABLE_VIRTUAL bool isSetPairAvailable(); MOCKABLE_VIRTUAL bool getSetPairAvailable() { return setPairAvailable; } MOCKABLE_VIRTUAL bool isChunkingAvailable(); @@ -166,6 +172,7 @@ class Drm : public DriverModel { MOCKABLE_VIRTUAL void queryPageFaultSupport(); bool hasPageFaultSupport() const; + bool hasSystemAllocSupport() const; bool hasKmdMigrationSupport() const; bool checkToDisableScratchPage() { return disableScratch; } unsigned int getGpuFaultCheckThreshold() const { return gpuFaultCheckThreshold; } @@ -348,6 +355,8 @@ class Drm : public DriverModel { bool requirePerContextVM = false; bool bindAvailable = false; bool directSubmissionActive = false; + bool vmBindSystemAlloc = false; + bool systemAllocEnable = false; bool setPairAvailable = false; bool chunkingAvailable = false; uint32_t chunkingMode = 0; diff --git a/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp b/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp index 383f26a0bac63..f426238a7ff80 100644 --- a/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp +++ b/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp @@ -37,6 +37,9 @@ #define STRINGIFY_ME(X) return #X #define RETURN_ME(X) return X +#ifndef DRM_XE_VM_BIND_FLAG_SYSTEM_ALLOCATOR +#define DRM_XE_VM_BIND_FLAG_SYSTEM_ALLOCATOR (1 << 4) +#endif namespace NEO { const char *IoctlHelperXe::xeGetClassName(int className) { @@ -1317,6 +1320,37 @@ int IoctlHelperXe::xeVmBind(const VmBindParams &vmBindParams, bool isBind) { const char *operation = isBind ? "bind" : "unbind"; int index = invalidIndex; + if (this->drm.isVmBindSystemAlloc()) { + drm_xe_vm_bind bind = {}; + bind.vm_id = vmBindParams.vmId; + bind.num_syncs = 0; + bind.num_binds = 1; + bind.bind.range = vmBindParams.length; + bind.bind.addr = 0; //gmmHelper->decanonize(vmBindParams.start); + bind.bind.obj_offset = vmBindParams.offset; + bind.bind.pat_index = static_cast(vmBindParams.patIndex); + bind.bind.extensions = vmBindParams.extensions; + bind.bind.flags = static_cast(vmBindParams.flags); + bind.bind.op = DRM_XE_VM_BIND_OP_MAP; + bind.bind.obj = 0; + ret = IoctlHelper::ioctl(DrmIoctl::gemVmBind, &bind); + xeLog(" vm=%d obj=0x%x off=0x%llx range=0x%llx addr=0x%llx operation=%d(%s) flags=%d(%s) nsy=%d pat=%hu ret=%d\n", + bind.vm_id, + bind.bind.obj, + bind.bind.obj_offset, + bind.bind.range, + bind.bind.addr, + bind.bind.op, + xeGetBindOperationName(bind.bind.op), + bind.bind.flags, + " ", //xeGetBindFlagNames(bind.bind.flags).c_str(), + bind.num_syncs, + bind.bind.pat_index, + ret); + return ret; + } + + if (isBind) { for (auto i = 0u; i < bindInfo.size(); i++) { if (vmBindParams.handle && vmBindParams.handle == bindInfo[i].handle) { @@ -1373,11 +1407,16 @@ int IoctlHelperXe::xeVmBind(const VmBindParams &vmBindParams, bool isBind) { bind.bind.obj_offset = bindInfo[index].userptr; } } else { - bind.bind.op = DRM_XE_VM_BIND_OP_UNMAP; - bind.bind.obj = 0; - if (bindInfo[index].userptr) { - bind.bind.obj_offset = bindInfo[index].userptr; + if (this->drm.isSystemAllocEnabled()) { + bind.bind.op = DRM_XE_VM_BIND_OP_MAP; + bind.bind.flags |= DRM_XE_VM_BIND_FLAG_SYSTEM_ALLOCATOR; + } else { + bind.bind.op = DRM_XE_VM_BIND_OP_UNMAP; } + bind.bind.obj = 0; + //if (bindInfo[index].userptr) { + // bind.bind.obj_offset = bindInfo[index].userptr; + //} } bindInfo[index].addr = bind.bind.addr; @@ -1403,17 +1442,19 @@ int IoctlHelperXe::xeVmBind(const VmBindParams &vmBindParams, bool isBind) { return ret; } - constexpr auto oneSecTimeout = 1000000000ll; - constexpr auto infiniteTimeout = -1; - bool debuggingEnabled = drm.getRootDeviceEnvironment().executionEnvironment.isDebuggingEnabled(); - uint64_t timeout = debuggingEnabled ? infiniteTimeout : oneSecTimeout; - if (debugManager.flags.VmBindWaitUserFenceTimeout.get() != -1) { - timeout = debugManager.flags.VmBindWaitUserFenceTimeout.get(); + if (!this->drm.isVmBindSystemAlloc()) { + constexpr auto oneSecTimeout = 1000000000ll; + constexpr auto infiniteTimeout = -1; + bool debuggingEnabled = drm.getRootDeviceEnvironment().executionEnvironment.isDebuggingEnabled(); + uint64_t timeout = debuggingEnabled ? infiniteTimeout : oneSecTimeout; + if (debugManager.flags.VmBindWaitUserFenceTimeout.get() != -1) { + timeout = debugManager.flags.VmBindWaitUserFenceTimeout.get(); + } + return xeWaitUserFence(bind.exec_queue_id, DRM_XE_UFENCE_WAIT_OP_EQ, + sync[0].addr, + sync[0].timeline_value, timeout, + false, NEO::InterruptId::notUsed, nullptr); } - return xeWaitUserFence(bind.exec_queue_id, DRM_XE_UFENCE_WAIT_OP_EQ, - sync[0].addr, - sync[0].timeline_value, timeout, - false, NEO::InterruptId::notUsed, nullptr); } xeLog("error: -> IoctlHelperXe::%s %s index=%d vmid=0x%x h=0x%x s=0x%llx o=0x%llx l=0x%llx f=0x%llx pat=%hu r=%d\n", From fd0fa908f7b0b93878aeb8f76e9805859ea8a871 Mon Sep 17 00:00:00 2001 From: "Falkowski, John" Date: Tue, 17 Dec 2024 17:36:11 +0000 Subject: [PATCH 2/2] feature: System Allocator support for Level Zero Related-To: NEO-12988 Signed-off-by: John Falkowski john.falkowski@intel.com Signed-off-by: Falkowski, John --- level_zero/core/source/cmdlist/cmdlist_hw.inl | 43 +++++++++++-------- .../os_interface/linux/drm_memory_manager.cpp | 5 ++- shared/source/os_interface/linux/drm_neo.cpp | 3 +- .../os_interface/linux/xe/ioctl_helper_xe.cpp | 3 -- 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/level_zero/core/source/cmdlist/cmdlist_hw.inl b/level_zero/core/source/cmdlist/cmdlist_hw.inl index 0ff5ba6677f33..bd674fd1ef8b1 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw.inl @@ -59,7 +59,6 @@ #include #include - namespace L0 { inline ze_result_t parseErrorCode(NEO::CommandContainer::ErrorCode returnValue) { @@ -515,6 +514,7 @@ ze_result_t CommandListCoreFamily::appendLaunchMultipleKernelsInd appendEventForProfiling(event, nullptr, true, false, false, false); auto allocData = device->getDriverHandle()->getSvmAllocsManager()->getSVMAlloc(static_cast(pNumLaunchArguments)); + DeviceImp *deviceImp = static_cast(device); if (allocData) { auto alloc = allocData->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex()); commandContainer.addToResidencyContainer(alloc); @@ -528,8 +528,8 @@ ze_result_t CommandListCoreFamily::appendLaunchMultipleKernelsInd return ret; } } - } else { - for (uint32_t i = 0; i < numKernels; i++) { + } else if (deviceImp->isSystemAllocEnabled()) { + for (uint32_t i = 0; i < numKernels; i++) { ret = appendLaunchKernelWithParams(Kernel::fromHandle(kernelHandles[i]), pLaunchArgumentsBuffer[i], nullptr, launchParams); @@ -537,6 +537,8 @@ ze_result_t CommandListCoreFamily::appendLaunchMultipleKernelsInd return ret; } } + } else { + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; } addToMappedEventList(event); appendSignalEventPostWalker(event, nullptr, nullptr, false, false, false); @@ -1501,7 +1503,6 @@ ze_result_t CommandListCoreFamily::appendMemoryCopy(void *dstptr, auto dstAllocationStruct = getAlignedAllocationData(this->device, dstptr, size, false, isCopyOffloadEnabled()); auto srcAllocationStruct = getAlignedAllocationData(this->device, srcptr, size, true, isCopyOffloadEnabled()); - if (dstAllocationStruct.alloc == nullptr || srcAllocationStruct.alloc == nullptr) { return ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY; } @@ -1593,6 +1594,7 @@ ze_result_t CommandListCoreFamily::appendMemoryCopy(void *dstptr, args.tlbFlush = true; encodeMiFlush(0, 0, args); } + ret = appendMemoryCopyBlit(dstAllocationStruct.alignedAllocationPtr, dstAllocationStruct.alloc, dstAllocationStruct.offset, srcAllocationStruct.alignedAllocationPtr, @@ -1741,8 +1743,10 @@ ze_result_t CommandListCoreFamily::appendMemoryCopyRegion(void *d if (dstAllocationStruct.alloc == nullptr || srcAllocationStruct.alloc == nullptr) { return ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY; } - - const bool isCopyOnlyEnabled = isCopyOnly(isCopyOffloadAllowed(*srcAllocationStruct.alloc, *dstAllocationStruct.alloc)); + bool isCopyOnlyEnabled = false; + if (dstAllocationStruct.alloc && srcAllocationStruct.alloc) { + isCopyOnlyEnabled = isCopyOnly(isCopyOffloadAllowed(*srcAllocationStruct.alloc, *dstAllocationStruct.alloc)); + } const bool inOrderCopyOnlySignalingAllowed = this->isInOrderExecutionEnabled() && !forceDisableCopyOnlyInOrderSignaling && isCopyOnlyEnabled; ze_result_t result = ZE_RESULT_SUCCESS; @@ -1927,6 +1931,7 @@ ze_result_t CommandListCoreFamily::appendMemoryCopyKernel2d(Align launchParams.isDestinationAllocationInSystemMemory = (dstAllocationType == NEO::AllocationType::bufferHostMemory) || (dstAllocationType == NEO::AllocationType::externalHostPtr); + return CommandListCoreFamily::appendLaunchKernel(builtinKernel->toHandle(), dispatchKernelArgs, signalEvent, numWaitEvents, @@ -2024,23 +2029,23 @@ ze_result_t CommandListCoreFamily::appendMemoryFill(void *ptr, bool hostPointerNeedsFlush = false; DeviceImp *deviceImp = static_cast(device); - if (!deviceImp->isSystemAllocEnabled()) { - NEO::SvmAllocationData *allocData = nullptr; - bool dstAllocFound = device->getDriverHandle()->findAllocationDataForRange(ptr, size, allocData); - if (dstAllocFound) { - if (allocData->memoryType == InternalMemoryType::hostUnifiedMemory || - allocData->memoryType == InternalMemoryType::sharedUnifiedMemory) { - hostPointerNeedsFlush = true; - } + + NEO::SvmAllocationData *allocData = nullptr; + bool dstAllocFound = device->getDriverHandle()->findAllocationDataForRange(ptr, size, allocData); + if (dstAllocFound) { + if (allocData->memoryType == InternalMemoryType::hostUnifiedMemory || + allocData->memoryType == InternalMemoryType::sharedUnifiedMemory) { + hostPointerNeedsFlush = true; + } + } else { + if ((device->getDriverHandle()->getHostPointerBaseAddress(ptr, nullptr) != ZE_RESULT_SUCCESS) && (!deviceImp->isSystemAllocEnabled())) { + return ZE_RESULT_ERROR_INVALID_ARGUMENT; } else { - if (device->getDriverHandle()->getHostPointerBaseAddress(ptr, nullptr) != ZE_RESULT_SUCCESS) { - return ZE_RESULT_ERROR_INVALID_ARGUMENT; - } else { - hostPointerNeedsFlush = true; - } + hostPointerNeedsFlush = true; } } + auto dstAllocation = this->getAlignedAllocationData(this->device, ptr, size, false, false); if (dstAllocation.alloc == nullptr) { return ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY; diff --git a/shared/source/os_interface/linux/drm_memory_manager.cpp b/shared/source/os_interface/linux/drm_memory_manager.cpp index 2d59deb54a012..f1baa951e7158 100644 --- a/shared/source/os_interface/linux/drm_memory_manager.cpp +++ b/shared/source/os_interface/linux/drm_memory_manager.cpp @@ -594,7 +594,10 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForNonSvmHostPtr(con auto offsetInPage = ptrDiff(allocationData.hostPtr, alignedPtr); auto rootDeviceIndex = allocationData.rootDeviceIndex; uint64_t gpuVirtualAddress = 0; - if (this->isLimitedRange(allocationData.rootDeviceIndex)) { + + if (this->getDrm(rootDeviceIndex).isSystemAllocEnabled()) { + gpuVirtualAddress = reinterpret_cast(alignedPtr); + } else if (this->isLimitedRange(allocationData.rootDeviceIndex)) { gpuVirtualAddress = acquireGpuRange(alignedSize, rootDeviceIndex, HeapIndex::heapStandard); } else { alignedSize = alignUp(alignedSize, MemoryConstants::pageSize2M); diff --git a/shared/source/os_interface/linux/drm_neo.cpp b/shared/source/os_interface/linux/drm_neo.cpp index 727ae2a76712f..54d2323efab96 100644 --- a/shared/source/os_interface/linux/drm_neo.cpp +++ b/shared/source/os_interface/linux/drm_neo.cpp @@ -46,6 +46,7 @@ #include "shared/source/utilities/api_intercept.h" #include "shared/source/utilities/directory.h" #include "shared/source/utilities/io_functions.h" +#include "shared/source/utilities/cpu_info.h" #include #include @@ -1590,7 +1591,7 @@ int Drm::createDrmVirtualMemory(uint32_t &drmVmId) { vmBind.vmId = static_cast(ctl.vmId); vmBind.flags = DRM_XE_VM_BIND_FLAG_SYSTEM_ALLOCATOR; vmBind.handle = 0; - vmBind.length = (0x1ull << 48); + vmBind.length = (0x1ull << NEO::CpuInfo::getInstance().getVirtualAddressSize()); vmBind.offset = 0; vmBind.start = 0; vmBind.userptr = 0; diff --git a/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp b/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp index f426238a7ff80..8cde30dfb93f0 100644 --- a/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp +++ b/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp @@ -1414,9 +1414,6 @@ int IoctlHelperXe::xeVmBind(const VmBindParams &vmBindParams, bool isBind) { bind.bind.op = DRM_XE_VM_BIND_OP_UNMAP; } bind.bind.obj = 0; - //if (bindInfo[index].userptr) { - // bind.bind.obj_offset = bindInfo[index].userptr; - //} } bindInfo[index].addr = bind.bind.addr;