@@ -86,6 +86,30 @@ TEST_F(DrmBufferObjectTest, exec) {
8686 EXPECT_EQ (0u , mock->execBuffer .flags );
8787}
8888
89+ TEST_F (DrmBufferObjectTest, givenDrmWithCoherencyPatchActiveWhenExecIsCalledThenFlagsContainNonCoherentFlag) {
90+ mock->ioctl_expected .total = 1 ;
91+ mock->ioctl_res = 0 ;
92+ mock->overideCoherencyPatchActive (true );
93+
94+ auto ret = bo->exec (0 , 0 , 0 );
95+ EXPECT_EQ (mock->ioctl_res , ret);
96+ uint64_t expectedFlag = I915_PRIVATE_EXEC_FORCE_NON_COHERENT;
97+ uint64_t currentFlag = mock->execBuffer .flags ;
98+ EXPECT_EQ (expectedFlag, currentFlag);
99+ }
100+
101+ TEST_F (DrmBufferObjectTest, givenDrmWithCoherencyPatchActiveWhenExecIsCalledWithCoherencyRequestThenFlagsDontContainNonCoherentFlag) {
102+ mock->ioctl_expected .total = 1 ;
103+ mock->ioctl_res = 0 ;
104+ mock->overideCoherencyPatchActive (true );
105+
106+ auto ret = bo->exec (0 , 0 , 0 , true );
107+ EXPECT_EQ (mock->ioctl_res , ret);
108+ uint64_t expectedFlag = 0 ;
109+ uint64_t currentFlag = mock->execBuffer .flags ;
110+ EXPECT_EQ (expectedFlag, currentFlag);
111+ }
112+
89113TEST_F (DrmBufferObjectTest, exec_ioctlFailed) {
90114 mock->ioctl_expected .total = 1 ;
91115 mock->ioctl_res = -1 ;
@@ -128,6 +152,48 @@ TEST_F(DrmBufferObjectTest, testExecObjectFlags) {
128152 EXPECT_FALSE (execObject.flags & EXEC_OBJECT_SUPPORTS_48B_ADDRESS);
129153}
130154
155+ TEST_F (DrmBufferObjectTest, onPinBBhasOnlyBbEndAndForceNonCoherent) {
156+ std::unique_ptr<uint32_t []> buff (new uint32_t [1024 ]);
157+ mock->ioctl_expected .total = 1 ;
158+ mock->ioctl_res = 0 ;
159+
160+ mock->overideCoherencyPatchActive (true );
161+ std::unique_ptr<BufferObject> boToPin (new TestedBufferObject (this ->mock ));
162+ ASSERT_NE (nullptr , boToPin.get ());
163+
164+ bo->setAddress (buff.get ());
165+ BufferObject *boArray[1 ] = {boToPin.get ()};
166+ auto ret = bo->pin (boArray, 1 );
167+ EXPECT_EQ (mock->ioctl_res , ret);
168+ uint32_t bb_end = 0x05000000 ;
169+ EXPECT_EQ (buff[0 ], bb_end);
170+ EXPECT_GT (mock->execBuffer .batch_len , 0u );
171+ uint32_t flag = I915_PRIVATE_EXEC_FORCE_NON_COHERENT;
172+ EXPECT_TRUE ((mock->execBuffer .flags & flag) == flag);
173+ bo->setAddress (nullptr );
174+ }
175+
176+ TEST_F (DrmBufferObjectTest, onPinBBhasOnlyBbEndAndNoForceNonCoherent) {
177+ std::unique_ptr<uint32_t []> buff (new uint32_t [1024 ]);
178+ mock->ioctl_expected .total = 1 ;
179+ mock->ioctl_res = 0 ;
180+
181+ mock->overideCoherencyPatchActive (false );
182+ std::unique_ptr<BufferObject> boToPin (new TestedBufferObject (this ->mock ));
183+ ASSERT_NE (nullptr , boToPin.get ());
184+
185+ bo->setAddress (buff.get ());
186+ BufferObject *boArray[1 ] = {boToPin.get ()};
187+ auto ret = bo->pin (boArray, 1 );
188+ EXPECT_EQ (mock->ioctl_res , ret);
189+ uint32_t bb_end = 0x05000000 ;
190+ EXPECT_EQ (buff[0 ], bb_end);
191+ EXPECT_GT (mock->execBuffer .batch_len , 0u );
192+ uint32_t flag = I915_PRIVATE_EXEC_FORCE_NON_COHERENT;
193+ EXPECT_TRUE ((mock->execBuffer .flags & flag) == 0 );
194+ bo->setAddress (nullptr );
195+ }
196+
131197TEST_F (DrmBufferObjectTest, onPinIoctlFailed) {
132198 std::unique_ptr<uint32_t []> buff (new uint32_t [1024 ]);
133199
0 commit comments