diff --git a/shared/source/os_interface/linux/drm_memory_manager.cpp b/shared/source/os_interface/linux/drm_memory_manager.cpp index 2c827f15a4..a98ce935f9 100644 --- a/shared/source/os_interface/linux/drm_memory_manager.cpp +++ b/shared/source/os_interface/linux/drm_memory_manager.cpp @@ -2398,7 +2398,7 @@ GraphicsAllocation *DrmMemoryManager::createSharedUnifiedMemoryAllocation(const auto ioctlHelper = drm.getIoctlHelper(); const auto vmAdviseAttribute = ioctlHelper->getVmAdviseAtomicAttribute(); - if (vmAdviseAttribute.has_value() && vmAdviseAttribute.value() == 0) { + if (vmAdviseAttribute == 0) { return nullptr; } @@ -2481,7 +2481,7 @@ GraphicsAllocation *DrmMemoryManager::createSharedUnifiedMemoryAllocation(const std::unique_ptr bo(new BufferObject(allocationData.rootDeviceIndex, &drm, patIndex, handle, currentSize, maxOsContextCount)); - if (vmAdviseAttribute.has_value() && !ioctlHelper->setVmBoAdvise(bo->peekHandle(), vmAdviseAttribute.value(), nullptr)) { + if (!ioctlHelper->setVmBoAdvise(bo->peekHandle(), vmAdviseAttribute, nullptr)) { this->munmapFunction(cpuBasePointer, totalSizeToAlloc); releaseGpuRange(reinterpret_cast(preferredAddress), totalSizeToAlloc, allocationData.rootDeviceIndex); return nullptr; diff --git a/shared/source/os_interface/linux/drm_neo.cpp b/shared/source/os_interface/linux/drm_neo.cpp index c33602612e..5bf4e4f5b4 100644 --- a/shared/source/os_interface/linux/drm_neo.cpp +++ b/shared/source/os_interface/linux/drm_neo.cpp @@ -1037,7 +1037,11 @@ void Drm::queryPageFaultSupport() { return; } - pageFaultSupported = this->ioctlHelper->isPageFaultSupported(); + if (const auto paramId = ioctlHelper->getHasPageFaultParamId(); paramId) { + int support = 0; + const auto ret = getParamIoctl(*paramId, &support); + pageFaultSupported = (0 == ret) && (support > 0); + } } bool Drm::hasPageFaultSupport() const { diff --git a/shared/source/os_interface/linux/ioctl_helper.h b/shared/source/os_interface/linux/ioctl_helper.h index 87b183fc12..e7242bd3a2 100644 --- a/shared/source/os_interface/linux/ioctl_helper.h +++ b/shared/source/os_interface/linux/ioctl_helper.h @@ -123,7 +123,7 @@ class IoctlHelper { virtual uint16_t getWaitUserFenceSoftFlag() = 0; virtual int execBuffer(ExecBuffer *execBuffer, uint64_t completionGpuAddress, TaskCountType counterValue) = 0; virtual bool completionFenceExtensionSupported(const bool isVmBindAvailable) = 0; - virtual bool isPageFaultSupported() = 0; + virtual std::optional getHasPageFaultParamId() = 0; virtual std::unique_ptr createVmControlExtRegion(const std::optional ®ionInstanceClass) = 0; virtual uint32_t getFlagsForVmCreate(bool disableScratch, bool enablePageFault, bool useVmBind) = 0; virtual uint32_t createContextWithAccessCounters(GemContextCreateExt &gcc) = 0; @@ -133,7 +133,7 @@ class IoctlHelper { virtual void setVmBindUserFence(VmBindParams &vmBind, VmBindExtUserFenceT vmBindUserFence) = 0; virtual std::optional getCopyClassSaturatePCIECapability() = 0; virtual std::optional getCopyClassSaturateLinkCapability() = 0; - virtual std::optional getVmAdviseAtomicAttribute() = 0; + virtual uint32_t getVmAdviseAtomicAttribute() = 0; virtual int vmBind(const VmBindParams &vmBindParams) = 0; virtual int vmUnbind(const VmBindParams &vmBindParams) = 0; virtual int getResetStats(ResetStats &resetStats, uint32_t *status, ResetStatsFault *resetStatsFault) = 0; @@ -274,7 +274,7 @@ class IoctlHelperUpstream : public IoctlHelperI915 { uint16_t getWaitUserFenceSoftFlag() override; int execBuffer(ExecBuffer *execBuffer, uint64_t completionGpuAddress, TaskCountType counterValue) override; bool completionFenceExtensionSupported(const bool isVmBindAvailable) override; - bool isPageFaultSupported() override; + std::optional getHasPageFaultParamId() override; std::unique_ptr createVmControlExtRegion(const std::optional ®ionInstanceClass) override; uint32_t getFlagsForVmCreate(bool disableScratch, bool enablePageFault, bool useVmBind) override; uint32_t createContextWithAccessCounters(GemContextCreateExt &gcc) override; @@ -284,7 +284,7 @@ class IoctlHelperUpstream : public IoctlHelperI915 { void setVmBindUserFence(VmBindParams &vmBind, VmBindExtUserFenceT vmBindUserFence) override; std::optional getCopyClassSaturatePCIECapability() override; std::optional getCopyClassSaturateLinkCapability() override; - std::optional getVmAdviseAtomicAttribute() override; + uint32_t getVmAdviseAtomicAttribute() override; int vmBind(const VmBindParams &vmBindParams) override; int vmUnbind(const VmBindParams &vmBindParams) override; int getResetStats(ResetStats &resetStats, uint32_t *status, ResetStatsFault *resetStatsFault) override; @@ -352,7 +352,7 @@ class IoctlHelperPrelim20 : public IoctlHelperI915 { uint16_t getWaitUserFenceSoftFlag() override; int execBuffer(ExecBuffer *execBuffer, uint64_t completionGpuAddress, TaskCountType counterValue) override; bool completionFenceExtensionSupported(const bool isVmBindAvailable) override; - bool isPageFaultSupported() override; + std::optional getHasPageFaultParamId() override; std::unique_ptr createVmControlExtRegion(const std::optional ®ionInstanceClass) override; uint32_t getFlagsForVmCreate(bool disableScratch, bool enablePageFault, bool useVmBind) override; uint32_t createContextWithAccessCounters(GemContextCreateExt &gcc) override; @@ -362,7 +362,7 @@ class IoctlHelperPrelim20 : public IoctlHelperI915 { void setVmBindUserFence(VmBindParams &vmBind, VmBindExtUserFenceT vmBindUserFence) override; std::optional getCopyClassSaturatePCIECapability() override; std::optional getCopyClassSaturateLinkCapability() override; - std::optional getVmAdviseAtomicAttribute() override; + uint32_t getVmAdviseAtomicAttribute() override; int vmBind(const VmBindParams &vmBindParams) override; int vmUnbind(const VmBindParams &vmBindParams) override; int getResetStats(ResetStats &resetStats, uint32_t *status, ResetStatsFault *resetStatsFault) override; diff --git a/shared/source/os_interface/linux/ioctl_helper_prelim.cpp b/shared/source/os_interface/linux/ioctl_helper_prelim.cpp index 32a5b88b4a..92da0e8624 100644 --- a/shared/source/os_interface/linux/ioctl_helper_prelim.cpp +++ b/shared/source/os_interface/linux/ioctl_helper_prelim.cpp @@ -557,19 +557,8 @@ int IoctlHelperPrelim20::queryDistances(std::vector &queryItems, std: return ret; } -bool IoctlHelperPrelim20::isPageFaultSupported() { - int pagefaultSupport{}; - GetParam getParam{}; - getParam.param = PRELIM_I915_PARAM_HAS_PAGE_FAULT; - getParam.value = &pagefaultSupport; - - int retVal = ioctl(DrmIoctl::getparam, &getParam); - if (debugManager.flags.PrintIoctlEntries.get()) { - printf("DRM_IOCTL_I915_GETPARAM: param: PRELIM_I915_PARAM_HAS_PAGE_FAULT, output value: %d, retCode:% d\n", - *getParam.value, - retVal); - } - return (retVal == 0) && (pagefaultSupport > 0); +std::optional IoctlHelperPrelim20::getHasPageFaultParamId() { + return DrmParam::paramHasPageFault; }; bool IoctlHelperPrelim20::getEuStallProperties(std::array &properties, uint64_t dssBufferSize, uint64_t samplingRate, @@ -742,7 +731,7 @@ std::optional IoctlHelperPrelim20::getCopyClassSaturateLinkCapability( return PRELIM_I915_COPY_CLASS_CAP_SATURATE_LINK; } -std::optional IoctlHelperPrelim20::getVmAdviseAtomicAttribute() { +uint32_t IoctlHelperPrelim20::getVmAdviseAtomicAttribute() { switch (NEO::debugManager.flags.SetVmAdviseAtomicAttribute.get()) { case 0: return PRELIM_I915_VM_ADVISE_ATOMIC_NONE; diff --git a/shared/source/os_interface/linux/ioctl_helper_upstream.cpp b/shared/source/os_interface/linux/ioctl_helper_upstream.cpp index c57fa839d5..858abd7982 100644 --- a/shared/source/os_interface/linux/ioctl_helper_upstream.cpp +++ b/shared/source/os_interface/linux/ioctl_helper_upstream.cpp @@ -191,8 +191,8 @@ bool IoctlHelperUpstream::completionFenceExtensionSupported(const bool isVmBindA return false; } -bool IoctlHelperUpstream::isPageFaultSupported() { - return false; +std::optional IoctlHelperUpstream::getHasPageFaultParamId() { + return std::nullopt; }; bool IoctlHelperUpstream::getEuStallProperties(std::array &properties, uint64_t dssBufferSize, @@ -243,7 +243,7 @@ std::optional IoctlHelperUpstream::getCopyClassSaturateLinkCapability( return std::nullopt; } -std::optional IoctlHelperUpstream::getVmAdviseAtomicAttribute() { +uint32_t IoctlHelperUpstream::getVmAdviseAtomicAttribute() { return 0; } diff --git a/shared/source/os_interface/linux/xe/CMakeLists.txt b/shared/source/os_interface/linux/xe/CMakeLists.txt index ee7abf3224..b39333f36a 100644 --- a/shared/source/os_interface/linux/xe/CMakeLists.txt +++ b/shared/source/os_interface/linux/xe/CMakeLists.txt @@ -11,7 +11,7 @@ set(NEO_CORE_OS_INTERFACE_LINUX_XE ${CMAKE_CURRENT_SOURCE_DIR}/ioctl_helper_xe.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ioctl_helper_xe.h ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/ioctl_helper_xe_query_hw_ip_version.cpp - ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/ioctl_helper_xe_query_features.cpp + ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/ioctl_helper_xe_vm_bind_flags.cpp ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/ioctl_helper_xe_perf.cpp ) 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 b678c4a09f..9037b332b2 100644 --- a/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp +++ b/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp @@ -642,7 +642,6 @@ void IoctlHelperXe::setupXeWaitUserFenceStruct(void *arg, uint32_t ctxId, uint16 } int IoctlHelperXe::xeWaitUserFence(uint32_t ctxId, uint16_t op, uint64_t addr, uint64_t value, int64_t timeout, bool userInterrupt, uint32_t externalInterruptId, GraphicsAllocation *allocForInterruptWait) { - UNRECOVERABLE_IF(addr == 0x0) drm_xe_wait_user_fence waitUserFence = {}; setupXeWaitUserFenceStruct(&waitUserFence, ctxId, op, addr, value, timeout); @@ -685,14 +684,11 @@ std::optional IoctlHelperXe::getPreferredLocationRegion(Pre bool IoctlHelperXe::setVmBoAdvise(int32_t handle, uint32_t attribute, void *region) { xeLog(" -> IoctlHelperXe::%s\n", __FUNCTION__); - // There is no vmAdvise attribute in Xe, so return success - return true; + return false; } bool IoctlHelperXe::setVmBoAdviseForChunking(int32_t handle, uint64_t start, uint64_t length, uint32_t attribute, void *region) { - xeLog(" -> IoctlHelperXe::%s\n", __FUNCTION__); - // There is no vmAdvise attribute in Xe, so return success - return true; + return false; } bool IoctlHelperXe::setVmPrefetch(uint64_t start, uint64_t length, uint32_t region, uint32_t vmId) { @@ -800,10 +796,9 @@ int IoctlHelperXe::queryDistances(std::vector &queryItems, std::vecto return 0; } -bool IoctlHelperXe::isPageFaultSupported() { - xeLog(" -> IoctlHelperXe::%s %d\n", __FUNCTION__, supportedFeatures.flags.pageFault == true); - - return supportedFeatures.flags.pageFault; +std::optional IoctlHelperXe::getHasPageFaultParamId() { + xeLog(" -> IoctlHelperXe::%s\n", __FUNCTION__); + return {}; }; uint32_t IoctlHelperXe::getEuStallFdParameter() { @@ -864,10 +859,9 @@ std::optional IoctlHelperXe::getCopyClassSaturateLinkCapability() { return {}; } -std::optional IoctlHelperXe::getVmAdviseAtomicAttribute() { +uint32_t IoctlHelperXe::getVmAdviseAtomicAttribute() { xeLog(" -> IoctlHelperXe::%s\n", __FUNCTION__); - // There is no vmAdvise attribute in Xe - return {}; + return 0; } int IoctlHelperXe::vmBind(const VmBindParams &vmBindParams) { @@ -1246,11 +1240,21 @@ int IoctlHelperXe::xeVmBind(const VmBindParams &vmBindParams, bool isBind) { } if (index != invalidIndex) { + + drm_xe_sync sync[1] = {}; + sync[0].type = DRM_XE_SYNC_TYPE_USER_FENCE; + sync[0].flags = DRM_XE_SYNC_FLAG_SIGNAL; + auto xeBindExtUserFence = reinterpret_cast(vmBindParams.userFence); + UNRECOVERABLE_IF(!xeBindExtUserFence); + UNRECOVERABLE_IF(xeBindExtUserFence->tag != UserFenceExtension::tagValue); + sync[0].addr = xeBindExtUserFence->addr; + sync[0].timeline_value = xeBindExtUserFence->value; + drm_xe_vm_bind bind = {}; bind.vm_id = vmBindParams.vmId; - bind.num_syncs = 0; bind.num_binds = 1; - + bind.num_syncs = 1; + bind.syncs = reinterpret_cast(&sync); bind.bind.range = vmBindParams.length; bind.bind.addr = gmmHelper->decanonize(vmBindParams.start); bind.bind.obj_offset = vmBindParams.offset; @@ -1258,20 +1262,6 @@ int IoctlHelperXe::xeVmBind(const VmBindParams &vmBindParams, bool isBind) { bind.bind.extensions = vmBindParams.extensions; bind.bind.flags = static_cast(vmBindParams.flags); - drm_xe_sync sync[1] = {}; - bool residencyRequired = vmBindParams.userFence == 0x0 ? false : true; - if (residencyRequired) { - auto xeBindExtUserFence = reinterpret_cast(vmBindParams.userFence); - UNRECOVERABLE_IF(xeBindExtUserFence->tag != UserFenceExtension::tagValue); - - sync[0].type = DRM_XE_SYNC_TYPE_USER_FENCE; - sync[0].flags = DRM_XE_SYNC_FLAG_SIGNAL; - sync[0].addr = xeBindExtUserFence->addr; - sync[0].timeline_value = xeBindExtUserFence->value; - bind.syncs = reinterpret_cast(&sync); - bind.num_syncs = 1; - } - if (isBind) { bind.bind.op = DRM_XE_VM_BIND_OP_MAP; bind.bind.obj = vmBindParams.handle; @@ -1311,21 +1301,17 @@ int IoctlHelperXe::xeVmBind(const VmBindParams &vmBindParams, bool isBind) { return ret; } - if (residencyRequired) { - 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); + 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 ret; + 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", diff --git a/shared/source/os_interface/linux/xe/ioctl_helper_xe.h b/shared/source/os_interface/linux/xe/ioctl_helper_xe.h index 144810a57e..3c894c000c 100644 --- a/shared/source/os_interface/linux/xe/ioctl_helper_xe.h +++ b/shared/source/os_interface/linux/xe/ioctl_helper_xe.h @@ -66,7 +66,7 @@ class IoctlHelperXe : public IoctlHelper { uint16_t getWaitUserFenceSoftFlag() override; int execBuffer(ExecBuffer *execBuffer, uint64_t completionGpuAddress, TaskCountType counterValue) override; bool completionFenceExtensionSupported(const bool isVmBindAvailable) override; - bool isPageFaultSupported() override; + std::optional getHasPageFaultParamId() override; std::unique_ptr createVmControlExtRegion(const std::optional ®ionInstanceClass) override; uint32_t getFlagsForVmCreate(bool disableScratch, bool enablePageFault, bool useVmBind) override; uint32_t createContextWithAccessCounters(GemContextCreateExt &gcc) override; @@ -76,7 +76,7 @@ class IoctlHelperXe : public IoctlHelper { void setVmBindUserFence(VmBindParams &vmBind, VmBindExtUserFenceT vmBindUserFence) override; std::optional getCopyClassSaturatePCIECapability() override; std::optional getCopyClassSaturateLinkCapability() override; - std::optional getVmAdviseAtomicAttribute() override; + uint32_t getVmAdviseAtomicAttribute() override; int vmBind(const VmBindParams &vmBindParams) override; int vmUnbind(const VmBindParams &vmBindParams) override; int getResetStats(ResetStats &resetStats, uint32_t *status, ResetStatsFault *resetStatsFault) override; @@ -215,8 +215,7 @@ class IoctlHelperXe : public IoctlHelper { struct { uint32_t vmBindReadOnly : 1; uint32_t vmBindImmediate : 1; - uint32_t pageFault : 1; - uint32_t reserved : 29; + uint32_t reserved : 30; } flags; uint32_t allFlags = 0; }; diff --git a/shared/source/os_interface/linux/xe/ioctl_helper_xe_query_features.cpp b/shared/source/os_interface/linux/xe/ioctl_helper_xe_query_features.cpp deleted file mode 100644 index e0a377824a..0000000000 --- a/shared/source/os_interface/linux/xe/ioctl_helper_xe_query_features.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2024 Intel Corporation - * - * SPDX-License-Identifier: MIT - * - */ - -#include "shared/source/os_interface/linux/xe/ioctl_helper_xe.h" - -#include "xe_drm.h" - -namespace NEO { -void IoctlHelperXe::querySupportedFeatures() { - auto checkVmCreateFlagsSupport = [&](uint32_t flags) -> bool { - struct drm_xe_vm_create vmCreate = {}; - vmCreate.flags = flags; - - auto ret = IoctlHelper::ioctl(DrmIoctl::gemVmCreate, &vmCreate); - if (ret == 0) { - struct drm_xe_vm_destroy vmDestroy = {}; - vmDestroy.vm_id = vmCreate.vm_id; - ret = IoctlHelper::ioctl(DrmIoctl::gemVmDestroy, &vmDestroy); - DEBUG_BREAK_IF(ret != 0); - return true; - } - return false; - }; - supportedFeatures.flags.pageFault = checkVmCreateFlagsSupport(DRM_XE_VM_CREATE_FLAG_LR_MODE | DRM_XE_VM_CREATE_FLAG_FAULT_MODE); -}; - -uint64_t IoctlHelperXe::getAdditionalFlagsForVmBind(bool bindImmediate, bool readOnlyResource) { - return 0; -} -} // namespace NEO \ No newline at end of file diff --git a/shared/source/os_interface/linux/xe/ioctl_helper_xe_vm_bind_flags.cpp b/shared/source/os_interface/linux/xe/ioctl_helper_xe_vm_bind_flags.cpp new file mode 100644 index 0000000000..aaafec3f61 --- /dev/null +++ b/shared/source/os_interface/linux/xe/ioctl_helper_xe_vm_bind_flags.cpp @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/os_interface/linux/xe/ioctl_helper_xe.h" + +namespace NEO { +void IoctlHelperXe::querySupportedFeatures(){}; + +uint64_t IoctlHelperXe::getAdditionalFlagsForVmBind(bool bindImmediate, bool readOnlyResource) { + return 0; +} +} // namespace NEO \ No newline at end of file diff --git a/shared/test/common/mocks/linux/mock_ioctl_helper.h b/shared/test/common/mocks/linux/mock_ioctl_helper.h index 0d8847041a..ab71999313 100644 --- a/shared/test/common/mocks/linux/mock_ioctl_helper.h +++ b/shared/test/common/mocks/linux/mock_ioctl_helper.h @@ -56,12 +56,6 @@ class MockIoctlHelper : public IoctlHelperPrelim20 { return IoctlHelperPrelim20::isWaitBeforeBindRequired(bind); } - std::optional getVmAdviseAtomicAttribute() override { - if (callBaseVmAdviseAtomicAttribute) - return IoctlHelperPrelim20::getVmAdviseAtomicAttribute(); - return vmAdviseAtomicAttribute; - } - bool allocateInterrupt(uint32_t &handle) override { allocateInterruptCalled++; return IoctlHelperPrelim20::allocateInterrupt(handle); @@ -97,7 +91,5 @@ class MockIoctlHelper : public IoctlHelperPrelim20 { uint32_t allocateInterruptCalled = 0; uint32_t releaseInterruptCalled = 0; uint32_t latestReleaseInterruptHandle = InterruptId::notUsed; - bool callBaseVmAdviseAtomicAttribute = true; - std::optional vmAdviseAtomicAttribute{}; }; } // namespace NEO diff --git a/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp index 241989d81c..c402253226 100644 --- a/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp @@ -7799,24 +7799,3 @@ TEST_F(DrmMemoryManagerTest, givenDebugVariableToToggleGpuVaBitsWhenAllocatingRe memoryManager->freeGraphicsMemory(allocation); } } - -TEST_F(DrmMemoryManagerTest, givenVmAdviseAtomicAttributeEqualZeroWhenCreateSharedUnifiedMemoryAllocationIsCalledThenNullptrReturned) { - std::vector regionInfo(1); - regionInfo[0].region = {drm_i915_gem_memory_class::I915_MEMORY_CLASS_SYSTEM, 0}; - - auto &drm = static_cast(memoryManager->getDrm(mockRootDeviceIndex)); - auto mockIoctlHelper = new MockIoctlHelper(*mock); - drm.memoryInfo.reset(new MemoryInfo(regionInfo, drm)); - drm.ioctlHelper.reset(mockIoctlHelper); - - mockIoctlHelper->callBaseVmAdviseAtomicAttribute = false; - mockIoctlHelper->vmAdviseAtomicAttribute = 0; - - AllocationData allocationData{}; - allocationData.size = MemoryConstants::cacheLineSize; - allocationData.rootDeviceIndex = mockRootDeviceIndex; - allocationData.alignment = MemoryConstants::pageSize; - - auto sharedUSM = memoryManager->createSharedUnifiedMemoryAllocation(allocationData); - EXPECT_EQ(nullptr, sharedUSM); -} \ No newline at end of file diff --git a/shared/test/unit_test/os_interface/linux/drm_query_topology_prelim_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_query_topology_prelim_tests.cpp index 281f743ab8..60794ce374 100644 --- a/shared/test/unit_test/os_interface/linux/drm_query_topology_prelim_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_query_topology_prelim_tests.cpp @@ -342,48 +342,6 @@ TEST(DrmQueryTest, givenPageFaultSupportEnabledWhenCallingQueryPageFaultSupportT } } -TEST(DrmQueryTest, givenPrintIoctlDebugFlagSetWhenCallingQueryPageFaultSupportThenCaptureExpectedOutput) { - DebugManagerStateRestore restore; - debugManager.flags.PrintIoctlEntries.set(true); - - auto executionEnvironment = std::make_unique(); - DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]}; - const auto &productHelper = executionEnvironment->rootDeviceEnvironments[0]->getHelper(); - - bool hasPageFaultSupport = true; - drm.context.hasPageFaultQueryValue = hasPageFaultSupport; - - testing::internal::CaptureStdout(); // start capturing - drm.queryPageFaultSupport(); - debugManager.flags.PrintIoctlEntries.set(false); - std::string outputString = testing::internal::GetCapturedStdout(); // stop capturing - - if (productHelper.isPageFaultSupported()) { - std::string expectedString = "DRM_IOCTL_I915_GETPARAM: param: PRELIM_I915_PARAM_HAS_PAGE_FAULT, output value: 1, retCode: 0\n"; - EXPECT_NE(std::string::npos, outputString.find(expectedString)); - } else { - EXPECT_TRUE(outputString.empty()); - } -} - -TEST(DrmQueryTest, givenPrintIoctlDebugFlagNotSetWhenIsPageFaultSupportedCalledThenNoCapturedOutput) { - DebugManagerStateRestore restore; - debugManager.flags.PrintIoctlEntries.set(false); - - auto executionEnvironment = std::make_unique(); - DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]}; - - bool hasPageFaultSupport = true; - drm.context.hasPageFaultQueryValue = hasPageFaultSupport; - - testing::internal::CaptureStdout(); // start capturing - drm.queryPageFaultSupport(); - debugManager.flags.PrintIoctlEntries.set(false); - std::string outputString = testing::internal::GetCapturedStdout(); // stop capturing - - EXPECT_TRUE(outputString.empty()); -} - TEST(DrmQueryTest, WhenQueryPageFaultSupportFailsThenReturnFalse) { auto executionEnvironment = std::make_unique(); DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]}; diff --git a/shared/test/unit_test/os_interface/linux/xe/CMakeLists.txt b/shared/test/unit_test/os_interface/linux/xe/CMakeLists.txt index 0f471a9aae..4ed9936794 100644 --- a/shared/test/unit_test/os_interface/linux/xe/CMakeLists.txt +++ b/shared/test/unit_test/os_interface/linux/xe/CMakeLists.txt @@ -9,7 +9,6 @@ set(NEO_CORE_OS_INTERFACE_TESTS_LINUX_XE ${CMAKE_CURRENT_SOURCE_DIR}/ioctl_helper_xe_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/ioctl_helper_xe_perf_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ioctl_helper_xe_tests.h - ${CMAKE_CURRENT_SOURCE_DIR}/ioctl_helper_xe_query_features_tests.cpp ) if(NEO_ENABLE_XE_EU_DEBUG_SUPPORT) list(APPEND NEO_CORE_OS_INTERFACE_TESTS_LINUX_XE diff --git a/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_query_features_tests.cpp b/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_query_features_tests.cpp deleted file mode 100644 index 7e04c341b4..0000000000 --- a/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_query_features_tests.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2024 Intel Corporation - * - * SPDX-License-Identifier: MIT - * - */ - -#include "shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.h" - -class DrmMockXeQueryFeatures : public DrmMockXe { - public: - using DrmMockXe::DrmMockXe; - - int ioctl(DrmIoctl request, void *arg) override { - switch (request) { - case DrmIoctl::gemVmCreate: { - auto vmCreate = static_cast(arg); - - if ((vmCreate->flags & DRM_XE_VM_CREATE_FLAG_FAULT_MODE) == DRM_XE_VM_CREATE_FLAG_FAULT_MODE && - (vmCreate->flags & DRM_XE_VM_CREATE_FLAG_LR_MODE) == DRM_XE_VM_CREATE_FLAG_LR_MODE && - (!supportsRecoverablePageFault)) { - return -EINVAL; - } - return 0; - } break; - - default: - return DrmMockXe::ioctl(request, arg); - } - }; - bool supportsRecoverablePageFault = true; -}; - -TEST(IoctlHelperXeQueryFeaturesTest, whenInitializeIoctlHelperThenQueryRecoverablePageFaultSupport) { - auto executionEnvironment = std::make_unique(); - DrmMockXeQueryFeatures drm{*executionEnvironment->rootDeviceEnvironments[0]}; - - for (const auto &recoverablePageFault : ::testing::Bool()) { - drm.supportsRecoverablePageFault = recoverablePageFault; - auto xeIoctlHelper = std::make_unique(drm); - xeIoctlHelper->initialize(); - EXPECT_EQ(xeIoctlHelper->supportedFeatures.flags.pageFault, recoverablePageFault); - } -} \ No newline at end of file diff --git a/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp b/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp index f3bc51fe47..b1c4c9b450 100644 --- a/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp @@ -256,9 +256,9 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingAnyMethodThenDummyValueIsRe EXPECT_EQ(std::nullopt, xeIoctlHelper->getPreferredLocationRegion(PreferredLocation::none, 0)); - EXPECT_TRUE(xeIoctlHelper->setVmBoAdvise(0, 0, nullptr)); + EXPECT_FALSE(xeIoctlHelper->setVmBoAdvise(0, 0, nullptr)); - EXPECT_TRUE(xeIoctlHelper->setVmBoAdviseForChunking(0, 0, 0, 0, nullptr)); + EXPECT_FALSE(xeIoctlHelper->setVmBoAdviseForChunking(0, 0, 0, 0, nullptr)); EXPECT_FALSE(xeIoctlHelper->isChunkingAvailable()); @@ -279,7 +279,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingAnyMethodThenDummyValueIsRe EXPECT_FALSE(xeIoctlHelper->completionFenceExtensionSupported(false)); - EXPECT_EQ(false, xeIoctlHelper->isPageFaultSupported()); + EXPECT_EQ(std::nullopt, xeIoctlHelper->getHasPageFaultParamId()); EXPECT_EQ(nullptr, xeIoctlHelper->createVmControlExtRegion({})); @@ -298,7 +298,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingAnyMethodThenDummyValueIsRe EXPECT_EQ(std::nullopt, xeIoctlHelper->getCopyClassSaturateLinkCapability()); - EXPECT_EQ(std::nullopt, xeIoctlHelper->getVmAdviseAtomicAttribute()); + EXPECT_EQ(0u, xeIoctlHelper->getVmAdviseAtomicAttribute()); VmBindParams vmBindParams{}; EXPECT_EQ(-1, xeIoctlHelper->vmBind(vmBindParams)); @@ -1606,37 +1606,6 @@ TEST(IoctlHelperXeTest, givenVmBindWaitUserFenceTimeoutWhenCallingVmBindThenWait } } -TEST(IoctlHelperXeTest, whenCallingVmBindAndUnbindWithNoResidencyRequiredThenWaitUserFenceIsNotCalled) { - DebugManagerStateRestore restorer; - auto executionEnvironment = std::make_unique(); - DrmMockXe drm{*executionEnvironment->rootDeviceEnvironments[0]}; - auto xeIoctlHelper = std::make_unique(drm); - - BindInfo mockBindInfo{}; - mockBindInfo.handle = 0x1234; - xeIoctlHelper->bindInfo.push_back(mockBindInfo); - - VmBindParams vmBindParams{}; - vmBindParams.handle = mockBindInfo.handle; - - drm.vmBindInputs.clear(); - drm.syncInputs.clear(); - drm.waitUserFenceInputs.clear(); - - EXPECT_EQ(0, xeIoctlHelper->vmBind(vmBindParams)); - EXPECT_EQ(1u, drm.vmBindInputs.size()); - EXPECT_EQ(0u, drm.syncInputs.size()); - EXPECT_EQ(0u, drm.waitUserFenceInputs.size()); - - drm.vmBindInputs.clear(); - drm.syncInputs.clear(); - drm.waitUserFenceInputs.clear(); - EXPECT_EQ(0, xeIoctlHelper->vmUnbind(vmBindParams)); - EXPECT_EQ(1u, drm.vmBindInputs.size()); - EXPECT_EQ(0u, drm.syncInputs.size()); - EXPECT_EQ(0u, drm.waitUserFenceInputs.size()); -} - TEST(IoctlHelperXeTest, whenGemVmBindFailsThenErrorIsPropagated) { DebugManagerStateRestore restorer; auto executionEnvironment = std::make_unique(); @@ -2050,7 +2019,6 @@ TEST(IoctlHelperXeTest, givenMultipleBindInfosWhenVmBindIsCalledThenProperHandle MockIoctlHelperXe::UserFenceExtension userFence{}; userFence.tag = userFence.tagValue; - userFence.addr = 0x1; VmBindParams vmBindParams{}; vmBindParams.userFence = castToUint64(&userFence); vmBindParams.handle = 0;