From d4cfdd05b2641865a38659fde352ae6aeb044b4f Mon Sep 17 00:00:00 2001 From: Kamil Kopryk Date: Tue, 20 Dec 2022 02:24:12 +0000 Subject: [PATCH] Pass productHelper to disableL3CacheForDebug function Related-To: NEO-6853 Signed-off-by: Kamil Kopryk --- shared/source/debugger/debugger_l0.cpp | 2 +- shared/source/device/device.cpp | 5 +++-- shared/source/helpers/hw_helper.h | 7 ++++--- shared/source/helpers/hw_helper_base.inl | 12 +++++++++++- shared/source/xe_hpg_core/hw_helper_xe_hpg_core.cpp | 4 ++-- shared/test/unit_test/helpers/hw_helper_tests.cpp | 10 ++++++---- .../xe_hpg_core/dg2/hw_info_config_tests_dg2.cpp | 8 ++++---- 7 files changed, 31 insertions(+), 17 deletions(-) diff --git a/shared/source/debugger/debugger_l0.cpp b/shared/source/debugger/debugger_l0.cpp index 353c7d8d5e..76e8087a2e 100644 --- a/shared/source/debugger/debugger_l0.cpp +++ b/shared/source/debugger/debugger_l0.cpp @@ -100,7 +100,7 @@ void DebuggerL0::initialize() { NEO::MemoryTransferHelper::transferMemoryToAllocation(productHelper.isBlitCopyRequiredForLocalMemory(hwInfo, *moduleDebugArea), *device, moduleDebugArea, 0, &debugArea, sizeof(DebugAreaHeader)); - if (gfxCoreHelper.disableL3CacheForDebug(hwInfo)) { + if (gfxCoreHelper.disableL3CacheForDebug(hwInfo, productHelper)) { device->getGmmHelper()->forceAllResourcesUncached(); } diff --git a/shared/source/device/device.cpp b/shared/source/device/device.cpp index 744eb0de1f..7cff92fb01 100644 --- a/shared/source/device/device.cpp +++ b/shared/source/device/device.cpp @@ -215,7 +215,8 @@ bool Device::createDeviceImpl() { } auto &gfxCoreHelper = getGfxCoreHelper(); - if (getDebugger() && gfxCoreHelper.disableL3CacheForDebug(hwInfo)) { + auto &productHelper = getProductHelper(); + if (getDebugger() && gfxCoreHelper.disableL3CacheForDebug(hwInfo, productHelper)) { getGmmHelper()->forceAllResourcesUncached(); } @@ -269,7 +270,7 @@ bool Device::createDeviceImpl() { if (DebugManager.flags.EnableChipsetUniqueUUID.get() != 0) { if (gfxCoreHelper.isChipsetUniqueUUIDSupported()) { - auto &productHelper = getProductHelper(); + uuid.isValid = productHelper.getUuid(this, uuid.id); } } diff --git a/shared/source/helpers/hw_helper.h b/shared/source/helpers/hw_helper.h index df83922f3b..87692e4732 100644 --- a/shared/source/helpers/hw_helper.h +++ b/shared/source/helpers/hw_helper.h @@ -40,6 +40,7 @@ struct AllocationProperties; struct EncodeSurfaceStateArgs; struct RootDeviceEnvironment; struct PipeControlArgs; +class ProductHelper; class GfxCoreHelper { public: @@ -149,7 +150,7 @@ class GfxCoreHelper { virtual uint64_t getPatIndex(CacheRegion cacheRegion, CachePolicy cachePolicy) const = 0; virtual bool isStatelessToStatefulWithOffsetSupported() const = 0; virtual void encodeBufferSurfaceState(EncodeSurfaceStateArgs &args) const = 0; - virtual bool disableL3CacheForDebug(const HardwareInfo &hwInfo) const = 0; + virtual bool disableL3CacheForDebug(const HardwareInfo &hwInfo, const ProductHelper &productHelper) const = 0; virtual bool isRevisionSpecificBinaryBuiltinRequired() const = 0; virtual bool forceNonGpuCoherencyWA(bool requiresCoherency) const = 0; virtual bool platformSupportsImplicitScaling(const NEO::HardwareInfo &hwInfo) const = 0; @@ -357,7 +358,7 @@ class GfxCoreHelperHw : public GfxCoreHelper { void setSipKernelData(uint32_t *&sipKernelBinary, size_t &kernelBinarySize) const override; void adjustPreemptionSurfaceSize(size_t &csrSize) const override; - + static bool isWorkaroundRequired(uint32_t lowestSteppingWithBug, uint32_t steppingWithFix, const HardwareInfo &hwInfo, const ProductHelper &productHelper); bool isScratchSpaceSurfaceStateAccessible() const override; uint32_t getMaxScratchSize() const override; bool preferInternalBcsEngine() const override; @@ -366,7 +367,7 @@ class GfxCoreHelperHw : public GfxCoreHelper { uint64_t getPatIndex(CacheRegion cacheRegion, CachePolicy cachePolicy) const override; bool isStatelessToStatefulWithOffsetSupported() const override; void encodeBufferSurfaceState(EncodeSurfaceStateArgs &args) const override; - bool disableL3CacheForDebug(const HardwareInfo &hwInfo) const override; + bool disableL3CacheForDebug(const HardwareInfo &hwInfo, const ProductHelper &productHelper) const override; bool isRevisionSpecificBinaryBuiltinRequired() const override; bool forceNonGpuCoherencyWA(bool requiresCoherency) const override; bool platformSupportsImplicitScaling(const NEO::HardwareInfo &hwInfo) const override; diff --git a/shared/source/helpers/hw_helper_base.inl b/shared/source/helpers/hw_helper_base.inl index 6a9992045a..0920754d97 100644 --- a/shared/source/helpers/hw_helper_base.inl +++ b/shared/source/helpers/hw_helper_base.inl @@ -665,13 +665,23 @@ template void GfxCoreHelperHw::adjustPreemptionSurfaceSize(size_t &csrSize) const { } +template +inline bool GfxCoreHelperHw::isWorkaroundRequired(uint32_t lowestSteppingWithBug, uint32_t steppingWithFix, const HardwareInfo &hwInfo, const ProductHelper &productHelper) { + auto lowestHwRevIdWithBug = productHelper.getHwRevIdFromStepping(lowestSteppingWithBug, hwInfo); + auto hwRevIdWithFix = productHelper.getHwRevIdFromStepping(steppingWithFix, hwInfo); + if ((lowestHwRevIdWithBug == CommonConstants::invalidStepping) || (hwRevIdWithFix == CommonConstants::invalidStepping)) { + return false; + } + return (lowestHwRevIdWithBug <= hwInfo.platform.usRevId && hwInfo.platform.usRevId < hwRevIdWithFix); +} + template void GfxCoreHelperHw::encodeBufferSurfaceState(EncodeSurfaceStateArgs &args) const { EncodeSurfaceState::encodeBuffer(args); } template -bool GfxCoreHelperHw::disableL3CacheForDebug(const HardwareInfo &) const { +bool GfxCoreHelperHw::disableL3CacheForDebug(const HardwareInfo &, const ProductHelper &productHelper) const { return false; } template diff --git a/shared/source/xe_hpg_core/hw_helper_xe_hpg_core.cpp b/shared/source/xe_hpg_core/hw_helper_xe_hpg_core.cpp index b7391d1dc1..01af80c67f 100644 --- a/shared/source/xe_hpg_core/hw_helper_xe_hpg_core.cpp +++ b/shared/source/xe_hpg_core/hw_helper_xe_hpg_core.cpp @@ -138,8 +138,8 @@ uint32_t GfxCoreHelperHw::computeSlmValues(const HardwareInfo &hwInfo, u } template <> -bool GfxCoreHelperHw::disableL3CacheForDebug(const HardwareInfo &hwInfo) const { - return isWorkaroundRequired(REVISION_A0, REVISION_B, hwInfo); +bool GfxCoreHelperHw::disableL3CacheForDebug(const HardwareInfo &hwInfo, const ProductHelper &productHelper) const { + return isWorkaroundRequired(REVISION_A0, REVISION_B, hwInfo, productHelper); } template <> diff --git a/shared/test/unit_test/helpers/hw_helper_tests.cpp b/shared/test/unit_test/helpers/hw_helper_tests.cpp index d5889d1c2b..7acf08f530 100644 --- a/shared/test/unit_test/helpers/hw_helper_tests.cpp +++ b/shared/test/unit_test/helpers/hw_helper_tests.cpp @@ -1252,13 +1252,15 @@ TEST(GfxCoreHelperTests, whenBlitterSupportIsDisabledThenDontExposeAnyBcsEngine) } HWTEST2_F(GfxCoreHelperTest, givenNotXeHpOrXeHpgCoreWhenDisableL3ForDebugCalledThenFalseIsReturned, IsNotXeHpOrXeHpgCore) { - const auto &gfxCoreHelper = GfxCoreHelper::get(renderCoreFamily); - EXPECT_FALSE(gfxCoreHelper.disableL3CacheForDebug(*defaultHwInfo)); + const auto &gfxCoreHelper = getHelper(); + auto &productHelper = getHelper(); + EXPECT_FALSE(gfxCoreHelper.disableL3CacheForDebug(*defaultHwInfo, productHelper)); } HWTEST2_F(GfxCoreHelperTest, givenXeHpOrXeHpgCoreWhenDisableL3ForDebugCalledThenTrueIsReturned, IsXeHpOrXeHpgCore) { - const auto &gfxCoreHelper = GfxCoreHelper::get(renderCoreFamily); - EXPECT_TRUE(gfxCoreHelper.disableL3CacheForDebug(*defaultHwInfo)); + const auto &gfxCoreHelper = getHelper(); + auto &productHelper = getHelper(); + EXPECT_TRUE(gfxCoreHelper.disableL3CacheForDebug(*defaultHwInfo, productHelper)); } HWTEST_F(GfxCoreHelperTest, givenGfxCoreHelperWhenGettingIfRevisionSpecificBinaryBuiltinIsRequiredThenFalseIsReturned) { diff --git a/shared/test/unit_test/xe_hpg_core/dg2/hw_info_config_tests_dg2.cpp b/shared/test/unit_test/xe_hpg_core/dg2/hw_info_config_tests_dg2.cpp index f7579df828..d33a87bdd7 100644 --- a/shared/test/unit_test/xe_hpg_core/dg2/hw_info_config_tests_dg2.cpp +++ b/shared/test/unit_test/xe_hpg_core/dg2/hw_info_config_tests_dg2.cpp @@ -363,15 +363,15 @@ DG2TEST_F(ProductHelperTestDg2, givenRevisionEnumAndDisableL3CacheForDebugCalled }; auto hardwareInfo = *defaultHwInfo; - const auto &gfxCoreHelper = GfxCoreHelper::get(hardwareInfo.platform.eRenderCoreFamily); - const auto &productHelper = *ProductHelper::get(hardwareInfo.platform.eProductFamily); + const auto &gfxCoreHelper = getHelper(); + const auto &productHelper = getHelper(); for (auto stepping : steppings) { hardwareInfo.platform.usRevId = productHelper.getHwRevIdFromStepping(stepping, hardwareInfo); if (stepping < REVISION_B) { - EXPECT_TRUE(gfxCoreHelper.disableL3CacheForDebug(hardwareInfo)); + EXPECT_TRUE(gfxCoreHelper.disableL3CacheForDebug(hardwareInfo, productHelper)); } else { - EXPECT_FALSE(gfxCoreHelper.disableL3CacheForDebug(hardwareInfo)); + EXPECT_FALSE(gfxCoreHelper.disableL3CacheForDebug(hardwareInfo, productHelper)); } } }