@@ -23,6 +23,7 @@ template <GFXCORE_FAMILY gfxCoreFamily>
2323class MockCommandListHw : public WhiteBox <::L0::CommandListCoreFamily<gfxCoreFamily>> {
2424 public:
2525 MockCommandListHw () : WhiteBox<::L0::CommandListCoreFamily<gfxCoreFamily>>() {}
26+ MockCommandListHw (bool failOnFirst) : WhiteBox<::L0::CommandListCoreFamily<gfxCoreFamily>>(), failOnFirstCopy(failOnFirst) {}
2627
2728 AlignedAllocationData getAlignedAllocation (L0::Device *device, const void *buffer, uint64_t bufferSize) override {
2829 return {0 , 0 , nullptr , true };
@@ -41,6 +42,10 @@ class MockCommandListHw : public WhiteBox<::L0::CommandListCoreFamily<gfxCoreFam
4142 appendMemoryCopyKernelWithGACalledTimes++;
4243 if (isStateless)
4344 appendMemoryCopyKernelWithGAStatelessCalledTimes++;
45+ if (failOnFirstCopy &&
46+ (appendMemoryCopyKernelWithGACalledTimes == 1 || appendMemoryCopyKernelWithGAStatelessCalledTimes == 1 )) {
47+ return ZE_RESULT_ERROR_UNKNOWN;
48+ }
4449 return ZE_RESULT_SUCCESS;
4550 }
4651 ze_result_t appendMemoryCopyBlit (uintptr_t dstPtr,
@@ -50,6 +55,9 @@ class MockCommandListHw : public WhiteBox<::L0::CommandListCoreFamily<gfxCoreFam
5055 uint64_t srcOffset,
5156 uint64_t size) override {
5257 appendMemoryCopyBlitCalledTimes++;
58+ if (failOnFirstCopy && appendMemoryCopyBlitCalledTimes == 1 ) {
59+ return ZE_RESULT_ERROR_UNKNOWN;
60+ }
5361 return ZE_RESULT_SUCCESS;
5462 }
5563
@@ -118,6 +126,7 @@ class MockCommandListHw : public WhiteBox<::L0::CommandListCoreFamily<gfxCoreFam
118126 Vec3<size_t > appendImageRegionCopySize = {0 , 0 , 0 };
119127 Vec3<size_t > appendImageRegionSrcOrigin = {9 , 9 , 9 };
120128 Vec3<size_t > appendImageRegionDstOrigin = {9 , 9 , 9 };
129+ bool failOnFirstCopy = false ;
121130};
122131
123132using Platforms = IsAtLeastProduct<IGFX_SKYLAKE>;
@@ -179,6 +188,20 @@ HWTEST2_F(CommandListCreate, givenCommandListWhenPageFaultCopyCalledThenappendPa
179188 EXPECT_EQ (cmdList.appendMemoryCopyKernelWithGAStatelessCalledTimes , 0u );
180189}
181190
191+ HWTEST2_F (CommandListCreate, givenCommandListWhenPageFaultCopyCalledWithCopyEngineThenappendPageFaultCopyWithappendMemoryCopyKernelWithGACalled, Platforms) {
192+ MockCommandListHw<gfxCoreFamily> cmdList;
193+ size_t size = (sizeof (uint32_t ) * 4 );
194+ cmdList.initialize (device, NEO::EngineGroupType::Copy, 0u );
195+ NEO::MockGraphicsAllocation mockAllocationSrc (0 , NEO::GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
196+ reinterpret_cast <void *>(0x1234 ), size, 0 , sizeof (uint32_t ),
197+ MemoryPool::System4KBPages);
198+ NEO::MockGraphicsAllocation mockAllocationDst (0 , NEO::GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
199+ reinterpret_cast <void *>(0x2345 ), size, 0 , sizeof (uint32_t ),
200+ MemoryPool::System4KBPages);
201+ cmdList.appendPageFaultCopy (&mockAllocationDst, &mockAllocationSrc, size, false );
202+ EXPECT_EQ (cmdList.appendMemoryCopyBlitCalledTimes , 1u );
203+ }
204+
182205HWTEST2_F (CommandListCreate, givenCommandListWhenPageFaultCopyCalledThenappendPageFaultCopyWithappendMemoryCopyKernelWithGACalledForMiddleAndRightSizesAreCalled, Platforms) {
183206 MockCommandListHw<gfxCoreFamily> cmdList;
184207 size_t size = ((sizeof (uint32_t ) * 4 ) + 1 );
@@ -194,6 +217,49 @@ HWTEST2_F(CommandListCreate, givenCommandListWhenPageFaultCopyCalledThenappendPa
194217 EXPECT_EQ (cmdList.appendMemoryCopyKernelWithGAStatelessCalledTimes , 0u );
195218}
196219
220+ HWTEST2_F (CommandListCreate, givenCommandListWhenPageFaultCopyCalledAndErrorOnMidCopyThenappendPageFaultCopyWithappendMemoryCopyKernelWithGACalledForMiddleIsCalled, Platforms) {
221+ MockCommandListHw<gfxCoreFamily> cmdList (true );
222+ size_t size = ((sizeof (uint32_t ) * 4 ) + 1 );
223+ cmdList.initialize (device, NEO::EngineGroupType::RenderCompute, 0u );
224+ NEO::MockGraphicsAllocation mockAllocationSrc (0 , NEO::GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
225+ reinterpret_cast <void *>(0x1234 ), size, 0 , sizeof (uint32_t ),
226+ MemoryPool::System4KBPages);
227+ NEO::MockGraphicsAllocation mockAllocationDst (0 , NEO::GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
228+ reinterpret_cast <void *>(0x2345 ), size, 0 , sizeof (uint32_t ),
229+ MemoryPool::System4KBPages);
230+ cmdList.appendPageFaultCopy (&mockAllocationDst, &mockAllocationSrc, size, false );
231+ EXPECT_EQ (cmdList.appendMemoryCopyKernelWithGACalledTimes , 1u );
232+ EXPECT_EQ (cmdList.appendMemoryCopyKernelWithGAStatelessCalledTimes , 0u );
233+ }
234+
235+ HWTEST2_F (CommandListCreate, givenCommandListWhenPageFaultCopyCalledWithCopyEngineThenappendPageFaultCopyWithappendMemoryCopyKernelWithGACalledForMiddleAndRightSizesAreCalled, Platforms) {
236+ MockCommandListHw<gfxCoreFamily> cmdList;
237+ size_t size = ((sizeof (uint32_t ) * 4 ) + 1 );
238+ cmdList.initialize (device, NEO::EngineGroupType::Copy, 0u );
239+ NEO::MockGraphicsAllocation mockAllocationSrc (0 , NEO::GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
240+ reinterpret_cast <void *>(0x1234 ), size, 0 , sizeof (uint32_t ),
241+ MemoryPool::System4KBPages);
242+ NEO::MockGraphicsAllocation mockAllocationDst (0 , NEO::GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
243+ reinterpret_cast <void *>(0x2345 ), size, 0 , sizeof (uint32_t ),
244+ MemoryPool::System4KBPages);
245+ cmdList.appendPageFaultCopy (&mockAllocationDst, &mockAllocationSrc, size, false );
246+ EXPECT_EQ (cmdList.appendMemoryCopyBlitCalledTimes , 2u );
247+ }
248+
249+ HWTEST2_F (CommandListCreate, givenCommandListWhenPageFaultCopyCalledWithCopyEngineAndErrorOnMidOperationThenappendPageFaultCopyWithappendMemoryCopyKernelWithGACalledForMiddleIsCalled, Platforms) {
250+ MockCommandListHw<gfxCoreFamily> cmdList (true );
251+ size_t size = ((sizeof (uint32_t ) * 4 ) + 1 );
252+ cmdList.initialize (device, NEO::EngineGroupType::Copy, 0u );
253+ NEO::MockGraphicsAllocation mockAllocationSrc (0 , NEO::GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
254+ reinterpret_cast <void *>(0x1234 ), size, 0 , sizeof (uint32_t ),
255+ MemoryPool::System4KBPages);
256+ NEO::MockGraphicsAllocation mockAllocationDst (0 , NEO::GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
257+ reinterpret_cast <void *>(0x2345 ), size, 0 , sizeof (uint32_t ),
258+ MemoryPool::System4KBPages);
259+ cmdList.appendPageFaultCopy (&mockAllocationDst, &mockAllocationSrc, size, false );
260+ EXPECT_EQ (cmdList.appendMemoryCopyBlitCalledTimes , 1u );
261+ }
262+
197263HWTEST2_F (CommandListCreate, givenCommandListWhen4GBytePageFaultCopyCalledThenPageFaultCopyWithappendMemoryCopyKernelWithGAStatelessCalled, Platforms) {
198264 MockCommandListHw<gfxCoreFamily> cmdList;
199265 size_t size = 0x100000000 ;
0 commit comments