|
6 | 6 | */ |
7 | 7 |
|
8 | 8 | #include "shared/source/os_interface/linux/drm_debug.h" |
| 9 | +#include "shared/source/os_interface/linux/os_context_linux.h" |
| 10 | +#include "shared/test/common/helpers/engine_descriptor_helper.h" |
9 | 11 | #include "shared/test/common/libult/linux/drm_query_mock.h" |
| 12 | +#include "shared/test/common/mocks/linux/mock_drm_allocation.h" |
| 13 | +#include "shared/test/common/mocks/linux/mock_drm_memory_manager.h" |
10 | 14 | #include "shared/test/common/test_macros/matchers.h" |
11 | 15 | #include "shared/test/common/test_macros/test.h" |
12 | 16 |
|
@@ -234,3 +238,142 @@ TEST(DrmPrelimTest, givenContextDebugNotAvailableWhenCheckedForSupportThenTrueIs |
234 | 238 | EXPECT_FALSE(drm->isContextDebugSupported()); |
235 | 239 | EXPECT_EQ(prevIoctls + 1u, drm->ioctlCallsCount); |
236 | 240 | } |
| 241 | + |
| 242 | +TEST_F(DrmDebugPrelimTest, givenAddedBindExtHandlesInBoWhenBindingWithinDefaultEngineContextThenExtensionsArePassedToVmBindIoctl) { |
| 243 | + auto executionEnvironment = std::make_unique<ExecutionEnvironment>(); |
| 244 | + executionEnvironment->prepareRootDeviceEnvironments(1); |
| 245 | + executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(NEO::defaultHwInfo.get()); |
| 246 | + executionEnvironment->initializeMemoryManager(); |
| 247 | + DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]}; |
| 248 | + |
| 249 | + MockBufferObject bo(&drm, 0, 0, 1); |
| 250 | + bo.addBindExtHandle(4); |
| 251 | + bo.addBindExtHandle(5); |
| 252 | + |
| 253 | + OsContextLinux osContext(drm, 0u, EngineDescriptorHelper::getDefaultDescriptor()); |
| 254 | + osContext.ensureContextInitialized(); |
| 255 | + bo.bind(&osContext, 0); |
| 256 | + |
| 257 | + EXPECT_NE(0u, drm.context.receivedVmBind->extensions); |
| 258 | + |
| 259 | + EXPECT_EQ(4u, drm.context.receivedVmBindUuidExt[0]->handle); |
| 260 | + EXPECT_NE(0u, drm.context.receivedVmBindUuidExt[0]->nextExtension); |
| 261 | + |
| 262 | + EXPECT_EQ(5u, drm.context.receivedVmBindUuidExt[1]->handle); |
| 263 | + EXPECT_EQ(0u, drm.context.receivedVmBindUuidExt[1]->nextExtension); |
| 264 | +} |
| 265 | + |
| 266 | +TEST_F(DrmDebugPrelimTest, givenAddedBindExtHandlesInBoWhenBindingWithinInternalContextThenExtensionsAreNotPassedToVmBindIoctl) { |
| 267 | + auto executionEnvironment = std::make_unique<ExecutionEnvironment>(); |
| 268 | + executionEnvironment->prepareRootDeviceEnvironments(1); |
| 269 | + executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(NEO::defaultHwInfo.get()); |
| 270 | + executionEnvironment->initializeMemoryManager(); |
| 271 | + DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]}; |
| 272 | + |
| 273 | + MockBufferObject bo(&drm, 0, 0, 1); |
| 274 | + bo.addBindExtHandle(4); |
| 275 | + bo.addBindExtHandle(5); |
| 276 | + |
| 277 | + OsContextLinux osContext(drm, 0u, {{aub_stream::EngineType::ENGINE_RCS, EngineUsage::Internal}, 1 /*deviceBitfield*/, PreemptionMode::Disabled, true /* isRootDevice*/, false /* isEngineInstanced*/}); |
| 278 | + osContext.ensureContextInitialized(); |
| 279 | + bo.bind(&osContext, 0); |
| 280 | + |
| 281 | + EXPECT_FALSE(drm.context.receivedVmBindUuidExt[0]); |
| 282 | +} |
| 283 | + |
| 284 | +TEST_F(DrmDebugPrelimTest, givenAddedBindExtHandlesInBoWhenBindingWithinCopyEngineContextThenExtensionsAreNotPassedToVmBindIoctl) { |
| 285 | + auto executionEnvironment = std::make_unique<ExecutionEnvironment>(); |
| 286 | + executionEnvironment->prepareRootDeviceEnvironments(1); |
| 287 | + executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(NEO::defaultHwInfo.get()); |
| 288 | + executionEnvironment->initializeMemoryManager(); |
| 289 | + DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]}; |
| 290 | + |
| 291 | + MockBufferObject bo(&drm, 0, 0, 1); |
| 292 | + bo.addBindExtHandle(4); |
| 293 | + bo.addBindExtHandle(5); |
| 294 | + |
| 295 | + drm.context.receivedVmBindUuidExt[0].reset(); |
| 296 | + |
| 297 | + OsContextLinux osContext(drm, 0u, {{aub_stream::EngineType::ENGINE_BCS, EngineUsage::Regular}, 1 /*deviceBitfield*/, PreemptionMode::Disabled, true /* isRootDevice*/, false /* isEngineInstanced*/}); |
| 298 | + osContext.ensureContextInitialized(); |
| 299 | + bo.bind(&osContext, 0); |
| 300 | + |
| 301 | + EXPECT_FALSE(drm.context.receivedVmBindUuidExt[0]); |
| 302 | +} |
| 303 | + |
| 304 | +HWTEST_F(DrmDebugPrelimTest, givenAddedBindExtHandlesInBoWhenUnbindingThenExtensionsAreNotSet) { |
| 305 | + auto executionEnvironment = std::make_unique<ExecutionEnvironment>(); |
| 306 | + executionEnvironment->prepareRootDeviceEnvironments(1); |
| 307 | + executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(NEO::defaultHwInfo.get()); |
| 308 | + executionEnvironment->initializeMemoryManager(); |
| 309 | + DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]}; |
| 310 | + |
| 311 | + MockBufferObject bo(&drm, 0, 0, 1); |
| 312 | + bo.addBindExtHandle(4); |
| 313 | + bo.addBindExtHandle(5); |
| 314 | + |
| 315 | + OsContextLinux osContext(drm, 0u, EngineDescriptorHelper::getDefaultDescriptor()); |
| 316 | + osContext.ensureContextInitialized(); |
| 317 | + bo.bind(&osContext, 0); |
| 318 | + EXPECT_NE(0u, drm.context.receivedVmBind->extensions); |
| 319 | + |
| 320 | + drm.context.receivedVmUnbind->extensions = 0; |
| 321 | + |
| 322 | + bo.unbind(&osContext, 0); |
| 323 | + if (HwHelperHw<FamilyType>::get().getNumCacheRegions() > 0) { |
| 324 | + EXPECT_NE(0u, drm.context.receivedVmUnbind->extensions); |
| 325 | + } else { |
| 326 | + EXPECT_EQ(0u, drm.context.receivedVmUnbind->extensions); |
| 327 | + } |
| 328 | + EXPECT_EQ(1u, drm.context.vmUnbindCalled); |
| 329 | +} |
| 330 | + |
| 331 | +TEST(DrmPrelimTest, givenProgramDebuggingAndContextDebugAvailableAndCCSEnginesWhenCreatingContextThenDebugFlagSipParamIsSet) { |
| 332 | + auto executionEnvironment = std::make_unique<ExecutionEnvironment>(); |
| 333 | + executionEnvironment->setDebuggingEnabled(); |
| 334 | + executionEnvironment->prepareRootDeviceEnvironments(1); |
| 335 | + executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get()); |
| 336 | + executionEnvironment->calculateMaxOsContextCount(); |
| 337 | + executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>(); |
| 338 | + |
| 339 | + DrmQueryMock *drm = new DrmQueryMock(*executionEnvironment->rootDeviceEnvironments[0]); |
| 340 | + drm->contextDebugSupported = true; |
| 341 | + executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm)); |
| 342 | + |
| 343 | + OsContextLinux osContext(*drm, 5u, EngineDescriptorHelper::getDefaultDescriptor()); |
| 344 | + osContext.ensureContextInitialized(); |
| 345 | + |
| 346 | + EXPECT_EQ(DrmPrelimHelper::getSIPContextParamDebugFlag() << 32 | DrmPrelimHelper::getSIPContextParamDebugFlag(), drm->context.receivedSetContextParamValue); |
| 347 | + // drmMock returns ctxId == 0 |
| 348 | + EXPECT_EQ(0u, drm->context.receivedSetContextParamCtxId); |
| 349 | + EXPECT_EQ(0u, drm->passedContextDebugId); |
| 350 | +} |
| 351 | + |
| 352 | +TEST(DrmPrelimTest, givenProgramDebuggingAndContextDebugAvailableAndCCSEnginesWhenCreatingContextThenContextRunaloneIsSetOnlyIfCCSEnginesArePresent) { |
| 353 | + auto executionEnvironment = std::make_unique<ExecutionEnvironment>(); |
| 354 | + executionEnvironment->setDebuggingEnabled(); |
| 355 | + executionEnvironment->prepareRootDeviceEnvironments(1); |
| 356 | + executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get()); |
| 357 | + executionEnvironment->calculateMaxOsContextCount(); |
| 358 | + executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>(); |
| 359 | + |
| 360 | + DrmQueryMock *drm = new DrmQueryMock(*executionEnvironment->rootDeviceEnvironments[0]); |
| 361 | + drm->contextDebugSupported = true; |
| 362 | + executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm)); |
| 363 | + |
| 364 | + OsContextLinux osContext(*drm, 5u, EngineDescriptorHelper::getDefaultDescriptor()); |
| 365 | + osContext.ensureContextInitialized(); |
| 366 | + |
| 367 | + EXPECT_EQ(DrmPrelimHelper::getSIPContextParamDebugFlag() << 32 | DrmPrelimHelper::getSIPContextParamDebugFlag(), drm->context.receivedSetContextParamValue); |
| 368 | + // drmMock returns ctxId == 0 |
| 369 | + EXPECT_EQ(0u, drm->context.receivedSetContextParamCtxId); |
| 370 | + EXPECT_EQ(0u, drm->passedContextDebugId); |
| 371 | + |
| 372 | + if (executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo()->gtSystemInfo.CCSInfo.NumberOfCCSEnabled > 0) { |
| 373 | + EXPECT_EQ(4u, drm->receivedContextParamRequestCount); |
| 374 | + EXPECT_EQ(1u, drm->context.receivedContextCreateExtSetParamRunaloneCount); |
| 375 | + } else { |
| 376 | + EXPECT_EQ(3u, drm->receivedContextParamRequestCount); |
| 377 | + EXPECT_EQ(0u, drm->context.receivedContextCreateExtSetParamRunaloneCount); |
| 378 | + } |
| 379 | +} |
0 commit comments