From a8d9e7ed3520c86daefd7d1ba5e9e3c35fdaf37d Mon Sep 17 00:00:00 2001 From: Tomasz Biernacik Date: Fri, 7 Mar 2025 15:52:31 +0000 Subject: [PATCH] fix: set correct default value of cacheable flag Related-To: NEO-9421 Signed-off-by: Tomasz Biernacik --- shared/source/os_interface/linux/drm_neo.cpp | 7 ++++--- .../linux/device_command_stream_fixture.h | 1 + .../linux/drm_memory_manager_tests.cpp | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/shared/source/os_interface/linux/drm_neo.cpp b/shared/source/os_interface/linux/drm_neo.cpp index 158e2f1b8e..9e03564368 100644 --- a/shared/source/os_interface/linux/drm_neo.cpp +++ b/shared/source/os_interface/linux/drm_neo.cpp @@ -1404,17 +1404,18 @@ uint64_t Drm::getPatIndex(Gmm *gmm, AllocationType allocationType, CacheRegion c } GMM_RESOURCE_INFO *resourceInfo = nullptr; - bool cachable = !CacheSettingsHelper::isUncachedType(usageType); + auto preferNoCpuAccess = CacheSettingsHelper::preferNoCpuAccess(usageType, rootDeviceEnvironment); + bool cacheable = !preferNoCpuAccess && !isUncachedType; bool compressed = false; if (gmm) { resourceInfo = gmm->gmmResourceInfo->peekGmmResourceInfo(); usageType = gmm->resourceParams.Usage; compressed = gmm->isCompressionEnabled(); - cachable = gmm->gmmResourceInfo->getResourceFlags()->Info.Cacheable; + cacheable = gmm->gmmResourceInfo->getResourceFlags()->Info.Cacheable; } - uint64_t patIndex = rootDeviceEnvironment.getGmmClientContext()->cachePolicyGetPATIndex(resourceInfo, usageType, compressed, cachable); + uint64_t patIndex = rootDeviceEnvironment.getGmmClientContext()->cachePolicyGetPATIndex(resourceInfo, usageType, compressed, cacheable); patIndex = productHelper.overridePatIndex(isUncachedType, patIndex, allocationType); UNRECOVERABLE_IF(patIndex == static_cast(GMM_PAT_ERROR)); diff --git a/shared/test/common/os_interface/linux/device_command_stream_fixture.h b/shared/test/common/os_interface/linux/device_command_stream_fixture.h index 3d210a57f0..bd3a5dd259 100644 --- a/shared/test/common/os_interface/linux/device_command_stream_fixture.h +++ b/shared/test/common/os_interface/linux/device_command_stream_fixture.h @@ -119,6 +119,7 @@ struct DrmMockCustom : public Drm { using Drm::pageFaultSupported; using Drm::queryTopology; using Drm::setupIoctlHelper; + using Drm::vmBindPatIndexProgrammingSupported; struct IoctlResExt { std::vector no; diff --git a/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp index a4446847e5..22d615cfab 100644 --- a/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp @@ -7599,6 +7599,24 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenCompress memoryManager->freeGraphicsMemory(allocation); } +TEST_F(DrmMemoryManagerTest, givenNoGmmWhenQueryingPatIndexThenPassCorrectParams) { + mock->vmBindPatIndexProgrammingSupported = true; + + auto &productHelper = this->device->getProductHelper(); + auto mockClientContext = static_cast(executionEnvironment->rootDeviceEnvironments[0]->getGmmClientContext()); + + for (auto allocationType = static_cast(AllocationType::buffer); allocationType < static_cast(AllocationType::count); ++allocationType) { + auto usageType = CacheSettingsHelper::getGmmUsageType(static_cast(allocationType), false, productHelper); + auto isUncachedType = CacheSettingsHelper::isUncachedType(usageType); + auto preferNoCpuAccess = CacheSettingsHelper::preferNoCpuAccess(usageType, *executionEnvironment->rootDeviceEnvironments[0]); + bool cacheable = !preferNoCpuAccess && !isUncachedType; + + mock->getPatIndex(nullptr, static_cast(allocationType), CacheRegion::defaultRegion, CachePolicy::writeBack, false, false); + EXPECT_EQ(cacheable, mockClientContext->passedCachableSettingForGetPatIndexQuery); + EXPECT_EQ(false, mockClientContext->passedCompressedSettingForGetPatIndexQuery); + } +} + TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenNotSetUseSystemMemoryWhenGraphicsAllocationInDevicePoolIsAllocatedForImageThenLocalMemoryAllocationIsReturnedFromStandard64KbHeap) { ImageDescriptor imgDesc = {}; imgDesc.imageType = ImageType::image2D;