feature: add debug key to set vmBind userFence wait timeout

- VmBindWaitUserFenceTimeout

Related-To: NEO-11219

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe 2024-06-18 10:47:51 +00:00 committed by Compute-Runtime-Automation
parent d97dccc409
commit cd3219d092
4 changed files with 63 additions and 2 deletions

View File

@ -446,6 +446,7 @@ DECLARE_DEBUG_VARIABLE(bool, AllowSingleTileEngineInstancedSubDevices, false, "C
DECLARE_DEBUG_VARIABLE(bool, EnablePrivateBO, false, "Enable PRELIM_I915_GEM_CREATE_EXT_VM_PRIVATE extension creating VM_PRIVATE BOs")
DECLARE_DEBUG_VARIABLE(bool, UseDeprecatedClDeviceIpVersion, false, "When enabled, the deprecated ip version scheme distinguishing between families and integrated devices will be queried in OCL")
DECLARE_DEBUG_VARIABLE(bool, EnableAIL, true, "Enables AIL")
DECLARE_DEBUG_VARIABLE(int64_t, VmBindWaitUserFenceTimeout, -1, "-1: default, >0: time in ns for wait function timeout")
DECLARE_DEBUG_VARIABLE(int32_t, ForceRunAloneContext, -1, "Control creation of run-alone HW context, -1:default, 0:disable, 1:enable")
DECLARE_DEBUG_VARIABLE(int32_t, AddClGlSharing, -1, "Add cl-gl extension")
DECLARE_DEBUG_VARIABLE(int32_t, EnableKernelTunning, -1, "Perform a tunning of enqueue kernel, -1:default(disabled), 0:disable, 1:enable simple kernel tunning, 2:enable full kernel tunning")

View File

@ -1301,10 +1301,13 @@ int IoctlHelperXe::xeVmBind(const VmBindParams &vmBindParams, bool isBind) {
return ret;
}
constexpr auto oneSecTimeout = 1000000000;
constexpr auto oneSecTimeout = 1000000000ll;
constexpr auto infiniteTimeout = -1;
bool debuggingEnabled = drm.getRootDeviceEnvironment().executionEnvironment.isDebuggingEnabled();
auto timeout = debuggingEnabled ? infiniteTimeout : oneSecTimeout;
uint64_t timeout = debuggingEnabled ? infiniteTimeout : oneSecTimeout;
if (debugManager.flags.VmBindWaitUserFenceTimeout.get() != -1) {
timeout = debugManager.flags.VmBindWaitUserFenceTimeout.get();
}
return xeWaitUserFence(bind.exec_queue_id, DRM_XE_UFENCE_WAIT_OP_EQ,
sync[0].addr,
sync[0].timeline_value, timeout,

View File

@ -350,6 +350,7 @@ UseUmKmDataTranslator = 0
EnableUserFenceForCompletionWait = -1
EnableResourceTags = 0
SetKmdWaitTimeout = -1
VmBindWaitUserFenceTimeout = -1
OverrideNotifyEnableForTagUpdatePostSync = -1
OverrideUseKmdWaitFunction = -1
EventWaitOnHost = -1

View File

@ -1550,6 +1550,62 @@ INSTANTIATE_TEST_SUITE_P(,
IoctlHelperXeFenceWaitTest,
::testing::Bool());
TEST(IoctlHelperXeTest, givenVmBindWaitUserFenceTimeoutWhenCallingVmBindThenWaitUserFenceIsCalledWithSpecificTimeout) {
DebugManagerStateRestore restorer;
debugManager.flags.VmBindWaitUserFenceTimeout.set(5000000000ll);
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
DrmMockXe drm{*executionEnvironment->rootDeviceEnvironments[0]};
auto xeIoctlHelper = std::make_unique<MockIoctlHelperXe>(drm);
uint64_t fenceAddress = 0x4321;
uint64_t fenceValue = 0x789;
BindInfo mockBindInfo{};
mockBindInfo.handle = 0x1234;
xeIoctlHelper->bindInfo.push_back(mockBindInfo);
VmBindExtUserFenceT vmBindExtUserFence{};
xeIoctlHelper->fillVmBindExtUserFence(vmBindExtUserFence, fenceAddress, fenceValue, 0u);
VmBindParams vmBindParams{};
vmBindParams.handle = mockBindInfo.handle;
xeIoctlHelper->setVmBindUserFence(vmBindParams, vmBindExtUserFence);
drm.vmBindInputs.clear();
drm.syncInputs.clear();
drm.waitUserFenceInputs.clear();
EXPECT_EQ(0u, vmBindParams.flags);
vmBindParams.flags = 0x12345; // set non-zero to check if flags are passed
auto expectedFlags = vmBindParams.flags;
EXPECT_EQ(0, xeIoctlHelper->vmBind(vmBindParams));
EXPECT_EQ(1u, drm.vmBindInputs.size());
EXPECT_EQ(1u, drm.syncInputs.size());
EXPECT_EQ(1u, drm.waitUserFenceInputs.size());
auto expectedMask = std::numeric_limits<uint64_t>::max();
auto expectedTimeout = 5000000000ll;
{
auto &sync = drm.syncInputs[0];
EXPECT_EQ(fenceAddress, sync.addr);
EXPECT_EQ(fenceValue, sync.timeline_value);
auto &waitUserFence = drm.waitUserFenceInputs[0];
EXPECT_EQ(fenceAddress, waitUserFence.addr);
EXPECT_EQ(static_cast<uint16_t>(DRM_XE_UFENCE_WAIT_OP_EQ), waitUserFence.op);
EXPECT_EQ(0u, waitUserFence.flags);
EXPECT_EQ(fenceValue, waitUserFence.value);
EXPECT_EQ(expectedMask, waitUserFence.mask);
EXPECT_EQ(expectedTimeout, waitUserFence.timeout);
EXPECT_EQ(0u, waitUserFence.exec_queue_id);
EXPECT_EQ(expectedFlags, drm.vmBindInputs[0].bind.flags);
}
}
TEST(IoctlHelperXeTest, whenGemVmBindFailsThenErrorIsPropagated) {
DebugManagerStateRestore restorer;
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();