@@ -739,6 +739,9 @@ HWTEST_F(DrmMemoryOperationsHandlerBindTest, givenPatIndexProgrammingEnabledWhen
739
739
740
740
if (debugFlag == 0 || !closSupported || debugFlag == -1 ) {
741
741
auto expectedIndex = static_cast <uint64_t >(MockGmmClientContextBase::MockPatIndex::cached);
742
+ if (hwHelper.isPatIndexFallbackWaRequired ()) {
743
+ expectedIndex = hwHelper.getPatIndex (CacheRegion::Default, CachePolicy::WriteBack);
744
+ }
742
745
743
746
EXPECT_EQ (expectedIndex, mock->context .receivedVmBindPatIndex .value ());
744
747
@@ -753,7 +756,51 @@ HWTEST_F(DrmMemoryOperationsHandlerBindTest, givenPatIndexProgrammingEnabledWhen
753
756
}
754
757
}
755
758
756
- HWTEST_F (DrmMemoryOperationsHandlerBindTest, givenPatIndexErrorAndUncachedDebugFlagSetWhenGetPatIndexCalledThenAbort) {
759
+ HWTEST_F (DrmMemoryOperationsHandlerBindTest, givenPatIndexErrorWhenVmBindCalledThenSetDefaultPatIndexExtension) {
760
+ DebugManager.flags .UseVmBind .set (1 );
761
+ mock->bindAvailable = true ;
762
+
763
+ auto csr = std::make_unique<UltCommandStreamReceiver<FamilyType>>(*executionEnvironment, 0 , DeviceBitfield (1 ));
764
+ auto osContext = memoryManager->createAndRegisterOsContext (csr.get (), EngineDescriptorHelper::getDefaultDescriptor ());
765
+ csr->setupContext (*osContext);
766
+
767
+ auto &hwHelper = HwHelper::get (executionEnvironment->rootDeviceEnvironments [0 ]->getHardwareInfo ()->platform .eRenderCoreFamily );
768
+ auto hwInfoConfig = HwInfoConfig::get (executionEnvironment->rootDeviceEnvironments [0 ]->getHardwareInfo ()->platform .eProductFamily );
769
+
770
+ bool closSupported = (hwHelper.getNumCacheRegions () > 0 );
771
+ bool patIndexProgrammingSupported = hwInfoConfig->isVmBindPatIndexProgrammingSupported ();
772
+
773
+ if (!closSupported || !patIndexProgrammingSupported) {
774
+ GTEST_SKIP ();
775
+ }
776
+
777
+ uint64_t gpuAddress = 0x123000 ;
778
+ size_t size = 1 ;
779
+ BufferObject bo (mock, static_cast <uint64_t >(MockGmmClientContextBase::MockPatIndex::cached), 0 , 1 , 1 );
780
+ DrmAllocation allocation (0 , 1 , AllocationType::BUFFER, &bo, nullptr , gpuAddress, size, MemoryPool::System4KBPages);
781
+
782
+ auto allocationPtr = static_cast <GraphicsAllocation *>(&allocation);
783
+
784
+ static_cast <MockGmmClientContextBase *>(executionEnvironment->rootDeviceEnvironments [0 ]->getGmmClientContext ())->returnErrorOnPatIndexQuery = true ;
785
+
786
+ for (int32_t debugFlag : {-1 , 0 , 1 }) {
787
+ DebugManager.flags .ClosEnabled .set (debugFlag);
788
+
789
+ mock->context .receivedVmBindPatIndex .reset ();
790
+ mock->context .receivedVmUnbindPatIndex .reset ();
791
+
792
+ bo.setPatIndex (mock->getPatIndex (allocation.getDefaultGmm (), allocation.getAllocationType (), CacheRegion::Default, CachePolicy::WriteBack, false ));
793
+
794
+ operationHandler->makeResident (device, ArrayRef<GraphicsAllocation *>(&allocationPtr, 1 ));
795
+
796
+ EXPECT_EQ (3u , mock->context .receivedVmBindPatIndex .value ());
797
+
798
+ operationHandler->evict (device, allocation);
799
+ EXPECT_EQ (3u , mock->context .receivedVmUnbindPatIndex .value ());
800
+ }
801
+ }
802
+
803
+ HWTEST_F (DrmMemoryOperationsHandlerBindTest, givenPatIndexErrorAndUncachedDebugFlagSetWhenVmBindCalledThenSetDefaultPatIndexExtension) {
757
804
DebugManager.flags .UseVmBind .set (1 );
758
805
DebugManager.flags .ForceAllResourcesUncached .set (1 );
759
806
mock->bindAvailable = true ;
@@ -774,12 +821,24 @@ HWTEST_F(DrmMemoryOperationsHandlerBindTest, givenPatIndexErrorAndUncachedDebugF
774
821
775
822
static_cast <MockGmmClientContextBase *>(executionEnvironment->rootDeviceEnvironments [0 ]->getGmmClientContext ())->returnErrorOnPatIndexQuery = true ;
776
823
824
+ mock->context .receivedVmBindPatIndex .reset ();
825
+ mock->context .receivedVmUnbindPatIndex .reset ();
826
+
777
827
uint64_t gpuAddress = 0x123000 ;
778
828
size_t size = 1 ;
779
829
BufferObject bo (mock, static_cast <uint64_t >(MockGmmClientContextBase::MockPatIndex::cached), 0 , 1 , 1 );
780
830
DrmAllocation allocation (0 , 1 , AllocationType::BUFFER, &bo, nullptr , gpuAddress, size, MemoryPool::System4KBPages);
781
831
782
- EXPECT_ANY_THROW (mock->getPatIndex (allocation.getDefaultGmm (), allocation.getAllocationType (), CacheRegion::Default, CachePolicy::WriteBack, false ));
832
+ bo.setPatIndex (mock->getPatIndex (allocation.getDefaultGmm (), allocation.getAllocationType (), CacheRegion::Default, CachePolicy::WriteBack, false ));
833
+
834
+ auto allocationPtr = static_cast <GraphicsAllocation *>(&allocation);
835
+
836
+ operationHandler->makeResident (device, ArrayRef<GraphicsAllocation *>(&allocationPtr, 1 ));
837
+
838
+ EXPECT_EQ (0u , mock->context .receivedVmBindPatIndex .value ());
839
+
840
+ operationHandler->evict (device, allocation);
841
+ EXPECT_EQ (0u , mock->context .receivedVmUnbindPatIndex .value ());
783
842
}
784
843
785
844
HWTEST_F (DrmMemoryOperationsHandlerBindTest, givenUncachedDebugFlagSetWhenVmBindCalledThenSetCorrectPatIndexExtension) {
@@ -793,6 +852,7 @@ HWTEST_F(DrmMemoryOperationsHandlerBindTest, givenUncachedDebugFlagSetWhenVmBind
793
852
794
853
auto timestampStorageAlloc = csr->getTimestampPacketAllocator ()->getTag ()->getBaseGraphicsAllocation ()->getDefaultGraphicsAllocation ();
795
854
855
+ auto &hwHelper = HwHelper::get (executionEnvironment->rootDeviceEnvironments [0 ]->getHardwareInfo ()->platform .eRenderCoreFamily );
796
856
auto hwInfoConfig = HwInfoConfig::get (executionEnvironment->rootDeviceEnvironments [0 ]->getHardwareInfo ()->platform .eProductFamily );
797
857
798
858
if (!hwInfoConfig->isVmBindPatIndexProgrammingSupported ()) {
@@ -805,6 +865,9 @@ HWTEST_F(DrmMemoryOperationsHandlerBindTest, givenUncachedDebugFlagSetWhenVmBind
805
865
operationHandler->makeResident (device, ArrayRef<GraphicsAllocation *>(×tampStorageAlloc, 1 ));
806
866
807
867
auto expectedIndex = static_cast <uint64_t >(MockGmmClientContextBase::MockPatIndex::uncached);
868
+ if (hwHelper.isPatIndexFallbackWaRequired ()) {
869
+ expectedIndex = hwHelper.getPatIndex (CacheRegion::Default, CachePolicy::Uncached);
870
+ }
808
871
809
872
EXPECT_EQ (expectedIndex, mock->context .receivedVmBindPatIndex .value ());
810
873
0 commit comments