Fail when handle cannot be obtain for an allocation

If a handle cannot be obtained, like PRIME_HANDLE_TO_FD, then
properly check for the error and propagate it upwards.

Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
This commit is contained in:
Jaime Arteaga
2022-11-10 02:57:51 +00:00
committed by Compute-Runtime-Automation
parent acb8186744
commit 4391ad21bb
23 changed files with 1007 additions and 115 deletions

View File

@ -481,7 +481,9 @@ TEST_F(WddmTestWithMockGdiDll, givenShareableAllocationWhenCreateThenSharedHandl
allocation.setDefaultGmm(gmm.get());
auto status = memoryManager.createGpuAllocationsWithRetry(&allocation);
EXPECT_TRUE(status);
EXPECT_NE(0u, allocation.peekInternalHandle(&memoryManager));
uint64_t handle = 0;
allocation.peekInternalHandle(&memoryManager, handle);
EXPECT_NE(0u, handle);
}
TEST(WddmAllocationTest, whenAllocationIsShareableThenSharedHandleToModifyIsSharedHandleOfAllocation) {
@ -489,7 +491,10 @@ TEST(WddmAllocationTest, whenAllocationIsShareableThenSharedHandleToModifyIsShar
auto sharedHandleToModify = allocation.getSharedHandleToModify();
EXPECT_NE(nullptr, sharedHandleToModify);
*sharedHandleToModify = 1234u;
EXPECT_EQ(*sharedHandleToModify, allocation.peekInternalHandle(nullptr));
uint64_t handle = 0;
int ret = allocation.peekInternalHandle(nullptr, handle);
EXPECT_EQ(ret, 0);
EXPECT_EQ(*sharedHandleToModify, handle);
}
TEST(WddmAllocationTest, whenAllocationIsNotShareableThenItDoesntReturnSharedHandleToModify) {

View File

@ -75,7 +75,9 @@ TEST_F(WddmMemoryManagerSimpleTest, givenShareableAllocationWhenAllocateInDevice
EXPECT_EQ(MemoryManager::AllocationStatus::Success, status);
EXPECT_EQ(MemoryPool::LocalMemory, allocation->getMemoryPool());
EXPECT_EQ(0u, allocation->getDefaultGmm()->resourceParams.Flags.Info.NonLocalOnly);
EXPECT_NE(allocation->peekInternalHandle(memoryManager.get()), 0u);
uint64_t handle = 0;
allocation->peekInternalHandle(memoryManager.get(), handle);
EXPECT_NE(handle, 0u);
EXPECT_EQ(1u, allocation->getDefaultGmm()->resourceParams.Flags.Info.LocalOnly);
EXPECT_EQ(1u, allocation->getDefaultGmm()->resourceParams.Flags.Info.NotLockable);
@ -102,7 +104,9 @@ TEST_F(WddmMemoryManagerSimpleTest, givenShareableAllocationWhenAllocateGraphics
EXPECT_NE(nullptr, allocation);
EXPECT_EQ(MemoryPool::LocalMemory, allocation->getMemoryPool());
EXPECT_EQ(0u, allocation->getDefaultGmm()->resourceParams.Flags.Info.NonLocalOnly);
EXPECT_NE(allocation->peekInternalHandle(memoryManager.get()), 0u);
uint64_t handle = 0;
allocation->peekInternalHandle(memoryManager.get(), handle);
EXPECT_NE(handle, 0u);
EXPECT_EQ(1u, allocation->getDefaultGmm()->resourceParams.Flags.Info.LocalOnly);
EXPECT_EQ(1u, allocation->getDefaultGmm()->resourceParams.Flags.Info.NotLockable);