diff --git a/shared/source/gmm_helper/cache_settings_helper.cpp b/shared/source/gmm_helper/cache_settings_helper.cpp index 0b178a26ca..d497524e9c 100644 --- a/shared/source/gmm_helper/cache_settings_helper.cpp +++ b/shared/source/gmm_helper/cache_settings_helper.cpp @@ -47,15 +47,7 @@ bool CacheSettingsHelper::preferNoCpuAccess(GMM_RESOURCE_USAGE_TYPE_ENUM gmmReso } GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getDefaultUsageTypeWithCachingEnabled(AllocationType allocationType, const ProductHelper &productHelper) { - if (productHelper.isDcFlushMitigated() && - (allocationType == AllocationType::externalHostPtr || - allocationType == AllocationType::bufferHostMemory || - allocationType == AllocationType::mapAllocation || - allocationType == AllocationType::svmCpu || - allocationType == AllocationType::svmZeroCopy || - allocationType == AllocationType::internalHostMemory || - allocationType == AllocationType::timestampPacketTagBuffer || - allocationType == AllocationType::tagBuffer)) { + if (productHelper.overridePatAndUsageForDcFlushMitigation(allocationType)) { return getDefaultUsageTypeWithCachingDisabled(allocationType, productHelper); } diff --git a/shared/source/os_interface/product_helper.h b/shared/source/os_interface/product_helper.h index 2dd72f4ec6..5ac3130cce 100644 --- a/shared/source/os_interface/product_helper.h +++ b/shared/source/os_interface/product_helper.h @@ -129,6 +129,7 @@ class ProductHelper { virtual bool isTile64With3DSurfaceOnBCSSupported(const HardwareInfo &hwInfo) const = 0; virtual bool isDcFlushAllowed() const = 0; virtual bool isDcFlushMitigated() const = 0; + virtual bool overridePatAndUsageForDcFlushMitigation(AllocationType allocationType) const = 0; virtual uint32_t computeMaxNeededSubSliceSpace(const HardwareInfo &hwInfo) const = 0; virtual bool getUuid(NEO::DriverModel *driverModel, const uint32_t subDeviceCount, const uint32_t deviceIndex, std::array &uuid) const = 0; virtual bool isFlushTaskAllowed() const = 0; diff --git a/shared/source/os_interface/product_helper.inl b/shared/source/os_interface/product_helper.inl index 3117709a3c..b7e5382ad2 100644 --- a/shared/source/os_interface/product_helper.inl +++ b/shared/source/os_interface/product_helper.inl @@ -400,6 +400,20 @@ bool ProductHelperHw::isDcFlushMitigated() const { return this->isDcFlushAllowed() != dcFlushAllowed; } +template +bool ProductHelperHw::overridePatAndUsageForDcFlushMitigation(AllocationType allocationType) const { + return this->isDcFlushMitigated() && + (allocationType == AllocationType::externalHostPtr || + allocationType == AllocationType::bufferHostMemory || + allocationType == AllocationType::mapAllocation || + allocationType == AllocationType::svmCpu || + allocationType == AllocationType::svmZeroCopy || + allocationType == AllocationType::internalHostMemory || + allocationType == AllocationType::timestampPacketTagBuffer || + allocationType == AllocationType::tagBuffer || + allocationType == AllocationType::gpuTimestampDeviceBuffer); +} + template uint32_t ProductHelperHw::computeMaxNeededSubSliceSpace(const HardwareInfo &hwInfo) const { return hwInfo.gtSystemInfo.MaxSubSlicesSupported; diff --git a/shared/source/os_interface/product_helper_hw.h b/shared/source/os_interface/product_helper_hw.h index a964cf462c..6e432963e2 100644 --- a/shared/source/os_interface/product_helper_hw.h +++ b/shared/source/os_interface/product_helper_hw.h @@ -74,6 +74,7 @@ class ProductHelperHw : public ProductHelper { bool isTile64With3DSurfaceOnBCSSupported(const HardwareInfo &hwInfo) const override; bool isDcFlushAllowed() const override; bool isDcFlushMitigated() const override; + bool overridePatAndUsageForDcFlushMitigation(AllocationType allocationType) const override; uint32_t computeMaxNeededSubSliceSpace(const HardwareInfo &hwInfo) const override; bool getUuid(NEO::DriverModel *driverModel, uint32_t subDeviceCount, uint32_t deviceIndex, std::array &uuid) const override; bool isFlushTaskAllowed() const override; diff --git a/shared/test/common/mocks/mock_product_helper.cpp b/shared/test/common/mocks/mock_product_helper.cpp index 2a0126ffb7..08fbca68e9 100644 --- a/shared/test/common/mocks/mock_product_helper.cpp +++ b/shared/test/common/mocks/mock_product_helper.cpp @@ -276,6 +276,11 @@ bool ProductHelperHw::isDcFlushMitigated() const { return false; } +template <> +bool ProductHelperHw::overridePatAndUsageForDcFlushMitigation(AllocationType allocationType) const { + return false; +} + template <> uint32_t ProductHelperHw::computeMaxNeededSubSliceSpace(const HardwareInfo &hwInfo) const { return hwInfo.gtSystemInfo.MaxSubSlicesSupported; 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 7febbcdcf8..8d1d918d14 100644 --- a/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp +++ b/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp @@ -745,6 +745,7 @@ TEST(GmmTest, givenAllocationTypeAndMitigatedDcFlushWhenGettingUsageTypeThenRetu case AllocationType::svmZeroCopy: case AllocationType::internalHostMemory: case AllocationType::timestampPacketTagBuffer: + case AllocationType::gpuTimestampDeviceBuffer: case AllocationType::bufferHostMemory: case AllocationType::tagBuffer: expectedUsage = uncachedGmmUsageType; @@ -793,9 +794,6 @@ TEST(GmmTest, givenAllocationTypeAndMitigatedDcFlushWhenGettingUsageTypeThenRetu } EXPECT_EQ(expectedUsage, usage); - if (expectedUsage != usage) { - std::cout << "fail"; - } } } 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 db5c2e94b2..b990f45e78 100644 --- a/shared/test/unit_test/os_interface/product_helper_tests.cpp +++ b/shared/test/unit_test/os_interface/product_helper_tests.cpp @@ -309,6 +309,31 @@ HWTEST_F(ProductHelperTest, givenVariousValuesWhenGettingAubStreamSteppingFromHw EXPECT_EQ(AubMemDump::SteppingValues::A, mockProductHelper.getAubStreamSteppingFromHwRevId(pInHwInfo)); } +HWTEST_F(ProductHelperTest, givenDcFlushMitigationWhenOverridePatAndUsageForDcFlushMitigationThenReturnCorrectValue) { + DebugManagerStateRestore restorer; + for (auto i = 0; i < static_cast(AllocationType::count); ++i) { + auto allocationType = static_cast(i); + EXPECT_FALSE(productHelper->overridePatAndUsageForDcFlushMitigation(allocationType)); + } + debugManager.flags.AllowDcFlush.set(0); + for (auto i = 0; i < static_cast(AllocationType::count); ++i) { + auto allocationType = static_cast(i); + if (allocationType == AllocationType::externalHostPtr || + allocationType == AllocationType::bufferHostMemory || + allocationType == AllocationType::mapAllocation || + allocationType == AllocationType::svmCpu || + allocationType == AllocationType::svmZeroCopy || + allocationType == AllocationType::internalHostMemory || + allocationType == AllocationType::timestampPacketTagBuffer || + allocationType == AllocationType::tagBuffer || + allocationType == AllocationType::gpuTimestampDeviceBuffer) { + EXPECT_EQ(productHelper->overridePatAndUsageForDcFlushMitigation(allocationType), productHelper->isDcFlushMitigated()); + } else { + EXPECT_FALSE(productHelper->overridePatAndUsageForDcFlushMitigation(allocationType)); + } + } +} + HWTEST_F(ProductHelperTest, givenProductHelperWhenAskedForDefaultEngineTypeAdjustmentThenFalseIsReturned) { EXPECT_FALSE(productHelper->isDefaultEngineTypeAdjustmentRequired(pInHwInfo));