From 4300f0bdbeded83c58f7f78352a5f5bd5b266695 Mon Sep 17 00:00:00 2001 From: Brandon Yates Date: Tue, 14 Jan 2025 00:46:48 +0000 Subject: [PATCH] feature: Enable page faults for xe driver with debugger 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 1b2d732145..52be9d2f9d 100644 --- a/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp +++ b/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp @@ -948,9 +948,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__); @@ -965,7 +964,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; } return flags; 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 cb878acf56..cb87971306 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 @@ -421,3 +421,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