mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 18:06:32 +08:00
Revert "feature: Add pat index programming to gem create ext call"
This reverts commit 6489379508.
Signed-off-by: Compute-Runtime-Validation <compute-runtime-validation@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
7868d2aed6
commit
2d7505c01c
@@ -1804,19 +1804,19 @@ BufferObject *DrmMemoryManager::createBufferObjectInMemoryRegion(uint32_t rootDe
|
||||
uint32_t handle = 0;
|
||||
int ret = 0;
|
||||
|
||||
auto patIndex = drm->getPatIndex(gmm, allocationType, CacheRegion::Default, CachePolicy::WriteBack, false);
|
||||
|
||||
auto banks = std::bitset<4>(memoryBanks);
|
||||
if (banks.count() > 1) {
|
||||
ret = memoryInfo->createGemExtWithMultipleRegions(memoryBanks, size, handle, patIndex);
|
||||
ret = memoryInfo->createGemExtWithMultipleRegions(memoryBanks, size, handle);
|
||||
} else {
|
||||
ret = memoryInfo->createGemExtWithSingleRegion(memoryBanks, size, handle, patIndex, pairHandle);
|
||||
ret = memoryInfo->createGemExtWithSingleRegion(memoryBanks, size, handle, pairHandle);
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto patIndex = drm->getPatIndex(gmm, allocationType, CacheRegion::Default, CachePolicy::WriteBack, false);
|
||||
|
||||
auto bo = new (std::nothrow) BufferObject(rootDeviceIndex, drm, patIndex, handle, size, maxOsContextCount);
|
||||
if (!bo) {
|
||||
return nullptr;
|
||||
@@ -1833,14 +1833,14 @@ bool DrmMemoryManager::createDrmChunkedAllocation(Drm *drm, DrmAllocation *alloc
|
||||
uint32_t handle = 0;
|
||||
auto memoryBanks = static_cast<uint32_t>(storageInfo.memoryBanks.to_ulong());
|
||||
uint32_t numOfChunks = DebugManager.flags.NumberOfBOChunks.get();
|
||||
|
||||
auto gmm = allocation->getGmm(0u);
|
||||
auto patIndex = drm->getPatIndex(gmm, allocation->getAllocationType(), CacheRegion::Default, CachePolicy::WriteBack, false);
|
||||
int ret = memoryInfo->createGemExtWithMultipleRegions(memoryBanks, boSize, handle, patIndex, -1, true, numOfChunks);
|
||||
int ret = memoryInfo->createGemExtWithMultipleRegions(memoryBanks, boSize, handle, -1, true, numOfChunks);
|
||||
if (ret != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto gmm = allocation->getGmm(0u);
|
||||
auto patIndex = drm->getPatIndex(gmm, allocation->getAllocationType(), CacheRegion::Default, CachePolicy::WriteBack, false);
|
||||
|
||||
auto bo = new (std::nothrow) BufferObject(allocation->getRootDeviceIndex(), drm, patIndex, handle, boSize, maxOsContextCount);
|
||||
UNRECOVERABLE_IF(bo == nullptr);
|
||||
bo->setAddress(boAddress);
|
||||
@@ -2236,9 +2236,7 @@ GraphicsAllocation *DrmMemoryManager::createSharedUnifiedMemoryAllocation(const
|
||||
auto memoryBanks = (DebugManager.flags.KMDSupportForCrossTileMigrationPolicy.get() > 0 || useChunking) ? allocationData.storageInfo.memoryBanks : DeviceBitfield(1 << memoryInstance);
|
||||
auto memRegions = createMemoryRegionsForSharedAllocation(*pHwInfo, *memoryInfo, allocationData, memoryBanks);
|
||||
|
||||
auto patIndex = drm.getPatIndex(nullptr, allocationData.type, CacheRegion::Default, CachePolicy::WriteBack, false);
|
||||
|
||||
int ret = memoryInfo->createGemExt(memRegions, currentSize, handle, patIndex, {}, -1, useChunking, numOfChunks);
|
||||
int ret = memoryInfo->createGemExt(memRegions, currentSize, handle, {}, -1, useChunking, numOfChunks);
|
||||
|
||||
if (ret) {
|
||||
this->munmapFunction(cpuPointer, totalSizeToAlloc);
|
||||
@@ -2246,6 +2244,8 @@ GraphicsAllocation *DrmMemoryManager::createSharedUnifiedMemoryAllocation(const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto patIndex = drm.getPatIndex(nullptr, allocationData.type, CacheRegion::Default, CachePolicy::WriteBack, false);
|
||||
|
||||
std::unique_ptr<BufferObject, BufferObject::Deleter> bo(new BufferObject(allocationData.rootDeviceIndex, &drm, patIndex, handle, currentSize, maxOsContextCount));
|
||||
|
||||
if (!ioctlHelper->setVmBoAdvise(bo->peekHandle(), vmAdviseAttribute, nullptr)) {
|
||||
|
||||
@@ -80,7 +80,7 @@ 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<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) = 0;
|
||||
virtual int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) = 0;
|
||||
virtual CacheRegion closAlloc() = 0;
|
||||
virtual uint16_t closAllocWays(CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) = 0;
|
||||
virtual CacheRegion closFree(CacheRegion closIndex) = 0;
|
||||
@@ -169,7 +169,7 @@ class IoctlHelperUpstream : 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<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) override;
|
||||
int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) override;
|
||||
CacheRegion closAlloc() override;
|
||||
uint16_t closAllocWays(CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) override;
|
||||
CacheRegion closFree(CacheRegion closIndex) override;
|
||||
@@ -215,10 +215,6 @@ class IoctlHelperUpstream : public IoctlHelper {
|
||||
std::string getIoctlString(DrmIoctl ioctlRequest) const override;
|
||||
bool getFabricLatency(uint32_t fabricId, uint32_t &latency, uint32_t &bandwidth) override;
|
||||
bool isWaitBeforeBindRequired(bool bind) const override;
|
||||
|
||||
protected:
|
||||
MOCKABLE_VIRTUAL void detectExtSetPatSupport();
|
||||
bool isSetPatSupported = false;
|
||||
};
|
||||
|
||||
template <PRODUCT_FAMILY gfxProduct>
|
||||
@@ -229,7 +225,7 @@ class IoctlHelperImpl : public IoctlHelperUpstream {
|
||||
return std::make_unique<IoctlHelperImpl<gfxProduct>>(drm);
|
||||
}
|
||||
|
||||
int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) override;
|
||||
int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) override;
|
||||
std::vector<MemoryRegion> translateToMemoryRegions(const std::vector<uint8_t> ®ionInfo) override;
|
||||
unsigned int getIoctlRequestValue(DrmIoctl ioctlRequest) const override;
|
||||
std::string getIoctlString(DrmIoctl ioctlRequest) const override;
|
||||
@@ -243,7 +239,7 @@ class IoctlHelperPrelim20 : 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<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) override;
|
||||
int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) override;
|
||||
CacheRegion closAlloc() override;
|
||||
uint16_t closAllocWays(CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) override;
|
||||
CacheRegion closFree(CacheRegion closIndex) override;
|
||||
|
||||
@@ -146,7 +146,7 @@ bool IoctlHelperPrelim20::isVmBindAvailable() {
|
||||
return vmBindSupported;
|
||||
}
|
||||
|
||||
int IoctlHelperPrelim20::createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) {
|
||||
int IoctlHelperPrelim20::createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) {
|
||||
uint32_t regionsSize = static_cast<uint32_t>(memClassInstances.size());
|
||||
std::vector<prelim_drm_i915_gem_memory_class_instance> regions(regionsSize);
|
||||
for (uint32_t i = 0; i < regionsSize; i++) {
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/helpers/common_types.h"
|
||||
#include "shared/source/helpers/constants.h"
|
||||
#include "shared/source/os_interface/linux/cache_info.h"
|
||||
#include "shared/source/os_interface/linux/drm_wrappers.h"
|
||||
#include "shared/source/os_interface/linux/i915_upstream.h"
|
||||
@@ -16,7 +15,6 @@
|
||||
namespace NEO {
|
||||
|
||||
bool IoctlHelperUpstream::initialize() {
|
||||
detectExtSetPatSupport();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -32,84 +30,41 @@ bool IoctlHelperUpstream::isVmBindAvailable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
int IoctlHelperUpstream::createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) {
|
||||
bool isPatIndexValid = (patIndex != CommonConstants::unsupportedPatIndex) && (patIndex <= std::numeric_limits<uint32_t>::max());
|
||||
bool useSetPat = this->isSetPatSupported && isPatIndexValid;
|
||||
|
||||
int IoctlHelperUpstream::createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) {
|
||||
uint32_t regionsSize = static_cast<uint32_t>(memClassInstances.size());
|
||||
std::vector<drm_i915_gem_memory_class_instance> regions(regionsSize);
|
||||
for (uint32_t i = 0; i < regionsSize; i++) {
|
||||
regions[i].memory_class = memClassInstances[i].memoryClass;
|
||||
regions[i].memory_instance = memClassInstances[i].memoryInstance;
|
||||
}
|
||||
|
||||
drm_i915_gem_create_ext_memory_regions memRegions{};
|
||||
memRegions.num_regions = regionsSize;
|
||||
memRegions.regions = reinterpret_cast<uintptr_t>(regions.data());
|
||||
memRegions.base.name = I915_GEM_CREATE_EXT_MEMORY_REGIONS;
|
||||
|
||||
drm_i915_gem_create_ext_set_pat setPat{};
|
||||
setPat.pat_index = static_cast<uint32_t>(patIndex);
|
||||
setPat.base.name = I915_GEM_CREATE_EXT_SET_PAT;
|
||||
|
||||
drm_i915_gem_create_ext createExt{};
|
||||
createExt.size = allocSize;
|
||||
createExt.extensions = reinterpret_cast<uintptr_t>(&memRegions);
|
||||
|
||||
if (useSetPat) {
|
||||
memRegions.base.next_extension = reinterpret_cast<uintptr_t>(&setPat);
|
||||
}
|
||||
printDebugString(DebugManager.flags.PrintBOCreateDestroyResult.get(), stdout, "Performing GEM_CREATE_EXT with { size: %lu",
|
||||
allocSize);
|
||||
|
||||
if (DebugManager.flags.PrintBOCreateDestroyResult.get()) {
|
||||
printDebugString(DebugManager.flags.PrintBOCreateDestroyResult.get(), stdout, "Performing GEM_CREATE_EXT with { size: %lu",
|
||||
allocSize);
|
||||
|
||||
for (uint32_t i = 0; i < regionsSize; i++) {
|
||||
auto region = regions[i];
|
||||
printDebugString(DebugManager.flags.PrintBOCreateDestroyResult.get(), stdout, ", memory class: %d, memory instance: %d",
|
||||
region.memory_class, region.memory_instance);
|
||||
}
|
||||
|
||||
if (useSetPat) {
|
||||
printDebugString(DebugManager.flags.PrintBOCreateDestroyResult.get(), stdout, ", pat index: %lu", patIndex);
|
||||
}
|
||||
|
||||
printDebugString(DebugManager.flags.PrintBOCreateDestroyResult.get(), stdout, "%s", " }\n");
|
||||
}
|
||||
|
||||
auto ret = ioctl(DrmIoctl::GemCreateExt, &createExt);
|
||||
|
||||
printDebugString(DebugManager.flags.PrintBOCreateDestroyResult.get(), stdout, "GEM_CREATE_EXT with EXT_MEMORY_REGIONS has returned: %d BO-%u with size: %lu\n", ret, createExt.handle, createExt.size);
|
||||
handle = createExt.handle;
|
||||
|
||||
printDebugString(DebugManager.flags.PrintBOCreateDestroyResult.get(), stdout, "GEM_CREATE_EXT with EXT_MEMORY_REGIONS%s has returned: %d BO-%u with size: %lu\n",
|
||||
(useSetPat) ? " with EXT_SET_PAT" : "",
|
||||
ret, createExt.handle, createExt.size);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void IoctlHelperUpstream::detectExtSetPatSupport() {
|
||||
drm_i915_gem_create_ext_set_pat setPat{};
|
||||
setPat.pat_index = 0;
|
||||
setPat.base.name = I915_GEM_CREATE_EXT_SET_PAT;
|
||||
|
||||
drm_i915_gem_create_ext createExt{};
|
||||
createExt.size = 1;
|
||||
createExt.extensions = reinterpret_cast<uintptr_t>(&setPat);
|
||||
|
||||
int returnValue = ioctl(DrmIoctl::GemCreateExt, &createExt);
|
||||
this->isSetPatSupported = (returnValue == 0);
|
||||
|
||||
printDebugString(DebugManager.flags.PrintBOCreateDestroyResult.get(), stdout, "EXT_SET_PAT support is: %s\n",
|
||||
this->isSetPatSupported ? "enabled" : "disabled");
|
||||
|
||||
if (returnValue == 0) {
|
||||
GemClose close{};
|
||||
close.handle = createExt.handle;
|
||||
returnValue = ioctl(DrmIoctl::GemClose, &close);
|
||||
UNRECOVERABLE_IF(returnValue);
|
||||
}
|
||||
}
|
||||
|
||||
CacheRegion IoctlHelperUpstream::closAlloc() {
|
||||
return CacheRegion::None;
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ constexpr static auto gfxProduct = IGFX_DG1;
|
||||
extern bool isQueryDrmTip(const std::vector<uint8_t> &queryInfo);
|
||||
|
||||
template <>
|
||||
int IoctlHelperImpl<gfxProduct>::createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) {
|
||||
auto ret = IoctlHelperUpstream::createGemExt(memClassInstances, allocSize, handle, patIndex, vmId, pairHandle, isChunked, numOfChunks);
|
||||
int IoctlHelperImpl<gfxProduct>::createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) {
|
||||
auto ret = IoctlHelperUpstream::createGemExt(memClassInstances, allocSize, handle, vmId, pairHandle, isChunked, numOfChunks);
|
||||
if (ret == 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -56,8 +56,8 @@ void MemoryInfo::assignRegionsFromDistances(const std::vector<DistanceInfo> &dis
|
||||
}
|
||||
}
|
||||
|
||||
int MemoryInfo::createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) {
|
||||
return this->drm.getIoctlHelper()->createGemExt(memClassInstances, allocSize, handle, patIndex, vmId, pairHandle, isChunked, numOfChunks);
|
||||
int MemoryInfo::createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) {
|
||||
return this->drm.getIoctlHelper()->createGemExt(memClassInstances, allocSize, handle, vmId, pairHandle, isChunked, numOfChunks);
|
||||
}
|
||||
|
||||
uint32_t MemoryInfo::getTileIndex(uint32_t memoryBank) {
|
||||
@@ -109,7 +109,7 @@ void MemoryInfo::printRegionSizes() {
|
||||
}
|
||||
}
|
||||
|
||||
int MemoryInfo::createGemExtWithSingleRegion(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, int32_t pairHandle) {
|
||||
int MemoryInfo::createGemExtWithSingleRegion(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, int32_t pairHandle) {
|
||||
auto pHwInfo = this->drm.getRootDeviceEnvironment().getHardwareInfo();
|
||||
auto regionClassAndInstance = getMemoryRegionClassAndInstance(memoryBanks, *pHwInfo);
|
||||
MemRegionsVec region = {regionClassAndInstance};
|
||||
@@ -121,11 +121,11 @@ int MemoryInfo::createGemExtWithSingleRegion(uint32_t memoryBanks, size_t allocS
|
||||
}
|
||||
}
|
||||
uint32_t numOfChunks = 0;
|
||||
auto ret = createGemExt(region, allocSize, handle, patIndex, vmId, pairHandle, false, numOfChunks);
|
||||
auto ret = createGemExt(region, allocSize, handle, vmId, pairHandle, false, numOfChunks);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int MemoryInfo::createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex) {
|
||||
int MemoryInfo::createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t allocSize, uint32_t &handle) {
|
||||
auto pHwInfo = this->drm.getRootDeviceEnvironment().getHardwareInfo();
|
||||
auto banks = std::bitset<4>(memoryBanks);
|
||||
MemRegionsVec memRegions{};
|
||||
@@ -140,11 +140,11 @@ int MemoryInfo::createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t all
|
||||
currentBank++;
|
||||
}
|
||||
uint32_t numOfChunks = 0;
|
||||
auto ret = createGemExt(memRegions, allocSize, handle, patIndex, {}, -1, false, numOfChunks);
|
||||
auto ret = createGemExt(memRegions, allocSize, handle, {}, -1, false, numOfChunks);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int MemoryInfo::createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) {
|
||||
int MemoryInfo::createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) {
|
||||
auto pHwInfo = this->drm.getRootDeviceEnvironment().getHardwareInfo();
|
||||
auto banks = std::bitset<4>(memoryBanks);
|
||||
MemRegionsVec memRegions{};
|
||||
@@ -158,7 +158,7 @@ int MemoryInfo::createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t all
|
||||
}
|
||||
currentBank++;
|
||||
}
|
||||
auto ret = createGemExt(memRegions, allocSize, handle, patIndex, {}, pairHandle, isChunked, numOfChunks);
|
||||
auto ret = createGemExt(memRegions, allocSize, handle, {}, pairHandle, isChunked, numOfChunks);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class MemoryInfo {
|
||||
|
||||
void assignRegionsFromDistances(const std::vector<DistanceInfo> &distances);
|
||||
|
||||
MOCKABLE_VIRTUAL int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks);
|
||||
MOCKABLE_VIRTUAL int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks);
|
||||
|
||||
MemoryClassInstance getMemoryRegionClassAndInstance(uint32_t memoryBank, const HardwareInfo &hwInfo);
|
||||
|
||||
@@ -38,9 +38,9 @@ class MemoryInfo {
|
||||
|
||||
uint32_t getTileIndex(uint32_t memoryBank);
|
||||
|
||||
MOCKABLE_VIRTUAL int createGemExtWithSingleRegion(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, int32_t pairHandle);
|
||||
MOCKABLE_VIRTUAL int createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex);
|
||||
MOCKABLE_VIRTUAL int createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, int32_t pairHandle, bool isChunked, uint32_t numOfChunks);
|
||||
MOCKABLE_VIRTUAL int createGemExtWithSingleRegion(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, int32_t pairHandle);
|
||||
MOCKABLE_VIRTUAL int createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t allocSize, uint32_t &handle);
|
||||
MOCKABLE_VIRTUAL int createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, int32_t pairHandle, bool isChunked, uint32_t numOfChunks);
|
||||
|
||||
const RegionContainer &getDrmRegionInfos() const { return drmQueryRegions; }
|
||||
|
||||
|
||||
@@ -435,7 +435,7 @@ bool IoctlHelperXe::getTopologyDataAndMap(const HardwareInfo &hwInfo, DrmQueryTo
|
||||
return true;
|
||||
}
|
||||
|
||||
int IoctlHelperXe::createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) {
|
||||
int IoctlHelperXe::createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) {
|
||||
struct drm_xe_gem_create create = {};
|
||||
uint32_t regionsSize = static_cast<uint32_t>(memClassInstances.size());
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ 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<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) override;
|
||||
int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) override;
|
||||
CacheRegion closAlloc() override;
|
||||
uint16_t closAllocWays(CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) override;
|
||||
CacheRegion closFree(CacheRegion closIndex) override;
|
||||
|
||||
@@ -69,14 +69,14 @@ struct MockedMemoryInfo : public NEO::MemoryInfo {
|
||||
size_t getMemoryRegionSize(uint32_t memoryBank) override {
|
||||
return 1024u;
|
||||
}
|
||||
int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) override {
|
||||
int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) override {
|
||||
if (allocSize == 0) {
|
||||
return EINVAL;
|
||||
}
|
||||
handle = 1u;
|
||||
return 0;
|
||||
}
|
||||
int createGemExtWithSingleRegion(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, int32_t pairHandle) override {
|
||||
int createGemExtWithSingleRegion(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, int32_t pairHandle) override {
|
||||
if (allocSize == 0) {
|
||||
return EINVAL;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ struct MockedMemoryInfo : public NEO::MemoryInfo {
|
||||
pairHandlePassed = pairHandle;
|
||||
return 0;
|
||||
}
|
||||
int createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex) override {
|
||||
int createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t allocSize, uint32_t &handle) override {
|
||||
if (allocSize == 0) {
|
||||
return EINVAL;
|
||||
}
|
||||
@@ -92,7 +92,7 @@ struct MockedMemoryInfo : public NEO::MemoryInfo {
|
||||
banks = memoryBanks;
|
||||
return 0;
|
||||
}
|
||||
int createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) override {
|
||||
int createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) override {
|
||||
if (allocSize == 0) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
@@ -373,7 +373,7 @@ TEST(MemoryInfo, givenMemoryInfoWithRegionsWhenCreatingGemWithExtensionsThenRetu
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
|
||||
uint32_t numOfChunks = 0;
|
||||
auto ret = memoryInfo->createGemExt(memClassInstance, 1024, handle, 0, {}, -1, false, numOfChunks);
|
||||
auto ret = memoryInfo->createGemExt(memClassInstance, 1024, handle, {}, -1, false, numOfChunks);
|
||||
EXPECT_EQ(1u, handle);
|
||||
EXPECT_EQ(0, ret);
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
@@ -397,7 +397,7 @@ TEST(MemoryInfo, givenMemoryInfoWithRegionsWhenCreatingGemExtWithSingleRegionThe
|
||||
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo, *drm);
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
auto ret = memoryInfo->createGemExtWithSingleRegion(1, 1024, handle, 0, -1);
|
||||
auto ret = memoryInfo->createGemExtWithSingleRegion(1, 1024, handle, -1);
|
||||
EXPECT_EQ(1u, handle);
|
||||
EXPECT_EQ(0, ret);
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
@@ -428,12 +428,12 @@ TEST(MemoryInfo, givenMemoryInfoWithRegionsWhenCreatingGemExtWithPairHandleThenR
|
||||
uint32_t pairHandle = 0;
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo, *drm);
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
auto ret = memoryInfo->createGemExtWithSingleRegion(1, 1024, pairHandle, 0, -1);
|
||||
auto ret = memoryInfo->createGemExtWithSingleRegion(1, 1024, pairHandle, -1);
|
||||
EXPECT_EQ(0, ret);
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
|
||||
uint32_t handle = 0;
|
||||
ret = memoryInfo->createGemExtWithSingleRegion(1, 1024, handle, 0, pairHandle);
|
||||
ret = memoryInfo->createGemExtWithSingleRegion(1, 1024, handle, pairHandle);
|
||||
EXPECT_EQ(0, ret);
|
||||
EXPECT_EQ(2u, drm->ioctlCallsCount);
|
||||
}
|
||||
@@ -461,7 +461,7 @@ TEST(MemoryInfo, givenMemoryInfoWithRegionsWhenCreatingGemExtWithChunkingButSize
|
||||
bool isChunked = true;
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo, *drm);
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
EXPECT_THROW(memoryInfo->createGemExtWithMultipleRegions(1, allocSize, handle, 0, pairHandle, isChunked, numOfChunks), std::runtime_error);
|
||||
EXPECT_THROW(memoryInfo->createGemExtWithMultipleRegions(1, allocSize, handle, pairHandle, isChunked, numOfChunks), std::runtime_error);
|
||||
}
|
||||
|
||||
TEST(MemoryInfo, givenMemoryInfoWithRegionsWhenCreatingGemExtWithChunkingWithSizeGreaterThanAllowedThenAllocationIsCreatedWithChunking) {
|
||||
@@ -487,7 +487,7 @@ TEST(MemoryInfo, givenMemoryInfoWithRegionsWhenCreatingGemExtWithChunkingWithSiz
|
||||
bool isChunked = true;
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo, *drm);
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
auto ret = memoryInfo->createGemExtWithMultipleRegions(1, allocSize, handle, 0, pairHandle, isChunked, numOfChunks);
|
||||
auto ret = memoryInfo->createGemExtWithMultipleRegions(1, allocSize, handle, pairHandle, isChunked, numOfChunks);
|
||||
EXPECT_EQ(0, ret);
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
}
|
||||
@@ -511,7 +511,7 @@ TEST(MemoryInfo, givenMemoryInfoWithRegionsAndPrivateBOSupportWhenCreatingGemExt
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
|
||||
uint32_t handle = 0;
|
||||
auto ret = memoryInfo->createGemExtWithSingleRegion(1, 1024, handle, 0, -1);
|
||||
auto ret = memoryInfo->createGemExtWithSingleRegion(1, 1024, handle, -1);
|
||||
EXPECT_EQ(1u, handle);
|
||||
EXPECT_EQ(0, ret);
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
@@ -541,7 +541,7 @@ TEST(MemoryInfo, givenMemoryInfoWithRegionsAndNoPrivateBOSupportWhenCreatingGemE
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
|
||||
uint32_t handle = 0;
|
||||
auto ret = memoryInfo->createGemExtWithSingleRegion(1, 1024, handle, 0, -1);
|
||||
auto ret = memoryInfo->createGemExtWithSingleRegion(1, 1024, handle, -1);
|
||||
EXPECT_EQ(1u, handle);
|
||||
EXPECT_EQ(0, ret);
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
@@ -570,7 +570,7 @@ TEST(MemoryInfo, givenMemoryInfoWithRegionsAndPrivateBOSupportedAndIsPerContextV
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
|
||||
uint32_t handle = 0;
|
||||
auto ret = memoryInfo->createGemExtWithSingleRegion(1, 1024, handle, 0, -1);
|
||||
auto ret = memoryInfo->createGemExtWithSingleRegion(1, 1024, handle, -1);
|
||||
EXPECT_EQ(1u, handle);
|
||||
EXPECT_EQ(0, ret);
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
@@ -603,7 +603,7 @@ TEST(MemoryInfo, givenMemoryInfoWithRegionsWhenCreatingGemExtWithMultipleRegions
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
uint32_t handle = 0;
|
||||
uint32_t memoryRegions = 0b1011;
|
||||
auto ret = memoryInfo->createGemExtWithMultipleRegions(memoryRegions, 1024, handle, 0);
|
||||
auto ret = memoryInfo->createGemExtWithMultipleRegions(memoryRegions, 1024, handle);
|
||||
EXPECT_EQ(1u, handle);
|
||||
EXPECT_EQ(0, ret);
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
@@ -644,7 +644,7 @@ TEST(MemoryInfo, givenMemoryInfoWithRegionsWhenCallingCreatingGemExtWithMultiple
|
||||
uint32_t handle = 0;
|
||||
uint32_t memoryRegions = 0b1011;
|
||||
uint32_t numOfChunks = 2;
|
||||
EXPECT_THROW(memoryInfo->createGemExtWithMultipleRegions(memoryRegions, MemoryConstants::chunkThreshold / (numOfChunks * 2), handle, 0, -1, true, numOfChunks), std::runtime_error);
|
||||
EXPECT_THROW(memoryInfo->createGemExtWithMultipleRegions(memoryRegions, MemoryConstants::chunkThreshold / (numOfChunks * 2), handle, -1, true, numOfChunks), std::runtime_error);
|
||||
}
|
||||
|
||||
TEST(MemoryInfo, givenMemoryInfoWithRegionsWhenCallingCreatingGemExtWithMultipleRegionsAndChunkingThenReturnCorrectValues) {
|
||||
@@ -672,7 +672,7 @@ TEST(MemoryInfo, givenMemoryInfoWithRegionsWhenCallingCreatingGemExtWithMultiple
|
||||
uint32_t memoryRegions = 0b1011;
|
||||
uint32_t numOfChunks = 2;
|
||||
size_t size = MemoryConstants::chunkThreshold * numOfChunks;
|
||||
auto ret = memoryInfo->createGemExtWithMultipleRegions(memoryRegions, size, handle, 0, -1, true, numOfChunks);
|
||||
auto ret = memoryInfo->createGemExtWithMultipleRegions(memoryRegions, size, handle, -1, true, numOfChunks);
|
||||
EXPECT_EQ(1u, handle);
|
||||
EXPECT_EQ(0, ret);
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
|
||||
@@ -236,7 +236,7 @@ HWTEST2_F(MemoryInfoTest, givenMemoryInfoWithRegionsWhenCreatingGemWithExtension
|
||||
uint32_t handle = 0;
|
||||
MemRegionsVec memClassInstance = {regionInfo[0].region, regionInfo[1].region};
|
||||
uint32_t numOfChunks = 0;
|
||||
auto ret = memoryInfo->createGemExt(memClassInstance, 1024, handle, 0, {}, -1, false, numOfChunks);
|
||||
auto ret = memoryInfo->createGemExt(memClassInstance, 1024, handle, {}, -1, false, numOfChunks);
|
||||
EXPECT_EQ(1u, handle);
|
||||
EXPECT_EQ(0, ret);
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
@@ -259,7 +259,7 @@ HWTEST2_F(MemoryInfoTest, givenMemoryInfoWithRegionsWhenCreatingGemExtWithSingle
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo, *drm);
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
|
||||
auto ret = memoryInfo->createGemExtWithSingleRegion(1, 1024, handle, 0, -1);
|
||||
auto ret = memoryInfo->createGemExtWithSingleRegion(1, 1024, handle, -1);
|
||||
EXPECT_EQ(1u, handle);
|
||||
EXPECT_EQ(0, ret);
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
|
||||
@@ -3645,6 +3645,7 @@ TEST(DrmMemoryManagerFreeGraphicsMemoryUnreferenceTest,
|
||||
TEST(DrmMemoryManagerFreeGraphicsMemoryUnreferenceTest,
|
||||
whenPrintBOCreateDestroyResultFlagIsSetAndCallToCreateSharedAllocationThenExpectedMessageIsPrinted) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
DebugManager.flags.PrintBOCreateDestroyResult.set(true);
|
||||
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
const uint32_t rootDeviceIndex = 0u;
|
||||
@@ -3658,7 +3659,6 @@ TEST(DrmMemoryManagerFreeGraphicsMemoryUnreferenceTest,
|
||||
osHandle handle = 1u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, {});
|
||||
|
||||
DebugManager.flags.PrintBOCreateDestroyResult.set(true);
|
||||
testing::internal::CaptureStdout();
|
||||
auto allocation = memoryManger.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, false, nullptr);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
|
||||
@@ -137,7 +137,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);
|
||||
auto ret = ioctlHelper->createGemExt(memClassInstance, 1024, handle, {}, -1, false, numOfChunks);
|
||||
|
||||
EXPECT_EQ(1u, handle);
|
||||
EXPECT_EQ(0, ret);
|
||||
@@ -155,7 +155,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);
|
||||
ioctlHelper->createGemExt(memClassInstance, allocSize, handle, {}, -1, true, getNumOfChunks);
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
std::string expectedOutput("GEM_CREATE_EXT with BOChunkingSize 65536, chunkingParamRegion.param.data 65536, numOfChunks 2\n");
|
||||
EXPECT_EQ(expectedOutput, output);
|
||||
@@ -172,7 +172,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::runtime_error);
|
||||
EXPECT_THROW(ioctlHelper->createGemExt(memClassInstance, allocSize, handle, {}, -1, true, getNumOfChunks), std::runtime_error);
|
||||
}
|
||||
|
||||
TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenCreateGemExtWithDebugFlagThenPrintDebugInfo) {
|
||||
@@ -184,7 +184,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);
|
||||
ioctlHelper->createGemExt(memClassInstance, 1024, handle, {}, -1, false, numOfChunks);
|
||||
|
||||
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");
|
||||
|
||||
@@ -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);
|
||||
auto ret = ioctlHelper->createGemExt(memClassInstance, 1024, handle, {}, -1, false, numOfChunks);
|
||||
|
||||
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);
|
||||
auto ret = ioctlHelper->createGemExt(memClassInstance, 1024, handle, {}, -1, false, numOfChunks);
|
||||
|
||||
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);
|
||||
auto ret = ioctlHelper->createGemExt(memClassInstance, 1024, handle, {}, -1, false, numOfChunks);
|
||||
|
||||
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");
|
||||
|
||||
@@ -18,67 +18,6 @@
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
struct MockIoctlHelperUpstream : IoctlHelperUpstream {
|
||||
using IoctlHelperUpstream::IoctlHelperUpstream;
|
||||
using IoctlHelperUpstream::isSetPatSupported;
|
||||
|
||||
void detectExtSetPatSupport() override {
|
||||
detectExtSetPatSupportCallCount++;
|
||||
IoctlHelperUpstream::detectExtSetPatSupport();
|
||||
}
|
||||
|
||||
int ioctl(DrmIoctl request, void *arg) override {
|
||||
ioctlCallCount++;
|
||||
if (request == DrmIoctl::GemCreateExt) {
|
||||
lastGemCreateContainedSetPat = checkWhetherGemCreateExtContainsSetPat(arg);
|
||||
if (overrideGemCreateExtReturnValue.has_value()) {
|
||||
return *overrideGemCreateExtReturnValue;
|
||||
}
|
||||
}
|
||||
return IoctlHelperUpstream::ioctl(request, arg);
|
||||
}
|
||||
|
||||
bool checkWhetherGemCreateExtContainsSetPat(void *arg) {
|
||||
auto &gemCreateExt = *reinterpret_cast<drm_i915_gem_create_ext *>(arg);
|
||||
auto pExtensionBase = reinterpret_cast<i915_user_extension *>(gemCreateExt.extensions);
|
||||
while (pExtensionBase != nullptr) {
|
||||
if (pExtensionBase->name == I915_GEM_CREATE_EXT_SET_PAT) {
|
||||
return true;
|
||||
}
|
||||
pExtensionBase = reinterpret_cast<i915_user_extension *>(pExtensionBase->next_extension);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t detectExtSetPatSupportCallCount = 0;
|
||||
size_t ioctlCallCount = 0;
|
||||
std::optional<int> overrideGemCreateExtReturnValue{};
|
||||
bool lastGemCreateContainedSetPat = false;
|
||||
};
|
||||
|
||||
TEST(IoctlHelperUpstreamTest, whenInitializeIsCalledThenDetectExtSetPatSupportFunctionIsCalled) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
MockIoctlHelperUpstream mockIoctlHelper{*drm};
|
||||
EXPECT_EQ(0u, mockIoctlHelper.detectExtSetPatSupportCallCount);
|
||||
EXPECT_FALSE(mockIoctlHelper.lastGemCreateContainedSetPat);
|
||||
EXPECT_EQ(0u, mockIoctlHelper.ioctlCallCount);
|
||||
|
||||
mockIoctlHelper.overrideGemCreateExtReturnValue = 0;
|
||||
mockIoctlHelper.initialize();
|
||||
EXPECT_EQ(1u, mockIoctlHelper.detectExtSetPatSupportCallCount);
|
||||
EXPECT_TRUE(mockIoctlHelper.lastGemCreateContainedSetPat);
|
||||
EXPECT_EQ(2u, mockIoctlHelper.ioctlCallCount); // create and close
|
||||
EXPECT_TRUE(mockIoctlHelper.isSetPatSupported);
|
||||
|
||||
mockIoctlHelper.overrideGemCreateExtReturnValue = -1;
|
||||
mockIoctlHelper.initialize();
|
||||
EXPECT_EQ(2u, mockIoctlHelper.detectExtSetPatSupportCallCount);
|
||||
EXPECT_TRUE(mockIoctlHelper.lastGemCreateContainedSetPat);
|
||||
EXPECT_EQ(3u, mockIoctlHelper.ioctlCallCount); // only create
|
||||
EXPECT_FALSE(mockIoctlHelper.isSetPatSupported);
|
||||
}
|
||||
|
||||
TEST(IoctlHelperUpstreamTest, whenGettingVmBindAvailabilityThenFalseIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
@@ -280,7 +219,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);
|
||||
auto ret = ioctlHelper->createGemExt(memClassInstance, 1024, handle, {}, -1, false, numOfChunks);
|
||||
|
||||
EXPECT_EQ(0, ret);
|
||||
EXPECT_EQ(1u, handle);
|
||||
@@ -291,110 +230,23 @@ TEST(IoctlHelperTestsUpstream, givenUpstreamWhenCreateGemExtThenReturnCorrectVal
|
||||
|
||||
TEST(IoctlHelperTestsUpstream, givenUpstreamWhenCreateGemExtWithDebugFlagThenPrintDebugInfo) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
DebugManager.flags.PrintBOCreateDestroyResult.set(true);
|
||||
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
DebugManager.flags.PrintBOCreateDestroyResult.set(true);
|
||||
testing::internal::CaptureStdout();
|
||||
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
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);
|
||||
ioctlHelper->createGemExt(memClassInstance, 1024, handle, {}, -1, false, numOfChunks);
|
||||
|
||||
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");
|
||||
EXPECT_EQ(expectedOutput, output);
|
||||
}
|
||||
|
||||
TEST(IoctlHelperTestsUpstream, givenSetPatSupportedWhenCreateGemExtThenSetPatExtensionsIsAdded) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
MockIoctlHelperUpstream mockIoctlHelper{*drm};
|
||||
|
||||
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);
|
||||
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);
|
||||
EXPECT_EQ(0, ret);
|
||||
EXPECT_EQ(2u, mockIoctlHelper.ioctlCallCount);
|
||||
EXPECT_TRUE(mockIoctlHelper.lastGemCreateContainedSetPat);
|
||||
}
|
||||
|
||||
TEST(IoctlHelperTestsUpstream, givenInvalidPatIndexWhenCreateGemExtThenSetPatExtensionsIsNotAdded) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
MockIoctlHelperUpstream mockIoctlHelper{*drm};
|
||||
|
||||
uint32_t handle = 0;
|
||||
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);
|
||||
EXPECT_EQ(0, ret);
|
||||
EXPECT_EQ(1u, mockIoctlHelper.ioctlCallCount);
|
||||
EXPECT_FALSE(mockIoctlHelper.lastGemCreateContainedSetPat);
|
||||
|
||||
invalidPatIndex = static_cast<uint64_t>(std::numeric_limits<uint32_t>::max()) + 1;
|
||||
ret = mockIoctlHelper.createGemExt(memClassInstance, 1, handle, invalidPatIndex, {}, -1, false, 0);
|
||||
EXPECT_EQ(0, ret);
|
||||
EXPECT_EQ(2u, mockIoctlHelper.ioctlCallCount);
|
||||
EXPECT_FALSE(mockIoctlHelper.lastGemCreateContainedSetPat);
|
||||
}
|
||||
|
||||
TEST(IoctlHelperTestsUpstream, givenSetPatSupportedWhenCreateGemExtWithDebugFlagThenPrintDebugInfoWithExtSetPat) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
MockIoctlHelperUpstream mockIoctlHelper{*drm};
|
||||
|
||||
DebugManager.flags.PrintBOCreateDestroyResult.set(true);
|
||||
testing::internal::CaptureStdout();
|
||||
|
||||
uint32_t handle = 0;
|
||||
mockIoctlHelper.isSetPatSupported = true;
|
||||
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::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");
|
||||
EXPECT_EQ(expectedOutput, output);
|
||||
}
|
||||
|
||||
TEST(IoctlHelperUpstreamTest, whenDetectExtSetPatSupportIsCalledWithDebugFlagThenPrintCorrectDebugInfo) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
MockIoctlHelperUpstream mockIoctlHelper{*drm};
|
||||
|
||||
DebugManager.flags.PrintBOCreateDestroyResult.set(true);
|
||||
testing::internal::CaptureStdout();
|
||||
mockIoctlHelper.overrideGemCreateExtReturnValue = 0;
|
||||
mockIoctlHelper.detectExtSetPatSupport();
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
std::string expectedOutput("EXT_SET_PAT support is: enabled\n");
|
||||
EXPECT_EQ(expectedOutput, output);
|
||||
|
||||
testing::internal::CaptureStdout();
|
||||
mockIoctlHelper.overrideGemCreateExtReturnValue = -1;
|
||||
mockIoctlHelper.detectExtSetPatSupport();
|
||||
output = testing::internal::GetCapturedStdout();
|
||||
expectedOutput = "EXT_SET_PAT support is: disabled\n";
|
||||
EXPECT_EQ(expectedOutput, output);
|
||||
}
|
||||
|
||||
TEST(IoctlHelperTestsUpstream, givenUpstreamWhenClosAllocThenReturnNoneRegion) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
|
||||
@@ -77,7 +77,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingGemCreateExtWithRegionsThen
|
||||
|
||||
uint32_t handle = 0u;
|
||||
uint32_t numOfChunks = 0;
|
||||
EXPECT_NE(0, xeIoctlHelper->createGemExt(memRegions, 0u, handle, 0, {}, -1, false, numOfChunks));
|
||||
EXPECT_NE(0, xeIoctlHelper->createGemExt(memRegions, 0u, handle, {}, -1, false, numOfChunks));
|
||||
}
|
||||
|
||||
TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingGemCreateExtWithRegionsAndVmIdThenDummyValueIsReturned) {
|
||||
@@ -96,7 +96,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingGemCreateExtWithRegionsAndV
|
||||
uint32_t handle = 0u;
|
||||
uint32_t numOfChunks = 0;
|
||||
GemVmControl test = {};
|
||||
EXPECT_NE(0, xeIoctlHelper->createGemExt(memRegions, 0u, handle, 0, test.vmId, -1, false, numOfChunks));
|
||||
EXPECT_NE(0, xeIoctlHelper->createGemExt(memRegions, 0u, handle, test.vmId, -1, false, numOfChunks));
|
||||
}
|
||||
|
||||
TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingAnyMethodThenDummyValueIsReturned) {
|
||||
@@ -120,7 +120,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));
|
||||
EXPECT_NE(0, xeIoctlHelper->createGemExt(memRegions, 0u, handle, {}, -1, false, numOfChunks));
|
||||
|
||||
EXPECT_TRUE(xeIoctlHelper->isVmBindAvailable());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user