From 8ae4a3bc7aa6afabf6113a1b2bbd25f9ff894574 Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Wed, 6 Mar 2024 10:03:52 +0000 Subject: [PATCH] fix: pass Sku/Wa tables for gmm without additional translations on Windows Related-To: NEO-10623 Signed-off-by: Mateusz Jablonski --- .../client_context/gmm_client_context.cpp | 6 +-- .../windows/wddm/set_gmm_input_args_wddm.cpp | 2 + .../source/os_interface/windows/wddm/wddm.cpp | 4 ++ .../source/os_interface/windows/wddm/wddm.h | 3 ++ shared/test/common/mocks/mock_wddm.h | 4 +- .../unit_test/gmm_helper/gmm_helper_tests.cpp | 23 ------------ .../linux/os_interface_linux_tests.cpp | 37 ++++++++++++++++++- .../windows/os_interface_win_tests.cpp | 34 ++++++++++++----- 8 files changed, 75 insertions(+), 38 deletions(-) diff --git a/shared/source/gmm_helper/client_context/gmm_client_context.cpp b/shared/source/gmm_helper/client_context/gmm_client_context.cpp index 0c47727e3f..583b1f7fd9 100644 --- a/shared/source/gmm_helper/client_context/gmm_client_context.cpp +++ b/shared/source/gmm_helper/client_context/gmm_client_context.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2022 Intel Corporation + * Copyright (C) 2018-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -26,9 +26,9 @@ GmmClientContext::GmmClientContext(const RootDeviceEnvironment &rootDeviceEnviro GMM_INIT_IN_ARGS inArgs{}; GMM_INIT_OUT_ARGS outArgs{}; - auto gtSystemInfo = hardwareInfo->gtSystemInfo; + const auto >SystemInfo = hardwareInfo->gtSystemInfo; inArgs.ClientType = GMM_CLIENT::GMM_OCL_VISTA; - inArgs.pGtSysInfo = >SystemInfo; + inArgs.pGtSysInfo = const_cast(>SystemInfo); inArgs.pSkuTable = &gmmFtrTable; inArgs.pWaTable = &gmmWaTable; inArgs.Platform = hardwareInfo->platform; diff --git a/shared/source/os_interface/windows/wddm/set_gmm_input_args_wddm.cpp b/shared/source/os_interface/windows/wddm/set_gmm_input_args_wddm.cpp index a775f7d96d..d9d98f0fab 100644 --- a/shared/source/os_interface/windows/wddm/set_gmm_input_args_wddm.cpp +++ b/shared/source/os_interface/windows/wddm/set_gmm_input_args_wddm.cpp @@ -15,6 +15,8 @@ void Wddm::setGmmInputArgs(void *args) { gmmInArgs->Platform.eRenderCoreFamily = gfxPlatform->eRenderCoreFamily; gmmInArgs->Platform.eDisplayCoreFamily = gfxPlatform->eDisplayCoreFamily; + gmmInArgs->pSkuTable = gfxFeatureTable.get(); + gmmInArgs->pWaTable = gfxWorkaroundTable.get(); gmmInArgs->stAdapterBDF = this->adapterBDF; gmmInArgs->ClientType = GMM_CLIENT::GMM_OCL_VISTA; diff --git a/shared/source/os_interface/windows/wddm/wddm.cpp b/shared/source/os_interface/windows/wddm/wddm.cpp index ac9d19e668..4d57954d9d 100644 --- a/shared/source/os_interface/windows/wddm/wddm.cpp +++ b/shared/source/os_interface/windows/wddm/wddm.cpp @@ -62,6 +62,8 @@ Wddm::Wddm(std::unique_ptr &&hwDeviceIdIn, RootDeviceEnvironment workaroundTable.reset(new WorkaroundTable()); gtSystemInfo.reset(new GT_SYSTEM_INFO); gfxPlatform.reset(new PLATFORM_KMD); + gfxFeatureTable.reset(new SKU_FEATURE_TABLE_KMD); + gfxWorkaroundTable.reset(new WA_TABLE_KMD); memset(gtSystemInfo.get(), 0, sizeof(*gtSystemInfo)); memset(gfxPlatform.get(), 0, sizeof(*gfxPlatform)); this->enablePreemptionRegValue = NEO::readEnablePreemptionRegKey(); @@ -267,6 +269,8 @@ bool Wddm::queryAdapterInfo() { if (status == STATUS_SUCCESS) { memcpy_s(gtSystemInfo.get(), sizeof(GT_SYSTEM_INFO), &adapterInfo.SystemInfo, sizeof(GT_SYSTEM_INFO)); memcpy_s(gfxPlatform.get(), sizeof(PLATFORM_KMD), &adapterInfo.GfxPlatform, sizeof(PLATFORM_KMD)); + memcpy_s(gfxFeatureTable.get(), sizeof(SKU_FEATURE_TABLE_KMD), &adapterInfo.SkuTable, sizeof(SKU_FEATURE_TABLE_KMD)); + memcpy_s(gfxWorkaroundTable.get(), sizeof(WA_TABLE_KMD), &adapterInfo.WaTable, sizeof(WA_TABLE_KMD)); if (debugManager.flags.ForceDeviceId.get() != "unk") { gfxPlatform->usDeviceID = static_cast(std::stoi(debugManager.flags.ForceDeviceId.get(), nullptr, 16)); diff --git a/shared/source/os_interface/windows/wddm/wddm.h b/shared/source/os_interface/windows/wddm/wddm.h index dd8d2a5793..401e6ed982 100644 --- a/shared/source/os_interface/windows/wddm/wddm.h +++ b/shared/source/os_interface/windows/wddm/wddm.h @@ -261,6 +261,9 @@ class Wddm : public DriverModel { std::unique_ptr featureTable; std::unique_ptr workaroundTable; + std::unique_ptr gfxFeatureTable; + std::unique_ptr gfxWorkaroundTable; + std::unique_ptr hwDeviceId; std::unique_ptr gmmMemory; std::unique_ptr kmDafListener; diff --git a/shared/test/common/mocks/mock_wddm.h b/shared/test/common/mocks/mock_wddm.h index 2ebb104dc1..73ca96daf6 100644 --- a/shared/test/common/mocks/mock_wddm.h +++ b/shared/test/common/mocks/mock_wddm.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2023 Intel Corporation + * Copyright (C) 2018-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -41,7 +41,9 @@ class WddmMock : public Wddm { using Wddm::forceEvictOnlyIfNecessary; using Wddm::getDeviceState; using Wddm::getSystemInfo; + using Wddm::gfxFeatureTable; using Wddm::gfxPlatform; + using Wddm::gfxWorkaroundTable; using Wddm::gmmMemory; using Wddm::hwDeviceId; using Wddm::mapGpuVirtualAddress; diff --git a/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp b/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp index 3a24a472fe..9f43742329 100644 --- a/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp +++ b/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp @@ -920,29 +920,6 @@ TEST_F(GmmEnvironmentTest, whenGmmHelperIsInitializedThenClientContextIsSet) { ASSERT_NE(nullptr, getGmmHelper()); EXPECT_NE(nullptr, getGmmClientContext()->getHandle()); } - -TEST_F(GmmHelperTests, givenValidGmmFunctionsWhenCreateGmmHelperWithInitializedOsInterfaceThenProperParametersArePassed) { - DeviceFactory::prepareDeviceEnvironments(*executionEnvironment); - VariableBackup passedInputArgsBackup(&passedInputArgs); - VariableBackup passedFtrTableBackup(&passedFtrTable); - VariableBackup passedGtSystemInfoBackup(&passedGtSystemInfo); - VariableBackup passedWaTableBackup(&passedWaTable); - VariableBackup copyInputArgsBackup(©InputArgs, true); - - auto hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo(); - SKU_FEATURE_TABLE expectedFtrTable = {}; - WA_TABLE expectedWaTable = {}; - SkuInfoTransfer::transferFtrTableForGmm(&expectedFtrTable, &hwInfo->featureTable); - SkuInfoTransfer::transferWaTableForGmm(&expectedWaTable, &hwInfo->workaroundTable); - - auto gmmHelper = std::make_unique(*executionEnvironment->rootDeviceEnvironments[0]); - EXPECT_EQ(0, memcmp(&hwInfo->platform, &passedInputArgs.Platform, sizeof(PLATFORM))); - EXPECT_EQ(0, memcmp(&hwInfo->gtSystemInfo, &passedGtSystemInfo, sizeof(GT_SYSTEM_INFO))); - EXPECT_EQ(0, memcmp(&expectedFtrTable, &passedFtrTable, sizeof(SKU_FEATURE_TABLE))); - EXPECT_EQ(0, memcmp(&expectedWaTable, &passedWaTable, sizeof(WA_TABLE))); - EXPECT_EQ(GMM_CLIENT::GMM_OCL_VISTA, passedInputArgs.ClientType); -} - TEST(GmmHelperTest, givenValidGmmFunctionsWhenCreateGmmHelperWithoutOsInterfaceThenInitializationDoesntCrashAndProperParametersArePassed) { VariableBackup passedInputArgsBackup(&passedInputArgs); VariableBackup passedFtrTableBackup(&passedFtrTable); diff --git a/shared/test/unit_test/os_interface/linux/os_interface_linux_tests.cpp b/shared/test/unit_test/os_interface/linux/os_interface_linux_tests.cpp index 9c0821700b..46347834c2 100644 --- a/shared/test/unit_test/os_interface/linux/os_interface_linux_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/os_interface_linux_tests.cpp @@ -1,20 +1,28 @@ /* - * Copyright (C) 2018-2023 Intel Corporation + * Copyright (C) 2018-2024 Intel Corporation * * SPDX-License-Identifier: MIT * */ #include "shared/source/command_stream/preemption.h" +#include "shared/source/gmm_helper/gmm_helper.h" #include "shared/source/helpers/gfx_core_helper.h" #include "shared/source/os_interface/linux/os_context_linux.h" #include "shared/source/os_interface/os_interface.h" +#include "shared/source/sku_info/operations/sku_info_transfer.h" +#include "shared/test/common/helpers/variable_backup.h" #include "shared/test/common/libult/linux/drm_mock.h" #include "shared/test/common/mocks/mock_execution_environment.h" #include "gtest/gtest.h" namespace NEO { +extern GMM_INIT_IN_ARGS passedInputArgs; +extern GT_SYSTEM_INFO passedGtSystemInfo; +extern SKU_FEATURE_TABLE passedFtrTable; +extern WA_TABLE passedWaTable; +extern bool copyInputArgs; TEST(OsInterfaceTest, GivenLinuxWhenCallingAre64kbPagesEnabledThenReturnFalse) { EXPECT_FALSE(OSInterface::are64kbPagesEnabled()); @@ -47,4 +55,31 @@ TEST(OsInterfaceTest, GivenLinuxOsInterfaceWhenCallingIsDebugAttachAvailableThen EXPECT_FALSE(osInterface.isDebugAttachAvailable()); } +TEST(OsInterfaceTest, whenOsInterfaceSetupGmmInputArgsThenArgsAreSet) { + MockExecutionEnvironment executionEnvironment{}; + auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0]; + auto drm = std::make_unique(rootDeviceEnvironment); + rootDeviceEnvironment.osInterface = std::make_unique(); + rootDeviceEnvironment.osInterface->setDriverModel(std::move(drm)); + + VariableBackup passedInputArgsBackup(&passedInputArgs); + VariableBackup passedFtrTableBackup(&passedFtrTable); + VariableBackup passedGtSystemInfoBackup(&passedGtSystemInfo); + VariableBackup passedWaTableBackup(&passedWaTable); + VariableBackup copyInputArgsBackup(©InputArgs, true); + + auto hwInfo = rootDeviceEnvironment.getHardwareInfo(); + SKU_FEATURE_TABLE expectedFtrTable = {}; + WA_TABLE expectedWaTable = {}; + SkuInfoTransfer::transferFtrTableForGmm(&expectedFtrTable, &hwInfo->featureTable); + SkuInfoTransfer::transferWaTableForGmm(&expectedWaTable, &hwInfo->workaroundTable); + + auto gmmHelper = std::make_unique(rootDeviceEnvironment); + EXPECT_EQ(0, memcmp(&hwInfo->platform, &passedInputArgs.Platform, sizeof(PLATFORM))); + EXPECT_EQ(&hwInfo->gtSystemInfo, passedInputArgs.pGtSysInfo); + EXPECT_EQ(0, memcmp(&expectedFtrTable, &passedFtrTable, sizeof(SKU_FEATURE_TABLE))); + EXPECT_EQ(0, memcmp(&expectedWaTable, &passedWaTable, sizeof(WA_TABLE))); + EXPECT_EQ(GMM_CLIENT::GMM_OCL_VISTA, passedInputArgs.ClientType); +} + } // namespace NEO diff --git a/shared/test/unit_test/os_interface/windows/os_interface_win_tests.cpp b/shared/test/unit_test/os_interface/windows/os_interface_win_tests.cpp index 8508fa32d1..cde2fe3679 100644 --- a/shared/test/unit_test/os_interface/windows/os_interface_win_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/os_interface_win_tests.cpp @@ -8,12 +8,21 @@ #include "shared/test/unit_test/os_interface/windows/os_interface_win_tests.h" #include "shared/source/execution_environment/root_device_environment.h" +#include "shared/source/gmm_helper/gmm_helper.h" #include "shared/source/os_interface/windows/os_context_win.h" #include "shared/source/os_interface/windows/sys_calls.h" #include "shared/test/common/helpers/engine_descriptor_helper.h" #include "shared/test/common/mocks/mock_execution_environment.h" #include "shared/test/common/os_interface/windows/wddm_fixture.h" +namespace NEO { +extern GMM_INIT_IN_ARGS passedInputArgs; +extern GT_SYSTEM_INFO passedGtSystemInfo; +extern SKU_FEATURE_TABLE passedFtrTable; +extern WA_TABLE passedWaTable; +extern bool copyInputArgs; +} // namespace NEO + TEST_F(OsInterfaceTest, GivenWindowsWhenOsSupportFor64KBpagesIsBeingQueriedThenTrueIsReturned) { EXPECT_TRUE(OSInterface::are64kbPagesEnabled()); } @@ -54,7 +63,7 @@ TEST_F(OsInterfaceTest, GivenDefaultOsInterfaceThenLocalMemoryEnabled) { TEST_F(OsInterfaceTest, whenOsInterfaceSetupGmmInputArgsThenArgsAreSet) { MockExecutionEnvironment executionEnvironment; - RootDeviceEnvironment rootDeviceEnvironment(executionEnvironment); + auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0]; auto wddm = new WddmMock(rootDeviceEnvironment); EXPECT_EQ(nullptr, rootDeviceEnvironment.osInterface.get()); wddm->init(); @@ -74,15 +83,20 @@ TEST_F(OsInterfaceTest, whenOsInterfaceSetupGmmInputArgsThenArgsAreSet) { uint32_t function = 0x56; adapterBDF.Function = function; - GMM_INIT_IN_ARGS gmmInputArgs = {}; - EXPECT_NE(0, memcmp(&wddm->adapterBDF, &gmmInputArgs.stAdapterBDF, sizeof(ADAPTER_BDF))); - EXPECT_STRNE(expectedRegistryPath, gmmInputArgs.DeviceRegistryPath); + VariableBackup passedInputArgsBackup(&passedInputArgs); + VariableBackup passedFtrTableBackup(&passedFtrTable); + VariableBackup passedGtSystemInfoBackup(&passedGtSystemInfo); + VariableBackup passedWaTableBackup(&passedWaTable); + VariableBackup copyInputArgsBackup(©InputArgs, true); - rootDeviceEnvironment.osInterface->getDriverModel()->setGmmInputArgs(&gmmInputArgs); + auto gmmHelper = std::make_unique(rootDeviceEnvironment); - EXPECT_EQ(0, memcmp(&wddm->adapterBDF, &gmmInputArgs.stAdapterBDF, sizeof(ADAPTER_BDF))); - EXPECT_EQ(GMM_CLIENT::GMM_OCL_VISTA, gmmInputArgs.ClientType); - EXPECT_STREQ(expectedRegistryPath, gmmInputArgs.DeviceRegistryPath); - EXPECT_EQ(expectedCoreFamily, gmmInputArgs.Platform.eRenderCoreFamily); - EXPECT_EQ(expectedCoreFamily, gmmInputArgs.Platform.eDisplayCoreFamily); + EXPECT_EQ(0, memcmp(&wddm->adapterBDF, &passedInputArgs.stAdapterBDF, sizeof(ADAPTER_BDF))); + EXPECT_EQ(GMM_CLIENT::GMM_OCL_VISTA, passedInputArgs.ClientType); + EXPECT_STREQ(expectedRegistryPath, passedInputArgs.DeviceRegistryPath); + EXPECT_EQ(expectedCoreFamily, passedInputArgs.Platform.eRenderCoreFamily); + EXPECT_EQ(expectedCoreFamily, passedInputArgs.Platform.eDisplayCoreFamily); + EXPECT_EQ(wddm->gfxFeatureTable.get(), passedInputArgs.pSkuTable); + EXPECT_EQ(wddm->gfxWorkaroundTable.get(), passedInputArgs.pWaTable); + EXPECT_EQ(&rootDeviceEnvironment.getHardwareInfo()->gtSystemInfo, passedInputArgs.pGtSysInfo); } \ No newline at end of file