2018-03-22 16:41:17 +08:00
|
|
|
/*
|
2024-03-22 19:18:35 +08:00
|
|
|
* Copyright (C) 2018-2024 Intel Corporation
|
2018-03-22 16:41:17 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2018-03-22 16:41:17 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2022-02-22 20:51:29 +08:00
|
|
|
#include "shared/source/command_stream/wait_status.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/os_interface/os_context.h"
|
2021-01-21 20:10:13 +08:00
|
|
|
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
|
|
|
#include "shared/test/common/mocks/mock_device.h"
|
2024-03-22 19:18:35 +08:00
|
|
|
#include "shared/test/common/mocks/mock_kmd_notify_helper.h"
|
2022-06-30 03:17:47 +08:00
|
|
|
#include "shared/test/common/test_macros/hw_test.h"
|
2020-02-24 17:22:30 +08:00
|
|
|
|
2020-02-23 05:50:57 +08:00
|
|
|
#include "opencl/source/command_queue/command_queue.h"
|
2020-03-18 20:08:45 +08:00
|
|
|
#include "opencl/test/unit_test/mocks/mock_cl_device.h"
|
2020-02-23 22:20:22 +08:00
|
|
|
#include "opencl/test/unit_test/mocks/mock_command_queue.h"
|
|
|
|
#include "opencl/test/unit_test/mocks/mock_context.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2022-03-14 18:15:57 +08:00
|
|
|
#include "gtest/gtest.h"
|
2018-03-22 16:41:17 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
using namespace NEO;
|
2018-03-22 16:41:17 +08:00
|
|
|
|
|
|
|
struct KmdNotifyTests : public ::testing::Test {
|
|
|
|
void SetUp() override {
|
2020-01-14 21:32:11 +08:00
|
|
|
device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
|
2020-03-04 15:51:02 +08:00
|
|
|
hwInfo = device->getRootDeviceEnvironment().getMutableHardwareInfo();
|
2021-07-23 18:36:36 +08:00
|
|
|
cmdQ.reset(new MockCommandQueue(&context, device.get(), nullptr, false));
|
2018-11-29 18:39:10 +08:00
|
|
|
*device->getDefaultEngine().commandStreamReceiver->getTagAddress() = taskCountToWait;
|
2021-09-17 21:05:26 +08:00
|
|
|
cmdQ->getGpgpuCommandStreamReceiver().waitForFlushStamp(flushStampToWait);
|
2021-12-18 02:42:13 +08:00
|
|
|
overrideKmdNotifyParams(true, 2, true, 1, false, 0, false, 0);
|
2018-03-22 16:41:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void overrideKmdNotifyParams(bool kmdNotifyEnable, int64_t kmdNotifyDelay,
|
|
|
|
bool quickKmdSleepEnable, int64_t quickKmdSleepDelay,
|
2021-12-18 02:42:13 +08:00
|
|
|
bool quickKmdSleepEnableForSporadicWaits, int64_t quickKmdSleepDelayForSporadicWaits,
|
|
|
|
bool quickKmdSleepEnableForDirectSubmission, int64_t quickKmdSleepDelayForDirectSubmission) {
|
2019-05-06 18:33:44 +08:00
|
|
|
auto &properties = hwInfo->capabilityTable.kmdNotifyProperties;
|
2018-03-22 16:41:17 +08:00
|
|
|
properties.enableKmdNotify = kmdNotifyEnable;
|
|
|
|
properties.delayKmdNotifyMicroseconds = kmdNotifyDelay;
|
|
|
|
properties.enableQuickKmdSleep = quickKmdSleepEnable;
|
|
|
|
properties.delayQuickKmdSleepMicroseconds = quickKmdSleepDelay;
|
|
|
|
properties.enableQuickKmdSleepForSporadicWaits = quickKmdSleepEnableForSporadicWaits;
|
|
|
|
properties.delayQuickKmdSleepForSporadicWaitsMicroseconds = quickKmdSleepDelayForSporadicWaits;
|
2021-12-18 02:42:13 +08:00
|
|
|
properties.enableQuickKmdSleepForDirectSubmission = quickKmdSleepEnableForDirectSubmission;
|
|
|
|
properties.delayQuickKmdSleepForDirectSubmissionMicroseconds = quickKmdSleepDelayForDirectSubmission;
|
2018-03-22 16:41:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Family>
|
2018-04-10 16:26:59 +08:00
|
|
|
class MockKmdNotifyCsr : public UltCommandStreamReceiver<Family> {
|
2018-03-29 16:41:39 +08:00
|
|
|
public:
|
2020-10-29 22:33:35 +08:00
|
|
|
MockKmdNotifyCsr(const ExecutionEnvironment &executionEnvironment, const DeviceBitfield deviceBitfield)
|
2020-10-28 23:08:37 +08:00
|
|
|
: UltCommandStreamReceiver<Family>(const_cast<ExecutionEnvironment &>(executionEnvironment), 0, deviceBitfield) {}
|
2022-01-13 21:03:40 +08:00
|
|
|
|
|
|
|
bool waitForFlushStamp(FlushStamp &flushStampToWait) override {
|
|
|
|
waitForFlushStampCalled++;
|
|
|
|
waitForFlushStampParamsPassed.push_back({flushStampToWait});
|
|
|
|
return waitForFlushStampResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct WaitForFlushStampParams {
|
|
|
|
FlushStamp flushStampToWait{};
|
|
|
|
};
|
|
|
|
|
|
|
|
uint32_t waitForFlushStampCalled = 0u;
|
|
|
|
bool waitForFlushStampResult = true;
|
|
|
|
StackVec<WaitForFlushStampParams, 1> waitForFlushStampParamsPassed{};
|
|
|
|
|
2022-11-22 21:53:59 +08:00
|
|
|
WaitStatus waitForCompletionWithTimeout(const WaitParams ¶ms, TaskCountType taskCountToWait) override {
|
2022-01-13 21:03:40 +08:00
|
|
|
waitForCompletionWithTimeoutCalled++;
|
2022-03-23 22:36:07 +08:00
|
|
|
waitForCompletionWithTimeoutParamsPassed.push_back({params.enableTimeout, params.waitTimeout, taskCountToWait});
|
2022-01-13 21:03:40 +08:00
|
|
|
return waitForCompletionWithTimeoutResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct WaitForCompletionWithTimeoutParams {
|
|
|
|
bool enableTimeout{};
|
|
|
|
int64_t timeoutMs{};
|
2022-11-22 21:53:59 +08:00
|
|
|
TaskCountType taskCountToWait{};
|
2022-01-13 21:03:40 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
uint32_t waitForCompletionWithTimeoutCalled = 0u;
|
2023-12-01 17:12:59 +08:00
|
|
|
WaitStatus waitForCompletionWithTimeoutResult = WaitStatus::ready;
|
2022-01-13 21:03:40 +08:00
|
|
|
StackVec<WaitForCompletionWithTimeoutParams, 2> waitForCompletionWithTimeoutParamsPassed{};
|
2018-03-22 16:41:17 +08:00
|
|
|
};
|
|
|
|
|
2018-04-10 16:26:59 +08:00
|
|
|
template <typename Family>
|
|
|
|
MockKmdNotifyCsr<Family> *createMockCsr() {
|
2022-01-13 21:03:40 +08:00
|
|
|
auto csr = new MockKmdNotifyCsr<Family>(*device->executionEnvironment, device->getDeviceBitfield());
|
2018-04-10 16:26:59 +08:00
|
|
|
device->resetCommandStreamReceiver(csr);
|
|
|
|
|
|
|
|
mockKmdNotifyHelper = new MockKmdNotifyHelper(&device->getHardwareInfo().capabilityTable.kmdNotifyProperties);
|
|
|
|
csr->resetKmdNotifyHelper(mockKmdNotifyHelper);
|
|
|
|
|
|
|
|
return csr;
|
|
|
|
}
|
|
|
|
|
|
|
|
MockKmdNotifyHelper *mockKmdNotifyHelper = nullptr;
|
2019-05-06 18:33:44 +08:00
|
|
|
HardwareInfo *hwInfo = nullptr;
|
2018-03-22 16:41:17 +08:00
|
|
|
MockContext context;
|
2020-01-14 21:32:11 +08:00
|
|
|
std::unique_ptr<MockClDevice> device;
|
2018-11-16 19:46:49 +08:00
|
|
|
std::unique_ptr<MockCommandQueue> cmdQ;
|
2018-03-22 16:41:17 +08:00
|
|
|
FlushStamp flushStampToWait = 1000;
|
2022-11-22 21:53:59 +08:00
|
|
|
TaskCountType taskCountToWait = 5;
|
2018-03-22 16:41:17 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
HWTEST_F(KmdNotifyTests, givenTaskCountWhenWaitUntilCompletionCalledThenAlwaysTryCpuPolling) {
|
2018-04-10 16:26:59 +08:00
|
|
|
auto csr = createMockCsr<FamilyType>();
|
2022-02-22 20:51:29 +08:00
|
|
|
|
2021-09-10 00:57:09 +08:00
|
|
|
cmdQ->waitUntilComplete(taskCountToWait, {}, flushStampToWait, false);
|
2022-01-13 21:03:40 +08:00
|
|
|
EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled);
|
|
|
|
EXPECT_EQ(true, csr->waitForCompletionWithTimeoutParamsPassed[0].enableTimeout);
|
|
|
|
EXPECT_EQ(2, csr->waitForCompletionWithTimeoutParamsPassed[0].timeoutMs);
|
|
|
|
EXPECT_EQ(taskCountToWait, csr->waitForCompletionWithTimeoutParamsPassed[0].taskCountToWait);
|
2018-03-22 16:41:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(KmdNotifyTests, givenTaskCountAndKmdNotifyDisabledWhenWaitUntilCompletionCalledThenTryCpuPollingWithoutTimeout) {
|
2021-12-18 02:42:13 +08:00
|
|
|
overrideKmdNotifyParams(false, 0, false, 0, false, 0, false, 0);
|
2018-04-10 16:26:59 +08:00
|
|
|
auto csr = createMockCsr<FamilyType>();
|
2022-02-22 20:51:29 +08:00
|
|
|
|
2021-09-10 00:57:09 +08:00
|
|
|
cmdQ->waitUntilComplete(taskCountToWait, {}, flushStampToWait, false);
|
2022-01-13 21:03:40 +08:00
|
|
|
EXPECT_EQ(0u, csr->waitForFlushStampCalled);
|
|
|
|
EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled);
|
|
|
|
EXPECT_EQ(false, csr->waitForCompletionWithTimeoutParamsPassed[0].enableTimeout);
|
|
|
|
EXPECT_EQ(0, csr->waitForCompletionWithTimeoutParamsPassed[0].timeoutMs);
|
|
|
|
EXPECT_EQ(taskCountToWait, csr->waitForCompletionWithTimeoutParamsPassed[0].taskCountToWait);
|
2018-03-22 16:41:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(KmdNotifyTests, givenNotReadyTaskCountWhenWaitUntilCompletionCalledThenTryCpuPollingAndKmdWait) {
|
2018-04-10 16:26:59 +08:00
|
|
|
auto csr = createMockCsr<FamilyType>();
|
2018-07-31 20:27:26 +08:00
|
|
|
*csr->getTagAddress() = taskCountToWait - 1;
|
2018-03-22 16:41:17 +08:00
|
|
|
|
2023-12-01 17:12:59 +08:00
|
|
|
csr->waitForCompletionWithTimeoutResult = WaitStatus::notReady;
|
2018-03-22 16:41:17 +08:00
|
|
|
|
2023-01-04 23:00:09 +08:00
|
|
|
// we have unrecoverable for this case, this will throw.
|
2021-09-10 00:57:09 +08:00
|
|
|
EXPECT_THROW(cmdQ->waitUntilComplete(taskCountToWait, {}, flushStampToWait, false), std::exception);
|
2022-01-13 21:03:40 +08:00
|
|
|
EXPECT_EQ(1u, csr->waitForFlushStampCalled);
|
|
|
|
EXPECT_EQ(flushStampToWait, csr->waitForFlushStampParamsPassed[0].flushStampToWait);
|
|
|
|
|
|
|
|
EXPECT_EQ(2u, csr->waitForCompletionWithTimeoutCalled);
|
|
|
|
|
|
|
|
EXPECT_EQ(true, csr->waitForCompletionWithTimeoutParamsPassed[0].enableTimeout);
|
|
|
|
EXPECT_EQ(2, csr->waitForCompletionWithTimeoutParamsPassed[0].timeoutMs);
|
|
|
|
EXPECT_EQ(taskCountToWait, csr->waitForCompletionWithTimeoutParamsPassed[0].taskCountToWait);
|
|
|
|
|
|
|
|
EXPECT_EQ(false, csr->waitForCompletionWithTimeoutParamsPassed[1].enableTimeout);
|
|
|
|
EXPECT_EQ(0, csr->waitForCompletionWithTimeoutParamsPassed[1].timeoutMs);
|
|
|
|
EXPECT_EQ(taskCountToWait, csr->waitForCompletionWithTimeoutParamsPassed[1].taskCountToWait);
|
2018-03-22 16:41:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(KmdNotifyTests, givenReadyTaskCountWhenWaitUntilCompletionCalledThenTryCpuPollingAndDontCallKmdWait) {
|
2018-04-10 16:26:59 +08:00
|
|
|
auto csr = createMockCsr<FamilyType>();
|
2018-03-22 16:41:17 +08:00
|
|
|
|
2021-09-10 00:57:09 +08:00
|
|
|
cmdQ->waitUntilComplete(taskCountToWait, {}, flushStampToWait, false);
|
2022-01-13 21:03:40 +08:00
|
|
|
EXPECT_EQ(0u, csr->waitForFlushStampCalled);
|
|
|
|
EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled);
|
|
|
|
EXPECT_EQ(true, csr->waitForCompletionWithTimeoutParamsPassed[0].enableTimeout);
|
|
|
|
EXPECT_EQ(2, csr->waitForCompletionWithTimeoutParamsPassed[0].timeoutMs);
|
|
|
|
EXPECT_EQ(taskCountToWait, csr->waitForCompletionWithTimeoutParamsPassed[0].taskCountToWait);
|
2018-03-22 16:41:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(KmdNotifyTests, givenDefaultArgumentWhenWaitUntilCompleteIsCalledThenDisableQuickKmdSleep) {
|
2018-04-10 16:26:59 +08:00
|
|
|
auto csr = createMockCsr<FamilyType>();
|
2018-03-22 16:41:17 +08:00
|
|
|
auto expectedTimeout = device->getHardwareInfo().capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds;
|
|
|
|
|
2021-09-10 00:57:09 +08:00
|
|
|
cmdQ->waitUntilComplete(taskCountToWait, {}, flushStampToWait, false);
|
2022-01-13 21:03:40 +08:00
|
|
|
EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled);
|
|
|
|
EXPECT_EQ(true, csr->waitForCompletionWithTimeoutParamsPassed[0].enableTimeout);
|
|
|
|
EXPECT_EQ(expectedTimeout, csr->waitForCompletionWithTimeoutParamsPassed[0].timeoutMs);
|
|
|
|
EXPECT_EQ(taskCountToWait, csr->waitForCompletionWithTimeoutParamsPassed[0].taskCountToWait);
|
2018-03-22 16:41:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(KmdNotifyTests, givenEnabledQuickSleepWhenWaitUntilCompleteIsCalledThenChangeDelayValue) {
|
2018-04-10 16:26:59 +08:00
|
|
|
auto csr = createMockCsr<FamilyType>();
|
2018-03-22 16:41:17 +08:00
|
|
|
auto expectedTimeout = device->getHardwareInfo().capabilityTable.kmdNotifyProperties.delayQuickKmdSleepMicroseconds;
|
|
|
|
|
2021-09-10 00:57:09 +08:00
|
|
|
cmdQ->waitUntilComplete(taskCountToWait, {}, flushStampToWait, true);
|
2022-01-13 21:03:40 +08:00
|
|
|
EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled);
|
|
|
|
EXPECT_EQ(true, csr->waitForCompletionWithTimeoutParamsPassed[0].enableTimeout);
|
|
|
|
EXPECT_EQ(expectedTimeout, csr->waitForCompletionWithTimeoutParamsPassed[0].timeoutMs);
|
|
|
|
EXPECT_EQ(taskCountToWait, csr->waitForCompletionWithTimeoutParamsPassed[0].taskCountToWait);
|
2018-03-22 16:41:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(KmdNotifyTests, givenDisabledQuickSleepWhenWaitUntilCompleteWithQuickSleepRequestIsCalledThenUseBaseDelayValue) {
|
2021-12-18 02:42:13 +08:00
|
|
|
overrideKmdNotifyParams(true, 1, false, 0, false, 0, false, 0);
|
2018-04-10 16:26:59 +08:00
|
|
|
auto csr = createMockCsr<FamilyType>();
|
2018-03-22 16:41:17 +08:00
|
|
|
auto expectedTimeout = device->getHardwareInfo().capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds;
|
|
|
|
|
2021-09-10 00:57:09 +08:00
|
|
|
cmdQ->waitUntilComplete(taskCountToWait, {}, flushStampToWait, true);
|
2022-01-13 21:03:40 +08:00
|
|
|
EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled);
|
|
|
|
EXPECT_EQ(true, csr->waitForCompletionWithTimeoutParamsPassed[0].enableTimeout);
|
|
|
|
EXPECT_EQ(expectedTimeout, csr->waitForCompletionWithTimeoutParamsPassed[0].timeoutMs);
|
|
|
|
EXPECT_EQ(taskCountToWait, csr->waitForCompletionWithTimeoutParamsPassed[0].taskCountToWait);
|
2018-03-22 16:41:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(KmdNotifyTests, givenNotReadyTaskCountWhenPollForCompletionCalledThenTimeout) {
|
2018-11-29 18:39:10 +08:00
|
|
|
*device->getDefaultEngine().commandStreamReceiver->getTagAddress() = taskCountToWait - 1;
|
2018-11-22 20:57:10 +08:00
|
|
|
auto success = device->getUltCommandStreamReceiver<FamilyType>().waitForCompletionWithTimeout(true, 1, taskCountToWait);
|
2023-12-01 17:12:59 +08:00
|
|
|
EXPECT_NE(NEO::WaitStatus::ready, success);
|
2018-03-22 16:41:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(KmdNotifyTests, givenZeroFlushStampWhenWaitIsCalledThenDisableTimeout) {
|
2018-04-10 16:26:59 +08:00
|
|
|
auto csr = createMockCsr<FamilyType>();
|
2018-03-22 16:41:17 +08:00
|
|
|
|
|
|
|
EXPECT_TRUE(device->getHardwareInfo().capabilityTable.kmdNotifyProperties.enableKmdNotify);
|
|
|
|
|
2022-03-23 22:36:07 +08:00
|
|
|
csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 0, false, QueueThrottle::MEDIUM);
|
2022-01-13 21:03:40 +08:00
|
|
|
EXPECT_EQ(0u, csr->waitForFlushStampCalled);
|
|
|
|
EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled);
|
|
|
|
EXPECT_EQ(false, csr->waitForCompletionWithTimeoutParamsPassed[0].enableTimeout);
|
|
|
|
EXPECT_EQ(taskCountToWait, csr->waitForCompletionWithTimeoutParamsPassed[0].taskCountToWait);
|
2018-03-22 16:41:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(KmdNotifyTests, givenNonQuickSleepRequestWhenItsSporadicWaitThenOverrideQuickSleepRequest) {
|
2021-12-18 02:42:13 +08:00
|
|
|
overrideKmdNotifyParams(true, 3, true, 2, true, 1, false, 0);
|
2018-04-10 16:26:59 +08:00
|
|
|
auto csr = createMockCsr<FamilyType>();
|
2018-03-22 16:41:17 +08:00
|
|
|
|
|
|
|
auto expectedDelay = device->getHardwareInfo().capabilityTable.kmdNotifyProperties.delayQuickKmdSleepMicroseconds;
|
|
|
|
|
2018-06-07 15:14:00 +08:00
|
|
|
int64_t timeSinceLastWait = mockKmdNotifyHelper->properties->delayQuickKmdSleepForSporadicWaitsMicroseconds + 1;
|
|
|
|
|
|
|
|
mockKmdNotifyHelper->lastWaitForCompletionTimestampUs = mockKmdNotifyHelper->getMicrosecondsSinceEpoch() - timeSinceLastWait;
|
2022-03-23 22:36:07 +08:00
|
|
|
csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, false, QueueThrottle::MEDIUM);
|
2022-01-13 21:03:40 +08:00
|
|
|
EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled);
|
|
|
|
EXPECT_EQ(expectedDelay, csr->waitForCompletionWithTimeoutParamsPassed[0].timeoutMs);
|
2018-03-22 16:41:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(KmdNotifyTests, givenNonQuickSleepRequestWhenItsNotSporadicWaitThenOverrideQuickSleepRequest) {
|
2021-12-18 02:42:13 +08:00
|
|
|
overrideKmdNotifyParams(true, 3, true, 2, true, 9999999, false, 0);
|
2018-04-10 16:26:59 +08:00
|
|
|
auto csr = createMockCsr<FamilyType>();
|
2018-03-22 16:41:17 +08:00
|
|
|
|
|
|
|
auto expectedDelay = device->getHardwareInfo().capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds;
|
|
|
|
|
2022-03-23 22:36:07 +08:00
|
|
|
csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, false, QueueThrottle::MEDIUM);
|
2022-01-13 21:03:40 +08:00
|
|
|
EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled);
|
|
|
|
EXPECT_EQ(expectedDelay, csr->waitForCompletionWithTimeoutParamsPassed[0].timeoutMs);
|
2018-11-16 19:46:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(KmdNotifyTests, givenKmdNotifyDisabledWhenPowerSavingModeIsRequestedThenTimeoutIsEnabled) {
|
2021-12-18 02:42:13 +08:00
|
|
|
overrideKmdNotifyParams(false, 3, false, 2, false, 9999999, false, 0);
|
2018-11-16 19:46:49 +08:00
|
|
|
auto csr = createMockCsr<FamilyType>();
|
2022-01-21 00:56:19 +08:00
|
|
|
|
2022-03-23 22:36:07 +08:00
|
|
|
csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, false, QueueThrottle::LOW);
|
2022-01-13 21:03:40 +08:00
|
|
|
EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled);
|
|
|
|
EXPECT_EQ(true, csr->waitForCompletionWithTimeoutParamsPassed[0].enableTimeout);
|
|
|
|
EXPECT_EQ(1, csr->waitForCompletionWithTimeoutParamsPassed[0].timeoutMs);
|
2018-11-16 19:46:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(KmdNotifyTests, givenKmdNotifyDisabledWhenQueueHasPowerSavingModeAndCallWaitThenTimeoutIsEnabled) {
|
2021-12-18 02:42:13 +08:00
|
|
|
overrideKmdNotifyParams(false, 3, false, 2, false, 9999999, false, 0);
|
2018-11-16 19:46:49 +08:00
|
|
|
auto csr = createMockCsr<FamilyType>();
|
2022-01-13 21:03:40 +08:00
|
|
|
|
2018-11-16 19:46:49 +08:00
|
|
|
cmdQ->throttle = QueueThrottle::LOW;
|
2022-02-22 20:51:29 +08:00
|
|
|
|
2021-09-10 00:57:09 +08:00
|
|
|
cmdQ->waitUntilComplete(1, {}, 1, false);
|
2022-01-13 21:03:40 +08:00
|
|
|
EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled);
|
|
|
|
EXPECT_EQ(true, csr->waitForCompletionWithTimeoutParamsPassed[0].enableTimeout);
|
|
|
|
EXPECT_EQ(1, csr->waitForCompletionWithTimeoutParamsPassed[0].timeoutMs);
|
2018-11-16 19:46:49 +08:00
|
|
|
}
|
|
|
|
|
2023-06-13 22:37:41 +08:00
|
|
|
HWTEST_F(KmdNotifyTests, givenKmdNotifyDisabledWhenQueueHasPowerSavingModButThereIsNoFlushStampAndCallWaitThenTimeoutIsDisabled) {
|
2021-12-18 02:42:13 +08:00
|
|
|
overrideKmdNotifyParams(false, 3, false, 2, false, 9999999, false, 0);
|
2018-11-16 19:46:49 +08:00
|
|
|
auto csr = createMockCsr<FamilyType>();
|
|
|
|
|
|
|
|
cmdQ->throttle = QueueThrottle::LOW;
|
2022-02-22 20:51:29 +08:00
|
|
|
|
2021-09-10 00:57:09 +08:00
|
|
|
cmdQ->waitUntilComplete(1, {}, 0, false);
|
2022-01-13 21:03:40 +08:00
|
|
|
EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled);
|
|
|
|
EXPECT_EQ(false, csr->waitForCompletionWithTimeoutParamsPassed[0].enableTimeout);
|
|
|
|
EXPECT_EQ(0, csr->waitForCompletionWithTimeoutParamsPassed[0].timeoutMs);
|
2018-03-22 16:41:17 +08:00
|
|
|
}
|
|
|
|
|
2023-06-13 22:37:41 +08:00
|
|
|
HWTEST_F(KmdNotifyTests, givenKmdNotifyDisabledWhenQueueHasPowerSavingModAndThereIsNoFlushStampButKmdWaitOnTaskCountAllowedAndCallWaitThenTimeoutIsEnabled) {
|
|
|
|
overrideKmdNotifyParams(false, 3, false, 2, false, 9999999, false, 0);
|
|
|
|
auto csr = createMockCsr<FamilyType>();
|
|
|
|
csr->isKmdWaitOnTaskCountAllowedValue = true;
|
|
|
|
|
|
|
|
cmdQ->throttle = QueueThrottle::LOW;
|
|
|
|
|
|
|
|
cmdQ->waitUntilComplete(1, {}, 0, false);
|
|
|
|
EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled);
|
|
|
|
EXPECT_EQ(true, csr->waitForCompletionWithTimeoutParamsPassed[0].enableTimeout);
|
|
|
|
EXPECT_EQ(1, csr->waitForCompletionWithTimeoutParamsPassed[0].timeoutMs);
|
|
|
|
}
|
|
|
|
|
2018-03-22 16:41:17 +08:00
|
|
|
HWTEST_F(KmdNotifyTests, givenQuickSleepRequestWhenItsSporadicWaitOptimizationIsDisabledThenDontOverrideQuickSleepRequest) {
|
2021-12-18 02:42:13 +08:00
|
|
|
overrideKmdNotifyParams(true, 3, true, 2, false, 0, false, 0);
|
2018-04-10 16:26:59 +08:00
|
|
|
auto csr = createMockCsr<FamilyType>();
|
2018-03-22 16:41:17 +08:00
|
|
|
|
|
|
|
auto expectedDelay = device->getHardwareInfo().capabilityTable.kmdNotifyProperties.delayQuickKmdSleepMicroseconds;
|
|
|
|
|
2022-03-23 22:36:07 +08:00
|
|
|
csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, true, QueueThrottle::MEDIUM);
|
2022-01-13 21:03:40 +08:00
|
|
|
EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled);
|
|
|
|
EXPECT_EQ(expectedDelay, csr->waitForCompletionWithTimeoutParamsPassed[0].timeoutMs);
|
2018-03-22 16:41:17 +08:00
|
|
|
}
|
|
|
|
|
2018-04-09 16:05:32 +08:00
|
|
|
HWTEST_F(KmdNotifyTests, givenTaskCountEqualToHwTagWhenWaitCalledThenDontMultiplyTimeout) {
|
2018-04-10 16:26:59 +08:00
|
|
|
auto csr = createMockCsr<FamilyType>();
|
2018-07-31 20:27:26 +08:00
|
|
|
*csr->getTagAddress() = taskCountToWait;
|
2018-04-09 16:05:32 +08:00
|
|
|
|
|
|
|
auto expectedTimeout = device->getHardwareInfo().capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds;
|
|
|
|
|
2022-03-23 22:36:07 +08:00
|
|
|
csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, false, QueueThrottle::MEDIUM);
|
2022-01-13 21:03:40 +08:00
|
|
|
EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled);
|
|
|
|
EXPECT_EQ(true, csr->waitForCompletionWithTimeoutParamsPassed[0].enableTimeout);
|
|
|
|
EXPECT_EQ(expectedTimeout, csr->waitForCompletionWithTimeoutParamsPassed[0].timeoutMs);
|
2018-04-09 16:05:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(KmdNotifyTests, givenTaskCountLowerThanHwTagWhenWaitCalledThenDontMultiplyTimeout) {
|
2018-04-10 16:26:59 +08:00
|
|
|
auto csr = createMockCsr<FamilyType>();
|
2018-07-31 20:27:26 +08:00
|
|
|
*csr->getTagAddress() = taskCountToWait + 5;
|
2018-04-09 16:05:32 +08:00
|
|
|
|
|
|
|
auto expectedTimeout = device->getHardwareInfo().capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds;
|
2018-03-29 16:41:39 +08:00
|
|
|
|
2022-03-23 22:36:07 +08:00
|
|
|
csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, false, QueueThrottle::MEDIUM);
|
2022-01-13 21:03:40 +08:00
|
|
|
EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled);
|
|
|
|
EXPECT_EQ(true, csr->waitForCompletionWithTimeoutParamsPassed[0].enableTimeout);
|
|
|
|
EXPECT_EQ(expectedTimeout, csr->waitForCompletionWithTimeoutParamsPassed[0].timeoutMs);
|
2018-03-29 16:41:39 +08:00
|
|
|
}
|
|
|
|
|
2018-03-22 16:41:17 +08:00
|
|
|
HWTEST_F(KmdNotifyTests, givenDefaultCommandStreamReceiverWhenWaitCalledThenUpdateWaitTimestamp) {
|
2021-12-18 02:42:13 +08:00
|
|
|
overrideKmdNotifyParams(true, 3, true, 2, true, 1, false, 0);
|
2018-03-22 16:41:17 +08:00
|
|
|
|
2018-04-10 16:26:59 +08:00
|
|
|
auto csr = createMockCsr<FamilyType>();
|
2018-06-07 15:14:00 +08:00
|
|
|
EXPECT_NE(0, mockKmdNotifyHelper->lastWaitForCompletionTimestampUs.load());
|
2018-03-22 16:41:17 +08:00
|
|
|
|
2018-04-10 16:26:59 +08:00
|
|
|
EXPECT_EQ(1u, mockKmdNotifyHelper->updateLastWaitForCompletionTimestampCalled);
|
2022-03-23 22:36:07 +08:00
|
|
|
csr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, QueueThrottle::MEDIUM);
|
2018-04-10 16:26:59 +08:00
|
|
|
EXPECT_EQ(2u, mockKmdNotifyHelper->updateLastWaitForCompletionTimestampCalled);
|
2018-03-23 02:02:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(KmdNotifyTests, givenDefaultCommandStreamReceiverWithDisabledSporadicWaitOptimizationWhenWaitCalledThenDontUpdateWaitTimestamp) {
|
2021-12-18 02:42:13 +08:00
|
|
|
overrideKmdNotifyParams(true, 3, true, 2, false, 0, false, 0);
|
2018-03-22 16:41:17 +08:00
|
|
|
|
2018-04-10 16:26:59 +08:00
|
|
|
auto csr = createMockCsr<FamilyType>();
|
2018-06-07 15:14:00 +08:00
|
|
|
EXPECT_EQ(0, mockKmdNotifyHelper->lastWaitForCompletionTimestampUs.load());
|
2018-03-23 02:02:58 +08:00
|
|
|
|
2022-03-23 22:36:07 +08:00
|
|
|
csr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, QueueThrottle::MEDIUM);
|
2018-04-10 16:26:59 +08:00
|
|
|
EXPECT_EQ(0u, mockKmdNotifyHelper->updateLastWaitForCompletionTimestampCalled);
|
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(KmdNotifyTests, givenNewHelperWhenItsSetToCsrThenUpdateAcLineStatus) {
|
2019-05-06 18:33:44 +08:00
|
|
|
auto helper = new MockKmdNotifyHelper(&(hwInfo->capabilityTable.kmdNotifyProperties));
|
2018-04-10 16:26:59 +08:00
|
|
|
EXPECT_EQ(0u, helper->updateAcLineStatusCalled);
|
|
|
|
|
|
|
|
auto csr = createMockCsr<FamilyType>();
|
|
|
|
csr->resetKmdNotifyHelper(helper);
|
|
|
|
EXPECT_EQ(1u, helper->updateAcLineStatusCalled);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(KmdNotifyTests, givenTaskCountDiffLowerThanMinimumToCheckAcLineWhenObtainingTimeoutPropertiesThenDontCheck) {
|
2019-05-06 18:33:44 +08:00
|
|
|
hwInfo->capabilityTable.kmdNotifyProperties.enableKmdNotify = false;
|
|
|
|
MockKmdNotifyHelper helper(&(hwInfo->capabilityTable.kmdNotifyProperties));
|
2018-04-10 16:26:59 +08:00
|
|
|
|
|
|
|
uint32_t hwTag = 9;
|
2022-11-22 21:53:59 +08:00
|
|
|
TaskCountType taskCountToWait = 10;
|
2018-04-10 16:26:59 +08:00
|
|
|
EXPECT_TRUE(taskCountToWait - hwTag < KmdNotifyConstants::minimumTaskCountDiffToCheckAcLine);
|
|
|
|
EXPECT_EQ(10u, KmdNotifyConstants::minimumTaskCountDiffToCheckAcLine);
|
|
|
|
|
2022-03-23 22:36:07 +08:00
|
|
|
helper.obtainTimeoutParams(false, hwTag, taskCountToWait, 1, QueueThrottle::MEDIUM, true, false);
|
2018-04-10 16:26:59 +08:00
|
|
|
|
|
|
|
EXPECT_EQ(0u, helper.updateAcLineStatusCalled);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(KmdNotifyTests, givenTaskCountDiffGreaterThanMinimumToCheckAcLineAndDisabledKmdNotifyWhenObtainingTimeoutPropertiesThenCheck) {
|
2019-05-06 18:33:44 +08:00
|
|
|
hwInfo->capabilityTable.kmdNotifyProperties.enableKmdNotify = false;
|
|
|
|
MockKmdNotifyHelper helper(&(hwInfo->capabilityTable.kmdNotifyProperties));
|
2018-04-10 16:26:59 +08:00
|
|
|
|
|
|
|
uint32_t hwTag = 10;
|
2022-11-22 21:53:59 +08:00
|
|
|
TaskCountType taskCountToWait = 21;
|
2018-04-10 16:26:59 +08:00
|
|
|
EXPECT_TRUE(taskCountToWait - hwTag > KmdNotifyConstants::minimumTaskCountDiffToCheckAcLine);
|
|
|
|
EXPECT_EQ(10u, KmdNotifyConstants::minimumTaskCountDiffToCheckAcLine);
|
|
|
|
|
2022-03-23 22:36:07 +08:00
|
|
|
helper.obtainTimeoutParams(false, hwTag, taskCountToWait, 1, QueueThrottle::MEDIUM, true, false);
|
2018-04-10 16:26:59 +08:00
|
|
|
|
|
|
|
EXPECT_EQ(1u, helper.updateAcLineStatusCalled);
|
|
|
|
}
|
|
|
|
|
2021-06-15 19:31:12 +08:00
|
|
|
TEST_F(KmdNotifyTests, givenKmdWaitModeNotActiveWhenObtainTimeoutParamsThenFalseIsReturned) {
|
2021-02-17 18:33:41 +08:00
|
|
|
MockKmdNotifyHelper helper(&(hwInfo->capabilityTable.kmdNotifyProperties));
|
|
|
|
|
2022-03-23 22:36:07 +08:00
|
|
|
auto params = helper.obtainTimeoutParams(false, 1, 1, 1, QueueThrottle::MEDIUM, false, false);
|
2021-02-17 18:33:41 +08:00
|
|
|
|
2022-03-23 22:36:07 +08:00
|
|
|
EXPECT_FALSE(params.enableTimeout);
|
|
|
|
EXPECT_FALSE(params.waitTimeout);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(KmdNotifyTests, givenHighThrottleWhenObtainTimeoutParamsThenIndefinitelyPollSetToTrue) {
|
|
|
|
MockKmdNotifyHelper helper(&(hwInfo->capabilityTable.kmdNotifyProperties));
|
|
|
|
|
|
|
|
auto params = helper.obtainTimeoutParams(false, 1, 1, 1, QueueThrottle::HIGH, false, false);
|
|
|
|
|
|
|
|
EXPECT_FALSE(params.enableTimeout);
|
|
|
|
EXPECT_FALSE(params.waitTimeout);
|
|
|
|
EXPECT_TRUE(params.indefinitelyPoll);
|
2021-02-17 18:33:41 +08:00
|
|
|
}
|
|
|
|
|
2018-04-10 16:26:59 +08:00
|
|
|
TEST_F(KmdNotifyTests, givenTaskCountDiffGreaterThanMinimumToCheckAcLineAndEnabledKmdNotifyWhenObtainingTimeoutPropertiesThenDontCheck) {
|
2019-05-06 18:33:44 +08:00
|
|
|
hwInfo->capabilityTable.kmdNotifyProperties.enableKmdNotify = true;
|
|
|
|
MockKmdNotifyHelper helper(&(hwInfo->capabilityTable.kmdNotifyProperties));
|
2018-04-10 16:26:59 +08:00
|
|
|
|
|
|
|
uint32_t hwTag = 10;
|
2022-11-22 21:53:59 +08:00
|
|
|
TaskCountType taskCountToWait = 21;
|
2018-04-10 16:26:59 +08:00
|
|
|
EXPECT_TRUE(taskCountToWait - hwTag > KmdNotifyConstants::minimumTaskCountDiffToCheckAcLine);
|
|
|
|
EXPECT_EQ(10u, KmdNotifyConstants::minimumTaskCountDiffToCheckAcLine);
|
|
|
|
|
2022-03-23 22:36:07 +08:00
|
|
|
helper.obtainTimeoutParams(false, hwTag, taskCountToWait, 1, QueueThrottle::MEDIUM, true, false);
|
2018-04-10 16:26:59 +08:00
|
|
|
|
|
|
|
EXPECT_EQ(0u, helper.updateAcLineStatusCalled);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(KmdNotifyTests, givenDisabledKmdNotifyMechanismWhenAcLineIsDisconnectedThenForceEnableTimeout) {
|
2019-05-06 18:33:44 +08:00
|
|
|
hwInfo->capabilityTable.kmdNotifyProperties.enableKmdNotify = false;
|
|
|
|
MockKmdNotifyHelper helper(&(hwInfo->capabilityTable.kmdNotifyProperties));
|
2018-04-10 16:26:59 +08:00
|
|
|
helper.acLineConnected = false;
|
|
|
|
|
2022-03-23 22:36:07 +08:00
|
|
|
auto params = helper.obtainTimeoutParams(false, 1, 2, 2, QueueThrottle::MEDIUM, true, false);
|
2018-04-10 16:26:59 +08:00
|
|
|
|
2022-03-23 22:36:07 +08:00
|
|
|
EXPECT_TRUE(params.enableTimeout);
|
|
|
|
EXPECT_EQ(KmdNotifyConstants::timeoutInMicrosecondsForDisconnectedAcLine, params.waitTimeout);
|
2018-04-10 16:26:59 +08:00
|
|
|
EXPECT_EQ(10000, KmdNotifyConstants::timeoutInMicrosecondsForDisconnectedAcLine);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(KmdNotifyTests, givenEnabledKmdNotifyMechanismWhenAcLineIsDisconnectedThenDontChangeTimeoutValue) {
|
2019-05-06 18:33:44 +08:00
|
|
|
hwInfo->capabilityTable.kmdNotifyProperties.enableKmdNotify = true;
|
|
|
|
hwInfo->capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds = 5;
|
|
|
|
MockKmdNotifyHelper helper(&(hwInfo->capabilityTable.kmdNotifyProperties));
|
2018-04-10 16:26:59 +08:00
|
|
|
helper.acLineConnected = false;
|
|
|
|
|
2022-03-23 22:36:07 +08:00
|
|
|
auto params = helper.obtainTimeoutParams(false, 1, 2, 2, QueueThrottle::MEDIUM, true, false);
|
2018-04-10 16:26:59 +08:00
|
|
|
|
2022-03-23 22:36:07 +08:00
|
|
|
EXPECT_TRUE(params.enableTimeout);
|
|
|
|
EXPECT_EQ(hwInfo->capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds, params.waitTimeout);
|
2018-04-10 16:26:59 +08:00
|
|
|
}
|
|
|
|
|
2023-06-29 22:21:41 +08:00
|
|
|
TEST_F(KmdNotifyTests, givenEnabledKmdNotifyMechanismAndTaskCountToWaitLargerThanHwTagPlusOneAndDirectSubmissionDisabledAndQueueThrottleMediumThenDoNotApplyMultiplier) {
|
|
|
|
hwInfo->capabilityTable.kmdNotifyProperties.enableKmdNotify = true;
|
|
|
|
hwInfo->capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds = 5;
|
|
|
|
MockKmdNotifyHelper helper(&(hwInfo->capabilityTable.kmdNotifyProperties));
|
|
|
|
|
|
|
|
auto params = helper.obtainTimeoutParams(false, 1, 10, 2, QueueThrottle::MEDIUM, true, false);
|
|
|
|
|
|
|
|
EXPECT_TRUE(params.enableTimeout);
|
|
|
|
EXPECT_EQ(hwInfo->capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds, params.waitTimeout);
|
|
|
|
}
|
|
|
|
|
2018-04-10 16:26:59 +08:00
|
|
|
TEST_F(KmdNotifyTests, givenDisabledKmdNotifyMechanismAndFlushStampIsZeroWhenAcLineIsDisconnectedThenDontForceEnableTimeout) {
|
2019-05-06 18:33:44 +08:00
|
|
|
hwInfo->capabilityTable.kmdNotifyProperties.enableKmdNotify = false;
|
|
|
|
MockKmdNotifyHelper helper(&(hwInfo->capabilityTable.kmdNotifyProperties));
|
2018-04-10 16:26:59 +08:00
|
|
|
helper.acLineConnected = false;
|
|
|
|
|
|
|
|
FlushStamp flushStampToWait = 0;
|
2022-03-23 22:36:07 +08:00
|
|
|
auto params = helper.obtainTimeoutParams(false, 1, 2, flushStampToWait, QueueThrottle::MEDIUM, true, false);
|
2018-04-10 16:26:59 +08:00
|
|
|
|
2022-03-23 22:36:07 +08:00
|
|
|
EXPECT_FALSE(params.enableTimeout);
|
2018-03-22 16:41:17 +08:00
|
|
|
}
|
2018-03-29 16:41:39 +08:00
|
|
|
|
2018-11-15 00:33:20 +08:00
|
|
|
TEST_F(KmdNotifyTests, givenDisabledKmdNotifyMechanismWhenPowerSavingModeIsSetThenKmdNotifyMechanismIsUsedAndReturnsShortestWaitingTimePossible) {
|
|
|
|
DebugManagerStateRestore stateRestore;
|
2023-11-30 16:32:25 +08:00
|
|
|
debugManager.flags.PowerSavingMode.set(1u);
|
2019-05-06 18:33:44 +08:00
|
|
|
hwInfo->capabilityTable.kmdNotifyProperties.enableKmdNotify = false;
|
|
|
|
MockKmdNotifyHelper helper(&(hwInfo->capabilityTable.kmdNotifyProperties));
|
2018-11-15 00:33:20 +08:00
|
|
|
helper.acLineConnected = false;
|
|
|
|
|
|
|
|
FlushStamp flushStampToWait = 1;
|
2022-03-23 22:36:07 +08:00
|
|
|
auto params = helper.obtainTimeoutParams(false, 1, 2, flushStampToWait, QueueThrottle::MEDIUM, true, false);
|
|
|
|
EXPECT_TRUE(params.enableTimeout);
|
|
|
|
EXPECT_EQ(1, params.waitTimeout);
|
2018-11-16 19:46:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(KmdNotifyTests, givenDisabledKmdNotifyMechanismWhenPowerSavingModeIsRequestedThenKmdNotifyMechanismIsUsedAndReturnsShortestWaitingTimePossible) {
|
2019-05-06 18:33:44 +08:00
|
|
|
hwInfo->capabilityTable.kmdNotifyProperties.enableKmdNotify = false;
|
|
|
|
MockKmdNotifyHelper helper(&(hwInfo->capabilityTable.kmdNotifyProperties));
|
2018-11-16 19:46:49 +08:00
|
|
|
|
|
|
|
FlushStamp flushStampToWait = 1;
|
2022-03-23 22:36:07 +08:00
|
|
|
auto params = helper.obtainTimeoutParams(false, 1, 2, flushStampToWait, QueueThrottle::LOW, true, false);
|
|
|
|
EXPECT_TRUE(params.enableTimeout);
|
|
|
|
EXPECT_EQ(1, params.waitTimeout);
|
2018-11-15 00:33:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(KmdNotifyTests, givenEnabledKmdNotifyMechanismWhenPowerSavingModeIsSetAndNoFlushStampProvidedWhenParametersAreObtainedThenFalseIsReturned) {
|
|
|
|
DebugManagerStateRestore stateRestore;
|
2023-11-30 16:32:25 +08:00
|
|
|
debugManager.flags.PowerSavingMode.set(1u);
|
2019-05-06 18:33:44 +08:00
|
|
|
hwInfo->capabilityTable.kmdNotifyProperties.enableKmdNotify = true;
|
|
|
|
MockKmdNotifyHelper helper(&(hwInfo->capabilityTable.kmdNotifyProperties));
|
2018-11-15 00:33:20 +08:00
|
|
|
helper.acLineConnected = false;
|
|
|
|
|
|
|
|
FlushStamp flushStampToWait = 0;
|
2022-03-23 22:36:07 +08:00
|
|
|
auto params = helper.obtainTimeoutParams(false, 1, 2, flushStampToWait, QueueThrottle::MEDIUM, true, false);
|
|
|
|
EXPECT_FALSE(params.enableTimeout);
|
|
|
|
EXPECT_EQ(0, params.waitTimeout);
|
2018-11-15 00:33:20 +08:00
|
|
|
}
|
2021-12-18 02:42:13 +08:00
|
|
|
|
|
|
|
TEST_F(KmdNotifyTests, givenEnabledKmdDirectSubmissionNotifyMechanismWhenDirectSubmissionIsEnabledThenSelectDelayTimeoutForDirectSubmission) {
|
|
|
|
overrideKmdNotifyParams(true, 150, false, 0, false, 0, true, 20);
|
|
|
|
|
|
|
|
MockKmdNotifyHelper helper(&(hwInfo->capabilityTable.kmdNotifyProperties));
|
|
|
|
|
|
|
|
constexpr int64_t expectedTimeout = 20;
|
|
|
|
constexpr bool directSubmission = true;
|
|
|
|
FlushStamp flushStampToWait = 1;
|
2022-03-23 22:36:07 +08:00
|
|
|
auto params = helper.obtainTimeoutParams(false, 1, 2, flushStampToWait, QueueThrottle::MEDIUM, true, directSubmission);
|
|
|
|
EXPECT_TRUE(params.enableTimeout);
|
|
|
|
EXPECT_EQ(expectedTimeout, params.waitTimeout);
|
2021-12-18 02:42:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(KmdNotifyTests, givenEnabledKmdDirectSubmissionNotifyMechanismWhenDirectSubmissionIsDisabledThenSelectBaseDelayTimeout) {
|
|
|
|
overrideKmdNotifyParams(true, 150, false, 0, false, 0, true, 20);
|
|
|
|
|
|
|
|
MockKmdNotifyHelper helper(&(hwInfo->capabilityTable.kmdNotifyProperties));
|
|
|
|
|
|
|
|
constexpr int64_t expectedTimeout = 150;
|
|
|
|
constexpr bool directSubmission = false;
|
|
|
|
FlushStamp flushStampToWait = 1;
|
2022-03-23 22:36:07 +08:00
|
|
|
auto params = helper.obtainTimeoutParams(false, 1, 2, flushStampToWait, QueueThrottle::MEDIUM, true, directSubmission);
|
|
|
|
EXPECT_TRUE(params.enableTimeout);
|
|
|
|
EXPECT_EQ(expectedTimeout, params.waitTimeout);
|
2021-12-18 02:42:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(KmdNotifyTests, givenDisabledKmdDirectSubmissionNotifyMechanismWhenDirectSubmissionIsEnabledThenSelectBaseDelayTimeout) {
|
|
|
|
overrideKmdNotifyParams(true, 150, false, 0, false, 0, false, 20);
|
|
|
|
|
|
|
|
MockKmdNotifyHelper helper(&(hwInfo->capabilityTable.kmdNotifyProperties));
|
|
|
|
|
|
|
|
constexpr int64_t expectedTimeout = 150;
|
|
|
|
constexpr bool directSubmission = true;
|
|
|
|
FlushStamp flushStampToWait = 1;
|
2022-03-23 22:36:07 +08:00
|
|
|
auto params = helper.obtainTimeoutParams(false, 1, 2, flushStampToWait, QueueThrottle::MEDIUM, true, directSubmission);
|
|
|
|
EXPECT_TRUE(params.enableTimeout);
|
|
|
|
EXPECT_EQ(expectedTimeout, params.waitTimeout);
|
2022-02-22 20:51:29 +08:00
|
|
|
}
|