@@ -505,7 +505,6 @@ TEST_F(DrmMemoryManagerTest, givenDrmAllocationWhenHandleFenceCompletionThenCall
505505
506506 mock->ioctl_expected .gemClose = 1 ;
507507 mock->ioctl_expected .gemWait = 2 ;
508- mock->ioctl_expected .contextDestroy = static_cast <int >(device->engines .size ());
509508 memoryManager->freeGraphicsMemory (allocation);
510509}
511510
@@ -949,9 +948,7 @@ TEST_F(DrmMemoryManagerTest, Given32bitAllocatorWhenAskedForBufferAllocationThen
949948 mock->ioctl_expected .gemClose = 1 ;
950949
951950 DebugManager.flags .Force32bitAddressing .set (true );
952- MockContext context;
953- memoryManager->setForce32BitAllocations (true );
954- context.memoryManager = memoryManager;
951+ MockContext context (device);
955952 memoryManager->setForce32BitAllocations (true );
956953
957954 auto size = MemoryConstants::pageSize;
@@ -981,9 +978,8 @@ TEST_F(DrmMemoryManagerTest, Given32bitAllocatorWhenAskedForBufferCreatedFromHos
981978 mock->ioctl_expected .gemClose = 1 ;
982979
983980 DebugManager.flags .Force32bitAddressing .set (true );
984- MockContext context;
981+ MockContext context (device) ;
985982 memoryManager->setForce32BitAllocations (true );
986- context.memoryManager = memoryManager;
987983
988984 auto size = MemoryConstants::pageSize;
989985 void *ptr = reinterpret_cast <void *>(0x1000 );
@@ -1042,9 +1038,8 @@ TEST_F(DrmMemoryManagerTest, Given32bitAllocatorWhenAskedForBufferCreatedFrom64B
10421038 mock->ioctl_expected .gemClose = 1 ;
10431039
10441040 DebugManager.flags .Force32bitAddressing .set (true );
1045- MockContext context;
1041+ MockContext context (device) ;
10461042 memoryManager->setForce32BitAllocations (true );
1047- context.memoryManager = memoryManager;
10481043
10491044 auto size = MemoryConstants::pageSize;
10501045 void *ptr = reinterpret_cast <void *>(0x100000000000 );
@@ -1163,9 +1158,8 @@ TEST_F(DrmMemoryManagerTest, GivenSizeAbove2GBWhenUseHostPtrAndAllocHostPtrAreCr
11631158 DebugManagerStateRestore dbgRestorer;
11641159 mock->ioctl_expected .total = -1 ;
11651160 DebugManager.flags .Force32bitAddressing .set (true );
1166- MockContext context;
1161+ MockContext context (device) ;
11671162 memoryManager->setForce32BitAllocations (true );
1168- context.memoryManager = memoryManager;
11691163
11701164 size_t size = 2 * GB;
11711165 void *ptr = reinterpret_cast <void *>(0x100000000000 );
@@ -1205,9 +1199,8 @@ TEST_F(DrmMemoryManagerTest, GivenSizeAbove2GBWhenAllocHostPtrAndUseHostPtrAreCr
12051199 DebugManagerStateRestore dbgRestorer;
12061200 mock->ioctl_expected .total = -1 ;
12071201 DebugManager.flags .Force32bitAddressing .set (true );
1208- MockContext context;
1202+ MockContext context (device) ;
12091203 memoryManager->setForce32BitAllocations (true );
1210- context.memoryManager = memoryManager;
12111204
12121205 size_t size = 2 * GB;
12131206 void *ptr = reinterpret_cast <void *>(0x100000000000 );
@@ -1246,8 +1239,7 @@ TEST_F(DrmMemoryManagerTest, GivenSizeAbove2GBWhenAllocHostPtrAndUseHostPtrAreCr
12461239TEST_F (DrmMemoryManagerTest, givenDrmBufferWhenItIsQueriedForInternalAllocationThenBoIsReturned) {
12471240 mock->ioctl_expected .total = -1 ;
12481241 mock->outputFd = 1337 ;
1249- MockContext context;
1250- context.memoryManager = memoryManager;
1242+ MockContext context (device);
12511243
12521244 size_t size = 1u ;
12531245 auto retVal = CL_SUCCESS;
@@ -1332,8 +1324,7 @@ HWTEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenTiledImageWithMipCountZe
13321324 mock->ioctl_expected .gemWait = 1 ;
13331325 mock->ioctl_expected .gemClose = 1 ;
13341326
1335- MockContext context;
1336- context.memoryManager = memoryManager;
1327+ MockContext context (device);
13371328
13381329 cl_image_format imageFormat;
13391330 imageFormat.image_channel_data_type = CL_UNORM_INT8;
@@ -1379,8 +1370,7 @@ HWTEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenTiledImageWithMipCountNo
13791370 mock->ioctl_expected .gemWait = 1 ;
13801371 mock->ioctl_expected .gemClose = 1 ;
13811372
1382- MockContext context;
1383- context.memoryManager = memoryManager;
1373+ MockContext context (device);
13841374
13851375 cl_image_format imageFormat;
13861376 imageFormat.image_channel_data_type = CL_UNORM_INT8;
@@ -1420,8 +1410,7 @@ HWTEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenTiledImageWithMipCountNo
14201410}
14211411
14221412TEST_F (DrmMemoryManagerTest, givenDrmMemoryManagerWhenTiledImageIsBeingCreatedAndAllocationFailsThenReturnNullptr) {
1423- MockContext context;
1424- context.memoryManager = memoryManager;
1413+ MockContext context (device);
14251414
14261415 cl_image_format imageFormat;
14271416 imageFormat.image_channel_data_type = CL_UNORM_INT8;
@@ -1449,21 +1438,38 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenTiledImageIsBeingCreatedAn
14491438
14501439 injectFailures (method);
14511440 mock->reset ();
1452- mock->ioctl_expected .contextDestroy = static_cast <int >(device->engines .size ());
14531441}
14541442
1455- HWTEST_F (DrmMemoryManagerTest, givenDrmMemoryManagerWhenTiledImageIsBeingCreatedFromHostPtrThenallocateGraphicsMemoryForImageIsUsed ) {
1443+ HWTEST_F (DrmMemoryManagerTest, givenDrmMemoryManagerWhenTiledImageIsBeingCreatedFromHostPtrThenAllocateGraphicsMemoryForImageIsUsed ) {
14561444 if (!UnitTestHelper<FamilyType>::tiledImagesSupported) {
14571445 GTEST_SKIP ();
14581446 }
14591447 mock->ioctl_expected .gemCreate = 1 ;
14601448 mock->ioctl_expected .gemSetTiling = 1 ;
1461- mock->ioctl_expected .gemUserptr = 1 ;
14621449 mock->ioctl_expected .gemWait = 2 ;
14631450 mock->ioctl_expected .gemClose = 2 ;
1451+ mock->ioctl_expected .gemUserptr = 1 ;
1452+
1453+ // builtins kernels
1454+ mock->ioctl_expected .gemUserptr += 5 ;
1455+
1456+ // command buffers
1457+ mock->ioctl_expected .gemUserptr += 2 ;
1458+ additionalDestroyDeviceIoctls.gemClose += 2 ;
1459+ additionalDestroyDeviceIoctls.gemWait += 2 ;
1460+
1461+ // indirect heaps
1462+ mock->ioctl_expected .gemUserptr += 3 ;
1463+ additionalDestroyDeviceIoctls.gemClose += 3 ;
1464+ additionalDestroyDeviceIoctls.gemWait += 3 ;
1465+
1466+ if (device->getDefaultEngine ().commandStreamReceiver ->peekTimestampPacketWriteEnabled ()) {
1467+ mock->ioctl_expected .gemUserptr ++;
1468+ additionalDestroyDeviceIoctls.gemClose ++;
1469+ additionalDestroyDeviceIoctls.gemWait ++;
1470+ }
14641471
14651472 MockContext context (device);
1466- context.memoryManager = memoryManager;
14671473
14681474 cl_image_format imageFormat;
14691475 imageFormat.image_channel_data_type = CL_UNORM_INT8;
@@ -1509,8 +1515,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenMemoryAllocatedForImageThe
15091515 mock->ioctl_expected .gemWait = 2 ;
15101516 mock->ioctl_expected .gemClose = 2 ;
15111517
1512- MockContext context;
1513- context.memoryManager = memoryManager;
1518+ MockContext context (device);
15141519
15151520 cl_image_format imageFormat;
15161521 imageFormat.image_channel_data_type = CL_UNORM_INT8;
@@ -1542,8 +1547,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenNonTiledImgWithMipCountZer
15421547 mock->ioctl_expected .gemWait = 2 ;
15431548 mock->ioctl_expected .gemClose = 2 ;
15441549
1545- MockContext context;
1546- context.memoryManager = memoryManager;
1550+ MockContext context (device);
15471551
15481552 cl_image_format imageFormat;
15491553 imageFormat.image_channel_data_type = CL_UNORM_INT8;
@@ -1586,8 +1590,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenNonTiledImgWithMipCountNon
15861590 mock->ioctl_expected .gemWait = 1 ;
15871591 mock->ioctl_expected .gemClose = 1 ;
15881592
1589- MockContext context;
1590- context.memoryManager = memoryManager;
1593+ MockContext context (device);
15911594
15921595 cl_image_format imageFormat;
15931596 imageFormat.image_channel_data_type = CL_UNORM_INT8;
@@ -1632,8 +1635,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhen1DarrayImageIsBeingCreated
16321635 mock->ioctl_expected .gemWait = 2 ;
16331636 mock->ioctl_expected .gemClose = 2 ;
16341637
1635- MockContext context;
1636- context.memoryManager = memoryManager;
1638+ MockContext context (device);
16371639
16381640 cl_image_format imageFormat;
16391641 imageFormat.image_channel_data_type = CL_UNORM_INT8;
@@ -1682,7 +1684,7 @@ TEST_F(DrmMemoryManagerTest, givenHostPointerNotRequiringCopyWhenAllocateGraphic
16821684 imageFormat.image_channel_order = CL_R;
16831685
16841686 cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR;
1685- MockContext context;
1687+ MockContext context (device) ;
16861688 auto surfaceFormat = Image::getSurfaceFormatFromTable (flags, &imageFormat, context.getDevice (0 )->getHardwareInfo ().capabilityTable .clVersionSupport );
16871689
16881690 auto imgInfo = MockGmm::initImgInfo (imgDesc, 0 , surfaceFormat);
@@ -1791,7 +1793,7 @@ TEST_F(DrmMemoryManagerTest, givenOsHandleWithNonTiledObjectWhenCreateFromShared
17911793 imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
17921794
17931795 imgInfo.imgDesc = Image::convertDescriptor (imgDesc);
1794- MockContext context;
1796+ MockContext context (device) ;
17951797 gmmSurfaceFormat = Image::getSurfaceFormatFromTable (flags, &gmmImgFormat, context.getDevice (0 )->getHardwareInfo ().capabilityTable .clVersionSupport );
17961798 imgInfo.surfaceFormat = &gmmSurfaceFormat->surfaceFormat ;
17971799 imgInfo.plane = GMM_PLANE_Y;
@@ -1833,7 +1835,7 @@ TEST_F(DrmMemoryManagerTest, givenOsHandleWithTileYObjectWhenCreateFromSharedHan
18331835 imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
18341836
18351837 imgInfo.imgDesc = Image::convertDescriptor (imgDesc);
1836- MockContext context;
1838+ MockContext context (device) ;
18371839 gmmSurfaceFormat = Image::getSurfaceFormatFromTable (flags, &gmmImgFormat, context.getDevice (0 )->getHardwareInfo ().capabilityTable .clVersionSupport );
18381840 imgInfo.surfaceFormat = &gmmSurfaceFormat->surfaceFormat ;
18391841 imgInfo.plane = GMM_PLANE_Y;
@@ -1875,7 +1877,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenCreateFromSharedHandleFail
18751877 imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
18761878
18771879 imgInfo.imgDesc = Image::convertDescriptor (imgDesc);
1878- MockContext context;
1880+ MockContext context (device) ;
18791881 gmmSurfaceFormat = Image::getSurfaceFormatFromTable (flags, &gmmImgFormat, context.getDevice (0 )->getHardwareInfo ().capabilityTable .clVersionSupport );
18801882 imgInfo.surfaceFormat = &gmmSurfaceFormat->surfaceFormat ;
18811883 imgInfo.plane = GMM_PLANE_Y;
@@ -1911,7 +1913,6 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerAndOsHandleWhenAllocationFails
19111913
19121914 injectFailures (method);
19131915 mock->reset ();
1914- mock->ioctl_expected .contextDestroy = static_cast <int >(device->engines .size ());
19151916}
19161917
19171918TEST_F (DrmMemoryManagerTest, givenDrmMemoryManagerAndThreeOsHandlesWhenReuseCreatesAreCalledThenGraphicsAllocationsAreReturned) {
@@ -2055,6 +2056,7 @@ TEST_F(DrmMemoryManagerTest, givenSharedHandleWhenAllocationIsCreatedAndIoctlPri
20552056TEST_F (DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatShareTheSameBufferObjectWhenTheyAreMadeResidentThenOnlyOneBoIsPassedToExec) {
20562057 auto testedCsr = new TestedDrmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>(*executionEnvironment);
20572058 device->resetCommandStreamReceiver (testedCsr);
2059+ mock->reset ();
20582060
20592061 mock->ioctl_expected .primeFdToHandle = 2 ;
20602062 mock->ioctl_expected .gemClose = 1 ;
@@ -2079,18 +2081,22 @@ TEST_F(DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatShareTheSameBufferOb
20792081
20802082TEST_F (DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatDoesnShareTheSameBufferObjectWhenTheyAreMadeResidentThenTwoBoIsPassedToExec) {
20812083 mock->ioctl_expected .primeFdToHandle = 2 ;
2082- mock->ioctl_expected .gemClose = 2 ;
2083- mock->ioctl_expected .gemWait = 2 ;
20842084
20852085 osHandle sharedHandle = 1u ;
20862086 AllocationProperties properties (rootDeviceIndex, false , MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false );
20872087 auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle (sharedHandle, properties, false );
20882088 mock->outputHandle ++;
20892089 auto graphicsAllocation2 = memoryManager->createGraphicsAllocationFromSharedHandle (sharedHandle, properties, false );
20902090
2091+ mock->testIoctls ();
2092+
20912093 auto testedCsr = new TestedDrmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>(*executionEnvironment);
20922094 device->resetCommandStreamReceiver (testedCsr);
20932095
2096+ mock->reset ();
2097+ mock->ioctl_expected .gemClose = 2 ;
2098+ mock->ioctl_expected .gemWait = 2 ;
2099+
20942100 testedCsr->makeResident (*graphicsAllocation);
20952101 testedCsr->makeResident (*graphicsAllocation2);
20962102 EXPECT_EQ (2u , testedCsr->getResidencyAllocations ().size ());
0 commit comments