Pass Drm to ioctl helper ctor

Related-To: NEO-6999
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski 2022-06-29 12:16:35 +00:00 committed by Compute-Runtime-Automation
parent 115761b4a5
commit c9e2b4bc32
15 changed files with 97 additions and 82 deletions

View File

@ -28,7 +28,8 @@ namespace L0 {
namespace ult {
class IoctlHelperPrelim20Mock : public NEO::IoctlHelperPrelim20 {
public:
using NEO::IoctlHelperPrelim20::IoctlHelperPrelim20;
bool getEuStallProperties(std::array<uint64_t, 12u> &properties, uint64_t dssBufferSize, uint64_t samplingRate,
uint64_t pollPeriod, uint64_t engineInstance, uint64_t notifyNReports) override {
return false;
@ -43,7 +44,7 @@ class DrmPrelimMock : public DrmMock {
&inputHwInfo->workaroundTable, &inputHwInfo->gtSystemInfo, inputHwInfo->capabilityTable);
customHwInfo->gtSystemInfo.MaxDualSubSlicesSupported = 64;
rootDeviceEnvironment.setHwInfo(customHwInfo.get());
this->ioctlHelper = std::make_unique<IoctlHelperPrelim20>();
this->ioctlHelper = std::make_unique<IoctlHelperPrelim20>(*this);
if (invokeQueryEngineInfo) {
queryEngineInfo(); // NOLINT(clang-analyzer-optin.cplusplus.VirtualCall)
}
@ -101,7 +102,7 @@ class DrmPrelimMock : public DrmMock {
void setIoctlHelperPrelim20Mock() {
backUpIoctlHelper = std::move(ioctlHelper);
ioctlHelper = static_cast<std::unique_ptr<NEO::IoctlHelper>>(std::make_unique<IoctlHelperPrelim20Mock>());
ioctlHelper = static_cast<std::unique_ptr<NEO::IoctlHelper>>(std::make_unique<IoctlHelperPrelim20Mock>(*this));
}
void restoreIoctlHelperPrelim20() {

View File

@ -989,7 +989,7 @@ void Drm::setupIoctlHelper(const PRODUCT_FAMILY productFamily) {
std::string prelimVersion = "";
getPrelimVersion(prelimVersion);
auto drmVersion = Drm::getDrmVersion(getFileDescriptor());
this->ioctlHelper.reset(IoctlHelper::get(productFamily, prelimVersion, drmVersion));
this->ioctlHelper = IoctlHelper::get(productFamily, prelimVersion, drmVersion, *this);
}
}

View File

@ -25,8 +25,6 @@ class IoctlHelper;
enum class CacheRegion : uint16_t;
struct HardwareInfo;
extern IoctlHelper *ioctlHelperFactory[IGFX_MAX_PRODUCT];
struct MemoryRegion {
MemoryClassInstance region;
uint64_t probedSize;
@ -65,10 +63,10 @@ using VmBindExtUserFenceT = uint8_t[56];
class IoctlHelper {
public:
IoctlHelper(Drm &drmArg) : drm(drmArg){};
virtual ~IoctlHelper() {}
static IoctlHelper *get(const PRODUCT_FAMILY productFamily, const std::string &prelimVersion, const std::string &drmVersion);
static std::unique_ptr<IoctlHelper> get(const PRODUCT_FAMILY productFamily, const std::string &prelimVersion, const std::string &drmVersion, Drm &drm);
uint32_t ioctl(Drm *drm, DrmIoctl request, void *arg);
virtual IoctlHelper *clone() = 0;
virtual bool isVmBindAvailable(Drm *drm) = 0;
virtual uint32_t createGemExt(Drm *drm, const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, std::optional<uint32_t> vmId) = 0;
@ -124,11 +122,14 @@ class IoctlHelper {
void logExecBuffer(const ExecBuffer &execBuffer, std::stringstream &logger);
int getDrmParamValueBase(DrmParam drmParam) const;
unsigned int getIoctlRequestValueBase(DrmIoctl ioctlRequest) const;
protected:
Drm &drm;
};
class IoctlHelperUpstream : public IoctlHelper {
public:
IoctlHelper *clone() override;
using IoctlHelper::IoctlHelper;
bool isVmBindAvailable(Drm *drm) override;
uint32_t createGemExt(Drm *drm, const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, std::optional<uint32_t> vmId) override;
@ -176,11 +177,10 @@ class IoctlHelperUpstream : public IoctlHelper {
template <PRODUCT_FAMILY gfxProduct>
class IoctlHelperImpl : public IoctlHelperUpstream {
public:
static IoctlHelper *get() {
static IoctlHelperImpl<gfxProduct> instance;
return &instance;
using IoctlHelperUpstream::IoctlHelperUpstream;
static std::unique_ptr<IoctlHelper> get(Drm &drm) {
return std::make_unique<IoctlHelperImpl<gfxProduct>>(drm);
}
IoctlHelper *clone() override;
uint32_t createGemExt(Drm *drm, const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, std::optional<uint32_t> vmId) override;
std::vector<MemoryRegion> translateToMemoryRegions(const std::vector<uint8_t> &regionInfo) override;
@ -189,7 +189,7 @@ class IoctlHelperImpl : public IoctlHelperUpstream {
class IoctlHelperPrelim20 : public IoctlHelper {
public:
IoctlHelper *clone() override;
using IoctlHelper::IoctlHelper;
bool isVmBindAvailable(Drm *drm) override;
uint32_t createGemExt(Drm *drm, const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, std::optional<uint32_t> vmId) override;

View File

@ -10,25 +10,22 @@
#include "shared/source/os_interface/linux/drm_neo.h"
#include "shared/source/os_interface/linux/ioctl_helper.h"
#include <functional>
#include <string>
namespace NEO {
IoctlHelper *ioctlHelperFactory[IGFX_MAX_PRODUCT] = {};
std::optional<std::function<std::unique_ptr<IoctlHelper>(Drm &drm)>> ioctlHelperFactory[IGFX_MAX_PRODUCT] = {};
std::map<std::string, std::shared_ptr<IoctlHelper>> ioctlHelperImpls{
{"", std::make_shared<IoctlHelperUpstream>()},
{"2.0", std::make_shared<IoctlHelperPrelim20>()}};
IoctlHelper *IoctlHelper::get(const PRODUCT_FAMILY productFamily, const std::string &prelimVersion, const std::string &drmVersion) {
auto productSpecificIoctlHelper = ioctlHelperFactory[productFamily];
if (productSpecificIoctlHelper) {
return productSpecificIoctlHelper->clone();
std::unique_ptr<IoctlHelper> IoctlHelper::get(const PRODUCT_FAMILY productFamily, const std::string &prelimVersion, const std::string &drmVersion, Drm &drm) {
auto productSpecificIoctlHelperCreator = ioctlHelperFactory[productFamily];
if (productSpecificIoctlHelperCreator) {
return productSpecificIoctlHelperCreator.value()(drm);
}
if (ioctlHelperImpls.find(prelimVersion) != ioctlHelperImpls.end()) {
return ioctlHelperImpls[prelimVersion]->clone();
if (prelimVersion == "") {
return std::make_unique<IoctlHelperUpstream>(drm);
}
return new IoctlHelperPrelim20{}; //fallback to 2.0 if no proper implementation has been found
return std::make_unique<IoctlHelperPrelim20>(drm);
}
} // namespace NEO

View File

@ -8,17 +8,18 @@
#include "shared/source/helpers/hw_info.h"
#include "shared/source/os_interface/linux/ioctl_helper.h"
#include <functional>
#include <memory>
namespace NEO {
IoctlHelper *ioctlHelperFactory[IGFX_MAX_PRODUCT] = {};
std::optional<std::function<std::unique_ptr<IoctlHelper>(Drm &drm)>> ioctlHelperFactory[IGFX_MAX_PRODUCT] = {};
IoctlHelper *IoctlHelper::get(const PRODUCT_FAMILY productFamily, const std::string &prelimVersion, const std::string &drmVersion) {
auto productSpecificIoctlHelper = ioctlHelperFactory[productFamily];
if (productSpecificIoctlHelper) {
return productSpecificIoctlHelper->clone();
std::unique_ptr<IoctlHelper> IoctlHelper::get(const PRODUCT_FAMILY productFamily, const std::string &prelimVersion, const std::string &drmVersion, Drm &drm) {
auto productSpecificIoctlHelperCreator = ioctlHelperFactory[productFamily];
if (productSpecificIoctlHelperCreator) {
return productSpecificIoctlHelperCreator.value()(drm);
}
return new IoctlHelperUpstream{};
return std::make_unique<IoctlHelperUpstream>(drm);
}
} // namespace NEO

View File

@ -24,10 +24,6 @@
namespace NEO {
IoctlHelper *IoctlHelperPrelim20::clone() {
return new IoctlHelperPrelim20{};
}
bool IoctlHelperPrelim20::isVmBindAvailable(Drm *drm) {
int vmBindSupported = 0;
GetParam getParam{};

View File

@ -15,10 +15,6 @@
namespace NEO {
IoctlHelper *IoctlHelperUpstream::clone() {
return new IoctlHelperUpstream{};
}
bool IoctlHelperUpstream::isVmBindAvailable(Drm *drm) {
return false;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Intel Corporation
* Copyright (C) 2021-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -7,13 +7,14 @@
#include "shared/source/os_interface/linux/ioctl_helper.h"
#include <functional>
namespace NEO {
extern IoctlHelper *ioctlHelperFactory[IGFX_MAX_PRODUCT];
extern std::optional<std::function<std::unique_ptr<IoctlHelper>(Drm &drm)>> ioctlHelperFactory[IGFX_MAX_PRODUCT];
struct EnableProductIoctlHelperDg1 {
EnableProductIoctlHelperDg1() {
IoctlHelper *pIoctlHelper = IoctlHelperImpl<IGFX_DG1>::get();
ioctlHelperFactory[IGFX_DG1] = pIoctlHelper;
ioctlHelperFactory[IGFX_DG1] = IoctlHelperImpl<IGFX_DG1>::get;
}
};

View File

@ -17,11 +17,6 @@ constexpr static auto gfxProduct = IGFX_DG1;
extern bool isQueryDrmTip(const std::vector<uint8_t> &queryInfo);
extern std::vector<uint8_t> translateToDrmTip(const uint8_t *dataQuery);
template <>
IoctlHelper *IoctlHelperImpl<gfxProduct>::clone() {
return new IoctlHelperImpl<gfxProduct>{};
}
template <>
uint32_t IoctlHelperImpl<gfxProduct>::createGemExt(Drm *drm, const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, std::optional<uint32_t> vmId) {
auto ret = IoctlHelperUpstream::createGemExt(drm, memClassInstances, allocSize, handle, vmId);

View File

@ -25,7 +25,7 @@ class DrmQueryMock : public DrmMock {
context.hwInfo = rootDeviceEnvironment.getHardwareInfo();
callBaseIsVmBindAvailable = true;
this->ioctlHelper = std::make_unique<IoctlHelperPrelim20>();
this->ioctlHelper = std::make_unique<IoctlHelperPrelim20>(*this);
EXPECT_TRUE(queryMemoryInfo());
EXPECT_EQ(2u + virtualMemoryIds.size(), ioctlCallsCount);

View File

@ -17,7 +17,7 @@ class DrmMockCustomPrelim : public DrmMockCustom {
using Drm::memoryInfo;
DrmMockCustomPrelim(RootDeviceEnvironment &rootDeviceEnvironment) : DrmMockCustom(rootDeviceEnvironment) {
this->ioctlHelper = std::make_unique<IoctlHelperPrelim20>();
this->ioctlHelper = std::make_unique<IoctlHelperPrelim20>(*this);
}
int ioctlExtra(DrmIoctl request, void *arg) override {

View File

@ -1077,8 +1077,12 @@ TEST(DrmQueryTest, givenUapiPrelimVersionWithInvalidPathThenReturnEmptyString) {
}
TEST(DrmTest, givenInvalidUapiPrelimVersionThenFallbackToBasePrelim) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
const auto productFamily = defaultHwInfo->platform.eProductFamily;
std::unique_ptr<IoctlHelper> ioctlHelper(IoctlHelper::get(productFamily, "-1", "unk"));
std::unique_ptr<IoctlHelper> ioctlHelper(IoctlHelper::get(productFamily, "-1", "unk", drm));
EXPECT_NE(nullptr, ioctlHelper.get());
}
@ -1227,6 +1231,7 @@ TEST(DrmWrapperTest, WhenGettingRevisionParamValueThenIoctlHelperIsNotNeeded) {
class MockIoctlHelper : public IoctlHelperPrelim20 {
public:
using IoctlHelperPrelim20::IoctlHelperPrelim20;
unsigned int getIoctlRequestValue(DrmIoctl ioctlRequest) const override {
return ioctlRequestValue;
};
@ -1240,7 +1245,11 @@ class MockIoctlHelper : public IoctlHelperPrelim20 {
};
TEST(DrmWrapperTest, whenGettingDrmParamOrIoctlRequestValueThenUseIoctlHelperWhenAvailable) {
MockIoctlHelper ioctlHelper{};
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
MockIoctlHelper ioctlHelper{drm};
EXPECT_EQ(getIoctlRequestValue(DrmIoctl::Getparam, &ioctlHelper), ioctlHelper.ioctlRequestValue);
EXPECT_NE(getIoctlRequestValue(DrmIoctl::Getparam, nullptr), getIoctlRequestValue(DrmIoctl::Getparam, &ioctlHelper));

View File

@ -46,7 +46,7 @@ class IoctlHelperPrelimFixture : public ::testing::Test {
executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
drm = std::make_unique<DrmPrelimMock>(*executionEnvironment->rootDeviceEnvironments[0]);
drm->ioctlHelper = std::make_unique<IoctlHelperPrelim20>();
drm->ioctlHelper = std::make_unique<IoctlHelperPrelim20>(*drm);
}
std::unique_ptr<ExecutionEnvironment> executionEnvironment;
@ -57,7 +57,7 @@ TEST(IoctlHelperPrelimTest, whenGettingVmBindAvailabilityThenProperValueIsReturn
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
IoctlHelperPrelim20 ioctlHelper{};
IoctlHelperPrelim20 ioctlHelper{drm};
for (auto &ioctlValue : {0, EINVAL}) {
drm.context.vmBindQueryReturn = ioctlValue;
@ -79,7 +79,7 @@ TEST(IoctlHelperPrelimTest, whenVmBindIsCalledThenProperValueIsReturnedBasedOnIo
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
IoctlHelperPrelim20 ioctlHelper{};
IoctlHelperPrelim20 ioctlHelper{drm};
VmBindParams vmBindParams{};
@ -95,7 +95,7 @@ TEST(IoctlHelperPrelimTest, whenVmUnbindIsCalledThenProperValueIsReturnedBasedOn
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
IoctlHelperPrelim20 ioctlHelper{};
IoctlHelperPrelim20 ioctlHelper{drm};
VmBindParams vmBindParams{};

View File

@ -6,8 +6,10 @@
*/
#include "shared/source/helpers/string.h"
#include "shared/source/os_interface/linux/drm_neo.h"
#include "shared/source/os_interface/linux/ioctl_helper.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/common/test_macros/test.h"
#include "third_party/uapi/prelim/drm/i915_drm.h"
@ -18,7 +20,9 @@ extern std::vector<uint8_t> getRegionInfo(const std::vector<MemoryRegion> &input
extern std::vector<uint8_t> getEngineInfo(const std::vector<EngineCapabilities> &inputEngines);
struct IoctlPrelimHelperTests : ::testing::Test {
IoctlHelperPrelim20 ioctlHelper{};
MockExecutionEnvironment executionEnvironment{};
std::unique_ptr<Drm> drm{Drm::create(std::make_unique<HwDeviceIdDrm>(0, ""), *executionEnvironment.rootDeviceEnvironments[0])};
IoctlHelperPrelim20 ioctlHelper{*drm};
};
TEST_F(IoctlPrelimHelperTests, whenGettingIoctlRequestValueThenPropertValueIsReturned) {
@ -113,11 +117,6 @@ TEST_F(IoctlPrelimHelperTests, givenPrelimsWhenTranslateToMemoryRegionsThenRetur
}
}
TEST_F(IoctlPrelimHelperTests, whenCloneIsCalledThenValidPtrIsReturned) {
std::unique_ptr<IoctlHelper> cloned(ioctlHelper.clone());
EXPECT_NE(nullptr, cloned);
}
TEST_F(IoctlPrelimHelperTests, givenEmptyRegionInstanceClassWhenCreatingVmControlRegionExtThenNullptrIsReturned) {
std::optional<MemoryClassInstance> regionInstanceClass{};

View File

@ -15,14 +15,16 @@
using namespace NEO;
TEST(IoctlHelperUpstreamTest, whenGettingVmBindAvailabilityThenFalseIsReturned) {
IoctlHelperUpstream ioctlHelper{};
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
IoctlHelperUpstream ioctlHelper{*drm};
EXPECT_FALSE(ioctlHelper.isVmBindAvailable(drm.get()));
}
TEST(IoctlHelperUpstreamTest, whenGettingIoctlRequestValueThenPropertValueIsReturned) {
IoctlHelperUpstream ioctlHelper{};
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
IoctlHelperUpstream ioctlHelper{*drm};
EXPECT_EQ(ioctlHelper.getIoctlRequestValue(DrmIoctl::Getparam), static_cast<unsigned int>(DRM_IOCTL_I915_GETPARAM));
EXPECT_EQ(ioctlHelper.getIoctlRequestValue(DrmIoctl::GemExecbuffer2), static_cast<unsigned int>(DRM_IOCTL_I915_GEM_EXECBUFFER2));
EXPECT_EQ(ioctlHelper.getIoctlRequestValue(DrmIoctl::GemWait), static_cast<unsigned int>(DRM_IOCTL_I915_GEM_WAIT));
@ -50,7 +52,9 @@ TEST(IoctlHelperUpstreamTest, whenGettingIoctlRequestValueThenPropertValueIsRetu
}
TEST(IoctlHelperUpstreamTest, whenGettingDrmParamValueThenPropertValueIsReturned) {
IoctlHelperUpstream ioctlHelper{};
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
IoctlHelperUpstream ioctlHelper{*drm};
EXPECT_EQ(ioctlHelper.getDrmParamValue(DrmParam::EngineClassCompute), 4);
EXPECT_EQ(ioctlHelper.getDrmParamValue(DrmParam::EngineClassRender), static_cast<int>(I915_ENGINE_CLASS_RENDER));
EXPECT_EQ(ioctlHelper.getDrmParamValue(DrmParam::EngineClassCopy), static_cast<int>(I915_ENGINE_CLASS_COPY));
@ -82,7 +86,9 @@ TEST(IoctlHelperUpstreamTest, whenGettingDrmParamValueThenPropertValueIsReturned
}
TEST(IoctlHelperUpstreamTest, whenCreatingVmControlRegionExtThenNullptrIsReturned) {
IoctlHelperUpstream ioctlHelper{};
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
IoctlHelperUpstream ioctlHelper{*drm};
std::optional<MemoryClassInstance> regionInstanceClass = MemoryClassInstance{};
EXPECT_TRUE(regionInstanceClass.has_value());
@ -94,7 +100,9 @@ TEST(IoctlHelperUpstreamTest, whenCreatingVmControlRegionExtThenNullptrIsReturne
}
TEST(IoctlHelperUpstreamTest, whenGettingFlagsForVmCreateThenZeroIsReturned) {
IoctlHelperUpstream ioctlHelper{};
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
IoctlHelperUpstream ioctlHelper{*drm};
for (auto &disableScratch : ::testing::Bool()) {
for (auto &enablePageFault : ::testing::Bool()) {
for (auto &useVmBind : ::testing::Bool()) {
@ -106,7 +114,9 @@ TEST(IoctlHelperUpstreamTest, whenGettingFlagsForVmCreateThenZeroIsReturned) {
}
TEST(IoctlHelperUpstreamTest, whenGettingFlagsForVmBindThenZeroIsReturned) {
IoctlHelperUpstream ioctlHelper{};
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
IoctlHelperUpstream ioctlHelper{*drm};
for (auto &bindCapture : ::testing::Bool()) {
for (auto &bindImmediate : ::testing::Bool()) {
for (auto &bindMakeResident : ::testing::Bool()) {
@ -118,7 +128,9 @@ TEST(IoctlHelperUpstreamTest, whenGettingFlagsForVmBindThenZeroIsReturned) {
}
TEST(IoctlHelperUpstreamTest, whenGettingVmBindExtFromHandlesThenNullptrIsReturned) {
IoctlHelperUpstream ioctlHelper{};
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
IoctlHelperUpstream ioctlHelper{*drm};
StackVec<uint32_t, 2> bindExtHandles;
bindExtHandles.push_back(1u);
bindExtHandles.push_back(2u);
@ -301,7 +313,7 @@ TEST(IoctlHelperTestsUpstream, whenCreateContextWithAccessCountersIsCalledThenEr
ASSERT_NE(nullptr, drm);
GemContextCreateExt gcc{};
IoctlHelperUpstream ioctlHelper{};
IoctlHelperUpstream ioctlHelper{*drm};
EXPECT_EQ(static_cast<uint32_t>(EINVAL), ioctlHelper.createContextWithAccessCounters(drm.get(), gcc));
}
@ -312,19 +324,23 @@ TEST(IoctlHelperTestsUpstream, whenCreateCooperativeContexIsCalledThenErrorIsRet
ASSERT_NE(nullptr, drm);
GemContextCreateExt gcc{};
IoctlHelperUpstream ioctlHelper{};
IoctlHelperUpstream ioctlHelper{*drm};
EXPECT_EQ(static_cast<uint32_t>(EINVAL), ioctlHelper.createCooperativeContext(drm.get(), gcc));
}
TEST(IoctlHelperTestsUpstream, whenFillVmBindSetPatThenNothingThrows) {
IoctlHelperUpstream ioctlHelper{};
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
IoctlHelperUpstream ioctlHelper{*drm};
VmBindExtSetPatT vmBindExtSetPat{};
EXPECT_NO_THROW(ioctlHelper.fillVmBindExtSetPat(vmBindExtSetPat, 0u, 0u));
}
TEST(IoctlHelperTestsUpstream, whenFillVmBindUserFenceThenNothingThrows) {
IoctlHelperUpstream ioctlHelper{};
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
IoctlHelperUpstream ioctlHelper{*drm};
VmBindExtUserFenceT vmBindExtUserFence{};
EXPECT_NO_THROW(ioctlHelper.fillVmBindExtUserFence(vmBindExtUserFence, 0u, 0u, 0u));
}
@ -335,7 +351,7 @@ TEST(IoctlHelperTestsUpstream, whenVmBindIsCalledThenZeroIsReturned) {
ASSERT_NE(nullptr, drm);
VmBindParams vmBindParams{};
IoctlHelperUpstream ioctlHelper{};
IoctlHelperUpstream ioctlHelper{*drm};
EXPECT_EQ(0, ioctlHelper.vmBind(drm.get(), vmBindParams));
}
@ -344,19 +360,23 @@ TEST(IoctlHelperTestsUpstream, whenVmUnbindIsCalledThenZeroIsReturned) {
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
ASSERT_NE(nullptr, drm);
IoctlHelperUpstream ioctlHelper{};
IoctlHelperUpstream ioctlHelper{*drm};
VmBindParams vmBindParams{};
EXPECT_EQ(0, ioctlHelper.vmUnbind(drm.get(), vmBindParams));
}
TEST(IoctlHelperTestsUpstream, givenUpstreamWhenGettingEuStallPropertiesThenFailureIsReturned) {
IoctlHelperUpstream ioctlHelper{};
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
IoctlHelperUpstream ioctlHelper{*drm};
std::array<uint64_t, 12u> properties = {};
EXPECT_FALSE(ioctlHelper.getEuStallProperties(properties, 0x101, 0x102, 0x103, 1, 1));
}
TEST(IoctlHelperTestsUpstream, givenUpstreamWhenGettingEuStallFdParameterThenZeroIsReturned) {
IoctlHelperUpstream ioctlHelper{};
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
IoctlHelperUpstream ioctlHelper{*drm};
EXPECT_EQ(0u, ioctlHelper.getEuStallFdParameter());
}
@ -364,7 +384,7 @@ TEST(IoctlHelperTestsUpstream, whenRegisterUuidIsCalledThenReturnNullHandle) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
IoctlHelperUpstream ioctlHelper{};
IoctlHelperUpstream ioctlHelper{*drm};
{
const auto [retVal, handle] = ioctlHelper.registerUuid(drm.get(), "", 0, 0, 0);
@ -383,7 +403,7 @@ TEST(IoctlHelperTestsUpstream, whenUnregisterUuidIsCalledThenZeroIsReturned) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
IoctlHelperUpstream ioctlHelper{};
IoctlHelperUpstream ioctlHelper{*drm};
EXPECT_EQ(0, ioctlHelper.unregisterUuid(drm.get(), 0));
}
@ -391,7 +411,7 @@ TEST(IoctlHelperTestsUpstream, whenIsContextDebugSupportedIsCalledThenFalseIsRet
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
IoctlHelperUpstream ioctlHelper{};
IoctlHelperUpstream ioctlHelper{*drm};
EXPECT_EQ(false, ioctlHelper.isContextDebugSupported(drm.get()));
}
@ -399,6 +419,6 @@ TEST(IoctlHelperTestsUpstream, whenSetContextDebugFlagIsCalledThenZeroIsReturned
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
IoctlHelperUpstream ioctlHelper{};
IoctlHelperUpstream ioctlHelper{*drm};
EXPECT_EQ(0, ioctlHelper.setContextDebugFlag(drm.get(), 0));
}