From b597f47a70b07257225589faf10a5dca784782f1 Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Thu, 18 Jul 2024 14:06:28 +0000 Subject: [PATCH] fix: correct number of slice count in configureHwInfoDrm adjust slice count to proper value based on previously calculated max slices and max subslice counts Related-To: NEO-12073 Signed-off-by: Mateusz Jablonski --- .../os_interface/linux/product_helper_drm.cpp | 9 +++- shared/source/os_interface/product_helper.h | 2 +- .../windows/product_helper_drm_stub.cpp | 4 +- .../skl/linux/product_helper_tests_skl.cpp | 2 +- .../linux/product_helper_linux_tests.cpp | 48 ++++++++++++++++++- 5 files changed, 57 insertions(+), 8 deletions(-) diff --git a/shared/source/os_interface/linux/product_helper_drm.cpp b/shared/source/os_interface/linux/product_helper_drm.cpp index 7a846ac61b..24fe81b0a7 100644 --- a/shared/source/os_interface/linux/product_helper_drm.cpp +++ b/shared/source/os_interface/linux/product_helper_drm.cpp @@ -7,6 +7,7 @@ #include "shared/source/debug_settings/debug_settings_manager.h" #include "shared/source/execution_environment/root_device_environment.h" +#include "shared/source/helpers/basic_math.h" #include "shared/source/helpers/constants.h" #include "shared/source/helpers/hw_info.h" #include "shared/source/os_interface/linux/drm_neo.h" @@ -62,7 +63,7 @@ int configureCacheInfo(HardwareInfo *hwInfo) { return 0; } -int ProductHelper::configureHwInfoDrm(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, const RootDeviceEnvironment &rootDeviceEnvironment) { +int ProductHelper::configureHwInfoDrm(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, const RootDeviceEnvironment &rootDeviceEnvironment) const { int ret = 0; auto osInterface = rootDeviceEnvironment.osInterface.get(); Drm *drm = osInterface->getDriverModel()->as(); @@ -111,9 +112,13 @@ int ProductHelper::configureHwInfoDrm(const HardwareInfo *inHwInfo, HardwareInfo gtSystemInfo->MaxEuPerSubSlice = gtSystemInfo->MaxEuPerSubSlice != 0 ? gtSystemInfo->MaxEuPerSubSlice : topologyData.maxEuPerSubSlice; gtSystemInfo->MaxSubSlicesSupported = std::max(static_cast(topologyData.maxSubSliceCount * topologyData.maxSliceCount), gtSystemInfo->MaxSubSlicesSupported); - gtSystemInfo->MaxSlicesSupported = topologyData.maxSliceCount; + gtSystemInfo->MaxSlicesSupported = std::max(static_cast(topologyData.maxSliceCount), gtSystemInfo->MaxSlicesSupported); gtSystemInfo->MaxDualSubSlicesSupported = gtSystemInfo->MaxSubSlicesSupported; + UNRECOVERABLE_IF(gtSystemInfo->MaxSlicesSupported == 0); + auto maxDssPerSlice = gtSystemInfo->MaxDualSubSlicesSupported / gtSystemInfo->MaxSlicesSupported; + gtSystemInfo->SliceCount = static_cast(Math::divideAndRoundUp(gtSystemInfo->DualSubSliceCount, maxDssPerSlice)); + gtSystemInfo->IsDynamicallyPopulated = true; for (uint32_t slice = 0; slice < GT_MAX_SLICE; slice++) { gtSystemInfo->SliceInfo[slice].Enabled = slice < gtSystemInfo->SliceCount; diff --git a/shared/source/os_interface/product_helper.h b/shared/source/os_interface/product_helper.h index 45965f104d..215733b874 100644 --- a/shared/source/os_interface/product_helper.h +++ b/shared/source/os_interface/product_helper.h @@ -74,7 +74,7 @@ class ProductHelper { static constexpr uint32_t uuidSize = 16u; static constexpr uint32_t luidSize = 8u; MOCKABLE_VIRTUAL int configureHwInfoWddm(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, const RootDeviceEnvironment &rootDeviceEnvironment); - int configureHwInfoDrm(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, const RootDeviceEnvironment &rootDeviceEnvironment); + int configureHwInfoDrm(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, const RootDeviceEnvironment &rootDeviceEnvironment) const; virtual int configureHardwareCustom(HardwareInfo *hwInfo, OSInterface *osIface) const = 0; virtual void adjustPlatformForProductFamily(HardwareInfo *hwInfo) = 0; virtual void adjustSamplerState(void *sampler, const HardwareInfo &hwInfo) const = 0; diff --git a/shared/source/os_interface/windows/product_helper_drm_stub.cpp b/shared/source/os_interface/windows/product_helper_drm_stub.cpp index a539d292b2..25816d1bec 100644 --- a/shared/source/os_interface/windows/product_helper_drm_stub.cpp +++ b/shared/source/os_interface/windows/product_helper_drm_stub.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2023 Intel Corporation + * Copyright (C) 2021-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -11,7 +11,7 @@ namespace NEO { -int ProductHelper::configureHwInfoDrm(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, const RootDeviceEnvironment &rootDeviceEnvironment) { +int ProductHelper::configureHwInfoDrm(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, const RootDeviceEnvironment &rootDeviceEnvironment) const { UNRECOVERABLE_IF(true); return {}; } diff --git a/shared/test/unit_test/gen9/skl/linux/product_helper_tests_skl.cpp b/shared/test/unit_test/gen9/skl/linux/product_helper_tests_skl.cpp index 0c02ab9935..017f73bde0 100644 --- a/shared/test/unit_test/gen9/skl/linux/product_helper_tests_skl.cpp +++ b/shared/test/unit_test/gen9/skl/linux/product_helper_tests_skl.cpp @@ -65,7 +65,7 @@ SKLTEST_F(SklProductHelperLinux, WhenConfiguringHwInfoThenInformationIsCorrect) EXPECT_EQ(0, ret); EXPECT_EQ((uint32_t)drm->storedEUVal, outHwInfo.gtSystemInfo.EUCount); EXPECT_EQ((uint32_t)drm->storedSSVal, outHwInfo.gtSystemInfo.SubSliceCount); - EXPECT_EQ(1u, outHwInfo.gtSystemInfo.SliceCount); + EXPECT_EQ(2u, outHwInfo.gtSystemInfo.SliceCount); EXPECT_EQ(aub_stream::ENGINE_RCS, outHwInfo.capabilityTable.defaultEngineType); auto &outKmdNotifyProperties = outHwInfo.capabilityTable.kmdNotifyProperties; diff --git a/shared/test/unit_test/os_interface/linux/product_helper_linux_tests.cpp b/shared/test/unit_test/os_interface/linux/product_helper_linux_tests.cpp index 5071e4b739..e742e122de 100644 --- a/shared/test/unit_test/os_interface/linux/product_helper_linux_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/product_helper_linux_tests.cpp @@ -10,6 +10,7 @@ #include "shared/source/command_stream/preemption_mode.h" #include "shared/source/helpers/gfx_core_helper.h" #include "shared/source/os_interface/linux/i915.h" +#include "shared/source/os_interface/linux/system_info.h" #include "shared/source/os_interface/os_interface.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/default_hw_info.h" @@ -393,7 +394,7 @@ HWTEST2_F(HwConfigLinux, GivenDifferentValuesFromTopologyQueryWhenConfiguringHwI EXPECT_EQ(static_cast(drm->storedSSVal * 2), outHwInfo.gtSystemInfo.MaxSubSlicesSupported); EXPECT_EQ(static_cast(drm->storedSSVal * 2), outHwInfo.gtSystemInfo.MaxDualSubSlicesSupported); EXPECT_EQ(16u, outHwInfo.gtSystemInfo.MaxEuPerSubSlice); - EXPECT_EQ(static_cast(drm->storedSVal), outHwInfo.gtSystemInfo.MaxSlicesSupported); + EXPECT_EQ(static_cast(drm->storedSVal * 4), outHwInfo.gtSystemInfo.MaxSlicesSupported); drm->storedSVal = 3; drm->storedSSVal = 12; @@ -434,9 +435,14 @@ HWTEST2_F(HwConfigLinux, givenSliceCountWhenConfigureHwInfoDrmThenProperInitiali auto hwInfo = *executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo(); HardwareInfo outHwInfo; auto &productHelper = executionEnvironment->rootDeviceEnvironments[0]->getHelper(); + + uint32_t subslicePerSlicePerSliceCount = 2; uint32_t sliceCount = 4; drm->storedSVal = sliceCount; - hwInfo.gtSystemInfo.SliceCount = sliceCount; + drm->storedSSVal = sliceCount * subslicePerSlicePerSliceCount; + + hwInfo.gtSystemInfo.MaxSubSlicesSupported = drm->storedSSVal; + hwInfo.gtSystemInfo.MaxDualSubSlicesSupported = drm->storedSSVal; int ret = productHelper.configureHwInfoDrm(&hwInfo, &outHwInfo, *executionEnvironment->rootDeviceEnvironments[0].get()); EXPECT_EQ(0, ret); @@ -450,3 +456,41 @@ HWTEST2_F(ProductHelperTest, givenProductHelperWhenIsPlatformQueryNotSupportedTh EXPECT_TRUE(productHelper->isPlatformQuerySupported()); } + +TEST(ConfigureHwInfoDrmTest, givenFlatSubsliceInfoRepresentationWhenConfigureHwInfoDrmThenCorrectTopologyBasedOnMaxSubslicePerSliceCount) { + auto executionEnvironment = std::make_unique(); + executionEnvironment->rootDeviceEnvironments[0]->initGmm(); + auto &rootDeviceEnvironment = *executionEnvironment->rootDeviceEnvironments[0]; + HardwareInfo &hwInfo = *rootDeviceEnvironment.getMutableHardwareInfo(); + const auto >SystemInfo = hwInfo.gtSystemInfo; + + auto drm = std::make_unique(rootDeviceEnvironment); + drm->querySystemInfo(); + + auto systemInfo = drm->getSystemInfo(); + EXPECT_NE(nullptr, systemInfo); + + drm->storedSSVal = systemInfo->getMaxDualSubSlicesSupported() - 1; + drm->storedEUVal = drm->storedSSVal * systemInfo->getMaxEuPerDualSubSlice(); + auto setupHardwareInfo = [](HardwareInfo *, bool, const ReleaseHelper *) {}; + DeviceDescriptor device = {0, &hwInfo, setupHardwareInfo}; + + int ret = drm->setupHardwareInfo(&device, false); + EXPECT_EQ(ret, 0); + systemInfo = drm->getSystemInfo(); + EXPECT_NE(nullptr, systemInfo); + + rootDeviceEnvironment.osInterface.reset(new OSInterface()); + auto osInterface = executionEnvironment->rootDeviceEnvironments[0]->osInterface.get(); + osInterface->setDriverModel(std::move(drm)); + + rootDeviceEnvironment.productHelper = std::make_unique>(); + + auto &productHelper = rootDeviceEnvironment.getProductHelper(); + productHelper.configureHwInfoDrm(&hwInfo, &hwInfo, rootDeviceEnvironment); + + EXPECT_EQ(gtSystemInfo.MaxSlicesSupported, systemInfo->getMaxSlicesSupported()); + EXPECT_EQ(gtSystemInfo.SliceCount, systemInfo->getMaxSlicesSupported()); + EXPECT_EQ(gtSystemInfo.SubSliceCount, systemInfo->getMaxDualSubSlicesSupported() - 1); + EXPECT_EQ(gtSystemInfo.DualSubSliceCount, systemInfo->getMaxDualSubSlicesSupported() - 1); +}