diff --git a/shared/source/execution_environment/root_device_environment.cpp b/shared/source/execution_environment/root_device_environment.cpp index f0177a7112..6f5811a854 100644 --- a/shared/source/execution_environment/root_device_environment.cpp +++ b/shared/source/execution_environment/root_device_environment.cpp @@ -86,6 +86,10 @@ void RootDeviceEnvironment::setHwInfoAndInitHelpers(const HardwareInfo *hwInfo) initHelpers(); } +void RootDeviceEnvironment::setHwInfo(const HardwareInfo *hwInfo) { + *this->hwInfo = *hwInfo; +} + bool RootDeviceEnvironment::isFullRangeSvm() const { return hwInfo->capabilityTable.gpuAddressSpace >= maxNBitValue(47); } diff --git a/shared/source/execution_environment/root_device_environment.h b/shared/source/execution_environment/root_device_environment.h index ef475d906e..32e81bae04 100644 --- a/shared/source/execution_environment/root_device_environment.h +++ b/shared/source/execution_environment/root_device_environment.h @@ -55,6 +55,7 @@ struct RootDeviceEnvironment { MOCKABLE_VIRTUAL const HardwareInfo *getHardwareInfo() const; HardwareInfo *getMutableHardwareInfo() const; void setHwInfoAndInitHelpers(const HardwareInfo *hwInfo); + void setHwInfo(const HardwareInfo *hwInfo); bool isFullRangeSvm() const; bool isWddmOnLinux() const; diff --git a/shared/source/os_interface/device_factory.cpp b/shared/source/os_interface/device_factory.cpp index 6c64dcea47..8154420f35 100644 --- a/shared/source/os_interface/device_factory.cpp +++ b/shared/source/os_interface/device_factory.cpp @@ -57,7 +57,13 @@ bool DeviceFactory::prepareDeviceEnvironmentsForProductFamilyOverride(ExecutionE for (auto rootDeviceIndex = 0u; rootDeviceIndex < numRootDevices; rootDeviceIndex++) { auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[rootDeviceIndex].get(); - rootDeviceEnvironment.setHwInfoAndInitHelpers(hwInfoConst); + rootDeviceEnvironment.setHwInfo(hwInfoConst); + + rootDeviceEnvironment.initProductHelper(); + rootDeviceEnvironment.initGfxCoreHelper(); + rootDeviceEnvironment.initApiGfxCoreHelper(); + rootDeviceEnvironment.initCompilerProductHelper(); + auto hardwareInfo = rootDeviceEnvironment.getMutableHardwareInfo(); if (DebugManager.flags.OverrideRevision.get() != -1) { @@ -92,6 +98,8 @@ bool DeviceFactory::prepareDeviceEnvironmentsForProductFamilyOverride(ExecutionE hardwareInfo->ipVersion = DebugManager.flags.OverrideHwIpVersion.get(); } + rootDeviceEnvironment.initReleaseHelper(); + if (DebugManager.flags.OverrideGpuAddressSpace.get() != -1) { hardwareInfo->capabilityTable.gpuAddressSpace = maxNBitValue(static_cast(DebugManager.flags.OverrideGpuAddressSpace.get())); } diff --git a/shared/source/os_interface/linux/drm_neo.cpp b/shared/source/os_interface/linux/drm_neo.cpp index 7894b015d7..3d3efd6729 100644 --- a/shared/source/os_interface/linux/drm_neo.cpp +++ b/shared/source/os_interface/linux/drm_neo.cpp @@ -430,7 +430,11 @@ int Drm::setupHardwareInfo(const DeviceDescriptor *device, bool setupFeatureTabl auto deviceId = hwInfo->platform.usDeviceID; auto revisionId = hwInfo->platform.usRevId; - rootDeviceEnvironment.setHwInfoAndInitHelpers(device->pHwInfo); + rootDeviceEnvironment.setHwInfo(device->pHwInfo); + rootDeviceEnvironment.initProductHelper(); + rootDeviceEnvironment.initGfxCoreHelper(); + rootDeviceEnvironment.initApiGfxCoreHelper(); + rootDeviceEnvironment.initCompilerProductHelper(); hwInfo->platform.usDeviceID = deviceId; hwInfo->platform.usRevId = revisionId; @@ -438,6 +442,7 @@ int Drm::setupHardwareInfo(const DeviceDescriptor *device, bool setupFeatureTabl const auto productFamily = hwInfo->platform.eProductFamily; setupIoctlHelper(productFamily); ioctlHelper->setupIpVersion(); + rootDeviceEnvironment.initReleaseHelper(); Drm::QueryTopologyData topologyData = {}; diff --git a/shared/test/unit_test/os_interface/device_factory_tests.cpp b/shared/test/unit_test/os_interface/device_factory_tests.cpp index 799b22bf13..d1acbd79cc 100644 --- a/shared/test/unit_test/os_interface/device_factory_tests.cpp +++ b/shared/test/unit_test/os_interface/device_factory_tests.cpp @@ -7,6 +7,7 @@ #include "shared/source/helpers/product_config_helper.h" #include "shared/source/os_interface/device_factory.h" +#include "shared/source/release_helper/release_helper.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/default_hw_info.h" #include "shared/test/common/mocks/mock_execution_environment.h" @@ -48,6 +49,27 @@ TEST_F(DeviceFactoryTests, givenHwIpVersionOverrideWhenPrepareDeviceEnvironments EXPECT_NE(0u, executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo()->platform.usDeviceID); } +TEST_F(DeviceFactoryTests, givenHwIpVersionOverrideWhenPrepareDeviceEnvironmentsForProductFamilyOverrideIsCalledThenReleaseHelperContainsCorrectIpVersion) { + MockExecutionEnvironment executionEnvironment(defaultHwInfo.get()); + auto config = defaultHwInfo.get()->ipVersion.value; + DebugManager.flags.OverrideHwIpVersion.set(config); + + bool success = DeviceFactory::prepareDeviceEnvironmentsForProductFamilyOverride(executionEnvironment); + ASSERT_TRUE(success); + auto *releaseHelper = executionEnvironment.rootDeviceEnvironments[0]->getReleaseHelper(); + + if (releaseHelper == nullptr) { + GTEST_SKIP(); + } + class ReleaseHelperExpose : public ReleaseHelper { + public: + using ReleaseHelper::hardwareIpVersion; + }; + + ReleaseHelperExpose *exposedReleaseHelper = static_cast(releaseHelper); + EXPECT_EQ(config, exposedReleaseHelper->hardwareIpVersion.value); +} + TEST_F(DeviceFactoryTests, givenHwIpVersionAndDeviceIdOverrideWhenPrepareDeviceEnvironmentsForProductFamilyOverrideIsCalledThenCorrectValueIsSet) { MockExecutionEnvironment executionEnvironment(defaultHwInfo.get()); auto config = defaultHwInfo.get()->ipVersion.value; diff --git a/shared/test/unit_test/os_interface/linux/drm_system_info_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_system_info_tests.cpp index 6a18eb2a9f..ae61b7cb80 100644 --- a/shared/test/unit_test/os_interface/linux/drm_system_info_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_system_info_tests.cpp @@ -8,6 +8,7 @@ #include "shared/source/os_interface/linux/ioctl_helper.h" #include "shared/source/os_interface/linux/system_info.h" #include "shared/source/os_interface/product_helper.h" +#include "shared/source/release_helper/release_helper.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/default_hw_info.h" #include "shared/test/common/helpers/gtest_helpers.h" @@ -89,6 +90,49 @@ TEST(DrmSystemInfoTest, givenSetupHardwareInfoWhenQuerySystemInfoFalseThenSystem EXPECT_TRUE(isEmpty(::testing::internal::GetCapturedStderr())); } +TEST(DrmSystemInfoTest, whenSetupHardwareInfoThenReleaseHelperContainsCorrectIpVersion) { + struct DrmMockToQuerySystemInfo : public DrmMock { + DrmMockToQuerySystemInfo(RootDeviceEnvironment &rootDeviceEnvironment) + : DrmMock(rootDeviceEnvironment) {} + bool querySystemInfo() override { return false; } + }; + + class MyMockIoctlHelper : public IoctlHelperPrelim20 { + public: + using IoctlHelperPrelim20::IoctlHelperPrelim20; + void setupIpVersion() override { + drm.getRootDeviceEnvironment().getMutableHardwareInfo()->ipVersion.architecture = 12u; + drm.getRootDeviceEnvironment().getMutableHardwareInfo()->ipVersion.release = 55u; + } + }; + + auto executionEnvironment = std::make_unique(); + executionEnvironment->rootDeviceEnvironments[0]->releaseHelper.reset(nullptr); + executionEnvironment->rootDeviceEnvironments[0]->initGmm(); + DrmMockToQuerySystemInfo drm(*executionEnvironment->rootDeviceEnvironments[0]); + drm.ioctlHelper = std::make_unique(drm); + HardwareInfo hwInfo = *defaultHwInfo; + auto setupHardwareInfo = [](HardwareInfo *, bool, const CompilerProductHelper &) {}; + DeviceDescriptor device = {0, &hwInfo, setupHardwareInfo}; + + int ret = drm.setupHardwareInfo(&device, false); + ASSERT_EQ(ret, 0); + + auto *releaseHelper = drm.getRootDeviceEnvironment().getReleaseHelper(); + + if (releaseHelper == nullptr) { + GTEST_SKIP(); + } + class ReleaseHelperExpose : public ReleaseHelper { + public: + using ReleaseHelper::hardwareIpVersion; + }; + + ReleaseHelperExpose *exposedReleaseHelper = static_cast(releaseHelper); + EXPECT_EQ(12u, exposedReleaseHelper->hardwareIpVersion.architecture); + EXPECT_EQ(55u, exposedReleaseHelper->hardwareIpVersion.release); +} + TEST(DrmSystemInfoTest, whenQueryingSystemInfoThenSystemInfoIsCreatedAndReturnsNonZeros) { auto executionEnvironment = std::make_unique(); DrmMockEngine drm(*executionEnvironment->rootDeviceEnvironments[0]);