mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-12 17:33:00 +08:00
Add support for PRELIM_I915_PARAM_SET_PAIR
This extension allows pairing two buffer objects so they can be exported using a single dma-buf handle. When imported, a single buffer object is created with a total size of the two buffer objects. Related-To: LOCI-3355 Sync to https://github.com/intel-gpu/drm-uapi-helper/releases/tag/v2.0-rc15 Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
3d0b6973fe
commit
a3b3f3e86e
@@ -46,6 +46,7 @@ class DrmMock : public Drm {
|
||||
using Drm::queryAndSetVmBindPatIndexProgrammingSupport;
|
||||
using Drm::queryDeviceIdAndRevision;
|
||||
using Drm::requirePerContextVM;
|
||||
using Drm::setPairAvailable;
|
||||
using Drm::setupIoctlHelper;
|
||||
using Drm::sliceCountChangeSupported;
|
||||
using Drm::systemInfo;
|
||||
@@ -137,6 +138,20 @@ class DrmMock : public Drm {
|
||||
return bindAvailable;
|
||||
}
|
||||
|
||||
bool isSetPairAvailable() override {
|
||||
if (callBaseIsSetPairAvailable) {
|
||||
return Drm::isSetPairAvailable();
|
||||
}
|
||||
return setPairAvailable;
|
||||
}
|
||||
|
||||
bool getSetPairAvailable() override {
|
||||
if (callBaseGetSetPairAvailable) {
|
||||
return Drm::getSetPairAvailable();
|
||||
}
|
||||
return setPairAvailable;
|
||||
}
|
||||
|
||||
uint32_t getBaseIoctlCalls() {
|
||||
return ioctlCallsForHelperInitialization + static_cast<uint32_t>(virtualMemoryIds.size());
|
||||
}
|
||||
@@ -175,6 +190,8 @@ class DrmMock : public Drm {
|
||||
bool allowDebugAttachCallBase = false;
|
||||
bool callBaseCreateDrmContext = true;
|
||||
bool callBaseIsVmBindAvailable = false;
|
||||
bool callBaseIsSetPairAvailable = false;
|
||||
bool callBaseGetSetPairAvailable = false;
|
||||
|
||||
bool capturedCooperativeContextRequest = false;
|
||||
|
||||
|
||||
@@ -48,6 +48,10 @@ int DrmMockPrelimContext::handlePrelimRequest(DrmIoctl request, void *arg) {
|
||||
vmBindQueryCalled++;
|
||||
*gp->value = vmBindQueryValue;
|
||||
return vmBindQueryReturn;
|
||||
} else if (gp->param == PRELIM_I915_PARAM_HAS_SET_PAIR) {
|
||||
setPairQueryCalled++;
|
||||
*gp->value = setPairQueryValue;
|
||||
return setPairQueryReturn;
|
||||
}
|
||||
} break;
|
||||
case DrmIoctl::GemContextGetparam: {
|
||||
@@ -158,9 +162,18 @@ int DrmMockPrelimContext::handlePrelimRequest(DrmIoctl request, void *arg) {
|
||||
|
||||
prelim_drm_i915_gem_create_ext_vm_private *vmPrivateExt = nullptr;
|
||||
if (extension->base.next_extension != 0) {
|
||||
vmPrivateExt = reinterpret_cast<prelim_drm_i915_gem_create_ext_vm_private *>(extension->base.next_extension);
|
||||
if (vmPrivateExt->base.name != PRELIM_I915_GEM_CREATE_EXT_VM_PRIVATE) {
|
||||
return EINVAL;
|
||||
|
||||
prelim_drm_i915_gem_create_ext_setparam *pairSetparamRegion = nullptr;
|
||||
pairSetparamRegion = reinterpret_cast<prelim_drm_i915_gem_create_ext_setparam *>(extension->base.next_extension);
|
||||
if (pairSetparamRegion->base.name == PRELIM_I915_GEM_CREATE_EXT_SETPARAM) {
|
||||
if ((pairSetparamRegion->base.name & PRELIM_I915_PARAM_SET_PAIR) == 0) {
|
||||
return EINVAL;
|
||||
}
|
||||
} else {
|
||||
vmPrivateExt = reinterpret_cast<prelim_drm_i915_gem_create_ext_vm_private *>(extension->base.next_extension);
|
||||
if (vmPrivateExt->base.name != PRELIM_I915_GEM_CREATE_EXT_VM_PRIVATE) {
|
||||
return EINVAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,6 +98,10 @@ struct DrmMockPrelimContext {
|
||||
uint64_t receivedSetContextParamCtxId{0};
|
||||
uint64_t receivedContextCreateExtSetParamRunaloneCount{0};
|
||||
|
||||
size_t setPairQueryCalled{0};
|
||||
int setPairQueryValue{0};
|
||||
int setPairQueryReturn{0};
|
||||
|
||||
size_t vmBindQueryCalled{0};
|
||||
int vmBindQueryValue{0};
|
||||
int vmBindQueryReturn{0};
|
||||
|
||||
@@ -238,3 +238,12 @@ bool DrmMockCustom::isVmBindAvailable() {
|
||||
return isVmBindAvailableCall.returnValue;
|
||||
}
|
||||
}
|
||||
|
||||
bool DrmMockCustom::getSetPairAvailable() {
|
||||
getSetPairAvailableCall.called++;
|
||||
if (getSetPairAvailableCall.callParent) {
|
||||
return Drm::getSetPairAvailable();
|
||||
} else {
|
||||
return getSetPairAvailableCall.returnValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,6 +127,8 @@ class DrmMockCustom : public Drm {
|
||||
|
||||
int waitUserFence(uint32_t ctxId, uint64_t address, uint64_t value, ValueWidth dataWidth, int64_t timeout, uint16_t flags) override;
|
||||
|
||||
bool getSetPairAvailable() override;
|
||||
|
||||
bool isVmBindAvailable() override;
|
||||
|
||||
bool completionFenceSupport() override {
|
||||
@@ -161,6 +163,7 @@ class DrmMockCustom : public Drm {
|
||||
IoctlResExt NONE = {-1, 0};
|
||||
|
||||
WaitUserFenceCall waitUserFenceCall{};
|
||||
IsVmBindAvailableCall getSetPairAvailableCall{};
|
||||
IsVmBindAvailableCall isVmBindAvailableCall{};
|
||||
|
||||
std::atomic<int> ioctl_res;
|
||||
|
||||
@@ -69,18 +69,19 @@ struct MockedMemoryInfo : public NEO::MemoryInfo {
|
||||
size_t getMemoryRegionSize(uint32_t memoryBank) override {
|
||||
return 1024u;
|
||||
}
|
||||
uint32_t createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, std::optional<uint32_t> vmId) override {
|
||||
uint32_t createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, std::optional<uint32_t> vmId, int32_t pairHandle) override {
|
||||
if (allocSize == 0) {
|
||||
return EINVAL;
|
||||
}
|
||||
handle = 1u;
|
||||
return 0u;
|
||||
}
|
||||
uint32_t createGemExtWithSingleRegion(uint32_t memoryBanks, size_t allocSize, uint32_t &handle) override {
|
||||
uint32_t createGemExtWithSingleRegion(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, int32_t pairHandle) override {
|
||||
if (allocSize == 0) {
|
||||
return EINVAL;
|
||||
}
|
||||
handle = 1u;
|
||||
pairHandlePassed = pairHandle;
|
||||
return 0u;
|
||||
}
|
||||
uint32_t createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t allocSize, uint32_t &handle) override {
|
||||
@@ -92,6 +93,7 @@ struct MockedMemoryInfo : public NEO::MemoryInfo {
|
||||
return 0u;
|
||||
}
|
||||
uint32_t banks = 0;
|
||||
int32_t pairHandlePassed = -1;
|
||||
};
|
||||
|
||||
class DrmMemoryManagerFixtureWithoutQuietIoctlExpectation {
|
||||
|
||||
@@ -61,3 +61,11 @@ TEST(DrmBindTest, whenCheckingVmBindAvailabilityThenIoctlHelperSupportIsUsed) {
|
||||
|
||||
EXPECT_EQ(drm.isVmBindAvailable(), drm.getIoctlHelper()->isVmBindAvailable());
|
||||
}
|
||||
|
||||
TEST(DrmBindTest, whenCheckingSetPairAvailabilityThenIoctlHelperSupportIsUsed) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
drm.callBaseIsSetPairAvailable = true;
|
||||
|
||||
EXPECT_EQ(drm.isSetPairAvailable(), drm.getIoctlHelper()->isSetPairAvailable());
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ TEST(MemoryInfo, givenMemoryInfoWithRegionsWhenCreatingGemWithExtensionsThenRetu
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo, *drm);
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
|
||||
auto ret = memoryInfo->createGemExt(memClassInstance, 1024, handle, {});
|
||||
auto ret = memoryInfo->createGemExt(memClassInstance, 1024, handle, {}, -1);
|
||||
EXPECT_EQ(1u, handle);
|
||||
EXPECT_EQ(0u, ret);
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
@@ -395,7 +395,7 @@ TEST(MemoryInfo, givenMemoryInfoWithRegionsWhenCreatingGemExtWithSingleRegionThe
|
||||
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo, *drm);
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
auto ret = memoryInfo->createGemExtWithSingleRegion(1, 1024, handle);
|
||||
auto ret = memoryInfo->createGemExtWithSingleRegion(1, 1024, handle, -1);
|
||||
EXPECT_EQ(1u, handle);
|
||||
EXPECT_EQ(0u, ret);
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
@@ -407,6 +407,35 @@ TEST(MemoryInfo, givenMemoryInfoWithRegionsWhenCreatingGemExtWithSingleRegionThe
|
||||
EXPECT_EQ(1024u, drm->context.receivedCreateGemExt->size);
|
||||
}
|
||||
|
||||
TEST(MemoryInfo, givenMemoryInfoWithRegionsWhenCreatingGemExtWithPairHandleThenReturnCorrectValues) {
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.EnableLocalMemory.set(1);
|
||||
|
||||
std::vector<MemoryRegion> regionInfo(2);
|
||||
regionInfo[0].region = {drm_i915_gem_memory_class::I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[0].probedSize = 8 * GB;
|
||||
regionInfo[1].region = {drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0};
|
||||
regionInfo[1].probedSize = 16 * GB;
|
||||
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
auto drm = std::make_unique<DrmQueryMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
drm->context.setPairQueryValue = 1;
|
||||
drm->context.setPairQueryReturn = 1;
|
||||
|
||||
uint32_t pairHandle = 0;
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo, *drm);
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
auto ret = memoryInfo->createGemExtWithSingleRegion(1, 1024, pairHandle, -1);
|
||||
EXPECT_EQ(0u, ret);
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
|
||||
uint32_t handle = 0;
|
||||
ret = memoryInfo->createGemExtWithSingleRegion(1, 1024, handle, pairHandle);
|
||||
EXPECT_EQ(0u, ret);
|
||||
EXPECT_EQ(2u, drm->ioctlCallsCount);
|
||||
}
|
||||
|
||||
TEST(MemoryInfo, givenMemoryInfoWithRegionsAndPrivateBOSupportWhenCreatingGemExtWithSingleRegionThenValidVmIdIsSet) {
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.EnableLocalMemory.set(1);
|
||||
@@ -426,7 +455,7 @@ TEST(MemoryInfo, givenMemoryInfoWithRegionsAndPrivateBOSupportWhenCreatingGemExt
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
|
||||
uint32_t handle = 0;
|
||||
auto ret = memoryInfo->createGemExtWithSingleRegion(1, 1024, handle);
|
||||
auto ret = memoryInfo->createGemExtWithSingleRegion(1, 1024, handle, -1);
|
||||
EXPECT_EQ(1u, handle);
|
||||
EXPECT_EQ(0u, ret);
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
@@ -456,7 +485,7 @@ TEST(MemoryInfo, givenMemoryInfoWithRegionsAndNoPrivateBOSupportWhenCreatingGemE
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
|
||||
uint32_t handle = 0;
|
||||
auto ret = memoryInfo->createGemExtWithSingleRegion(1, 1024, handle);
|
||||
auto ret = memoryInfo->createGemExtWithSingleRegion(1, 1024, handle, -1);
|
||||
EXPECT_EQ(1u, handle);
|
||||
EXPECT_EQ(0u, ret);
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
@@ -485,7 +514,7 @@ TEST(MemoryInfo, givenMemoryInfoWithRegionsAndPrivateBOSupportedAndIsPerContextV
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
|
||||
uint32_t handle = 0;
|
||||
auto ret = memoryInfo->createGemExtWithSingleRegion(1, 1024, handle);
|
||||
auto ret = memoryInfo->createGemExtWithSingleRegion(1, 1024, handle, -1);
|
||||
EXPECT_EQ(1u, handle);
|
||||
EXPECT_EQ(0u, ret);
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
|
||||
@@ -233,7 +233,7 @@ HWTEST2_F(MemoryInfoTest, givenMemoryInfoWithRegionsWhenCreatingGemWithExtension
|
||||
|
||||
uint32_t handle = 0;
|
||||
MemRegionsVec memClassInstance = {regionInfo[0].region, regionInfo[1].region};
|
||||
auto ret = memoryInfo->createGemExt(memClassInstance, 1024, handle, {});
|
||||
auto ret = memoryInfo->createGemExt(memClassInstance, 1024, handle, {}, -1);
|
||||
EXPECT_EQ(1u, handle);
|
||||
EXPECT_EQ(0u, ret);
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
@@ -256,7 +256,7 @@ HWTEST2_F(MemoryInfoTest, givenMemoryInfoWithRegionsWhenCreatingGemExtWithSingle
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo, *drm);
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
|
||||
auto ret = memoryInfo->createGemExtWithSingleRegion(1, 1024, handle);
|
||||
auto ret = memoryInfo->createGemExtWithSingleRegion(1, 1024, handle, -1);
|
||||
EXPECT_EQ(1u, handle);
|
||||
EXPECT_EQ(0u, ret);
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
|
||||
@@ -57,7 +57,8 @@ TEST_F(DrmMemoryManagerLocalMemoryPrelimTest, givenDrmMemoryManagerWithPrelimSup
|
||||
gpuAddress,
|
||||
size,
|
||||
(1 << (MemoryBanks::getBankForLocalMemory(0) - 1)),
|
||||
1));
|
||||
1,
|
||||
-1));
|
||||
ASSERT_NE(nullptr, bo);
|
||||
|
||||
EXPECT_EQ(1u, mock->ioctlCallsCount);
|
||||
@@ -1253,7 +1254,8 @@ TEST_F(DrmMemoryManagerLocalMemoryPrelimTest, givenPrintBOCreateDestroyResultFla
|
||||
gpuAddress,
|
||||
size,
|
||||
(1 << (MemoryBanks::getBankForLocalMemory(0) - 1)),
|
||||
1));
|
||||
1,
|
||||
-1));
|
||||
EXPECT_NE(nullptr, bo);
|
||||
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
|
||||
@@ -121,7 +121,8 @@ HWTEST2_F(DrmMemoryManagerLocalMemoryTest, givenDrmMemoryManagerWhenCreateBuffer
|
||||
gpuAddress,
|
||||
size,
|
||||
(1 << (MemoryBanks::getBankForLocalMemory(0) - 1)),
|
||||
1));
|
||||
1,
|
||||
-1));
|
||||
ASSERT_NE(nullptr, bo);
|
||||
EXPECT_EQ(1u, mock->ioctlCallsCount);
|
||||
EXPECT_EQ(1u, mock->createExt.handle);
|
||||
@@ -441,7 +442,8 @@ class DrmMemoryManagerLocalMemoryMemoryBankMock : public TestedDrmMemoryManager
|
||||
uint64_t gpuAddress,
|
||||
size_t size,
|
||||
uint32_t memoryBanks,
|
||||
size_t maxOsContextCount) override {
|
||||
size_t maxOsContextCount,
|
||||
int32_t pairHandle) override {
|
||||
memoryBankIsOne = (memoryBanks == 1) ? true : false;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -4233,7 +4233,7 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenDrmMemor
|
||||
auto gpuAddress = 0x1234u;
|
||||
auto size = MemoryConstants::pageSize;
|
||||
|
||||
auto bo = std::unique_ptr<BufferObject>(memoryManager->createBufferObjectInMemoryRegion(&memoryManager->getDrm(0), nullptr, AllocationType::BUFFER, gpuAddress, size, MemoryBanks::MainBank, 1));
|
||||
auto bo = std::unique_ptr<BufferObject>(memoryManager->createBufferObjectInMemoryRegion(&memoryManager->getDrm(0), nullptr, AllocationType::BUFFER, gpuAddress, size, MemoryBanks::MainBank, 1, -1));
|
||||
EXPECT_EQ(nullptr, bo);
|
||||
}
|
||||
|
||||
@@ -4241,7 +4241,7 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenDrmMemor
|
||||
auto gpuAddress = 0x1234u;
|
||||
auto size = 0u;
|
||||
|
||||
auto bo = std::unique_ptr<BufferObject>(memoryManager->createBufferObjectInMemoryRegion(&memoryManager->getDrm(0), nullptr, AllocationType::BUFFER, gpuAddress, size, MemoryBanks::MainBank, 1));
|
||||
auto bo = std::unique_ptr<BufferObject>(memoryManager->createBufferObjectInMemoryRegion(&memoryManager->getDrm(0), nullptr, AllocationType::BUFFER, gpuAddress, size, MemoryBanks::MainBank, 1, -1));
|
||||
EXPECT_EQ(nullptr, bo);
|
||||
}
|
||||
|
||||
@@ -4265,6 +4265,90 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenUseKmdMi
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenMemoryAllocationWithNoSetPairAndOneHandleAndCommandBufferTypeThenNoPairHandleIsPassed) {
|
||||
VariableBackup<bool> backupSetPairCallParent{&mock->getSetPairAvailableCall.callParent, false};
|
||||
VariableBackup<bool> backupSetPairReturnValue{&mock->getSetPairAvailableCall.returnValue, true};
|
||||
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
|
||||
AllocationData allocData;
|
||||
allocData.allFlags = 0;
|
||||
allocData.size = MemoryConstants::pageSize;
|
||||
allocData.type = AllocationType::COMMAND_BUFFER;
|
||||
allocData.rootDeviceIndex = rootDeviceIndex;
|
||||
allocData.storageInfo.memoryBanks = 0b01;
|
||||
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
EXPECT_EQ(MemoryManager::AllocationStatus::Success, status);
|
||||
|
||||
EXPECT_EQ(-1, static_cast<MockedMemoryInfo *>(mock->getMemoryInfo())->pairHandlePassed);
|
||||
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenMemoryAllocationWithSetPairAndOneHandleThenThenNoPairHandleIsPassed) {
|
||||
VariableBackup<bool> backupSetPairCallParent{&mock->getSetPairAvailableCall.callParent, false};
|
||||
VariableBackup<bool> backupSetPairReturnValue{&mock->getSetPairAvailableCall.returnValue, true};
|
||||
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
|
||||
AllocationData allocData;
|
||||
allocData.allFlags = 0;
|
||||
allocData.size = MemoryConstants::pageSize;
|
||||
allocData.type = AllocationType::BUFFER;
|
||||
allocData.rootDeviceIndex = rootDeviceIndex;
|
||||
allocData.storageInfo.memoryBanks = 0b01;
|
||||
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
EXPECT_EQ(MemoryManager::AllocationStatus::Success, status);
|
||||
|
||||
EXPECT_EQ(-1, static_cast<MockedMemoryInfo *>(mock->getMemoryInfo())->pairHandlePassed);
|
||||
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenMemoryAllocationWithSetPairAndTwoHandlesThenPairHandleIsPassed) {
|
||||
VariableBackup<bool> backupSetPairCallParent{&mock->getSetPairAvailableCall.callParent, false};
|
||||
VariableBackup<bool> backupSetPairReturnValue{&mock->getSetPairAvailableCall.returnValue, true};
|
||||
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
|
||||
AllocationData allocData;
|
||||
allocData.allFlags = 0;
|
||||
allocData.size = MemoryConstants::pageSize;
|
||||
allocData.type = AllocationType::BUFFER;
|
||||
allocData.rootDeviceIndex = rootDeviceIndex;
|
||||
allocData.storageInfo.memoryBanks = 0b11;
|
||||
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
EXPECT_EQ(MemoryManager::AllocationStatus::Success, status);
|
||||
|
||||
EXPECT_NE(-1, static_cast<MockedMemoryInfo *>(mock->getMemoryInfo())->pairHandlePassed);
|
||||
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenMemoryAllocationWithNoSetPairAndTwoHandlesThenPairHandleIsPassed) {
|
||||
VariableBackup<bool> backupSetPairCallParent{&mock->getSetPairAvailableCall.callParent, false};
|
||||
VariableBackup<bool> backupSetPairReturnValue{&mock->getSetPairAvailableCall.returnValue, false};
|
||||
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
|
||||
AllocationData allocData;
|
||||
allocData.allFlags = 0;
|
||||
allocData.size = MemoryConstants::pageSize;
|
||||
allocData.type = AllocationType::BUFFER;
|
||||
allocData.rootDeviceIndex = rootDeviceIndex;
|
||||
allocData.storageInfo.memoryBanks = 0b11;
|
||||
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
EXPECT_EQ(MemoryManager::AllocationStatus::Success, status);
|
||||
|
||||
EXPECT_EQ(-1, static_cast<MockedMemoryInfo *>(mock->getMemoryInfo())->pairHandlePassed);
|
||||
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenUseSystemMemoryFlagWhenGraphicsAllocationInDevicePoolIsAllocatedThenNullptrIsReturned) {
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
|
||||
AllocationData allocData;
|
||||
|
||||
@@ -1085,3 +1085,45 @@ TEST(DrmResidencyHandlerTests, givenDebugFlagUseVmBindSetDefaultWhenQueryingIsVm
|
||||
EXPECT_FALSE(drm.bindAvailable);
|
||||
EXPECT_EQ(1u, drm.context.vmBindQueryCalled);
|
||||
}
|
||||
|
||||
TEST(DrmResidencyHandlerTests, whenQueryingForSetPairAvailableAndNoSupportAvailableThenExpectedValueIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
drm.context.setPairQueryValue = 0;
|
||||
drm.context.setPairQueryReturn = 0;
|
||||
EXPECT_FALSE(drm.setPairAvailable);
|
||||
|
||||
EXPECT_EQ(0u, drm.context.setPairQueryCalled);
|
||||
drm.callBaseIsSetPairAvailable = true;
|
||||
EXPECT_FALSE(drm.isSetPairAvailable());
|
||||
EXPECT_FALSE(drm.setPairAvailable);
|
||||
EXPECT_EQ(1u, drm.context.setPairQueryCalled);
|
||||
}
|
||||
|
||||
TEST(DrmResidencyHandlerTests, whenQueryingForSetPairAvailableAndSupportAvailableThenExpectedValueIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
drm.context.setPairQueryValue = 1;
|
||||
drm.context.setPairQueryReturn = 0;
|
||||
EXPECT_FALSE(drm.setPairAvailable);
|
||||
|
||||
EXPECT_EQ(0u, drm.context.setPairQueryCalled);
|
||||
drm.callBaseIsSetPairAvailable = true;
|
||||
EXPECT_TRUE(drm.isSetPairAvailable());
|
||||
EXPECT_TRUE(drm.setPairAvailable);
|
||||
EXPECT_EQ(1u, drm.context.setPairQueryCalled);
|
||||
}
|
||||
|
||||
TEST(DrmResidencyHandlerTests, whenQueryingForSetPairAvailableAndFailureInQueryThenValueIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
drm.context.setPairQueryValue = 1;
|
||||
drm.context.setPairQueryReturn = 1;
|
||||
EXPECT_FALSE(drm.setPairAvailable);
|
||||
|
||||
EXPECT_EQ(0u, drm.context.setPairQueryCalled);
|
||||
drm.callBaseIsSetPairAvailable = true;
|
||||
EXPECT_FALSE(drm.isSetPairAvailable());
|
||||
EXPECT_FALSE(drm.setPairAvailable);
|
||||
EXPECT_EQ(1u, drm.context.setPairQueryCalled);
|
||||
}
|
||||
@@ -112,7 +112,7 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenCreateGemExtThenReturnSuccess)
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
uint32_t handle = 0;
|
||||
MemRegionsVec memClassInstance = {{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
auto ret = ioctlHelper->createGemExt(memClassInstance, 1024, handle, {});
|
||||
auto ret = ioctlHelper->createGemExt(memClassInstance, 1024, handle, {}, -1);
|
||||
|
||||
EXPECT_EQ(1u, handle);
|
||||
EXPECT_EQ(0u, ret);
|
||||
@@ -127,7 +127,7 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenCreateGemExtWithDebugFlagThenPr
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
uint32_t handle = 0;
|
||||
MemRegionsVec memClassInstance = {{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
ioctlHelper->createGemExt(memClassInstance, 1024, handle, {});
|
||||
ioctlHelper->createGemExt(memClassInstance, 1024, handle, {}, -1);
|
||||
|
||||
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");
|
||||
|
||||
@@ -26,7 +26,7 @@ DG1TEST_F(IoctlHelperTestsDg1, givenDg1WhenCreateGemExtThenReturnCorrectValue) {
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
uint32_t handle = 0;
|
||||
MemRegionsVec memClassInstance = {{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
auto ret = ioctlHelper->createGemExt(memClassInstance, 1024, handle, {});
|
||||
auto ret = ioctlHelper->createGemExt(memClassInstance, 1024, handle, {}, -1);
|
||||
|
||||
EXPECT_EQ(0u, ret);
|
||||
EXPECT_EQ(1u, handle);
|
||||
@@ -47,7 +47,7 @@ DG1TEST_F(IoctlHelperTestsDg1, givenDg1WithDrmTipWhenCreateGemExtWithDebugFlagTh
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
uint32_t handle = 0;
|
||||
MemRegionsVec memClassInstance = {{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
auto ret = ioctlHelper->createGemExt(memClassInstance, 1024, handle, {});
|
||||
auto ret = ioctlHelper->createGemExt(memClassInstance, 1024, handle, {}, -1);
|
||||
|
||||
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");
|
||||
@@ -68,7 +68,7 @@ DG1TEST_F(IoctlHelperTestsDg1, givenDg1WhenCreateGemExtWithDebugFlagThenPrintDeb
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
uint32_t handle = 0;
|
||||
MemRegionsVec memClassInstance = {{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
auto ret = ioctlHelper->createGemExt(memClassInstance, 1024, handle, {});
|
||||
auto ret = ioctlHelper->createGemExt(memClassInstance, 1024, handle, {}, -1);
|
||||
|
||||
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");
|
||||
|
||||
@@ -204,7 +204,7 @@ TEST(IoctlHelperTestsUpstream, givenUpstreamWhenCreateGemExtThenReturnCorrectVal
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
uint32_t handle = 0;
|
||||
MemRegionsVec memClassInstance = {{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
auto ret = ioctlHelper->createGemExt(memClassInstance, 1024, handle, {});
|
||||
auto ret = ioctlHelper->createGemExt(memClassInstance, 1024, handle, {}, -1);
|
||||
|
||||
EXPECT_EQ(0u, ret);
|
||||
EXPECT_EQ(1u, handle);
|
||||
@@ -224,7 +224,7 @@ TEST(IoctlHelperTestsUpstream, givenUpstreamWhenCreateGemExtWithDebugFlagThenPri
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
uint32_t handle = 0;
|
||||
MemRegionsVec memClassInstance = {{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
ioctlHelper->createGemExt(memClassInstance, 1024, handle, {});
|
||||
ioctlHelper->createGemExt(memClassInstance, 1024, handle, {}, -1);
|
||||
|
||||
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");
|
||||
|
||||
Reference in New Issue
Block a user