fix: override for driver protection bits

Add product helper method, default no override.
Use single param. Usage unknown means no override.

Related-To: NEO-14482

Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
Dominik Dabek
2025-05-16 14:24:45 +00:00
committed by Compute-Runtime-Automation
parent 468c62086e
commit c5c87ab6f9
9 changed files with 22 additions and 9 deletions

View File

@@ -36,7 +36,7 @@ class GmmResourceInfo : NonCopyableAndNonMovableClass {
MOCKABLE_VIRTUAL size_t getRenderPitch() { return static_cast<size_t>(resourceInfo->GetRenderPitch()); }
MOCKABLE_VIRTUAL uint64_t getDriverProtectionBits(bool overrideUsage, uint32_t usage);
MOCKABLE_VIRTUAL uint64_t getDriverProtectionBits(uint32_t overrideUsage);
MOCKABLE_VIRTUAL uint32_t getNumSamples() { return resourceInfo->GetNumSamples(); }

View File

@@ -9,7 +9,7 @@
namespace NEO {
uint64_t GmmResourceInfo::getDriverProtectionBits(bool overrideUsage, uint32_t usage) {
uint64_t GmmResourceInfo::getDriverProtectionBits(uint32_t overrideUsage) {
return 0u;
}

View File

@@ -9,10 +9,10 @@
namespace NEO {
uint64_t GmmResourceInfo::getDriverProtectionBits(bool overrideUsage, uint32_t usage) {
uint64_t GmmResourceInfo::getDriverProtectionBits(uint32_t overrideUsage) {
GMM_OVERRIDE_VALUES overrideValues{};
if (overrideUsage) {
overrideValues.Usage = usage;
if (GMM_RESOURCE_USAGE_UNKNOWN != overrideUsage) {
overrideValues.Usage = overrideUsage;
}
return static_cast<uint64_t>(resourceInfo->GetDriverProtectionBits(overrideValues));
}

View File

@@ -9,7 +9,7 @@
namespace NEO {
uint64_t GmmResourceInfo::getDriverProtectionBits(bool overrideUsage, uint32_t usage) {
uint64_t GmmResourceInfo::getDriverProtectionBits(uint32_t overrideUsage) {
return 0u;
}

View File

@@ -258,6 +258,7 @@ class ProductHelper {
virtual uint32_t getNumCacheRegions() const = 0;
virtual uint32_t adjustMaxThreadsPerThreadGroup(uint32_t maxThreadsPerThreadGroup, uint32_t simt, uint32_t totalWorkItems, uint32_t grfCount, bool isHwLocalIdGeneration, bool isHeaplessModeEnabled) const = 0;
virtual uint64_t getPatIndex(CacheRegion cacheRegion, CachePolicy cachePolicy) const = 0;
virtual uint32_t getGmmResourceUsageOverride(uint32_t usageType) const = 0;
virtual bool isSharingWith3dOrMediaAllowed() const = 0;
virtual bool isL3FlushAfterPostSyncRequired(bool heaplessEnabled) const = 0;
virtual void overrideDirectSubmissionTimeouts(std::chrono::microseconds &timeout, std::chrono::microseconds &maxTimeout) const = 0;

View File

@@ -956,6 +956,11 @@ uint64_t ProductHelperHw<gfxProduct>::getPatIndex(CacheRegion cacheRegion, Cache
return -1;
}
template <PRODUCT_FAMILY gfxProduct>
uint32_t ProductHelperHw<gfxProduct>::getGmmResourceUsageOverride(uint32_t usageType) const {
return 0u;
}
template <PRODUCT_FAMILY gfxProduct>
bool ProductHelperHw<gfxProduct>::isEvictionIfNecessaryFlagSupported() const {
return true;

View File

@@ -196,6 +196,7 @@ class ProductHelperHw : public ProductHelper {
uint32_t getNumCacheRegions() const override;
uint32_t adjustMaxThreadsPerThreadGroup(uint32_t maxThreadsPerThreadGroup, uint32_t simt, uint32_t totalWorkItems, uint32_t grfCount, bool isHwLocalIdGeneration, bool isHeaplessModeEnabled) const override;
uint64_t getPatIndex(CacheRegion cacheRegion, CachePolicy cachePolicy) const override;
uint32_t getGmmResourceUsageOverride(uint32_t usageType) const override;
bool isSharingWith3dOrMediaAllowed() const override;
bool isL3FlushAfterPostSyncRequired(bool heaplessEnabled) const override;
void overrideDirectSubmissionTimeouts(std::chrono::microseconds &timeout, std::chrono::microseconds &maxTimeout) const override;

View File

@@ -33,9 +33,9 @@ class MockGmmResourceInfo : public GmmResourceInfo {
size_t getRenderPitch() override { return rowPitch; }
uint64_t getDriverProtectionBits(bool overrideUsage, uint32_t usage) override {
driverProtectionBitsUsageWasOverriden = overrideUsage;
driverProtectionBitsUsageOverride = usage;
uint64_t getDriverProtectionBits(uint32_t overrideUsage) override {
driverProtectionBitsUsageWasOverriden = GMM_RESOURCE_USAGE_UNKNOWN != overrideUsage;
driverProtectionBitsUsageOverride = overrideUsage;
return driverProtectionBits;
}

View File

@@ -993,6 +993,12 @@ HWTEST_F(ProductHelperTest, givenBooleanUncachedWhenCallOverridePatIndexThenProp
EXPECT_EQ(patIndex, productHelper->overridePatIndex(isUncached, patIndex, AllocationType::buffer));
}
HWTEST_F(ProductHelperTest, givenGmmUsageTypeWhenCallingGetGmmResourceUsageOverrideThenReturnNoOverride) {
constexpr uint32_t noOverride = GMM_RESOURCE_USAGE_UNKNOWN;
EXPECT_EQ(noOverride, productHelper->getGmmResourceUsageOverride(GMM_RESOURCE_USAGE_OCL_BUFFER));
EXPECT_EQ(noOverride, productHelper->getGmmResourceUsageOverride(GMM_RESOURCE_USAGE_XADAPTER_SHARED_RESOURCE));
}
HWTEST_F(ProductHelperTest, givenProductHelperWhenGettingSupportedNumGrfsThenCorrectValueIsReturned) {
if (releaseHelper) {
EXPECT_EQ(releaseHelper->getSupportedNumGrfs(), productHelper->getSupportedNumGrfs(releaseHelper));