2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2021-05-16 20:51:16 +02:00
|
|
|
* Copyright (C) 2018-2021 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-18 09:11:08 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/helpers/file_io.h"
|
2020-04-10 13:54:07 +02:00
|
|
|
#include "shared/source/helpers/hw_info.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/os_interface/device_factory.h"
|
|
|
|
#include "shared/source/os_interface/linux/os_context_linux.h"
|
|
|
|
#include "shared/source/os_interface/linux/os_interface.h"
|
2021-03-12 10:46:18 +00:00
|
|
|
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
2021-01-21 13:10:13 +01:00
|
|
|
#include "shared/test/common/helpers/default_hw_info.h"
|
2020-02-24 10:22:30 +01:00
|
|
|
|
2020-02-23 15:20:22 +01:00
|
|
|
#include "opencl/test/unit_test/fixtures/memory_management_fixture.h"
|
2020-09-11 14:18:23 +02:00
|
|
|
#include "opencl/test/unit_test/mocks/mock_platform.h"
|
2020-02-23 15:20:22 +01:00
|
|
|
#include "opencl/test/unit_test/os_interface/linux/drm_mock.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
|
|
|
#include <fstream>
|
2019-04-23 15:42:33 +02:00
|
|
|
#include <memory>
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
using namespace NEO;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2020-12-16 09:38:09 +01:00
|
|
|
TEST(DrmTest, WhenGettingDeviceIdThenCorrectIdReturned) {
|
2020-09-11 14:18:23 +02:00
|
|
|
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
|
|
|
DrmMock *pDrm = new DrmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
2017-12-21 00:45:38 +01:00
|
|
|
EXPECT_NE(nullptr, pDrm);
|
|
|
|
|
|
|
|
pDrm->StoredDeviceID = 0x1234;
|
|
|
|
int deviceID = 0;
|
|
|
|
int ret = pDrm->getDeviceID(deviceID);
|
|
|
|
EXPECT_EQ(0, ret);
|
|
|
|
EXPECT_EQ(pDrm->StoredDeviceID, deviceID);
|
|
|
|
delete pDrm;
|
|
|
|
}
|
|
|
|
|
2021-04-23 14:30:04 +00:00
|
|
|
TEST(DrmTest, GivenValidPciPathWhenGettingAdapterBdfThenCorrectValuesAreReturned) {
|
|
|
|
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
|
|
|
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
|
|
|
|
|
|
|
{
|
|
|
|
drm.setPciPath("ab:cd.e");
|
|
|
|
auto adapterBdf = drm.getAdapterBDF();
|
|
|
|
EXPECT_EQ(0xabu, adapterBdf.Bus);
|
|
|
|
EXPECT_EQ(0xcdu, adapterBdf.Device);
|
|
|
|
EXPECT_EQ(0xeu, adapterBdf.Function);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
drm.setPciPath("01:23.4");
|
|
|
|
auto adapterBdf = drm.getAdapterBDF();
|
|
|
|
EXPECT_EQ(0x1u, adapterBdf.Bus);
|
|
|
|
EXPECT_EQ(0x23u, adapterBdf.Device);
|
|
|
|
EXPECT_EQ(0x4u, adapterBdf.Function);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-10 13:54:07 +02:00
|
|
|
TEST(DrmTest, GivenInvalidPciPathWhenFrequencyIsQueriedThenReturnError) {
|
2020-09-11 14:18:23 +02:00
|
|
|
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
|
|
|
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
2020-04-10 13:54:07 +02:00
|
|
|
auto hwInfo = *defaultHwInfo;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
int maxFrequency = 0;
|
2020-04-08 18:14:19 +02:00
|
|
|
|
|
|
|
drm.setPciPath("invalidPci");
|
2020-04-10 13:54:07 +02:00
|
|
|
int ret = drm.getMaxGpuFrequency(hwInfo, maxFrequency);
|
|
|
|
EXPECT_NE(0, ret);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
EXPECT_EQ(0, maxFrequency);
|
|
|
|
}
|
|
|
|
|
2020-12-16 09:38:09 +01:00
|
|
|
TEST(DrmTest, WhenGettingRevisionIdThenCorrectIdIsReturned) {
|
2020-09-11 14:18:23 +02:00
|
|
|
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
|
|
|
DrmMock *pDrm = new DrmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
2017-12-21 00:45:38 +01:00
|
|
|
EXPECT_NE(nullptr, pDrm);
|
|
|
|
|
|
|
|
pDrm->StoredDeviceID = 0x1234;
|
|
|
|
pDrm->StoredDeviceRevID = 0xB;
|
|
|
|
int deviceID = 0;
|
|
|
|
int ret = pDrm->getDeviceID(deviceID);
|
|
|
|
EXPECT_EQ(0, ret);
|
|
|
|
int revID = 0;
|
|
|
|
ret = pDrm->getDeviceRevID(revID);
|
|
|
|
EXPECT_EQ(0, ret);
|
|
|
|
|
|
|
|
EXPECT_EQ(pDrm->StoredDeviceID, deviceID);
|
|
|
|
EXPECT_EQ(pDrm->StoredDeviceRevID, revID);
|
|
|
|
|
|
|
|
delete pDrm;
|
|
|
|
}
|
|
|
|
|
2019-12-17 15:17:52 +01:00
|
|
|
TEST(DrmTest, GivenDrmWhenAskedForGttSizeThenReturnCorrectValue) {
|
2020-09-11 14:18:23 +02:00
|
|
|
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
|
|
|
auto drm = std::make_unique<DrmMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
2019-12-17 15:17:52 +01:00
|
|
|
uint64_t queryGttSize = 0;
|
|
|
|
|
|
|
|
drm->StoredRetValForGetGttSize = 0;
|
2019-04-23 15:42:33 +02:00
|
|
|
drm->storedGTTSize = 1ull << 31;
|
2019-12-17 15:17:52 +01:00
|
|
|
EXPECT_EQ(0, drm->queryGttSize(queryGttSize));
|
|
|
|
EXPECT_EQ(drm->storedGTTSize, queryGttSize);
|
|
|
|
|
|
|
|
queryGttSize = 0;
|
|
|
|
drm->StoredRetValForGetGttSize = -1;
|
|
|
|
EXPECT_NE(0, drm->queryGttSize(queryGttSize));
|
|
|
|
EXPECT_EQ(0u, queryGttSize);
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
2020-12-16 09:38:09 +01:00
|
|
|
TEST(DrmTest, GivenDrmWhenAskedForPreemptionThenCorrectValueReturned) {
|
2020-09-11 14:18:23 +02:00
|
|
|
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
|
|
|
DrmMock *pDrm = new DrmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
2019-03-21 22:21:52 -07:00
|
|
|
pDrm->StoredRetVal = 0;
|
|
|
|
pDrm->StoredPreemptionSupport =
|
|
|
|
I915_SCHEDULER_CAP_ENABLED |
|
|
|
|
I915_SCHEDULER_CAP_PRIORITY |
|
|
|
|
I915_SCHEDULER_CAP_PREEMPTION;
|
2018-12-07 15:03:23 +01:00
|
|
|
pDrm->checkPreemptionSupport();
|
|
|
|
EXPECT_TRUE(pDrm->isPreemptionSupported());
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
pDrm->StoredPreemptionSupport = 0;
|
2018-12-07 15:03:23 +01:00
|
|
|
pDrm->checkPreemptionSupport();
|
|
|
|
EXPECT_FALSE(pDrm->isPreemptionSupported());
|
2019-03-21 22:21:52 -07:00
|
|
|
|
|
|
|
pDrm->StoredRetVal = -1;
|
|
|
|
pDrm->StoredPreemptionSupport =
|
|
|
|
I915_SCHEDULER_CAP_ENABLED |
|
|
|
|
I915_SCHEDULER_CAP_PRIORITY |
|
|
|
|
I915_SCHEDULER_CAP_PREEMPTION;
|
|
|
|
pDrm->checkPreemptionSupport();
|
|
|
|
EXPECT_FALSE(pDrm->isPreemptionSupported());
|
|
|
|
|
|
|
|
pDrm->StoredPreemptionSupport = 0;
|
|
|
|
pDrm->checkPreemptionSupport();
|
|
|
|
EXPECT_FALSE(pDrm->isPreemptionSupported());
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
delete pDrm;
|
|
|
|
}
|
|
|
|
|
2018-04-11 15:53:16 +02:00
|
|
|
TEST(DrmTest, GivenDrmWhenAskedForContextThatFailsThenFalseIsReturned) {
|
2020-09-11 14:18:23 +02:00
|
|
|
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
|
|
|
DrmMock *pDrm = new DrmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
2017-12-21 00:45:38 +01:00
|
|
|
pDrm->StoredRetVal = -1;
|
2021-02-10 15:13:50 +00:00
|
|
|
EXPECT_THROW(pDrm->createDrmContext(1, false), std::exception);
|
2017-12-21 00:45:38 +01:00
|
|
|
pDrm->StoredRetVal = 0;
|
|
|
|
delete pDrm;
|
|
|
|
}
|
2018-04-11 15:53:16 +02:00
|
|
|
|
2018-12-11 08:21:56 +01:00
|
|
|
TEST(DrmTest, givenDrmWhenOsContextIsCreatedThenCreateAndDestroyNewDrmOsContext) {
|
2020-09-11 14:18:23 +02:00
|
|
|
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
|
|
|
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
2021-03-31 13:06:23 +00:00
|
|
|
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
|
2018-12-11 08:21:56 +01:00
|
|
|
|
|
|
|
{
|
2021-03-08 18:50:32 +00:00
|
|
|
OsContextLinux osContext1(drmMock, 0u, 1, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::Regular}, PreemptionMode::Disabled, false);
|
2021-04-15 16:14:04 +00:00
|
|
|
osContext1.ensureContextInitialized();
|
2019-02-27 11:17:17 +01:00
|
|
|
|
2019-07-17 15:38:14 +02:00
|
|
|
EXPECT_EQ(1u, osContext1.getDrmContextIds().size());
|
2020-07-07 09:34:31 +02:00
|
|
|
EXPECT_EQ(drmMock.receivedCreateContextId, osContext1.getDrmContextIds()[0]);
|
2018-12-11 08:21:56 +01:00
|
|
|
EXPECT_EQ(0u, drmMock.receivedDestroyContextId);
|
|
|
|
|
|
|
|
{
|
2021-03-08 18:50:32 +00:00
|
|
|
OsContextLinux osContext2(drmMock, 0u, 1, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::Regular}, PreemptionMode::Disabled, false);
|
2021-04-15 16:14:04 +00:00
|
|
|
osContext2.ensureContextInitialized();
|
2019-07-17 15:38:14 +02:00
|
|
|
EXPECT_EQ(1u, osContext2.getDrmContextIds().size());
|
2020-07-07 09:34:31 +02:00
|
|
|
EXPECT_EQ(drmMock.receivedCreateContextId, osContext2.getDrmContextIds()[0]);
|
2018-12-11 08:21:56 +01:00
|
|
|
EXPECT_EQ(0u, drmMock.receivedDestroyContextId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-23 10:50:19 +02:00
|
|
|
EXPECT_EQ(2u, drmMock.receivedContextParamRequestCount);
|
|
|
|
}
|
|
|
|
|
2020-08-04 10:23:54 +02:00
|
|
|
TEST(DrmTest, whenCreatingDrmContextWithVirtualMemoryAddressSpaceThenProperVmIdIsSet) {
|
2020-09-11 14:18:23 +02:00
|
|
|
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
2021-03-31 13:06:23 +00:00
|
|
|
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
|
2020-09-11 14:18:23 +02:00
|
|
|
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
2020-07-23 10:50:19 +02:00
|
|
|
|
2020-08-04 10:23:54 +02:00
|
|
|
ASSERT_EQ(1u, drmMock.virtualMemoryIds.size());
|
|
|
|
|
2021-03-08 18:50:32 +00:00
|
|
|
OsContextLinux osContext(drmMock, 0u, 1, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::Regular}, PreemptionMode::Disabled, false);
|
2021-04-15 16:14:04 +00:00
|
|
|
osContext.ensureContextInitialized();
|
2020-07-23 10:50:19 +02:00
|
|
|
|
|
|
|
EXPECT_EQ(drmMock.receivedContextParamRequest.value, drmMock.getVirtualMemoryAddressSpace(0u));
|
2018-12-11 08:21:56 +01:00
|
|
|
}
|
|
|
|
|
2020-08-04 10:23:54 +02:00
|
|
|
TEST(DrmTest, whenCreatingDrmContextWithNoVirtualMemoryAddressSpaceThenProperContextIdIsSet) {
|
2020-09-11 14:18:23 +02:00
|
|
|
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
2021-03-31 13:06:23 +00:00
|
|
|
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
|
2020-09-11 14:18:23 +02:00
|
|
|
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
2020-08-04 10:23:54 +02:00
|
|
|
drmMock.destroyVirtualMemoryAddressSpace();
|
|
|
|
|
|
|
|
ASSERT_EQ(0u, drmMock.virtualMemoryIds.size());
|
|
|
|
|
2021-03-08 18:50:32 +00:00
|
|
|
OsContextLinux osContext(drmMock, 0u, 1, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::Regular}, PreemptionMode::Disabled, false);
|
2021-04-15 16:14:04 +00:00
|
|
|
osContext.ensureContextInitialized();
|
2020-08-04 10:23:54 +02:00
|
|
|
|
|
|
|
EXPECT_EQ(0u, drmMock.receivedCreateContextId);
|
|
|
|
EXPECT_EQ(0u, drmMock.receivedContextParamRequestCount);
|
|
|
|
}
|
|
|
|
|
2020-02-10 08:05:32 -08:00
|
|
|
TEST(DrmTest, givenDrmAndNegativeCheckNonPersistentContextsSupportWhenOsContextIsCreatedThenReceivedContextParamRequestCountReturnsCorrectValue) {
|
2020-09-11 14:18:23 +02:00
|
|
|
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
2021-03-31 13:06:23 +00:00
|
|
|
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
|
2020-09-11 14:18:23 +02:00
|
|
|
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
2019-12-18 19:38:22 +01:00
|
|
|
auto expectedCount = 0u;
|
|
|
|
|
|
|
|
{
|
2020-02-10 08:05:32 -08:00
|
|
|
drmMock.StoredRetValForPersistant = -1;
|
|
|
|
drmMock.checkNonPersistentContextsSupport();
|
2020-07-23 10:50:19 +02:00
|
|
|
expectedCount += 2;
|
2021-03-08 18:50:32 +00:00
|
|
|
OsContextLinux osContext(drmMock, 0u, 1, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::Regular}, PreemptionMode::Disabled, false);
|
2021-04-15 16:14:04 +00:00
|
|
|
osContext.ensureContextInitialized();
|
2019-12-18 19:38:22 +01:00
|
|
|
EXPECT_EQ(expectedCount, drmMock.receivedContextParamRequestCount);
|
|
|
|
}
|
|
|
|
{
|
2020-02-10 08:05:32 -08:00
|
|
|
drmMock.StoredRetValForPersistant = 0;
|
|
|
|
drmMock.checkNonPersistentContextsSupport();
|
2019-12-18 19:38:22 +01:00
|
|
|
++expectedCount;
|
2021-03-08 18:50:32 +00:00
|
|
|
OsContextLinux osContext(drmMock, 0u, 1, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::Regular}, PreemptionMode::Disabled, false);
|
2021-04-15 16:14:04 +00:00
|
|
|
osContext.ensureContextInitialized();
|
2020-07-23 10:50:19 +02:00
|
|
|
expectedCount += 2;
|
2019-12-18 19:38:22 +01:00
|
|
|
EXPECT_EQ(expectedCount, drmMock.receivedContextParamRequestCount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-11 08:21:56 +01:00
|
|
|
TEST(DrmTest, givenDrmPreemptionEnabledAndLowPriorityEngineWhenCreatingOsContextThenCallSetContextPriorityIoctl) {
|
2020-09-11 14:18:23 +02:00
|
|
|
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
2021-03-31 13:06:23 +00:00
|
|
|
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
|
2020-09-11 14:18:23 +02:00
|
|
|
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
2018-12-11 08:21:56 +01:00
|
|
|
drmMock.preemptionSupported = false;
|
|
|
|
|
2021-03-08 18:50:32 +00:00
|
|
|
OsContextLinux osContext1(drmMock, 0u, 1, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::Regular}, PreemptionMode::Disabled, false);
|
2021-04-15 16:14:04 +00:00
|
|
|
osContext1.ensureContextInitialized();
|
2021-03-08 18:50:32 +00:00
|
|
|
OsContextLinux osContext2(drmMock, 0u, 1, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::LowPriority}, PreemptionMode::Disabled, false);
|
2021-04-15 16:14:04 +00:00
|
|
|
osContext2.ensureContextInitialized();
|
2019-02-27 11:17:17 +01:00
|
|
|
|
2020-07-23 10:50:19 +02:00
|
|
|
EXPECT_EQ(2u, drmMock.receivedContextParamRequestCount);
|
2018-12-11 08:21:56 +01:00
|
|
|
|
|
|
|
drmMock.preemptionSupported = true;
|
|
|
|
|
2021-03-08 18:50:32 +00:00
|
|
|
OsContextLinux osContext3(drmMock, 0u, 1, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::Regular}, PreemptionMode::Disabled, false);
|
2021-04-15 16:14:04 +00:00
|
|
|
osContext3.ensureContextInitialized();
|
2020-07-23 10:50:19 +02:00
|
|
|
EXPECT_EQ(3u, drmMock.receivedContextParamRequestCount);
|
2018-12-11 08:21:56 +01:00
|
|
|
|
2021-03-08 18:50:32 +00:00
|
|
|
OsContextLinux osContext4(drmMock, 0u, 1, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::LowPriority}, PreemptionMode::Disabled, false);
|
2021-04-15 16:14:04 +00:00
|
|
|
osContext4.ensureContextInitialized();
|
2020-07-23 10:50:19 +02:00
|
|
|
EXPECT_EQ(5u, drmMock.receivedContextParamRequestCount);
|
2020-07-07 09:34:31 +02:00
|
|
|
EXPECT_EQ(drmMock.receivedCreateContextId, drmMock.receivedContextParamRequest.ctx_id);
|
2018-12-11 08:21:56 +01:00
|
|
|
EXPECT_EQ(static_cast<uint64_t>(I915_CONTEXT_PARAM_PRIORITY), drmMock.receivedContextParamRequest.param);
|
|
|
|
EXPECT_EQ(static_cast<uint64_t>(-1023), drmMock.receivedContextParamRequest.value);
|
|
|
|
EXPECT_EQ(0u, drmMock.receivedContextParamRequest.size);
|
2018-04-11 15:53:16 +02:00
|
|
|
}
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2021-03-12 10:46:18 +00:00
|
|
|
TEST(DrmTest, givenDirectSubmissionEnabledOnBlitterWhenCreateBcsEngineThenLowPriorityIsSet) {
|
|
|
|
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
2021-03-31 13:06:23 +00:00
|
|
|
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
|
2021-03-12 10:46:18 +00:00
|
|
|
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
|
|
|
|
2021-03-08 18:50:32 +00:00
|
|
|
OsContextLinux osContext(drmMock, 0u, 1, EngineTypeUsage{aub_stream::ENGINE_BCS, EngineUsage::Regular}, PreemptionMode::Disabled, false);
|
2021-04-15 16:14:04 +00:00
|
|
|
osContext.ensureContextInitialized();
|
2021-03-12 10:46:18 +00:00
|
|
|
EXPECT_EQ(1u, drmMock.receivedContextParamRequestCount);
|
|
|
|
|
|
|
|
DebugManagerStateRestore restorer;
|
|
|
|
DebugManager.flags.EnableDirectSubmission.set(1);
|
|
|
|
DebugManager.flags.DirectSubmissionOverrideBlitterSupport.set(1);
|
|
|
|
|
2021-03-08 18:50:32 +00:00
|
|
|
OsContextLinux osContext2(drmMock, 0u, 1, EngineTypeUsage{aub_stream::ENGINE_BCS, EngineUsage::Regular}, PreemptionMode::Disabled, false);
|
2021-04-15 16:14:04 +00:00
|
|
|
osContext2.ensureContextInitialized();
|
2021-03-12 10:46:18 +00:00
|
|
|
EXPECT_EQ(3u, drmMock.receivedContextParamRequestCount);
|
|
|
|
EXPECT_EQ(drmMock.receivedCreateContextId, drmMock.receivedContextParamRequest.ctx_id);
|
|
|
|
EXPECT_EQ(static_cast<uint64_t>(I915_CONTEXT_PARAM_PRIORITY), drmMock.receivedContextParamRequest.param);
|
|
|
|
EXPECT_EQ(static_cast<uint64_t>(-1023), drmMock.receivedContextParamRequest.value);
|
|
|
|
EXPECT_EQ(0u, drmMock.receivedContextParamRequest.size);
|
|
|
|
|
2021-03-08 18:50:32 +00:00
|
|
|
OsContextLinux osContext3(drmMock, 0u, 1, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::Regular}, PreemptionMode::Disabled, false);
|
2021-04-15 16:14:04 +00:00
|
|
|
osContext3.ensureContextInitialized();
|
2021-03-12 10:46:18 +00:00
|
|
|
EXPECT_EQ(4u, drmMock.receivedContextParamRequestCount);
|
|
|
|
}
|
|
|
|
|
2021-04-01 14:12:51 +00:00
|
|
|
TEST(DrmTest, givenDirectSubmissionEnabledOnBlitterAndDirectSubmissionLowPriorityBlitterSetZeroWhenCreateBcsEngineThenLowPriorityIsNotSet) {
|
|
|
|
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
2021-03-31 13:06:23 +00:00
|
|
|
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
|
2021-04-01 14:12:51 +00:00
|
|
|
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
|
|
|
|
|
|
|
OsContextLinux osContext(drmMock, 0u, 1, EngineTypeUsage{aub_stream::ENGINE_BCS, EngineUsage::Regular}, PreemptionMode::Disabled, false);
|
2021-04-15 16:14:04 +00:00
|
|
|
osContext.ensureContextInitialized();
|
2021-04-01 14:12:51 +00:00
|
|
|
EXPECT_EQ(1u, drmMock.receivedContextParamRequestCount);
|
|
|
|
|
|
|
|
DebugManagerStateRestore restorer;
|
|
|
|
DebugManager.flags.EnableDirectSubmission.set(1);
|
|
|
|
DebugManager.flags.DirectSubmissionOverrideBlitterSupport.set(1);
|
|
|
|
DebugManager.flags.DirectSubmissionLowPriorityBlitter.set(0);
|
|
|
|
|
|
|
|
OsContextLinux osContext2(drmMock, 0u, 1, EngineTypeUsage{aub_stream::ENGINE_BCS, EngineUsage::Regular}, PreemptionMode::Disabled, false);
|
2021-04-15 16:14:04 +00:00
|
|
|
osContext2.ensureContextInitialized();
|
2021-04-01 14:12:51 +00:00
|
|
|
EXPECT_EQ(2u, drmMock.receivedContextParamRequestCount);
|
|
|
|
}
|
|
|
|
|
2020-12-16 09:38:09 +01:00
|
|
|
TEST(DrmTest, WhenGettingExecSoftPinThenCorrectValueIsReturned) {
|
2020-09-11 14:18:23 +02:00
|
|
|
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
|
|
|
DrmMock *pDrm = new DrmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
2017-12-21 00:45:38 +01:00
|
|
|
int execSoftPin = 0;
|
|
|
|
|
|
|
|
int ret = pDrm->getExecSoftPin(execSoftPin);
|
|
|
|
EXPECT_EQ(0, ret);
|
|
|
|
EXPECT_EQ(0, execSoftPin);
|
|
|
|
|
|
|
|
pDrm->StoredExecSoftPin = 1;
|
|
|
|
ret = pDrm->getExecSoftPin(execSoftPin);
|
|
|
|
EXPECT_EQ(0, ret);
|
|
|
|
EXPECT_EQ(1, execSoftPin);
|
|
|
|
|
|
|
|
delete pDrm;
|
|
|
|
}
|
|
|
|
|
2020-12-16 09:38:09 +01:00
|
|
|
TEST(DrmTest, WhenEnablingTurboBoostThenSucceeds) {
|
2020-09-11 14:18:23 +02:00
|
|
|
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
|
|
|
DrmMock *pDrm = new DrmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
int ret = pDrm->enableTurboBoost();
|
|
|
|
EXPECT_EQ(0, ret);
|
|
|
|
|
|
|
|
delete pDrm;
|
|
|
|
}
|
|
|
|
|
2020-12-16 09:38:09 +01:00
|
|
|
TEST(DrmTest, WhenGettingEnabledPooledEuThenCorrectValueIsReturned) {
|
2020-09-11 14:18:23 +02:00
|
|
|
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
|
|
|
DrmMock *pDrm = new DrmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
int enabled = 0;
|
|
|
|
int ret = 0;
|
|
|
|
pDrm->StoredHasPooledEU = -1;
|
|
|
|
#if defined(I915_PARAM_HAS_POOLED_EU)
|
|
|
|
ret = pDrm->getEnabledPooledEu(enabled);
|
|
|
|
EXPECT_EQ(0, ret);
|
|
|
|
EXPECT_EQ(-1, enabled);
|
|
|
|
|
|
|
|
pDrm->StoredHasPooledEU = 0;
|
|
|
|
ret = pDrm->getEnabledPooledEu(enabled);
|
|
|
|
EXPECT_EQ(0, ret);
|
|
|
|
EXPECT_EQ(0, enabled);
|
|
|
|
|
|
|
|
pDrm->StoredHasPooledEU = 1;
|
|
|
|
ret = pDrm->getEnabledPooledEu(enabled);
|
|
|
|
EXPECT_EQ(0, ret);
|
|
|
|
EXPECT_EQ(1, enabled);
|
|
|
|
|
|
|
|
pDrm->StoredRetValForPooledEU = -1;
|
|
|
|
ret = pDrm->getEnabledPooledEu(enabled);
|
|
|
|
EXPECT_EQ(-1, ret);
|
|
|
|
EXPECT_EQ(1, enabled);
|
|
|
|
#else
|
|
|
|
ret = pDrm->getEnabledPooledEu(enabled);
|
|
|
|
EXPECT_EQ(0, ret);
|
|
|
|
EXPECT_EQ(0, enabled);
|
|
|
|
#endif
|
|
|
|
delete pDrm;
|
|
|
|
}
|
|
|
|
|
2020-12-16 09:38:09 +01:00
|
|
|
TEST(DrmTest, WhenGettingMinEuInPoolThenCorrectValueIsReturned) {
|
2020-09-11 14:18:23 +02:00
|
|
|
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
|
|
|
DrmMock *pDrm = new DrmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
pDrm->StoredMinEUinPool = -1;
|
|
|
|
int minEUinPool = 0;
|
|
|
|
int ret = 0;
|
|
|
|
#if defined(I915_PARAM_MIN_EU_IN_POOL)
|
|
|
|
ret = pDrm->getMinEuInPool(minEUinPool);
|
|
|
|
EXPECT_EQ(0, ret);
|
|
|
|
EXPECT_EQ(-1, minEUinPool);
|
|
|
|
|
|
|
|
pDrm->StoredMinEUinPool = 0;
|
|
|
|
ret = pDrm->getMinEuInPool(minEUinPool);
|
|
|
|
EXPECT_EQ(0, ret);
|
|
|
|
EXPECT_EQ(0, minEUinPool);
|
|
|
|
|
|
|
|
pDrm->StoredMinEUinPool = 1;
|
|
|
|
ret = pDrm->getMinEuInPool(minEUinPool);
|
|
|
|
EXPECT_EQ(0, ret);
|
|
|
|
EXPECT_EQ(1, minEUinPool);
|
|
|
|
|
|
|
|
pDrm->StoredRetValForMinEUinPool = -1;
|
|
|
|
ret = pDrm->getMinEuInPool(minEUinPool);
|
|
|
|
EXPECT_EQ(-1, ret);
|
|
|
|
EXPECT_EQ(1, minEUinPool);
|
|
|
|
#else
|
|
|
|
ret = pDrm->getMinEuInPool(minEUinPool);
|
|
|
|
EXPECT_EQ(0, ret);
|
|
|
|
EXPECT_EQ(0, minEUinPool);
|
|
|
|
#endif
|
|
|
|
delete pDrm;
|
2018-02-28 12:09:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(DrmTest, givenDrmWhenGetErrnoIsCalledThenErrnoValueIsReturned) {
|
2020-09-11 14:18:23 +02:00
|
|
|
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
|
|
|
DrmMock *pDrm = new DrmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
2018-02-28 12:09:48 +01:00
|
|
|
EXPECT_NE(nullptr, pDrm);
|
|
|
|
|
|
|
|
auto errnoFromDrm = pDrm->getErrno();
|
|
|
|
EXPECT_EQ(errno, errnoFromDrm);
|
|
|
|
delete pDrm;
|
|
|
|
}
|
2019-08-21 03:50:47 -07:00
|
|
|
TEST(DrmTest, givenPlatformWhereGetSseuRetFailureWhenCallSetQueueSliceCountThenSliceCountIsNotSet) {
|
|
|
|
uint64_t newSliceCount = 1;
|
2020-09-11 14:18:23 +02:00
|
|
|
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
|
|
|
auto drm = std::make_unique<DrmMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
2019-08-21 03:50:47 -07:00
|
|
|
drm->StoredRetValForGetSSEU = -1;
|
|
|
|
drm->checkQueueSliceSupport();
|
|
|
|
|
|
|
|
EXPECT_FALSE(drm->sliceCountChangeSupported);
|
|
|
|
EXPECT_FALSE(drm->setQueueSliceCount(newSliceCount));
|
|
|
|
EXPECT_NE(drm->getSliceMask(newSliceCount), drm->storedParamSseu);
|
|
|
|
}
|
|
|
|
|
2020-02-10 08:05:32 -08:00
|
|
|
TEST(DrmTest, whenCheckNonPeristentSupportIsCalledThenAreNonPersistentContextsSupportedReturnsCorrectValues) {
|
2020-09-11 14:18:23 +02:00
|
|
|
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
|
|
|
auto drm = std::make_unique<DrmMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
2020-02-10 08:05:32 -08:00
|
|
|
drm->StoredRetValForPersistant = -1;
|
|
|
|
drm->checkNonPersistentContextsSupport();
|
|
|
|
EXPECT_FALSE(drm->areNonPersistentContextsSupported());
|
|
|
|
drm->StoredRetValForPersistant = 0;
|
|
|
|
drm->checkNonPersistentContextsSupport();
|
|
|
|
EXPECT_TRUE(drm->areNonPersistentContextsSupported());
|
2019-12-18 19:38:22 +01:00
|
|
|
}
|
|
|
|
|
2019-08-21 03:50:47 -07:00
|
|
|
TEST(DrmTest, givenPlatformWhereSetSseuRetFailureWhenCallSetQueueSliceCountThenReturnFalse) {
|
|
|
|
uint64_t newSliceCount = 1;
|
2020-09-11 14:18:23 +02:00
|
|
|
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
|
|
|
auto drm = std::make_unique<DrmMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
2019-08-21 03:50:47 -07:00
|
|
|
drm->StoredRetValForSetSSEU = -1;
|
|
|
|
drm->StoredRetValForGetSSEU = 0;
|
|
|
|
drm->checkQueueSliceSupport();
|
|
|
|
|
|
|
|
EXPECT_TRUE(drm->sliceCountChangeSupported);
|
|
|
|
EXPECT_FALSE(drm->setQueueSliceCount(newSliceCount));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(DrmTest, givenPlatformWithSupportToChangeSliceCountWhenCallSetQueueSliceCountThenReturnTrue) {
|
|
|
|
uint64_t newSliceCount = 1;
|
2020-09-11 14:18:23 +02:00
|
|
|
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
|
|
|
auto drm = std::make_unique<DrmMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
2019-08-21 03:50:47 -07:00
|
|
|
drm->StoredRetValForSetSSEU = 0;
|
|
|
|
drm->StoredRetValForSetSSEU = 0;
|
|
|
|
drm->checkQueueSliceSupport();
|
|
|
|
|
|
|
|
EXPECT_TRUE(drm->sliceCountChangeSupported);
|
|
|
|
EXPECT_TRUE(drm->setQueueSliceCount(newSliceCount));
|
|
|
|
drm_i915_gem_context_param_sseu sseu = {};
|
|
|
|
EXPECT_EQ(0, drm->getQueueSliceCount(&sseu));
|
|
|
|
EXPECT_EQ(drm->getSliceMask(newSliceCount), sseu.slice_mask);
|
|
|
|
}
|
2020-09-08 17:33:33 +02:00
|
|
|
|
2020-02-05 17:43:02 +01:00
|
|
|
namespace NEO {
|
|
|
|
namespace SysCalls {
|
|
|
|
extern uint32_t closeFuncCalled;
|
|
|
|
extern int closeFuncArgPassed;
|
2020-07-07 09:34:31 +02:00
|
|
|
extern uint32_t vmId;
|
2020-02-05 17:43:02 +01:00
|
|
|
} // namespace SysCalls
|
|
|
|
} // namespace NEO
|
|
|
|
|
|
|
|
TEST(HwDeviceId, whenHwDeviceIdIsDestroyedThenFileDescriptorIsClosed) {
|
|
|
|
SysCalls::closeFuncCalled = 0;
|
|
|
|
int fileDescriptor = 0x1234;
|
|
|
|
{
|
2020-04-08 18:14:19 +02:00
|
|
|
HwDeviceId hwDeviceId(fileDescriptor, "");
|
2020-02-05 17:43:02 +01:00
|
|
|
}
|
|
|
|
EXPECT_EQ(1u, SysCalls::closeFuncCalled);
|
|
|
|
EXPECT_EQ(fileDescriptor, SysCalls::closeFuncArgPassed);
|
|
|
|
}
|
2020-07-07 09:34:31 +02:00
|
|
|
|
|
|
|
TEST(DrmTest, givenDrmWhenCreatingOsContextThenCreateDrmContextWithVmId) {
|
2020-09-11 14:18:23 +02:00
|
|
|
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
2021-03-31 13:06:23 +00:00
|
|
|
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
|
2020-09-11 14:18:23 +02:00
|
|
|
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
2021-03-08 18:50:32 +00:00
|
|
|
OsContextLinux osContext(drmMock, 0u, 1, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::Regular}, PreemptionMode::Disabled, false);
|
2021-04-15 16:14:04 +00:00
|
|
|
osContext.ensureContextInitialized();
|
2020-07-07 09:34:31 +02:00
|
|
|
|
|
|
|
EXPECT_EQ(SysCalls::vmId, drmMock.getVirtualMemoryAddressSpace(0));
|
|
|
|
|
|
|
|
auto &contextIds = osContext.getDrmContextIds();
|
|
|
|
EXPECT_EQ(1u, contextIds.size());
|
|
|
|
}
|
2020-07-15 08:07:53 +02:00
|
|
|
|
|
|
|
TEST(DrmTest, givenDrmWithPerContextVMRequiredWhenCreatingOsContextsThenImplicitVmIdPerContextIsUsed) {
|
|
|
|
auto &rootEnv = *platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0];
|
2020-11-23 14:31:20 +00:00
|
|
|
rootEnv.executionEnvironment.setDebuggingEnabled();
|
2020-07-15 08:07:53 +02:00
|
|
|
|
2020-09-11 14:18:23 +02:00
|
|
|
DrmMock drmMock(rootEnv);
|
2020-07-15 08:07:53 +02:00
|
|
|
EXPECT_TRUE(drmMock.requirePerContextVM);
|
|
|
|
|
2021-03-08 18:50:32 +00:00
|
|
|
OsContextLinux osContext1(drmMock, 0u, 1, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::Regular}, PreemptionMode::Disabled, false);
|
2021-04-15 16:14:04 +00:00
|
|
|
osContext1.ensureContextInitialized();
|
2020-07-15 08:07:53 +02:00
|
|
|
EXPECT_EQ(0u, drmMock.receivedCreateContextId);
|
|
|
|
|
2021-03-08 18:50:32 +00:00
|
|
|
OsContextLinux osContext2(drmMock, 5u, 1, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::Regular}, PreemptionMode::Disabled, false);
|
2021-04-15 16:14:04 +00:00
|
|
|
osContext2.ensureContextInitialized();
|
2020-07-15 08:07:53 +02:00
|
|
|
EXPECT_EQ(0u, drmMock.receivedCreateContextId);
|
|
|
|
}
|
2020-08-17 12:07:39 +02:00
|
|
|
|
2021-04-29 16:02:10 +00:00
|
|
|
TEST(DrmTest, givenPerContextVMRequiredWhenCreatingOsContextsThenImplicitVmIdPerContextIsQueriedAndStored) {
|
2020-08-17 12:07:39 +02:00
|
|
|
auto &rootEnv = *platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0];
|
2020-11-23 14:31:20 +00:00
|
|
|
rootEnv.executionEnvironment.setDebuggingEnabled();
|
2020-08-17 12:07:39 +02:00
|
|
|
|
2020-09-11 14:18:23 +02:00
|
|
|
DrmMock drmMock(rootEnv);
|
2020-08-17 12:07:39 +02:00
|
|
|
EXPECT_TRUE(drmMock.requirePerContextVM);
|
|
|
|
|
|
|
|
drmMock.StoredRetValForVmId = 20;
|
|
|
|
|
2021-03-08 18:50:32 +00:00
|
|
|
OsContextLinux osContext(drmMock, 0u, 1, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::Regular}, PreemptionMode::Disabled, false);
|
2021-04-15 16:14:04 +00:00
|
|
|
osContext.ensureContextInitialized();
|
2020-08-17 12:07:39 +02:00
|
|
|
EXPECT_EQ(0u, drmMock.receivedCreateContextId);
|
|
|
|
EXPECT_EQ(1u, drmMock.receivedContextParamRequestCount);
|
|
|
|
|
|
|
|
auto &drmVmIds = osContext.getDrmVmIds();
|
2021-04-29 16:02:10 +00:00
|
|
|
EXPECT_EQ(32u, drmVmIds.size());
|
2020-08-17 12:07:39 +02:00
|
|
|
|
|
|
|
EXPECT_EQ(20u, drmVmIds[0]);
|
|
|
|
}
|
|
|
|
|
2021-04-29 16:02:10 +00:00
|
|
|
TEST(DrmTest, givenPerContextVMRequiredWhenCreatingOsContextForSubDeviceThenImplicitVmIdPerContextIsQueriedAndStoredAtSubDeviceIndex) {
|
|
|
|
auto &rootEnv = *platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0];
|
|
|
|
rootEnv.executionEnvironment.setDebuggingEnabled();
|
|
|
|
|
|
|
|
DrmMock drmMock(rootEnv);
|
|
|
|
EXPECT_TRUE(drmMock.requirePerContextVM);
|
|
|
|
|
|
|
|
drmMock.StoredRetValForVmId = 20;
|
|
|
|
DeviceBitfield deviceBitfield(1 << 3);
|
|
|
|
|
|
|
|
OsContextLinux osContext(drmMock, 0u, deviceBitfield, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::Regular}, PreemptionMode::Disabled, false);
|
|
|
|
osContext.ensureContextInitialized();
|
|
|
|
EXPECT_EQ(0u, drmMock.receivedCreateContextId);
|
|
|
|
EXPECT_EQ(1u, drmMock.receivedContextParamRequestCount);
|
|
|
|
|
|
|
|
auto &drmVmIds = osContext.getDrmVmIds();
|
|
|
|
EXPECT_EQ(32u, drmVmIds.size());
|
|
|
|
|
|
|
|
EXPECT_EQ(20u, drmVmIds[3]);
|
|
|
|
|
|
|
|
EXPECT_EQ(0u, drmVmIds[0]);
|
|
|
|
EXPECT_EQ(0u, drmVmIds[2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(DrmTest, givenPerContextVMRequiredWhenCreatingOsContextsForRootDeviceThenImplicitVmIdsPerContextAreQueriedAndStoredAtSubDeviceIndices) {
|
|
|
|
auto &rootEnv = *platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0];
|
|
|
|
rootEnv.executionEnvironment.setDebuggingEnabled();
|
|
|
|
|
|
|
|
DrmMock drmMock(rootEnv);
|
|
|
|
EXPECT_TRUE(drmMock.requirePerContextVM);
|
|
|
|
|
|
|
|
drmMock.StoredRetValForVmId = 20;
|
|
|
|
DeviceBitfield deviceBitfield(1 | 1 << 1);
|
|
|
|
|
|
|
|
OsContextLinux osContext(drmMock, 0u, deviceBitfield, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::Regular}, PreemptionMode::Disabled, false);
|
|
|
|
osContext.ensureContextInitialized();
|
|
|
|
EXPECT_EQ(0u, drmMock.receivedCreateContextId);
|
|
|
|
EXPECT_EQ(2u, drmMock.receivedContextParamRequestCount);
|
|
|
|
|
|
|
|
auto &drmVmIds = osContext.getDrmVmIds();
|
|
|
|
EXPECT_EQ(32u, drmVmIds.size());
|
|
|
|
|
|
|
|
EXPECT_EQ(20u, drmVmIds[0]);
|
|
|
|
EXPECT_EQ(20u, drmVmIds[1]);
|
|
|
|
|
|
|
|
EXPECT_EQ(0u, drmVmIds[2]);
|
|
|
|
EXPECT_EQ(0u, drmVmIds[31]);
|
|
|
|
}
|
|
|
|
|
2020-08-17 12:07:39 +02:00
|
|
|
TEST(DrmTest, givenNoPerContextVmsDrmWhenCreatingOsContextsThenVmIdIsNotQueriedAndStored) {
|
2020-09-11 14:18:23 +02:00
|
|
|
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
2021-03-31 13:06:23 +00:00
|
|
|
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
|
2020-09-11 14:18:23 +02:00
|
|
|
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
2020-08-17 12:07:39 +02:00
|
|
|
EXPECT_FALSE(drmMock.requirePerContextVM);
|
|
|
|
|
|
|
|
drmMock.StoredRetValForVmId = 1;
|
|
|
|
|
2021-03-08 18:50:32 +00:00
|
|
|
OsContextLinux osContext(drmMock, 0u, 1, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::Regular}, PreemptionMode::Disabled, false);
|
2021-04-15 16:14:04 +00:00
|
|
|
osContext.ensureContextInitialized();
|
2020-08-17 12:07:39 +02:00
|
|
|
EXPECT_EQ(0u, drmMock.receivedCreateContextId);
|
|
|
|
EXPECT_EQ(1u, drmMock.receivedContextParamRequestCount);
|
|
|
|
|
|
|
|
auto &drmVmIds = osContext.getDrmVmIds();
|
|
|
|
EXPECT_EQ(0u, drmVmIds.size());
|
|
|
|
}
|
2021-01-25 20:43:48 +00:00
|
|
|
|
|
|
|
TEST(DrmTest, givenProgramDebuggingAndContextDebugAvailableWhenCreatingContextThenSetContextDebugFlagIsCalled) {
|
|
|
|
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>();
|
|
|
|
|
|
|
|
DrmMockNonFailing drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
|
|
|
drmMock.contextDebugSupported = true;
|
|
|
|
|
2021-03-08 18:50:32 +00:00
|
|
|
OsContextLinux osContext(drmMock, 5u, 1, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::Regular}, PreemptionMode::Disabled, false);
|
2021-04-15 16:14:04 +00:00
|
|
|
osContext.ensureContextInitialized();
|
2021-01-25 20:43:48 +00:00
|
|
|
|
|
|
|
// drmMock returns ctxId == 0
|
|
|
|
EXPECT_EQ(0u, drmMock.passedContextDebugId);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(DrmTest, givenProgramDebuggingAndContextDebugAvailableWhenCreatingContextForInternalEngineThenSetContextDebugFlagIsNotCalled) {
|
|
|
|
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>();
|
|
|
|
|
|
|
|
DrmMockNonFailing drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
|
|
|
drmMock.contextDebugSupported = true;
|
|
|
|
|
2021-03-08 18:50:32 +00:00
|
|
|
OsContextLinux osContext(drmMock, 5u, 1, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::Internal}, PreemptionMode::Disabled, false);
|
2021-04-15 16:14:04 +00:00
|
|
|
osContext.ensureContextInitialized();
|
2021-01-25 20:43:48 +00:00
|
|
|
|
|
|
|
EXPECT_EQ(static_cast<uint32_t>(-1), drmMock.passedContextDebugId);
|
|
|
|
}
|
2021-04-27 14:45:13 +00:00
|
|
|
|
|
|
|
TEST(DrmQueryTest, GivenDrmWhenSetupHardwareInfoCalledThenCorrectMaxValuesInGtSystemInfoAreSet) {
|
|
|
|
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
|
|
|
|
|
|
|
*executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo() = *NEO::defaultHwInfo.get();
|
|
|
|
auto hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo();
|
|
|
|
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
|
|
|
|
|
|
|
drm.failRetTopology = true;
|
|
|
|
|
|
|
|
drm.StoredEUVal = 48;
|
|
|
|
drm.StoredSSVal = 6;
|
|
|
|
hwInfo->gtSystemInfo.SliceCount = 2;
|
|
|
|
|
|
|
|
auto setupHardwareInfo = [](HardwareInfo *, bool) {};
|
|
|
|
DeviceDescriptor device = {0, hwInfo, setupHardwareInfo, GTTYPE_UNDEFINED};
|
|
|
|
|
|
|
|
drm.setupHardwareInfo(&device, false);
|
|
|
|
|
|
|
|
EXPECT_EQ(hwInfo->gtSystemInfo.SliceCount, hwInfo->gtSystemInfo.MaxSlicesSupported);
|
|
|
|
EXPECT_EQ(6u, hwInfo->gtSystemInfo.MaxSubSlicesSupported);
|
|
|
|
EXPECT_EQ(8u, hwInfo->gtSystemInfo.MaxEuPerSubSlice);
|
|
|
|
}
|