From 62b30fa72c9d94d174b62c73c0e7421e4d992ef9 Mon Sep 17 00:00:00 2001 From: Brandon Yates Date: Tue, 14 Jan 2025 09:32:55 +0000 Subject: [PATCH] feature: Enable page faults for xe driver with debugger on Related-to: NEO-10134 Signed-off-by: Brandon Yates --- .../source/os_interface/linux/xe/ioctl_helper_xe.cpp | 6 +++--- .../linux/xe/ioctl_helper_xe_debugger_tests.cpp | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) 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 dc3510bd4d..7175b0086d 100644 --- a/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp +++ b/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp @@ -968,9 +968,8 @@ int IoctlHelperXe::queryDistances(std::vector &queryItems, std::vecto bool IoctlHelperXe::isPageFaultSupported() { xeLog(" -> IoctlHelperXe::%s %d\n", __FUNCTION__, false); - return false; -}; +} uint32_t IoctlHelperXe::getEuStallFdParameter() { xeLog(" -> IoctlHelperXe::%s\n", __FUNCTION__); @@ -985,7 +984,8 @@ std::unique_ptr IoctlHelperXe::createVmControlExtRegion(const std::op uint32_t IoctlHelperXe::getFlagsForVmCreate(bool disableScratch, bool enablePageFault, bool useVmBind) { xeLog(" -> IoctlHelperXe::%s %d,%d,%d\n", __FUNCTION__, disableScratch, enablePageFault, useVmBind); uint32_t flags = DRM_XE_VM_CREATE_FLAG_LR_MODE; - if (enablePageFault) { + bool debuggingEnabled = drm.getRootDeviceEnvironment().executionEnvironment.isDebuggingEnabled(); + if (enablePageFault || debuggingEnabled) { flags |= DRM_XE_VM_CREATE_FLAG_FAULT_MODE; } if (!disableScratch) { diff --git a/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_debugger_tests.cpp b/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_debugger_tests.cpp index b5162d3545..b0a9270f58 100644 --- a/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_debugger_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_debugger_tests.cpp @@ -436,3 +436,14 @@ TEST_F(IoctlHelperXeTest, givenDebuggingEnabledWhenCallingVmBindThenWaitUserFenc waitUserFence = drm->waitUserFenceInputs[0]; EXPECT_EQ(expectedTimeout, waitUserFence.timeout); } + +TEST_F(IoctlHelperXeTest, givenDebuggingEnabledWhenCallinggetFlagsForVmCreateThenFaultModeIsEnabled) { + auto executionEnvironment = std::make_unique(); + executionEnvironment->setDebuggingMode(DebuggingMode::online); + auto drm = DrmMockXeDebug::create(*executionEnvironment->rootDeviceEnvironments[0]); + auto xeIoctlHelper = std::make_unique(*drm); + uint32_t flags = xeIoctlHelper->getFlagsForVmCreate(false, false, false); + EXPECT_EQ(flags & DRM_XE_VM_CREATE_FLAG_FAULT_MODE, static_cast(DRM_XE_VM_CREATE_FLAG_FAULT_MODE)); + flags = xeIoctlHelper->getFlagsForVmCreate(false, true, false); + EXPECT_EQ(flags & DRM_XE_VM_CREATE_FLAG_FAULT_MODE, static_cast(DRM_XE_VM_CREATE_FLAG_FAULT_MODE)); +} \ No newline at end of file