From 12d1bce6b928fcc21c55fc1912ea43079f0dcf85 Mon Sep 17 00:00:00 2001 From: Katarzyna Cencelewska Date: Wed, 22 May 2024 13:31:31 +0000 Subject: [PATCH] fix: change gmm resource for externalHostPtr Resolves: NEO-10157 Signed-off-by: Katarzyna Cencelewska --- .../gmm_helper/cache_settings_helper.cpp | 2 +- .../os_interface/linux/drm_memory_manager.cpp | 14 ++++++----- .../source/os_interface/linux/ioctl_helper.h | 12 +++++----- .../os_interface/linux/ioctl_helper_i915.cpp | 2 +- .../linux/ioctl_helper_prelim.cpp | 2 +- .../linux/ioctl_helper_upstream.cpp | 2 +- .../linux/local/dg1/ioctl_helper_dg1.cpp | 4 ++-- .../source/os_interface/linux/memory_info.cpp | 7 ++++-- .../os_interface/linux/xe/ioctl_helper_xe.cpp | 12 +++++----- .../os_interface/linux/xe/ioctl_helper_xe.h | 6 ++--- shared/source/os_interface/product_helper.h | 1 + .../product_helper_bdw_and_later.inl | 5 ++++ .../source/os_interface/product_helper_hw.h | 1 + .../pvc/os_agnostic_product_helper_pvc.inl | 5 ++++ .../dg2/os_agnostic_product_helper_dg2.inl | 5 ++++ .../os_agnostic_product_helper_xe_lpg.inl | 9 ++++++++ .../test/common/mocks/mock_product_helper.cpp | 5 ++++ .../test_macros/header/common_matchers.h | 1 + .../unit_test/gmm_helper/gmm_helper_tests.cpp | 2 ++ .../os_interface/linux/drm_tests.cpp | 2 +- .../linux/drm_with_prelim_tests.cpp | 8 +++---- .../linux/ioctl_helper_tests_dg1.cpp | 6 ++--- .../linux/ioctl_helper_tests_prelim.cpp | 4 ++-- .../linux/ioctl_helper_tests_upstream.cpp | 14 +++++------ .../linux/xe/ioctl_helper_xe_tests.cpp | 23 +++++++++++-------- .../os_interface/product_helper_tests.cpp | 7 ++++++ .../pvc/test_product_helper_pvc.cpp | 3 ++- ...s_agnostic_product_helper_xe_lpg_tests.cpp | 11 +++++++++ 28 files changed, 119 insertions(+), 56 deletions(-) diff --git a/shared/source/gmm_helper/cache_settings_helper.cpp b/shared/source/gmm_helper/cache_settings_helper.cpp index d497524e9c..e60ce5333b 100644 --- a/shared/source/gmm_helper/cache_settings_helper.cpp +++ b/shared/source/gmm_helper/cache_settings_helper.cpp @@ -69,11 +69,11 @@ GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getDefaultUsageTypeWithCaching case AllocationType::sharedBuffer: case AllocationType::svmGpu: case AllocationType::unifiedSharedMemory: - case AllocationType::externalHostPtr: if (debugManager.flags.DisableCachingForStatefulBufferAccess.get()) { return getDefaultUsageTypeWithCachingDisabled(allocationType, productHelper); } return GMM_RESOURCE_USAGE_OCL_BUFFER; + case AllocationType::externalHostPtr: case AllocationType::bufferHostMemory: case AllocationType::internalHostMemory: case AllocationType::mapAllocation: diff --git a/shared/source/os_interface/linux/drm_memory_manager.cpp b/shared/source/os_interface/linux/drm_memory_manager.cpp index 73b9b05db7..ad39b63504 100644 --- a/shared/source/os_interface/linux/drm_memory_manager.cpp +++ b/shared/source/os_interface/linux/drm_memory_manager.cpp @@ -43,6 +43,7 @@ #include "shared/source/os_interface/linux/os_context_linux.h" #include "shared/source/os_interface/linux/sys_calls.h" #include "shared/source/os_interface/os_interface.h" +#include "shared/source/os_interface/product_helper.h" #include #include @@ -653,10 +654,9 @@ GraphicsAllocation *DrmMemoryManager::allocatePhysicalDeviceMemory(const Allocat auto &drm = getDrm(allocationData.rootDeviceIndex); auto ioctlHelper = drm.getIoctlHelper(); - - uint32_t handle = ioctlHelper->createGem(bufferSize, static_cast(allocationData.storageInfo.memoryBanks.to_ulong())); - auto patIndex = drm.getPatIndex(gmm.get(), allocationData.type, CacheRegion::defaultRegion, CachePolicy::writeBack, false, MemoryPoolHelper::isSystemMemoryPool(memoryPool)); + auto isCoherent = productHelper.isCoherentAllocation(patIndex); + uint32_t handle = ioctlHelper->createGem(bufferSize, static_cast(allocationData.storageInfo.memoryBanks.to_ulong()), isCoherent); std::unique_ptr bo(new BufferObject(allocationData.rootDeviceIndex, &drm, patIndex, handle, bufferSize, maxOsContextCount)); @@ -702,7 +702,8 @@ GraphicsAllocation *DrmMemoryManager::allocateMemoryByKMD(const AllocationData & if (0 != ret) { auto ioctlHelper = drm.getIoctlHelper(); - handle = ioctlHelper->createGem(bufferSize, static_cast(allocationData.storageInfo.memoryBanks.to_ulong())); + auto isCoherent = productHelper.isCoherentAllocation(patIndex); + handle = ioctlHelper->createGem(bufferSize, static_cast(allocationData.storageInfo.memoryBanks.to_ulong()), isCoherent); boType = BufferObject::BOType::legacy; } @@ -738,9 +739,10 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForImageImpl(const A auto &drm = this->getDrm(allocationData.rootDeviceIndex); auto ioctlHelper = drm.getIoctlHelper(); - uint32_t handle = ioctlHelper->createGem(allocationData.imgInfo->size, static_cast(allocationData.storageInfo.memoryBanks.to_ulong())); - auto patIndex = drm.getPatIndex(gmm.get(), allocationData.type, CacheRegion::defaultRegion, CachePolicy::writeBack, false, MemoryPoolHelper::isSystemMemoryPool(memoryPool)); + auto &productHelper = drm.getRootDeviceEnvironment().getProductHelper(); + auto isCoherent = productHelper.isCoherentAllocation(patIndex); + uint32_t handle = ioctlHelper->createGem(allocationData.imgInfo->size, static_cast(allocationData.storageInfo.memoryBanks.to_ulong()), isCoherent); std::unique_ptr bo(new (std::nothrow) BufferObject(allocationData.rootDeviceIndex, &drm, patIndex, handle, allocationData.imgInfo->size, maxOsContextCount)); if (!bo) { diff --git a/shared/source/os_interface/linux/ioctl_helper.h b/shared/source/os_interface/linux/ioctl_helper.h index 7801202f95..c8f7a433ec 100644 --- a/shared/source/os_interface/linux/ioctl_helper.h +++ b/shared/source/os_interface/linux/ioctl_helper.h @@ -99,8 +99,8 @@ class IoctlHelper { virtual bool isSetPairAvailable() = 0; virtual bool isChunkingAvailable() = 0; virtual bool isVmBindAvailable() = 0; - virtual int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional memPolicyMode, std::optional> memPolicyNodemask) = 0; - virtual uint32_t createGem(uint64_t size, uint32_t memoryBanks) = 0; + virtual int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional memPolicyMode, std::optional> memPolicyNodemask, std::optional isCoherent) = 0; + virtual uint32_t createGem(uint64_t size, uint32_t memoryBanks, std::optional isCoherent) = 0; virtual CacheRegion closAlloc() = 0; virtual uint16_t closAllocWays(CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) = 0; virtual CacheRegion closFree(CacheRegion closIndex) = 0; @@ -228,7 +228,7 @@ class IoctlHelperI915 : public IoctlHelper { bool getTopologyDataAndMap(const HardwareInfo &hwInfo, DrmQueryTopologyData &topologyData, TopologyMap &topologyMap) override; void fillBindInfoForIpcHandle(uint32_t handle, size_t size) override; bool getFdFromVmExport(uint32_t vmId, uint32_t flags, int32_t *fd) override; - uint32_t createGem(uint64_t size, uint32_t memoryBanks) override; + uint32_t createGem(uint64_t size, uint32_t memoryBanks, std::optional isCoherent) override; bool setGemTiling(void *setTiling) override; bool getGemTiling(void *setTiling) override; bool setGpuCpuTimes(TimeStampData *pGpuCpuTime, OSTime *osTime) override; @@ -250,7 +250,7 @@ class IoctlHelperUpstream : public IoctlHelperI915 { bool isSetPairAvailable() override; bool isChunkingAvailable() override; bool isVmBindAvailable() override; - int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional memPolicyMode, std::optional> memPolicyNodemask) override; + int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional memPolicyMode, std::optional> memPolicyNodemask, std::optional isCoherent) override; CacheRegion closAlloc() override; uint16_t closAllocWays(CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) override; CacheRegion closFree(CacheRegion closIndex) override; @@ -315,7 +315,7 @@ class IoctlHelperImpl : public IoctlHelperUpstream { return std::make_unique>(drm); } - int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional memPolicyMode, std::optional> memPolicyNodemask) override; + int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional memPolicyMode, std::optional> memPolicyNodemask, std::optional isCoherent) override; std::vector translateToMemoryRegions(const std::vector ®ionInfo) override; unsigned int getIoctlRequestValue(DrmIoctl ioctlRequest) const override; std::string getIoctlString(DrmIoctl ioctlRequest) const override; @@ -328,7 +328,7 @@ class IoctlHelperPrelim20 : public IoctlHelperI915 { bool isSetPairAvailable() override; bool isChunkingAvailable() override; bool isVmBindAvailable() override; - int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional memPolicyMode, std::optional> memPolicyNodemask) override; + int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional memPolicyMode, std::optional> memPolicyNodemask, std::optional isCoherent) override; CacheRegion closAlloc() override; uint16_t closAllocWays(CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) override; CacheRegion closFree(CacheRegion closIndex) override; diff --git a/shared/source/os_interface/linux/ioctl_helper_i915.cpp b/shared/source/os_interface/linux/ioctl_helper_i915.cpp index 9eb1a1f42d..5847b43220 100644 --- a/shared/source/os_interface/linux/ioctl_helper_i915.cpp +++ b/shared/source/os_interface/linux/ioctl_helper_i915.cpp @@ -544,7 +544,7 @@ bool IoctlHelperI915::getFdFromVmExport(uint32_t vmId, uint32_t flags, int32_t * return false; } -uint32_t IoctlHelperI915::createGem(uint64_t size, uint32_t memoryBanks) { +uint32_t IoctlHelperI915::createGem(uint64_t size, uint32_t memoryBanks, std::optional isCoherent) { GemCreate gemCreate = {}; gemCreate.size = size; [[maybe_unused]] auto ret = ioctl(DrmIoctl::gemCreate, &gemCreate); diff --git a/shared/source/os_interface/linux/ioctl_helper_prelim.cpp b/shared/source/os_interface/linux/ioctl_helper_prelim.cpp index e86ccf0dc5..93eb836226 100644 --- a/shared/source/os_interface/linux/ioctl_helper_prelim.cpp +++ b/shared/source/os_interface/linux/ioctl_helper_prelim.cpp @@ -157,7 +157,7 @@ bool IoctlHelperPrelim20::isVmBindAvailable() { return vmBindSupported; } -int IoctlHelperPrelim20::createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional memPolicyMode, std::optional> memPolicyNodemask) { +int IoctlHelperPrelim20::createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional memPolicyMode, std::optional> memPolicyNodemask, std::optional isCoherent) { uint32_t regionsSize = static_cast(memClassInstances.size()); std::vector regions(regionsSize); for (uint32_t i = 0; i < regionsSize; i++) { diff --git a/shared/source/os_interface/linux/ioctl_helper_upstream.cpp b/shared/source/os_interface/linux/ioctl_helper_upstream.cpp index 44ab5facae..858abd7982 100644 --- a/shared/source/os_interface/linux/ioctl_helper_upstream.cpp +++ b/shared/source/os_interface/linux/ioctl_helper_upstream.cpp @@ -33,7 +33,7 @@ bool IoctlHelperUpstream::isVmBindAvailable() { return false; } -int IoctlHelperUpstream::createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional memPolicyMode, std::optional> memPolicyNodemask) { +int IoctlHelperUpstream::createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional memPolicyMode, std::optional> memPolicyNodemask, std::optional isCoherent) { bool isPatIndexValid = (patIndex != CommonConstants::unsupportedPatIndex) && (patIndex <= std::numeric_limits::max()); bool useSetPat = this->isSetPatSupported && isPatIndexValid; diff --git a/shared/source/os_interface/linux/local/dg1/ioctl_helper_dg1.cpp b/shared/source/os_interface/linux/local/dg1/ioctl_helper_dg1.cpp index 0b003daf6f..2f22554bb8 100644 --- a/shared/source/os_interface/linux/local/dg1/ioctl_helper_dg1.cpp +++ b/shared/source/os_interface/linux/local/dg1/ioctl_helper_dg1.cpp @@ -21,8 +21,8 @@ constexpr static auto gfxProduct = IGFX_DG1; extern bool isQueryDrmTip(const std::vector &queryInfo); template <> -int IoctlHelperImpl::createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional memPolicyMode, std::optional> memPolicyNodemask) { - auto ret = IoctlHelperUpstream::createGemExt(memClassInstances, allocSize, handle, patIndex, vmId, pairHandle, isChunked, numOfChunks, memPolicyMode, memPolicyNodemask); +int IoctlHelperImpl::createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional memPolicyMode, std::optional> memPolicyNodemask, std::optional isCoherent) { + auto ret = IoctlHelperUpstream::createGemExt(memClassInstances, allocSize, handle, patIndex, vmId, pairHandle, isChunked, numOfChunks, memPolicyMode, memPolicyNodemask, isCoherent); if (ret == 0) { return ret; } diff --git a/shared/source/os_interface/linux/memory_info.cpp b/shared/source/os_interface/linux/memory_info.cpp index 1791e61e52..1da2b218fc 100644 --- a/shared/source/os_interface/linux/memory_info.cpp +++ b/shared/source/os_interface/linux/memory_info.cpp @@ -15,6 +15,7 @@ #include "shared/source/helpers/hw_info.h" #include "shared/source/os_interface/linux/drm_neo.h" #include "shared/source/os_interface/linux/numa_library.h" +#include "shared/source/os_interface/product_helper.h" #include @@ -68,15 +69,17 @@ void MemoryInfo::assignRegionsFromDistances(const std::vector &dis int MemoryInfo::createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, bool isUSMHostAllocation) { std::vector memPolicyNodeMask; int mode = -1; + auto &productHelper = this->drm.getRootDeviceEnvironment().getHelper(); + auto isCoherent = productHelper.isCoherentAllocation(patIndex); if (memPolicySupported && isUSMHostAllocation && Linux::NumaLibrary::getMemPolicy(&mode, memPolicyNodeMask)) { if (memPolicyMode != -1) { mode = memPolicyMode; } - return this->drm.getIoctlHelper()->createGemExt(memClassInstances, allocSize, handle, patIndex, vmId, pairHandle, isChunked, numOfChunks, mode, memPolicyNodeMask); + return this->drm.getIoctlHelper()->createGemExt(memClassInstances, allocSize, handle, patIndex, vmId, pairHandle, isChunked, numOfChunks, mode, memPolicyNodeMask, isCoherent); } else { - return this->drm.getIoctlHelper()->createGemExt(memClassInstances, allocSize, handle, patIndex, vmId, pairHandle, isChunked, numOfChunks, std::nullopt, std::nullopt); + return this->drm.getIoctlHelper()->createGemExt(memClassInstances, allocSize, handle, patIndex, vmId, pairHandle, isChunked, numOfChunks, std::nullopt, std::nullopt, isCoherent); } } diff --git a/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp b/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp index ba7fca4b18..364c109607 100644 --- a/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp +++ b/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp @@ -537,9 +537,9 @@ uint16_t IoctlHelperXe::getDefaultEngineClass(const aub_stream::EngineType &defa * * @return returns caching policy defined as DRM_XE_GEM_CPU_CACHING_WC or DRM_XE_GEM_CPU_CACHING_WB */ -uint16_t IoctlHelperXe::getCpuCachingMode(bool allocationInSystemMemory) const { +uint16_t IoctlHelperXe::getCpuCachingMode(std::optional isCoherent, bool allocationInSystemMemory) const { uint16_t cpuCachingMode = DRM_XE_GEM_CPU_CACHING_WC; - if (allocationInSystemMemory) { + if ((isCoherent.value_or(false) == true) || (isCoherent == std::nullopt && allocationInSystemMemory)) { cpuCachingMode = DRM_XE_GEM_CPU_CACHING_WB; } @@ -550,7 +550,7 @@ uint16_t IoctlHelperXe::getCpuCachingMode(bool allocationInSystemMemory) const { return cpuCachingMode; } -int IoctlHelperXe::createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional memPolicyMode, std::optional> memPolicyNodemask) { +int IoctlHelperXe::createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional memPolicyMode, std::optional> memPolicyNodemask, std::optional isCoherent) { struct drm_xe_gem_create create = {}; uint32_t regionsSize = static_cast(memClassInstances.size()); @@ -570,7 +570,7 @@ int IoctlHelperXe::createGemExt(const MemRegionsVec &memClassInstances, size_t a memoryInstances.set(memoryClassInstance.memoryInstance); } create.placement = static_cast(memoryInstances.to_ulong()); - create.cpu_caching = this->getCpuCachingMode(mem.memoryClass == drm_xe_memory_class::DRM_XE_MEM_REGION_CLASS_SYSMEM); + create.cpu_caching = this->getCpuCachingMode(isCoherent, mem.memoryClass == drm_xe_memory_class::DRM_XE_MEM_REGION_CLASS_SYSMEM); auto ret = IoctlHelper::ioctl(DrmIoctl::gemCreate, &create); handle = create.handle; @@ -581,7 +581,7 @@ int IoctlHelperXe::createGemExt(const MemRegionsVec &memClassInstances, size_t a return ret; } -uint32_t IoctlHelperXe::createGem(uint64_t size, uint32_t memoryBanks) { +uint32_t IoctlHelperXe::createGem(uint64_t size, uint32_t memoryBanks, std::optional isCoherent) { struct drm_xe_gem_create create = {}; create.size = size; auto pHwInfo = drm.getRootDeviceEnvironment().getHardwareInfo(); @@ -603,7 +603,7 @@ uint32_t IoctlHelperXe::createGem(uint64_t size, uint32_t memoryBanks) { memoryInstances.set(regionClassAndInstance.memoryInstance); } create.placement = static_cast(memoryInstances.to_ulong()); - create.cpu_caching = this->getCpuCachingMode(create.placement == drm_xe_memory_class::DRM_XE_MEM_REGION_CLASS_SYSMEM); + create.cpu_caching = this->getCpuCachingMode(isCoherent, create.placement == drm_xe_memory_class::DRM_XE_MEM_REGION_CLASS_SYSMEM); [[maybe_unused]] auto ret = ioctl(DrmIoctl::gemCreate, &create); xeLog(" -> IoctlHelperXe::%s vmid=0x%x s=0x%lx f=0x%x p=0x%x h=0x%x c=%hu r=%d\n", __FUNCTION__, diff --git a/shared/source/os_interface/linux/xe/ioctl_helper_xe.h b/shared/source/os_interface/linux/xe/ioctl_helper_xe.h index 15cf83cb81..719051a43c 100644 --- a/shared/source/os_interface/linux/xe/ioctl_helper_xe.h +++ b/shared/source/os_interface/linux/xe/ioctl_helper_xe.h @@ -41,8 +41,8 @@ class IoctlHelperXe : public IoctlHelper { bool isSetPairAvailable() override; bool isChunkingAvailable() override; bool isVmBindAvailable() override; - int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional memPolicyMode, std::optional> memPolicyNodemask) override; - uint32_t createGem(uint64_t size, uint32_t memoryBanks) override; + int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional memPolicyMode, std::optional> memPolicyNodemask, std::optional isCoherent) override; + uint32_t createGem(uint64_t size, uint32_t memoryBanks, std::optional isCoherent) override; CacheRegion closAlloc() override; uint16_t closAllocWays(CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) override; CacheRegion closFree(CacheRegion closIndex) override; @@ -120,7 +120,7 @@ class IoctlHelperXe : public IoctlHelper { void fillExecBuffer(ExecBuffer &execBuffer, uintptr_t buffersPtr, uint32_t bufferCount, uint32_t startOffset, uint32_t size, uint64_t flags, uint32_t drmContextId) override; void logExecBuffer(const ExecBuffer &execBuffer, std::stringstream &logger) override; bool setDomainCpu(uint32_t handle, bool writeEnable) override; - uint16_t getCpuCachingMode(bool allocationInSystemMemory) const; + uint16_t getCpuCachingMode(std::optional isCoherent, bool allocationInSystemMemory) const; void addDebugMetadata(DrmResourceClass type, uint64_t *offset, uint64_t size); void addDebugMetadataCookie(uint64_t cookie); uint32_t registerResource(DrmResourceClass classType, const void *data, size_t size) override; diff --git a/shared/source/os_interface/product_helper.h b/shared/source/os_interface/product_helper.h index 6ca1a66136..9605ff8cc7 100644 --- a/shared/source/os_interface/product_helper.h +++ b/shared/source/os_interface/product_helper.h @@ -236,6 +236,7 @@ class ProductHelper { virtual bool isDeviceToHostCopySignalingFenceRequired() const = 0; virtual size_t getMaxFillPaternSizeForCopyEngine() const = 0; virtual bool isAvailableExtendedScratch() const = 0; + virtual std::optional isCoherentAllocation(uint64_t patIndex) const = 0; virtual ~ProductHelper() = default; diff --git a/shared/source/os_interface/product_helper_bdw_and_later.inl b/shared/source/os_interface/product_helper_bdw_and_later.inl index 0ea1e226b3..3bc31053bd 100644 --- a/shared/source/os_interface/product_helper_bdw_and_later.inl +++ b/shared/source/os_interface/product_helper_bdw_and_later.inl @@ -113,4 +113,9 @@ bool ProductHelperHw::useLocalPreferredForCacheableBuffers() const { return false; } +template +std::optional ProductHelperHw::isCoherentAllocation(uint64_t patIndex) const { + return std::nullopt; +} + } // namespace NEO diff --git a/shared/source/os_interface/product_helper_hw.h b/shared/source/os_interface/product_helper_hw.h index cdf16b6503..237cbf80e4 100644 --- a/shared/source/os_interface/product_helper_hw.h +++ b/shared/source/os_interface/product_helper_hw.h @@ -181,6 +181,7 @@ class ProductHelperHw : public ProductHelper { bool isDeviceToHostCopySignalingFenceRequired() const override; size_t getMaxFillPaternSizeForCopyEngine() const override; bool isAvailableExtendedScratch() const override; + std::optional isCoherentAllocation(uint64_t patIndex) const override; ~ProductHelperHw() override = default; diff --git a/shared/source/xe_hpc_core/pvc/os_agnostic_product_helper_pvc.inl b/shared/source/xe_hpc_core/pvc/os_agnostic_product_helper_pvc.inl index 6a3378c181..36cd349940 100644 --- a/shared/source/xe_hpc_core/pvc/os_agnostic_product_helper_pvc.inl +++ b/shared/source/xe_hpc_core/pvc/os_agnostic_product_helper_pvc.inl @@ -242,4 +242,9 @@ bool ProductHelperHw::supportReadOnlyAllocations() const { return true; } +template <> +std::optional ProductHelperHw::isCoherentAllocation(uint64_t patIndex) const { + return std::nullopt; +} + } // namespace NEO diff --git a/shared/source/xe_hpg_core/dg2/os_agnostic_product_helper_dg2.inl b/shared/source/xe_hpg_core/dg2/os_agnostic_product_helper_dg2.inl index 8f0ff450f4..238a8f0702 100644 --- a/shared/source/xe_hpg_core/dg2/os_agnostic_product_helper_dg2.inl +++ b/shared/source/xe_hpg_core/dg2/os_agnostic_product_helper_dg2.inl @@ -256,6 +256,11 @@ void ProductHelperHw::adjustNumberOfCcs(HardwareInfo &hwInfo) const hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 1; } +template <> +std::optional ProductHelperHw::isCoherentAllocation(uint64_t patIndex) const { + return std::nullopt; +} + template <> bool ProductHelperHw::isDeviceUsmAllocationReuseSupported() const { return false; diff --git a/shared/source/xe_hpg_core/xe_lpg/os_agnostic_product_helper_xe_lpg.inl b/shared/source/xe_hpg_core/xe_lpg/os_agnostic_product_helper_xe_lpg.inl index 1039c5fd52..efb28005bc 100644 --- a/shared/source/xe_hpg_core/xe_lpg/os_agnostic_product_helper_xe_lpg.inl +++ b/shared/source/xe_hpg_core/xe_lpg/os_agnostic_product_helper_xe_lpg.inl @@ -108,6 +108,15 @@ bool ProductHelperHw::isNewCoherencyModelSupported() const { return true; } +template <> +std::optional ProductHelperHw::isCoherentAllocation(uint64_t patIndex) const { + std::array listOfCoherentPatIndexes = {3, 4}; + if (std::find(listOfCoherentPatIndexes.begin(), listOfCoherentPatIndexes.end(), patIndex) != listOfCoherentPatIndexes.end()) { + return true; + } + return false; +} + template <> bool ProductHelperHw::isDeviceUsmAllocationReuseSupported() const { return true; diff --git a/shared/test/common/mocks/mock_product_helper.cpp b/shared/test/common/mocks/mock_product_helper.cpp index 7fbe97a103..07248bf80e 100644 --- a/shared/test/common/mocks/mock_product_helper.cpp +++ b/shared/test/common/mocks/mock_product_helper.cpp @@ -432,6 +432,11 @@ bool ProductHelperHw::useLocalPreferredForCacheableBuffers() const { return false; } +template <> +std::optional ProductHelperHw::isCoherentAllocation(uint64_t patIndex) const { + return std::nullopt; +} + struct UnknownProduct { struct FrontEndStateSupport { static constexpr bool scratchSize = false; diff --git a/shared/test/common/test_macros/header/common_matchers.h b/shared/test/common/test_macros/header/common_matchers.h index 80cec1db79..e58c38f951 100644 --- a/shared/test/common/test_macros/header/common_matchers.h +++ b/shared/test/common/test_macros/header/common_matchers.h @@ -79,6 +79,7 @@ using IsAtLeastSkl = IsAtLeastProduct; using IsAtLeastMtl = IsAtLeastProduct; using IsAtMostDg2 = IsAtMostProduct; +using IsAtMostPVC = IsAtMostProduct; using IsNotPVC = IsNotWithinProducts; using IsNotPvcOrDg2 = IsNotWithinProducts; 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 47bf62bf03..a94154d2d2 100644 --- a/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp +++ b/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp @@ -713,6 +713,7 @@ TEST(GmmTest, givenAllocationTypeWhenGettingUsageTypeThenReturnCorrectValue) { expectedUsage = (forceUncached || productHelper.isDcFlushAllowed()) ? uncachedGmmUsageType : GMM_RESOURCE_USAGE_OCL_BUFFER; break; + case AllocationType::externalHostPtr: case AllocationType::bufferHostMemory: case AllocationType::internalHostMemory: case AllocationType::mapAllocation: @@ -784,6 +785,7 @@ TEST(GmmTest, givenAllocationTypeAndMitigatedDcFlushWhenGettingUsageTypeThenRetu case AllocationType::linearStream: expectedUsage = GMM_RESOURCE_USAGE_OCL_STATE_HEAP_BUFFER; break; + case AllocationType::externalHostPtr: case AllocationType::bufferHostMemory: case AllocationType::internalHostMemory: case AllocationType::mapAllocation: diff --git a/shared/test/unit_test/os_interface/linux/drm_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_tests.cpp index cd50a44675..b754c2c6c5 100644 --- a/shared/test/unit_test/os_interface/linux/drm_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_tests.cpp @@ -1862,7 +1862,7 @@ TEST(IoctlHelperTest, givenIoctlHelperWhenCallCreateGemThenProperValuesSet) { uint32_t memoryBanks = 3u; EXPECT_EQ(0, drm.ioctlCount.gemCreate); - uint32_t handle = ioctlHelper->createGem(size, memoryBanks); + uint32_t handle = ioctlHelper->createGem(size, memoryBanks, false); EXPECT_EQ(1, drm.ioctlCount.gemCreate); EXPECT_EQ(size, drm.createParamsSize); diff --git a/shared/test/unit_test/os_interface/linux/drm_with_prelim_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_with_prelim_tests.cpp index fc990a4f18..928693e546 100644 --- a/shared/test/unit_test/os_interface/linux/drm_with_prelim_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_with_prelim_tests.cpp @@ -168,7 +168,7 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenCreateGemExtThenReturnSuccess) uint32_t handle = 0; MemRegionsVec memClassInstance = {{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0}}; uint32_t numOfChunks = 0; - auto ret = ioctlHelper->createGemExt(memClassInstance, 1024, handle, 0, {}, -1, false, numOfChunks, std::nullopt, std::nullopt); + auto ret = ioctlHelper->createGemExt(memClassInstance, 1024, handle, 0, {}, -1, false, numOfChunks, std::nullopt, std::nullopt, std::nullopt); EXPECT_EQ(1u, handle); EXPECT_EQ(0, ret); @@ -192,7 +192,7 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenCreateGemExtWithChunkingThenGet uint32_t handle = 0; uint32_t getNumOfChunks = 2; MemRegionsVec memClassInstance = {{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0}}; - ioctlHelper->createGemExt(memClassInstance, allocSize, handle, 0, {}, -1, true, getNumOfChunks, std::nullopt, std::nullopt); + ioctlHelper->createGemExt(memClassInstance, allocSize, handle, 0, {}, -1, true, getNumOfChunks, std::nullopt, std::nullopt, std::nullopt); std::string output = testing::internal::GetCapturedStdout(); std::string expectedOutput("GEM_CREATE_EXT BO-1 with BOChunkingSize 65536, chunkingParamRegion.param.data 65536, numOfChunks 2\n"); EXPECT_EQ(expectedOutput, output); @@ -209,7 +209,7 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenCreateGemExtWithChunkingAndAllo uint32_t handle = 0; uint32_t getNumOfChunks = 2; MemRegionsVec memClassInstance = {{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0}}; - EXPECT_THROW(ioctlHelper->createGemExt(memClassInstance, allocSize, handle, 0, {}, -1, true, getNumOfChunks, std::nullopt, std::nullopt), std::runtime_error); + EXPECT_THROW(ioctlHelper->createGemExt(memClassInstance, allocSize, handle, 0, {}, -1, true, getNumOfChunks, std::nullopt, std::nullopt, std::nullopt), std::runtime_error); } TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenCreateGemExtWithDebugFlagThenPrintDebugInfo) { @@ -221,7 +221,7 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenCreateGemExtWithDebugFlagThenPr uint32_t handle = 0; MemRegionsVec memClassInstance = {{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0}}; uint32_t numOfChunks = 0; - ioctlHelper->createGemExt(memClassInstance, 1024, handle, 0, {}, -1, false, numOfChunks, std::nullopt, std::nullopt); + ioctlHelper->createGemExt(memClassInstance, 1024, handle, 0, {}, -1, false, numOfChunks, std::nullopt, std::nullopt, std::nullopt); std::string output = testing::internal::GetCapturedStdout(); std::string expectedOutput("Performing GEM_CREATE_EXT with { size: 1024, param: 0x1000000010001, memory class: 1, memory instance: 0 }\nGEM_CREATE_EXT has returned: 0 BO-1 with size: 1024\n"); diff --git a/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_dg1.cpp b/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_dg1.cpp index f38b8ce6a8..8098666da7 100644 --- a/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_dg1.cpp +++ b/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_dg1.cpp @@ -28,7 +28,7 @@ DG1TEST_F(IoctlHelperTestsDg1, givenDg1WhenCreateGemExtThenReturnCorrectValue) { uint32_t handle = 0; MemRegionsVec memClassInstance = {{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0}}; uint32_t numOfChunks = 0; - auto ret = ioctlHelper->createGemExt(memClassInstance, 1024, handle, 0, {}, -1, false, numOfChunks, std::nullopt, std::nullopt); + auto ret = ioctlHelper->createGemExt(memClassInstance, 1024, handle, 0, {}, -1, false, numOfChunks, std::nullopt, std::nullopt, false); EXPECT_EQ(0, ret); EXPECT_EQ(1u, handle); @@ -50,7 +50,7 @@ DG1TEST_F(IoctlHelperTestsDg1, givenDg1WithDrmTipWhenCreateGemExtWithDebugFlagTh uint32_t handle = 0; MemRegionsVec memClassInstance = {{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0}}; uint32_t numOfChunks = 0; - auto ret = ioctlHelper->createGemExt(memClassInstance, 1024, handle, 0, {}, -1, false, numOfChunks, std::nullopt, std::nullopt); + auto ret = ioctlHelper->createGemExt(memClassInstance, 1024, handle, 0, {}, -1, false, numOfChunks, std::nullopt, std::nullopt, false); std::string output = testing::internal::GetCapturedStdout(); std::string expectedOutput("Performing GEM_CREATE_EXT with { size: 1024, memory class: 1, memory instance: 0 }\nGEM_CREATE_EXT with EXT_MEMORY_REGIONS has returned: 0 BO-1 with size: 1024\n"); @@ -72,7 +72,7 @@ DG1TEST_F(IoctlHelperTestsDg1, givenDg1WhenCreateGemExtWithDebugFlagThenPrintDeb uint32_t handle = 0; MemRegionsVec memClassInstance = {{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0}}; uint32_t numOfChunks = 0; - auto ret = ioctlHelper->createGemExt(memClassInstance, 1024, handle, 0, {}, -1, false, numOfChunks, std::nullopt, std::nullopt); + auto ret = ioctlHelper->createGemExt(memClassInstance, 1024, handle, 0, {}, -1, false, numOfChunks, std::nullopt, std::nullopt, false); std::string output = testing::internal::GetCapturedStdout(); std::string expectedOutput("Performing GEM_CREATE_EXT with { size: 1024, memory class: 1, memory instance: 0 }\nGEM_CREATE_EXT with EXT_MEMORY_REGIONS has returned: -1 BO-0 with size: 1024\nGEM_CREATE_EXT with EXT_SETPARAM has returned: 0 BO-1 with size: 1024\n"); diff --git a/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_prelim.cpp b/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_prelim.cpp index 3a9a9bbd92..08edec272c 100644 --- a/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_prelim.cpp +++ b/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_prelim.cpp @@ -498,7 +498,7 @@ TEST(IoctlPrelimHelperCreateGemExtTests, givenPrelimWhenCreateGemExtWithMemPolic uint32_t memPolicyMode = 0; mockIoctlHelper.overrideGemCreateExtReturnValue = 0; mockIoctlHelper.initialize(); - auto ret = mockIoctlHelper.createGemExt(memClassInstance, 1024, handle, 0, {}, -1, false, numOfChunks, memPolicyMode, memPolicy); + auto ret = mockIoctlHelper.createGemExt(memClassInstance, 1024, handle, 0, {}, -1, false, numOfChunks, memPolicyMode, memPolicy, false); std::string output = testing::internal::GetCapturedStdout(); std::string expectedSubstring("memory policy:"); @@ -524,7 +524,7 @@ TEST(IoctlPrelimHelperCreateGemExtTests, givenPrelimWhenCreateGemExtWithMemPolic uint32_t memPolicyMode = 0; mockIoctlHelper.overrideGemCreateExtReturnValue = 0; mockIoctlHelper.initialize(); - auto ret = mockIoctlHelper.createGemExt(memClassInstance, size, handle, 0, {}, -1, true, numOfChunks, memPolicyMode, memPolicy); + auto ret = mockIoctlHelper.createGemExt(memClassInstance, size, handle, 0, {}, -1, true, numOfChunks, memPolicyMode, memPolicy, false); EXPECT_EQ(0, ret); EXPECT_TRUE(mockIoctlHelper.lastGemCreateContainedMemPolicy); diff --git a/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_upstream.cpp b/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_upstream.cpp index e975704f4f..19101a760a 100644 --- a/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_upstream.cpp +++ b/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_upstream.cpp @@ -346,7 +346,7 @@ TEST(IoctlHelperTestsUpstream, givenUpstreamWhenCreateGemExtThenReturnCorrectVal uint32_t handle = 0; MemRegionsVec memClassInstance = {{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0}}; uint32_t numOfChunks = 0; - auto ret = ioctlHelper->createGemExt(memClassInstance, 1024, handle, 0, {}, -1, false, numOfChunks, std::nullopt, std::nullopt); + auto ret = ioctlHelper->createGemExt(memClassInstance, 1024, handle, 0, {}, -1, false, numOfChunks, std::nullopt, std::nullopt, false); EXPECT_EQ(0, ret); EXPECT_EQ(1u, handle); @@ -368,7 +368,7 @@ TEST(IoctlHelperTestsUpstream, givenUpstreamWhenCreateGemExtWithDebugFlagThenPri uint32_t handle = 0; MemRegionsVec memClassInstance = {{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0}}; uint32_t numOfChunks = 0; - ioctlHelper->createGemExt(memClassInstance, 1024, handle, 0, {}, -1, false, numOfChunks, std::nullopt, std::nullopt); + ioctlHelper->createGemExt(memClassInstance, 1024, handle, 0, {}, -1, false, numOfChunks, std::nullopt, std::nullopt, false); std::string output = testing::internal::GetCapturedStdout(); std::string expectedOutput("Performing GEM_CREATE_EXT with { size: 1024, memory class: 1, memory instance: 0 }\nGEM_CREATE_EXT with EXT_MEMORY_REGIONS has returned: 0 BO-1 with size: 1024\n"); @@ -383,13 +383,13 @@ TEST(IoctlHelperTestsUpstream, givenSetPatSupportedWhenCreateGemExtThenSetPatExt uint32_t handle = 0; MemRegionsVec memClassInstance = {{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0}}; mockIoctlHelper.isSetPatSupported = false; - auto ret = mockIoctlHelper.createGemExt(memClassInstance, 1, handle, 0, {}, -1, false, 0, std::nullopt, std::nullopt); + auto ret = mockIoctlHelper.createGemExt(memClassInstance, 1, handle, 0, {}, -1, false, 0, std::nullopt, std::nullopt, false); EXPECT_EQ(0, ret); EXPECT_EQ(1u, mockIoctlHelper.ioctlCallCount); EXPECT_FALSE(mockIoctlHelper.lastGemCreateContainedSetPat); mockIoctlHelper.isSetPatSupported = true; - ret = mockIoctlHelper.createGemExt(memClassInstance, 1, handle, 0, {}, -1, false, 0, std::nullopt, std::nullopt); + ret = mockIoctlHelper.createGemExt(memClassInstance, 1, handle, 0, {}, -1, false, 0, std::nullopt, std::nullopt, false); EXPECT_EQ(0, ret); EXPECT_EQ(2u, mockIoctlHelper.ioctlCallCount); EXPECT_TRUE(mockIoctlHelper.lastGemCreateContainedSetPat); @@ -404,13 +404,13 @@ TEST(IoctlHelperTestsUpstream, givenInvalidPatIndexWhenCreateGemExtThenSetPatExt mockIoctlHelper.isSetPatSupported = true; uint64_t invalidPatIndex = CommonConstants::unsupportedPatIndex; MemRegionsVec memClassInstance = {{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0}}; - auto ret = mockIoctlHelper.createGemExt(memClassInstance, 1, handle, invalidPatIndex, {}, -1, false, 0, std::nullopt, std::nullopt); + auto ret = mockIoctlHelper.createGemExt(memClassInstance, 1, handle, invalidPatIndex, {}, -1, false, 0, std::nullopt, std::nullopt, false); EXPECT_EQ(0, ret); EXPECT_EQ(1u, mockIoctlHelper.ioctlCallCount); EXPECT_FALSE(mockIoctlHelper.lastGemCreateContainedSetPat); invalidPatIndex = static_cast(std::numeric_limits::max()) + 1; - ret = mockIoctlHelper.createGemExt(memClassInstance, 1, handle, invalidPatIndex, {}, -1, false, 0, std::nullopt, std::nullopt); + ret = mockIoctlHelper.createGemExt(memClassInstance, 1, handle, invalidPatIndex, {}, -1, false, 0, std::nullopt, std::nullopt, false); EXPECT_EQ(0, ret); EXPECT_EQ(2u, mockIoctlHelper.ioctlCallCount); EXPECT_FALSE(mockIoctlHelper.lastGemCreateContainedSetPat); @@ -432,7 +432,7 @@ TEST(IoctlHelperTestsUpstream, givenSetPatSupportedWhenCreateGemExtWithDebugFlag MemRegionsVec memClassInstance = {{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0}}; uint32_t numOfChunks = 0; uint64_t patIndex = 5; - mockIoctlHelper.createGemExt(memClassInstance, 1024, handle, patIndex, {}, -1, false, numOfChunks, std::nullopt, std::nullopt); + mockIoctlHelper.createGemExt(memClassInstance, 1024, handle, patIndex, {}, -1, false, numOfChunks, std::nullopt, std::nullopt, false); std::string output = testing::internal::GetCapturedStdout(); std::string expectedOutput("Performing GEM_CREATE_EXT with { size: 1024, memory class: 1, memory instance: 0, pat index: 5 }\nGEM_CREATE_EXT with EXT_MEMORY_REGIONS with EXT_SET_PAT has returned: 0 BO-1 with size: 1024\n"); diff --git a/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp b/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp index b437f1acc2..7148429e40 100644 --- a/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp @@ -65,7 +65,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingGemCreateExtWithRegionsThen uint32_t numOfChunks = 0; EXPECT_TRUE(xeIoctlHelper->bindInfo.empty()); - EXPECT_NE(0, xeIoctlHelper->createGemExt(memRegions, 0u, handle, 0, {}, -1, false, numOfChunks, std::nullopt, std::nullopt)); + EXPECT_NE(0, xeIoctlHelper->createGemExt(memRegions, 0u, handle, 0, {}, -1, false, numOfChunks, std::nullopt, std::nullopt, false)); EXPECT_FALSE(xeIoctlHelper->bindInfo.empty()); EXPECT_EQ(DRM_XE_GEM_CPU_CACHING_WC, drm.createParamsCpuCaching); } @@ -88,7 +88,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingGemCreateExtWithRegionsAndV GemVmControl test = {}; EXPECT_TRUE(xeIoctlHelper->bindInfo.empty()); - EXPECT_NE(0, xeIoctlHelper->createGemExt(memRegions, 0u, handle, 0, test.vmId, -1, false, numOfChunks, std::nullopt, std::nullopt)); + EXPECT_NE(0, xeIoctlHelper->createGemExt(memRegions, 0u, handle, 0, test.vmId, -1, false, numOfChunks, std::nullopt, std::nullopt, false)); EXPECT_FALSE(xeIoctlHelper->bindInfo.empty()); EXPECT_EQ(DRM_XE_GEM_CPU_CACHING_WC, drm.createParamsCpuCaching); } @@ -109,7 +109,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallGemCreateAndNoLocalMemoryThenP EXPECT_EQ(0, drm.ioctlCnt.gemCreate); EXPECT_TRUE(xeIoctlHelper->bindInfo.empty()); - uint32_t handle = xeIoctlHelper->createGem(size, memoryBanks); + uint32_t handle = xeIoctlHelper->createGem(size, memoryBanks, false); EXPECT_EQ(1, drm.ioctlCnt.gemCreate); EXPECT_FALSE(xeIoctlHelper->bindInfo.empty()); @@ -139,7 +139,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallGemCreateWhenMemoryBanksZeroTh EXPECT_EQ(0, drm.ioctlCnt.gemCreate); EXPECT_TRUE(xeIoctlHelper->bindInfo.empty()); - uint32_t handle = xeIoctlHelper->createGem(size, memoryBanks); + uint32_t handle = xeIoctlHelper->createGem(size, memoryBanks, false); EXPECT_EQ(1, drm.ioctlCnt.gemCreate); EXPECT_FALSE(xeIoctlHelper->bindInfo.empty()); @@ -169,7 +169,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallGemCreateAndLocalMemoryThenPro EXPECT_EQ(0, drm.ioctlCnt.gemCreate); EXPECT_TRUE(xeIoctlHelper->bindInfo.empty()); - uint32_t handle = xeIoctlHelper->createGem(size, memoryBanks); + uint32_t handle = xeIoctlHelper->createGem(size, memoryBanks, false); EXPECT_EQ(1, drm.ioctlCnt.gemCreate); EXPECT_FALSE(xeIoctlHelper->bindInfo.empty()); @@ -236,7 +236,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingAnyMethodThenDummyValueIsRe MemRegionsVec memRegions{}; uint32_t handle = 0u; uint32_t numOfChunks = 0; - EXPECT_NE(0, xeIoctlHelper->createGemExt(memRegions, 0u, handle, 0, {}, -1, false, numOfChunks, std::nullopt, std::nullopt)); + EXPECT_NE(0, xeIoctlHelper->createGemExt(memRegions, 0u, handle, 0, {}, -1, false, numOfChunks, std::nullopt, std::nullopt, false)); EXPECT_TRUE(xeIoctlHelper->isVmBindAvailable()); @@ -1745,11 +1745,16 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenGetCpuCachingModeCalledThenCorrect drm.memoryInfo.reset(xeIoctlHelper->createMemoryInfo().release()); ASSERT_NE(nullptr, xeIoctlHelper); - EXPECT_EQ(xeIoctlHelper->getCpuCachingMode(false), DRM_XE_GEM_CPU_CACHING_WC); - EXPECT_EQ(xeIoctlHelper->getCpuCachingMode(true), DRM_XE_GEM_CPU_CACHING_WB); + EXPECT_EQ(xeIoctlHelper->getCpuCachingMode(false, false), DRM_XE_GEM_CPU_CACHING_WC); + EXPECT_EQ(xeIoctlHelper->getCpuCachingMode(false, true), DRM_XE_GEM_CPU_CACHING_WC); + EXPECT_EQ(xeIoctlHelper->getCpuCachingMode(true, true), DRM_XE_GEM_CPU_CACHING_WB); + EXPECT_EQ(xeIoctlHelper->getCpuCachingMode(true, false), DRM_XE_GEM_CPU_CACHING_WB); + + EXPECT_EQ(xeIoctlHelper->getCpuCachingMode(std::nullopt, false), DRM_XE_GEM_CPU_CACHING_WC); + EXPECT_EQ(xeIoctlHelper->getCpuCachingMode(std::nullopt, true), DRM_XE_GEM_CPU_CACHING_WB); debugManager.flags.OverrideCpuCaching.set(DRM_XE_GEM_CPU_CACHING_WB); - EXPECT_EQ(xeIoctlHelper->getCpuCachingMode(false), DRM_XE_GEM_CPU_CACHING_WB); + EXPECT_EQ(xeIoctlHelper->getCpuCachingMode(false, false), DRM_XE_GEM_CPU_CACHING_WB); } TEST(IoctlHelperXeTest, whenCallingVmBindThenPatIndexIsSet) { 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 4f4bc3e228..873efedff5 100644 --- a/shared/test/unit_test/os_interface/product_helper_tests.cpp +++ b/shared/test/unit_test/os_interface/product_helper_tests.cpp @@ -950,3 +950,10 @@ HWTEST_F(ProductHelperTest, givenProductHelperWhenAskingForReadOnlyResourceSuppo HWTEST_F(ProductHelperTest, givenProductHelperWhenAskingForDeviceToHostCopySignalingFenceFalseReturned) { EXPECT_FALSE(productHelper->isDeviceToHostCopySignalingFenceRequired()); } + +HWTEST2_F(ProductHelperTest, givenPatIndexWhenCheckIsCoherentAllocationThenReturnNullopt, IsAtMostPVC) { + std::array listOfCoherentPatIndexes = {0, 1, 2, 3, 4}; + for (auto patIndex : listOfCoherentPatIndexes) { + EXPECT_EQ(std::nullopt, productHelper->isCoherentAllocation(patIndex)); + } +} \ No newline at end of file diff --git a/shared/test/unit_test/xe_hpc_core/pvc/test_product_helper_pvc.cpp b/shared/test/unit_test/xe_hpc_core/pvc/test_product_helper_pvc.cpp index 1f8ddbb23c..f379fd0190 100644 --- a/shared/test/unit_test/xe_hpc_core/pvc/test_product_helper_pvc.cpp +++ b/shared/test/unit_test/xe_hpc_core/pvc/test_product_helper_pvc.cpp @@ -332,6 +332,7 @@ PVCTEST_F(PvcProductHelper, whenQueryingMaxNumSamplersThenReturnZero) { PVCTEST_F(PvcProductHelper, whenCheckingIfDummyBlitWaIsRequiredThenTrueIsReturned) { EXPECT_TRUE(productHelper->isDummyBlitWaRequired()); } + PVCTEST_F(PvcProductHelper, givenProductHelperWhenAskingForReadOnlyResourceSupportThenTrueReturned) { EXPECT_TRUE(productHelper->supportReadOnlyAllocations()); -} +} \ No newline at end of file diff --git a/shared/test/unit_test/xe_hpg_core/os_agnostic_product_helper_xe_lpg_tests.cpp b/shared/test/unit_test/xe_hpg_core/os_agnostic_product_helper_xe_lpg_tests.cpp index 344b20385b..6075b65623 100644 --- a/shared/test/unit_test/xe_hpg_core/os_agnostic_product_helper_xe_lpg_tests.cpp +++ b/shared/test/unit_test/xe_hpg_core/os_agnostic_product_helper_xe_lpg_tests.cpp @@ -358,3 +358,14 @@ HWTEST2_F(XeLpgProductHelperTests, givenProductHelperWhenCallIsNewCoherencyModel HWTEST2_F(XeLpgProductHelperTests, givenProductHelperWhenCheckDummyBlitWaRequiredThenReturnTrue, IsXeLpg) { EXPECT_TRUE(productHelper->isDummyBlitWaRequired()); } + +HWTEST2_F(XeLpgProductHelperTests, givenPatIndexWhenCheckIsCoherentAllocationThenReturnProperValue, IsXeLpg) { + std::array listOfCoherentPatIndexes = {3, 4}; + for (auto patIndex : listOfCoherentPatIndexes) { + EXPECT_TRUE(productHelper->isCoherentAllocation(patIndex).value()); + } + std::array listOfNonCoherentPatIndexes = {0, 1, 2}; + for (auto patIndex : listOfNonCoherentPatIndexes) { + EXPECT_FALSE(productHelper->isCoherentAllocation(patIndex).value()); + } +} \ No newline at end of file