mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 15:53:45 +08:00
Test prelim VM bind, debug
Signed-off-by: Daniel Chabrowski daniel.chabrowski@intel.com Related-To: NEO-6591
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
439389ae19
commit
de0361cfa5
@@ -10,7 +10,6 @@ set(NEO_CORE_OS_INTERFACE_TESTS_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/device_factory_tests_linux.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_bind_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_command_stream_l0_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_debug_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_engine_info_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_mock_impl.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_query_tests.cpp
|
||||
@@ -28,6 +27,7 @@ if(NEO_ENABLE_i915_PRELIM_DETECTION)
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_query_topology_prelim_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_info_prelim_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_with_prelim_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_vm_bind_prelim_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ioctl_helper_tests_prelim.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/prelim_helper_func.cpp
|
||||
)
|
||||
@@ -41,6 +41,7 @@ endif()
|
||||
|
||||
if("${BRANCH_TYPE}" STREQUAL "")
|
||||
list(APPEND NEO_CORE_OS_INTERFACE_TESTS_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_debug_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_info_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ioctl_helper_tests_upstream.cpp
|
||||
)
|
||||
|
||||
@@ -6,7 +6,11 @@
|
||||
*/
|
||||
|
||||
#include "shared/source/os_interface/linux/drm_debug.h"
|
||||
#include "shared/source/os_interface/linux/os_context_linux.h"
|
||||
#include "shared/test/common/helpers/engine_descriptor_helper.h"
|
||||
#include "shared/test/common/libult/linux/drm_query_mock.h"
|
||||
#include "shared/test/common/mocks/linux/mock_drm_allocation.h"
|
||||
#include "shared/test/common/mocks/linux/mock_drm_memory_manager.h"
|
||||
#include "shared/test/common/test_macros/matchers.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
|
||||
@@ -234,3 +238,142 @@ TEST(DrmPrelimTest, givenContextDebugNotAvailableWhenCheckedForSupportThenTrueIs
|
||||
EXPECT_FALSE(drm->isContextDebugSupported());
|
||||
EXPECT_EQ(prevIoctls + 1u, drm->ioctlCallsCount);
|
||||
}
|
||||
|
||||
TEST_F(DrmDebugPrelimTest, givenAddedBindExtHandlesInBoWhenBindingWithinDefaultEngineContextThenExtensionsArePassedToVmBindIoctl) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(NEO::defaultHwInfo.get());
|
||||
executionEnvironment->initializeMemoryManager();
|
||||
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
MockBufferObject bo(&drm, 0, 0, 1);
|
||||
bo.addBindExtHandle(4);
|
||||
bo.addBindExtHandle(5);
|
||||
|
||||
OsContextLinux osContext(drm, 0u, EngineDescriptorHelper::getDefaultDescriptor());
|
||||
osContext.ensureContextInitialized();
|
||||
bo.bind(&osContext, 0);
|
||||
|
||||
EXPECT_NE(0u, drm.context.receivedVmBind->extensions);
|
||||
|
||||
EXPECT_EQ(4u, drm.context.receivedVmBindUuidExt[0]->handle);
|
||||
EXPECT_NE(0u, drm.context.receivedVmBindUuidExt[0]->nextExtension);
|
||||
|
||||
EXPECT_EQ(5u, drm.context.receivedVmBindUuidExt[1]->handle);
|
||||
EXPECT_EQ(0u, drm.context.receivedVmBindUuidExt[1]->nextExtension);
|
||||
}
|
||||
|
||||
TEST_F(DrmDebugPrelimTest, givenAddedBindExtHandlesInBoWhenBindingWithinInternalContextThenExtensionsAreNotPassedToVmBindIoctl) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(NEO::defaultHwInfo.get());
|
||||
executionEnvironment->initializeMemoryManager();
|
||||
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
MockBufferObject bo(&drm, 0, 0, 1);
|
||||
bo.addBindExtHandle(4);
|
||||
bo.addBindExtHandle(5);
|
||||
|
||||
OsContextLinux osContext(drm, 0u, {{aub_stream::EngineType::ENGINE_RCS, EngineUsage::Internal}, 1 /*deviceBitfield*/, PreemptionMode::Disabled, true /* isRootDevice*/, false /* isEngineInstanced*/});
|
||||
osContext.ensureContextInitialized();
|
||||
bo.bind(&osContext, 0);
|
||||
|
||||
EXPECT_FALSE(drm.context.receivedVmBindUuidExt[0]);
|
||||
}
|
||||
|
||||
TEST_F(DrmDebugPrelimTest, givenAddedBindExtHandlesInBoWhenBindingWithinCopyEngineContextThenExtensionsAreNotPassedToVmBindIoctl) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(NEO::defaultHwInfo.get());
|
||||
executionEnvironment->initializeMemoryManager();
|
||||
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
MockBufferObject bo(&drm, 0, 0, 1);
|
||||
bo.addBindExtHandle(4);
|
||||
bo.addBindExtHandle(5);
|
||||
|
||||
drm.context.receivedVmBindUuidExt[0].reset();
|
||||
|
||||
OsContextLinux osContext(drm, 0u, {{aub_stream::EngineType::ENGINE_BCS, EngineUsage::Regular}, 1 /*deviceBitfield*/, PreemptionMode::Disabled, true /* isRootDevice*/, false /* isEngineInstanced*/});
|
||||
osContext.ensureContextInitialized();
|
||||
bo.bind(&osContext, 0);
|
||||
|
||||
EXPECT_FALSE(drm.context.receivedVmBindUuidExt[0]);
|
||||
}
|
||||
|
||||
HWTEST_F(DrmDebugPrelimTest, givenAddedBindExtHandlesInBoWhenUnbindingThenExtensionsAreNotSet) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(NEO::defaultHwInfo.get());
|
||||
executionEnvironment->initializeMemoryManager();
|
||||
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
MockBufferObject bo(&drm, 0, 0, 1);
|
||||
bo.addBindExtHandle(4);
|
||||
bo.addBindExtHandle(5);
|
||||
|
||||
OsContextLinux osContext(drm, 0u, EngineDescriptorHelper::getDefaultDescriptor());
|
||||
osContext.ensureContextInitialized();
|
||||
bo.bind(&osContext, 0);
|
||||
EXPECT_NE(0u, drm.context.receivedVmBind->extensions);
|
||||
|
||||
drm.context.receivedVmUnbind->extensions = 0;
|
||||
|
||||
bo.unbind(&osContext, 0);
|
||||
if (HwHelperHw<FamilyType>::get().getNumCacheRegions() > 0) {
|
||||
EXPECT_NE(0u, drm.context.receivedVmUnbind->extensions);
|
||||
} else {
|
||||
EXPECT_EQ(0u, drm.context.receivedVmUnbind->extensions);
|
||||
}
|
||||
EXPECT_EQ(1u, drm.context.vmUnbindCalled);
|
||||
}
|
||||
|
||||
TEST(DrmPrelimTest, givenProgramDebuggingAndContextDebugAvailableAndCCSEnginesWhenCreatingContextThenDebugFlagSipParamIsSet) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->setDebuggingEnabled();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
|
||||
executionEnvironment->calculateMaxOsContextCount();
|
||||
executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
|
||||
|
||||
DrmQueryMock *drm = new DrmQueryMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
drm->contextDebugSupported = true;
|
||||
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
|
||||
|
||||
OsContextLinux osContext(*drm, 5u, EngineDescriptorHelper::getDefaultDescriptor());
|
||||
osContext.ensureContextInitialized();
|
||||
|
||||
EXPECT_EQ(DrmPrelimHelper::getSIPContextParamDebugFlag() << 32 | DrmPrelimHelper::getSIPContextParamDebugFlag(), drm->context.receivedSetContextParamValue);
|
||||
// drmMock returns ctxId == 0
|
||||
EXPECT_EQ(0u, drm->context.receivedSetContextParamCtxId);
|
||||
EXPECT_EQ(0u, drm->passedContextDebugId);
|
||||
}
|
||||
|
||||
TEST(DrmPrelimTest, givenProgramDebuggingAndContextDebugAvailableAndCCSEnginesWhenCreatingContextThenContextRunaloneIsSetOnlyIfCCSEnginesArePresent) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->setDebuggingEnabled();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
|
||||
executionEnvironment->calculateMaxOsContextCount();
|
||||
executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
|
||||
|
||||
DrmQueryMock *drm = new DrmQueryMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
drm->contextDebugSupported = true;
|
||||
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
|
||||
|
||||
OsContextLinux osContext(*drm, 5u, EngineDescriptorHelper::getDefaultDescriptor());
|
||||
osContext.ensureContextInitialized();
|
||||
|
||||
EXPECT_EQ(DrmPrelimHelper::getSIPContextParamDebugFlag() << 32 | DrmPrelimHelper::getSIPContextParamDebugFlag(), drm->context.receivedSetContextParamValue);
|
||||
// drmMock returns ctxId == 0
|
||||
EXPECT_EQ(0u, drm->context.receivedSetContextParamCtxId);
|
||||
EXPECT_EQ(0u, drm->passedContextDebugId);
|
||||
|
||||
if (executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo()->gtSystemInfo.CCSInfo.NumberOfCCSEnabled > 0) {
|
||||
EXPECT_EQ(4u, drm->receivedContextParamRequestCount);
|
||||
EXPECT_EQ(1u, drm->context.receivedContextCreateExtSetParamRunaloneCount);
|
||||
} else {
|
||||
EXPECT_EQ(3u, drm->receivedContextParamRequestCount);
|
||||
EXPECT_EQ(0u, drm->context.receivedContextCreateExtSetParamRunaloneCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
#include "shared/source/execution_environment/root_device_environment.h"
|
||||
#include "shared/source/os_interface/linux/os_context_linux.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/engine_descriptor_helper.h"
|
||||
#include "shared/test/common/libult/linux/drm_query_mock.h"
|
||||
#include "shared/test/common/mocks/linux/mock_drm_allocation.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
TEST(DrmVmBindTest, givenBoRequiringImmediateBindWhenBindingThenImmediateFlagIsPassed) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(NEO::defaultHwInfo.get());
|
||||
executionEnvironment->initializeMemoryManager();
|
||||
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
MockBufferObject bo(&drm, 0, 0, 1);
|
||||
bo.requireImmediateBinding(true);
|
||||
|
||||
OsContextLinux osContext(drm, 0u, EngineDescriptorHelper::getDefaultDescriptor());
|
||||
osContext.ensureContextInitialized();
|
||||
bo.bind(&osContext, 0);
|
||||
|
||||
EXPECT_EQ(DrmPrelimHelper::getImmediateVmBindFlag(), drm.context.receivedVmBind->flags);
|
||||
}
|
||||
|
||||
TEST(DrmVmBindTest, givenBoRequiringExplicitResidencyWhenBindingThenMakeResidentFlagIsPassedAndUserFenceIsSetup) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(NEO::defaultHwInfo.get());
|
||||
executionEnvironment->initializeMemoryManager();
|
||||
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
drm.pageFaultSupported = true;
|
||||
|
||||
for (auto requireResidency : {false, true}) {
|
||||
MockBufferObject bo(&drm, 0, 0, 1);
|
||||
bo.requireExplicitResidency(requireResidency);
|
||||
|
||||
OsContextLinux osContext(drm, 0u, EngineDescriptorHelper::getDefaultDescriptor());
|
||||
osContext.ensureContextInitialized();
|
||||
uint32_t vmHandleId = 0;
|
||||
bo.bind(&osContext, vmHandleId);
|
||||
|
||||
if (requireResidency) {
|
||||
EXPECT_EQ(DrmPrelimHelper::getImmediateVmBindFlag() | DrmPrelimHelper::getMakeResidentVmBindFlag(), drm.context.receivedVmBind->flags);
|
||||
ASSERT_TRUE(drm.context.receivedVmBindSyncFence);
|
||||
EXPECT_EQ(castToUint64(drm.getFenceAddr(vmHandleId)), drm.context.receivedVmBindSyncFence->addr);
|
||||
EXPECT_EQ(drm.fenceVal[vmHandleId], drm.context.receivedVmBindSyncFence->val);
|
||||
} else {
|
||||
EXPECT_EQ(DrmPrelimHelper::getImmediateVmBindFlag(), drm.context.receivedVmBind->flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(DrmVmBindTest, givenBoNotRequiringExplicitResidencyWhenCallingWaitForBindThenDontWaitOnUserFence) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(NEO::defaultHwInfo.get());
|
||||
executionEnvironment->initializeMemoryManager();
|
||||
|
||||
struct DrmQueryMockToTestWaitForBind : public DrmQueryMock {
|
||||
using DrmQueryMock::DrmQueryMock;
|
||||
|
||||
int waitUserFence(uint32_t ctxId, uint64_t address, uint64_t value, ValueWidth dataWidth, int64_t timeout, uint16_t flags) override {
|
||||
waitUserFenceCalled = true;
|
||||
return 0;
|
||||
}
|
||||
bool waitUserFenceCalled = false;
|
||||
};
|
||||
|
||||
DrmQueryMockToTestWaitForBind drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
drm.pageFaultSupported = true;
|
||||
|
||||
for (auto requireResidency : {false, true}) {
|
||||
MockBufferObject bo(&drm, 0, 0, 1);
|
||||
bo.requireExplicitResidency(requireResidency);
|
||||
|
||||
OsContextLinux osContext(drm, 0u, EngineDescriptorHelper::getDefaultDescriptor());
|
||||
osContext.ensureContextInitialized();
|
||||
uint32_t vmHandleId = 0;
|
||||
bo.bind(&osContext, vmHandleId);
|
||||
|
||||
drm.waitForBind(vmHandleId);
|
||||
|
||||
if (requireResidency) {
|
||||
EXPECT_TRUE(drm.waitUserFenceCalled);
|
||||
} else {
|
||||
EXPECT_FALSE(drm.waitUserFenceCalled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(DrmVmBindTest, givenUseKmdMigrationWhenCallingBindBoOnUnifiedSharedMemoryThenAllocationShouldPageFaultAndExplicitResidencyIsNotRequired) {
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.UseKmdMigration.set(1);
|
||||
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(NEO::defaultHwInfo.get());
|
||||
executionEnvironment->initializeMemoryManager();
|
||||
|
||||
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
drm.pageFaultSupported = true;
|
||||
|
||||
OsContextLinux osContext(drm, 0u, EngineDescriptorHelper::getDefaultDescriptor());
|
||||
osContext.ensureContextInitialized();
|
||||
uint32_t vmHandleId = 0;
|
||||
|
||||
MockBufferObject bo(&drm, 0, 0, 1);
|
||||
MockDrmAllocation allocation(AllocationType::UNIFIED_SHARED_MEMORY, MemoryPool::LocalMemory);
|
||||
allocation.bufferObjects[0] = &bo;
|
||||
|
||||
allocation.bindBO(&bo, &osContext, vmHandleId, nullptr, true);
|
||||
|
||||
EXPECT_TRUE(allocation.shouldAllocationPageFault(&drm));
|
||||
EXPECT_FALSE(bo.isExplicitResidencyRequired());
|
||||
EXPECT_EQ(DrmPrelimHelper::getImmediateVmBindFlag(), drm.context.receivedVmBind->flags);
|
||||
}
|
||||
Reference in New Issue
Block a user