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 1b8522bdde..fb2a85ff1d 100644 --- a/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp +++ b/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp @@ -160,7 +160,7 @@ bool IoctlHelperXe::queryDeviceIdAndRevision(Drm &drm) { hwInfo->platform.usDeviceID = config->info[DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID] & 0xffff; hwInfo->platform.usRevId = static_cast((config->info[DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID] >> 16) & 0xff); - if ((debugManager.flags.EnableRecoverablePageFaults.get() != 0) && (debugManager.flags.EnableSharedSystemUsmSupport.get() != 0) && (config->info[DRM_XE_QUERY_CONFIG_FLAGS] & DRM_XE_QUERY_CONFIG_FLAG_HAS_CPU_ADDR_MIRROR)) { + if ((debugManager.flags.EnableRecoverablePageFaults.get() != 0) && (debugManager.flags.EnableSharedSystemUsmSupport.get() == 1) && (config->info[DRM_XE_QUERY_CONFIG_FLAGS] & DRM_XE_QUERY_CONFIG_FLAG_HAS_CPU_ADDR_MIRROR)) { drm.setSharedSystemAllocEnable(true); drm.setPageFaultSupported(true); } 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 41fab10525..0c4757207f 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 @@ -2783,6 +2783,7 @@ TEST_F(IoctlHelperXeTest, whenQueryDeviceIdAndRevisionConfigFlagHasGpuAddrMirror MockExecutionEnvironment executionEnvironment{}; std::unique_ptr drm{Drm::create(std::make_unique(0, ""), *executionEnvironment.rootDeviceEnvironments[0])}; DebugManagerStateRestore restore; + debugManager.flags.EnableSharedSystemUsmSupport.set(1); mockIoctl = [](int fileDescriptor, unsigned long int request, void *arg) -> int { if (request == DRM_IOCTL_XE_DEVICE_QUERY) { struct drm_xe_device_query *deviceQuery = static_cast(arg); @@ -2805,6 +2806,33 @@ TEST_F(IoctlHelperXeTest, whenQueryDeviceIdAndRevisionConfigFlagHasGpuAddrMirror EXPECT_TRUE(drm->hasPageFaultSupport()); } +TEST_F(IoctlHelperXeTest, whenQueryDeviceIdAndRevisionConfigFlagHasGpuAddrMirrorSetButDebugFlagNotSetThenSharedSystemAllocEnableFalse) { + MockExecutionEnvironment executionEnvironment{}; + std::unique_ptr drm{Drm::create(std::make_unique(0, ""), *executionEnvironment.rootDeviceEnvironments[0])}; + DebugManagerStateRestore restore; + debugManager.flags.EnableSharedSystemUsmSupport.set(-1); + mockIoctl = [](int fileDescriptor, unsigned long int request, void *arg) -> int { + if (request == DRM_IOCTL_XE_DEVICE_QUERY) { + struct drm_xe_device_query *deviceQuery = static_cast(arg); + if (deviceQuery->query == DRM_XE_DEVICE_QUERY_CONFIG) { + if (deviceQuery->data) { + struct drm_xe_query_config *config = reinterpret_cast(deviceQuery->data); + config->num_params = DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID + 1; + config->info[DRM_XE_QUERY_CONFIG_FLAGS] = DRM_XE_QUERY_CONFIG_FLAG_HAS_CPU_ADDR_MIRROR; + } else { + deviceQuery->size = (DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID + 1) * sizeof(uint64_t); + } + return 0; + } + } + return -1; + }; + + EXPECT_TRUE(IoctlHelperXe::queryDeviceIdAndRevision(*drm)); + EXPECT_FALSE(drm->isSharedSystemAllocEnabled()); + EXPECT_FALSE(drm->hasPageFaultSupport()); +} + TEST_F(IoctlHelperXeTest, whenQueryDeviceIdAndRevisionAndConfigFlagHasGpuAddrMirrorClearThenSharedSystemAllocEnableFalse) { MockExecutionEnvironment executionEnvironment{}; std::unique_ptr drm{Drm::create(std::make_unique(0, ""), *executionEnvironment.rootDeviceEnvironments[0])};