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