From dec695f405d95ca08079ed03fe5b84f0dc501eb5 Mon Sep 17 00:00:00 2001 From: "Naklicki, Mateusz" Date: Thu, 19 Dec 2024 16:00:01 +0000 Subject: [PATCH] fix: add scratch page support with xekmd Also explicitly disable it by default. Signed-off-by: Naklicki, Mateusz --- .../os_interface/linux/xe/ioctl_helper_xe.cpp | 3 +++ .../xe2_hpg_core/linux/product_helper_bmg.cpp | 5 +++++ .../xe2_hpg_core/linux/product_helper_lnl.cpp | 5 +++++ .../os_interface/linux/drm_tests.cpp | 2 +- .../linux/xe/ioctl_helper_xe_tests.cpp | 22 ++++++++++++------- .../os_interface/product_helper_tests.cpp | 3 +-- .../linux/product_helper_tests_bmg_linux.cpp | 4 ++-- .../linux/product_helper_tests_lnl_linux.cpp | 4 ++-- 8 files changed, 33 insertions(+), 15 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 2841fdc4fc..f223871f2b 100644 --- a/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp +++ b/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp @@ -968,6 +968,9 @@ uint32_t IoctlHelperXe::getFlagsForVmCreate(bool disableScratch, bool enablePage if (enablePageFault) { flags |= DRM_XE_VM_CREATE_FLAG_FAULT_MODE; } + if (!disableScratch) { + flags |= DRM_XE_VM_CREATE_FLAG_SCRATCH_PAGE; + } return flags; } diff --git a/shared/source/xe2_hpg_core/linux/product_helper_bmg.cpp b/shared/source/xe2_hpg_core/linux/product_helper_bmg.cpp index a28586f30c..f06fc51202 100644 --- a/shared/source/xe2_hpg_core/linux/product_helper_bmg.cpp +++ b/shared/source/xe2_hpg_core/linux/product_helper_bmg.cpp @@ -33,5 +33,10 @@ int ProductHelperHw::configureHardwareCustom(HardwareInfo *hwInfo, O return 0; } +template <> +bool ProductHelperHw::isDisableScratchPagesSupported() const { + return true; +} + template class ProductHelperHw; } // namespace NEO diff --git a/shared/source/xe2_hpg_core/linux/product_helper_lnl.cpp b/shared/source/xe2_hpg_core/linux/product_helper_lnl.cpp index 97d86a83a5..fc9d9f4c5c 100644 --- a/shared/source/xe2_hpg_core/linux/product_helper_lnl.cpp +++ b/shared/source/xe2_hpg_core/linux/product_helper_lnl.cpp @@ -35,5 +35,10 @@ int ProductHelperHw::configureHardwareCustom(HardwareInfo *hwInfo, O return 0; } +template <> +bool ProductHelperHw::isDisableScratchPagesSupported() const { + return true; +} + template class ProductHelperHw; } // namespace NEO diff --git a/shared/test/unit_test/os_interface/linux/drm_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_tests.cpp index e0eac950c3..1f7529a8bf 100644 --- a/shared/test/unit_test/os_interface/linux/drm_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_tests.cpp @@ -1549,7 +1549,7 @@ HWTEST2_F(DrmDisableScratchPagesDefaultTest, } HWTEST2_F(DrmDisableScratchPagesDefaultTest, - givenDefaultDisableScratchPagesThenCheckingGpuFaultCheckIsSetToDefaultAndScratchPageIsEnabled, IsNotPVC) { + givenDefaultDisableScratchPagesThenCheckingGpuFaultCheckIsSetToDefaultAndScratchPageIsEnabled, IsBeforeXeHpcCore) { auto executionEnvironment = std::make_unique(); DrmMockCheckPageFault drm{*executionEnvironment->rootDeviceEnvironments[0]}; drm.configureScratchPagePolicy(); 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 69cc8084f2..a4df3ccbc6 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 @@ -456,14 +456,20 @@ TEST_F(IoctlHelperXeTest, whenGettingFlagsForVmCreateThenPropertValueIsReturned) DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]}; auto xeIoctlHelper = std::make_unique(drm); - EXPECT_EQ(static_cast(DRM_XE_VM_CREATE_FLAG_LR_MODE | DRM_XE_VM_CREATE_FLAG_FAULT_MODE), xeIoctlHelper->getFlagsForVmCreate(true, true, true)); - EXPECT_EQ(static_cast(DRM_XE_VM_CREATE_FLAG_LR_MODE | DRM_XE_VM_CREATE_FLAG_FAULT_MODE), xeIoctlHelper->getFlagsForVmCreate(true, true, false)); - EXPECT_EQ(static_cast(DRM_XE_VM_CREATE_FLAG_LR_MODE | DRM_XE_VM_CREATE_FLAG_FAULT_MODE), xeIoctlHelper->getFlagsForVmCreate(false, true, true)); - EXPECT_EQ(static_cast(DRM_XE_VM_CREATE_FLAG_LR_MODE | DRM_XE_VM_CREATE_FLAG_FAULT_MODE), xeIoctlHelper->getFlagsForVmCreate(false, true, false)); - EXPECT_EQ(static_cast(DRM_XE_VM_CREATE_FLAG_LR_MODE), xeIoctlHelper->getFlagsForVmCreate(true, false, true)); - EXPECT_EQ(static_cast(DRM_XE_VM_CREATE_FLAG_LR_MODE), xeIoctlHelper->getFlagsForVmCreate(true, false, false)); - EXPECT_EQ(static_cast(DRM_XE_VM_CREATE_FLAG_LR_MODE), xeIoctlHelper->getFlagsForVmCreate(false, false, true)); - EXPECT_EQ(static_cast(DRM_XE_VM_CREATE_FLAG_LR_MODE), xeIoctlHelper->getFlagsForVmCreate(false, false, false)); + for (auto &disableScratch : ::testing::Bool()) { + for (auto &enablePageFault : ::testing::Bool()) { + for (auto &useVmBind : ::testing::Bool()) { + auto flags = xeIoctlHelper->getFlagsForVmCreate(disableScratch, enablePageFault, useVmBind); + EXPECT_EQ(static_cast(DRM_XE_VM_CREATE_FLAG_LR_MODE), (flags & DRM_XE_VM_CREATE_FLAG_LR_MODE)); + if (enablePageFault) { + EXPECT_EQ(static_cast(DRM_XE_VM_CREATE_FLAG_FAULT_MODE), (flags & DRM_XE_VM_CREATE_FLAG_FAULT_MODE)); + } + if (!disableScratch) { + EXPECT_EQ(static_cast(DRM_XE_VM_CREATE_FLAG_SCRATCH_PAGE), (flags & DRM_XE_VM_CREATE_FLAG_SCRATCH_PAGE)); + } + } + } + } } TEST_F(IoctlHelperXeTest, whenGettingFlagsForVmBindThenPropertValueIsReturned) { diff --git a/shared/test/unit_test/os_interface/product_helper_tests.cpp b/shared/test/unit_test/os_interface/product_helper_tests.cpp index b1c8a110f8..d647c8e5c4 100644 --- a/shared/test/unit_test/os_interface/product_helper_tests.cpp +++ b/shared/test/unit_test/os_interface/product_helper_tests.cpp @@ -457,8 +457,7 @@ HWTEST_F(ProductHelperTest, givenProductHelperWhenAskedIfKmdMigrationIsSupported EXPECT_FALSE(productHelper->isKmdMigrationSupported()); } -HWTEST2_F(ProductHelperTest, givenProductHelperWhenAskedIfDisableScratchPagesIsSupportedThenReturnFalse, IsNotPVC) { - +HWTEST2_F(ProductHelperTest, givenProductHelperWhenAskedIfDisableScratchPagesIsSupportedThenReturnFalse, IsBeforeXeHpcCore) { EXPECT_FALSE(productHelper->isDisableScratchPagesSupported()); } diff --git a/shared/test/unit_test/xe2_hpg_core/bmg/linux/product_helper_tests_bmg_linux.cpp b/shared/test/unit_test/xe2_hpg_core/bmg/linux/product_helper_tests_bmg_linux.cpp index 5b8e956162..156332805c 100644 --- a/shared/test/unit_test/xe2_hpg_core/bmg/linux/product_helper_tests_bmg_linux.cpp +++ b/shared/test/unit_test/xe2_hpg_core/bmg/linux/product_helper_tests_bmg_linux.cpp @@ -61,8 +61,8 @@ BMGTEST_F(BmgProductHelperLinux, givenProductHelperWhenAskedIsKmdMigrationSuppor EXPECT_FALSE(productHelper->isKmdMigrationSupported()); } -BMGTEST_F(BmgProductHelperLinux, givenProductHelperWhenAskedIsDisableScratchPagesSupportedThenReturnFalse) { - EXPECT_FALSE(productHelper->isDisableScratchPagesSupported()); +BMGTEST_F(BmgProductHelperLinux, givenProductHelperWhenAskedIsDisableScratchPagesSupportedThenReturnTrue) { + EXPECT_TRUE(productHelper->isDisableScratchPagesSupported()); } BMGTEST_F(BmgProductHelperLinux, WhenGtIsSetupThenGtSystemInfoIsCorrect) { diff --git a/shared/test/unit_test/xe2_hpg_core/lnl/linux/product_helper_tests_lnl_linux.cpp b/shared/test/unit_test/xe2_hpg_core/lnl/linux/product_helper_tests_lnl_linux.cpp index 4e5276f21a..e8db2bc36c 100644 --- a/shared/test/unit_test/xe2_hpg_core/lnl/linux/product_helper_tests_lnl_linux.cpp +++ b/shared/test/unit_test/xe2_hpg_core/lnl/linux/product_helper_tests_lnl_linux.cpp @@ -60,8 +60,8 @@ LNLTEST_F(LnlProductHelperLinux, givenProductHelperWhenAskedIsKmdMigrationSuppor EXPECT_FALSE(productHelper->isKmdMigrationSupported()); } -LNLTEST_F(LnlProductHelperLinux, givenProductHelperWhenAskedIsDisableScratchPagesSupportedThenReturnFalse) { - EXPECT_FALSE(productHelper->isDisableScratchPagesSupported()); +LNLTEST_F(LnlProductHelperLinux, givenProductHelperWhenAskedIsDisableScratchPagesSupportedThenReturnTrue) { + EXPECT_TRUE(productHelper->isDisableScratchPagesSupported()); } LNLTEST_F(LnlProductHelperLinux, givenProductHelperWhenCheckDirectSubmissionSupportedThenFalseIsReturned) {