2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2024-01-09 21:39:18 +08:00
|
|
|
* Copyright (C) 2018-2024 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2023-02-02 00:23:01 +08:00
|
|
|
#include "shared/source/helpers/gfx_core_helper.h"
|
2020-09-17 19:27:32 +08:00
|
|
|
#include "shared/source/helpers/string.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/os_interface/linux/drm_neo.h"
|
2022-01-04 22:48:05 +08:00
|
|
|
#include "shared/test/common/helpers/default_hw_info.h"
|
2022-05-12 23:56:50 +08:00
|
|
|
#include "shared/test/common/mocks/linux/mock_drm_wrappers.h"
|
2022-03-16 23:52:08 +08:00
|
|
|
#include "shared/test/common/os_interface/linux/device_command_stream_fixture.h"
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#include <cstdio>
|
|
|
|
#include <fstream>
|
2019-08-21 18:50:47 +08:00
|
|
|
#include <limits.h>
|
2021-06-28 21:17:49 +08:00
|
|
|
#include <map>
|
2023-04-17 21:56:47 +08:00
|
|
|
#include <optional>
|
2022-01-21 00:56:19 +08:00
|
|
|
#include <vector>
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
using namespace NEO;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-03-30 15:00:26 +08:00
|
|
|
class DrmMock : public Drm {
|
2017-12-21 07:45:38 +08:00
|
|
|
public:
|
2023-06-13 23:19:02 +08:00
|
|
|
using Drm::adapterBDF;
|
2020-11-20 04:43:01 +08:00
|
|
|
using Drm::bindAvailable;
|
2021-01-30 06:23:06 +08:00
|
|
|
using Drm::cacheInfo;
|
2019-08-21 18:50:47 +08:00
|
|
|
using Drm::checkQueueSliceSupport;
|
2023-03-08 12:06:00 +08:00
|
|
|
using Drm::chunkingAvailable;
|
2023-07-06 05:41:17 +08:00
|
|
|
using Drm::chunkingMode;
|
2022-01-20 02:14:10 +08:00
|
|
|
using Drm::completionFenceSupported;
|
2021-01-26 04:43:48 +08:00
|
|
|
using Drm::contextDebugSupported;
|
2019-11-09 01:49:54 +08:00
|
|
|
using Drm::engineInfo;
|
2022-02-11 23:03:58 +08:00
|
|
|
using Drm::fenceVal;
|
2020-12-12 05:28:22 +08:00
|
|
|
using Drm::generateElfUUID;
|
2020-09-08 23:33:33 +08:00
|
|
|
using Drm::generateUUID;
|
2019-08-21 18:50:47 +08:00
|
|
|
using Drm::getQueueSliceCount;
|
2022-01-21 20:39:11 +08:00
|
|
|
using Drm::ioctlHelper;
|
2019-03-19 20:53:55 +08:00
|
|
|
using Drm::memoryInfo;
|
2023-07-06 05:41:17 +08:00
|
|
|
using Drm::minimalChunkingSize;
|
2020-02-11 00:05:32 +08:00
|
|
|
using Drm::nonPersistentContextsSupported;
|
2021-11-09 05:42:07 +08:00
|
|
|
using Drm::pageFaultSupported;
|
2022-02-11 23:03:58 +08:00
|
|
|
using Drm::pagingFence;
|
2018-12-11 15:21:56 +08:00
|
|
|
using Drm::preemptionSupported;
|
2019-04-30 19:09:49 +08:00
|
|
|
using Drm::query;
|
2022-05-04 21:59:12 +08:00
|
|
|
using Drm::queryAndSetVmBindPatIndexProgrammingSupport;
|
2022-06-08 20:43:51 +08:00
|
|
|
using Drm::queryDeviceIdAndRevision;
|
2020-07-15 14:07:53 +08:00
|
|
|
using Drm::requirePerContextVM;
|
2022-09-20 15:07:59 +08:00
|
|
|
using Drm::setPairAvailable;
|
2022-01-21 20:39:11 +08:00
|
|
|
using Drm::setupIoctlHelper;
|
2019-08-21 18:50:47 +08:00
|
|
|
using Drm::sliceCountChangeSupported;
|
2020-11-24 23:00:33 +08:00
|
|
|
using Drm::systemInfo;
|
2020-07-07 15:34:31 +08:00
|
|
|
using Drm::virtualMemoryIds;
|
2023-10-12 22:06:59 +08:00
|
|
|
using Drm::vmBindPatIndexProgrammingSupported;
|
2018-12-11 15:21:56 +08:00
|
|
|
|
2022-07-15 19:12:14 +08:00
|
|
|
DrmMock(int fd, RootDeviceEnvironment &rootDeviceEnvironment);
|
2020-07-07 15:34:31 +08:00
|
|
|
DrmMock(RootDeviceEnvironment &rootDeviceEnvironment) : DrmMock(mockFd, rootDeviceEnvironment) {}
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2022-07-15 19:12:14 +08:00
|
|
|
~DrmMock() override;
|
2022-03-16 23:52:08 +08:00
|
|
|
|
2022-05-26 01:05:52 +08:00
|
|
|
int ioctl(DrmIoctl request, void *arg) override;
|
2020-09-10 18:36:44 +08:00
|
|
|
int getErrno() override {
|
|
|
|
if (baseErrno) {
|
|
|
|
return Drm::getErrno();
|
|
|
|
}
|
|
|
|
return errnoRetVal;
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2024-04-26 22:39:26 +08:00
|
|
|
int waitUserFence(uint32_t ctxId, uint64_t address, uint64_t value, ValueWidth dataWidth, int64_t timeout, uint16_t flags, bool userInterrupt, uint32_t externalInterruptId) override;
|
2022-02-11 23:03:58 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
void writeConfigFile(const char *name, int deviceID) {
|
|
|
|
std::ofstream tempfile(name, std::ios::binary);
|
|
|
|
if (tempfile.is_open()) {
|
|
|
|
PCIConfig config;
|
2023-04-26 18:13:07 +08:00
|
|
|
config.deviceID = deviceID;
|
2017-12-21 07:45:38 +08:00
|
|
|
tempfile.write(reinterpret_cast<char *>(&config), sizeof(config));
|
|
|
|
tempfile.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void deleteConfigFile(const char *name) {
|
|
|
|
std::ofstream tempfile(name);
|
|
|
|
if (tempfile.is_open()) {
|
|
|
|
tempfile.close();
|
|
|
|
remove(name);
|
|
|
|
}
|
|
|
|
}
|
2019-07-23 17:45:10 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
void setFileDescriptor(int fd) {
|
2021-05-25 01:34:55 +08:00
|
|
|
hwDeviceId = std::make_unique<HwDeviceIdDrm>(fd, "");
|
2020-04-09 00:14:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void setPciPath(const char *pciPath) {
|
2021-05-25 01:34:55 +08:00
|
|
|
hwDeviceId = std::make_unique<HwDeviceIdDrm>(getFileDescriptor(), pciPath);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2020-11-20 04:43:01 +08:00
|
|
|
void setBindAvailable() {
|
|
|
|
this->bindAvailable = true;
|
|
|
|
}
|
2021-01-26 04:43:48 +08:00
|
|
|
void setContextDebugFlag(uint32_t drmContextId) override {
|
|
|
|
passedContextDebugId = drmContextId;
|
|
|
|
return Drm::setContextDebugFlag(drmContextId);
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2021-02-24 01:57:27 +08:00
|
|
|
bool isDebugAttachAvailable() override {
|
|
|
|
if (allowDebugAttachCallBase) {
|
|
|
|
return Drm::isDebugAttachAvailable();
|
|
|
|
}
|
|
|
|
return allowDebugAttach;
|
|
|
|
}
|
|
|
|
|
2021-11-12 06:11:38 +08:00
|
|
|
void queryPageFaultSupport() override {
|
|
|
|
Drm::queryPageFaultSupport();
|
|
|
|
queryPageFaultSupportCalled = true;
|
|
|
|
}
|
|
|
|
|
2023-02-12 06:03:06 +08:00
|
|
|
int createDrmContext(uint32_t drmVmId, bool isDirectSubmissionRequested, bool isCooperativeContextRequested) override {
|
2022-02-11 05:15:09 +08:00
|
|
|
capturedCooperativeContextRequest = isCooperativeContextRequested;
|
|
|
|
if (callBaseCreateDrmContext) {
|
|
|
|
return Drm::createDrmContext(drmVmId, isDirectSubmissionRequested, isCooperativeContextRequested);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-03-17 19:50:23 +08:00
|
|
|
int createDrmVirtualMemory(uint32_t &drmVmId) override {
|
|
|
|
createDrmVmCalled++;
|
|
|
|
return Drm::createDrmVirtualMemory(drmVmId);
|
|
|
|
}
|
|
|
|
|
2022-04-22 00:59:48 +08:00
|
|
|
bool isVmBindAvailable() override {
|
|
|
|
if (callBaseIsVmBindAvailable) {
|
|
|
|
return Drm::isVmBindAvailable();
|
|
|
|
}
|
|
|
|
return bindAvailable;
|
|
|
|
}
|
|
|
|
|
2022-09-20 15:07:59 +08:00
|
|
|
bool isSetPairAvailable() override {
|
|
|
|
if (callBaseIsSetPairAvailable) {
|
|
|
|
return Drm::isSetPairAvailable();
|
|
|
|
}
|
|
|
|
return setPairAvailable;
|
|
|
|
}
|
|
|
|
|
2023-03-08 12:06:00 +08:00
|
|
|
bool isChunkingAvailable() override {
|
|
|
|
if (callBaseIsChunkingAvailable) {
|
|
|
|
return Drm::isChunkingAvailable();
|
|
|
|
}
|
|
|
|
return chunkingAvailable;
|
|
|
|
}
|
|
|
|
|
2023-07-06 05:41:17 +08:00
|
|
|
uint32_t getChunkingMode() override {
|
|
|
|
if (callBaseChunkingMode) {
|
|
|
|
return Drm::isChunkingAvailable();
|
|
|
|
}
|
|
|
|
return chunkingMode;
|
|
|
|
}
|
|
|
|
|
2022-09-20 15:07:59 +08:00
|
|
|
bool getSetPairAvailable() override {
|
|
|
|
if (callBaseGetSetPairAvailable) {
|
|
|
|
return Drm::getSetPairAvailable();
|
|
|
|
}
|
|
|
|
return setPairAvailable;
|
|
|
|
}
|
|
|
|
|
2022-09-12 20:50:07 +08:00
|
|
|
uint32_t getBaseIoctlCalls() {
|
2022-10-31 21:57:24 +08:00
|
|
|
return static_cast<uint32_t>(virtualMemoryIds.size());
|
2022-09-12 20:50:07 +08:00
|
|
|
}
|
2023-04-17 21:56:47 +08:00
|
|
|
bool useVMBindImmediate() const override {
|
|
|
|
if (isVMBindImmediateSupported.has_value())
|
|
|
|
return *isVMBindImmediateSupported;
|
|
|
|
else
|
|
|
|
return Drm::useVMBindImmediate();
|
|
|
|
}
|
2024-03-28 16:46:55 +08:00
|
|
|
int queryGttSize(uint64_t >tSizeOutput, bool alignUpToFullRange) override {
|
2023-04-28 21:24:48 +08:00
|
|
|
gttSizeOutput = storedGTTSize;
|
|
|
|
return storedRetValForGetGttSize;
|
|
|
|
}
|
2022-09-12 20:50:07 +08:00
|
|
|
|
2019-04-10 20:32:41 +08:00
|
|
|
static const int mockFd = 33;
|
|
|
|
|
2020-06-09 21:51:26 +08:00
|
|
|
bool failRetTopology = false;
|
2020-09-10 18:36:44 +08:00
|
|
|
bool baseErrno = true;
|
|
|
|
int errnoRetVal = 0;
|
2021-06-25 23:33:33 +08:00
|
|
|
int storedEUVal = 8;
|
|
|
|
int storedSSVal = 2;
|
|
|
|
int storedSVal = 1;
|
|
|
|
int storedDeviceID = 1;
|
|
|
|
int storedDeviceRevID = 1;
|
|
|
|
int storedHasPooledEU = 1;
|
|
|
|
int storedMinEUinPool = 1;
|
|
|
|
int storedPersistentContextsSupport = 1;
|
|
|
|
int storedRetVal = 0;
|
|
|
|
int storedRetValForGetGttSize = 0;
|
|
|
|
int storedRetValForGetSSEU = 0;
|
|
|
|
int storedRetValForSetSSEU = 0;
|
|
|
|
int storedRetValForDeviceID = 0;
|
|
|
|
int storedRetValForEUVal = 0;
|
|
|
|
int storedRetValForSSVal = 0;
|
|
|
|
int storedRetValForDeviceRevID = 0;
|
|
|
|
int storedRetValForPooledEU = 0;
|
|
|
|
int storedRetValForMinEUinPool = 0;
|
|
|
|
int storedRetValForPersistant = 0;
|
2022-05-27 23:13:55 +08:00
|
|
|
int storedRetValForVmCreate = 0;
|
2022-07-15 19:12:14 +08:00
|
|
|
int storedPreemptionSupport = 0;
|
2021-06-25 23:33:33 +08:00
|
|
|
int storedRetValForVmId = 1;
|
|
|
|
int storedCsTimestampFrequency = 1000;
|
2023-04-26 01:31:35 +08:00
|
|
|
int storedOaTimestampFrequency = 123456;
|
2020-06-09 21:51:26 +08:00
|
|
|
bool disableSomeTopology = false;
|
2021-02-24 01:57:27 +08:00
|
|
|
bool allowDebugAttach = false;
|
|
|
|
bool allowDebugAttachCallBase = false;
|
2022-02-11 05:15:09 +08:00
|
|
|
bool callBaseCreateDrmContext = true;
|
2022-04-22 00:59:48 +08:00
|
|
|
bool callBaseIsVmBindAvailable = false;
|
2022-09-20 15:07:59 +08:00
|
|
|
bool callBaseIsSetPairAvailable = false;
|
2023-03-08 12:06:00 +08:00
|
|
|
bool callBaseIsChunkingAvailable = false;
|
2023-07-06 05:41:17 +08:00
|
|
|
bool callBaseGetChunkingMode = false;
|
|
|
|
bool callBaseChunkingMode = false;
|
2022-09-20 15:07:59 +08:00
|
|
|
bool callBaseGetSetPairAvailable = false;
|
2022-10-31 16:33:00 +08:00
|
|
|
bool unrecoverableContextSet = false;
|
2022-10-31 21:57:24 +08:00
|
|
|
bool failRetHwIpVersion = false;
|
|
|
|
bool returnInvalidHwIpVersionLength = false;
|
2024-03-09 09:22:47 +08:00
|
|
|
bool failPerfOpen = false;
|
2022-02-11 05:15:09 +08:00
|
|
|
|
|
|
|
bool capturedCooperativeContextRequest = false;
|
2022-10-18 04:26:22 +08:00
|
|
|
bool incrementVmId = false;
|
2023-04-17 21:56:47 +08:00
|
|
|
std::optional<bool> isVMBindImmediateSupported{};
|
2022-02-11 05:15:09 +08:00
|
|
|
|
2021-06-25 23:33:33 +08:00
|
|
|
uint32_t passedContextDebugId = std::numeric_limits<uint32_t>::max();
|
2022-05-24 23:06:15 +08:00
|
|
|
std::vector<ResetStats> resetStatsToReturn{};
|
2020-06-09 21:51:26 +08:00
|
|
|
|
2022-05-23 23:05:47 +08:00
|
|
|
GemContextCreateExtSetParam receivedContextCreateSetParam = {};
|
2021-02-10 23:13:50 +08:00
|
|
|
uint32_t receivedContextCreateFlags = 0;
|
2018-12-11 15:21:56 +08:00
|
|
|
uint32_t receivedDestroyContextId = 0;
|
2019-03-19 20:53:55 +08:00
|
|
|
uint32_t ioctlCallsCount = 0;
|
2018-12-11 15:21:56 +08:00
|
|
|
|
|
|
|
uint32_t receivedContextParamRequestCount = 0;
|
2022-05-20 23:04:07 +08:00
|
|
|
GemContextParam receivedContextParamRequest = {};
|
2021-09-10 05:16:11 +08:00
|
|
|
uint64_t receivedRecoverableContextValue = std::numeric_limits<uint64_t>::max();
|
2022-10-31 16:33:00 +08:00
|
|
|
uint64_t requestSetVmId = std::numeric_limits<uint64_t>::max();
|
2023-03-17 19:50:23 +08:00
|
|
|
int createDrmVmCalled = 0;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2021-11-12 06:11:38 +08:00
|
|
|
bool queryPageFaultSupportCalled = false;
|
|
|
|
|
2023-01-04 23:00:09 +08:00
|
|
|
// DRM_IOCTL_I915_GEM_EXECBUFFER2
|
2022-05-12 23:56:50 +08:00
|
|
|
std::vector<MockExecBuffer> execBuffers{};
|
|
|
|
std::vector<MockExecObject> receivedBos{};
|
2022-10-28 17:25:16 +08:00
|
|
|
int execBufferResult = 0;
|
2023-01-04 23:00:09 +08:00
|
|
|
// DRM_IOCTL_I915_GEM_CREATE
|
2022-05-24 23:06:15 +08:00
|
|
|
uint64_t createParamsSize = 0;
|
|
|
|
uint32_t createParamsHandle = 0;
|
2023-01-04 23:00:09 +08:00
|
|
|
// DRM_IOCTL_I915_GEM_SET_TILING
|
2022-05-24 23:06:15 +08:00
|
|
|
uint32_t setTilingMode = 0;
|
|
|
|
uint32_t setTilingHandle = 0;
|
|
|
|
uint32_t setTilingStride = 0;
|
2023-01-04 23:00:09 +08:00
|
|
|
// DRM_IOCTL_PRIME_FD_TO_HANDLE
|
2022-05-24 23:06:15 +08:00
|
|
|
uint32_t outputHandle = 0;
|
|
|
|
int32_t inputFd = 0;
|
2020-10-21 16:50:53 +08:00
|
|
|
int fdToHandleRetVal = 0;
|
2023-01-04 23:00:09 +08:00
|
|
|
// DRM_IOCTL_HANDLE_TO_FD
|
2022-05-24 23:06:15 +08:00
|
|
|
int32_t outputFd = 0;
|
2022-10-12 09:33:43 +08:00
|
|
|
bool incrementOutputFdAfterCall = false;
|
2023-01-04 23:00:09 +08:00
|
|
|
// DRM_IOCTL_I915_GEM_USERPTR
|
2022-05-24 23:06:15 +08:00
|
|
|
uint32_t returnHandle = 0;
|
|
|
|
uint64_t gpuMemSize = 3u * MemoryConstants::gigaByte;
|
2023-01-04 23:00:09 +08:00
|
|
|
// DRM_IOCTL_I915_QUERY
|
2022-05-18 05:40:34 +08:00
|
|
|
QueryItem storedQueryItem = {};
|
2023-01-04 23:00:09 +08:00
|
|
|
// DRM_IOCTL_I915_GEM_WAIT
|
2022-05-24 23:06:15 +08:00
|
|
|
GemWait receivedGemWait = {};
|
2023-01-04 23:00:09 +08:00
|
|
|
// DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT
|
2022-03-16 23:52:08 +08:00
|
|
|
uint32_t storedDrmContextId{};
|
2023-01-04 23:00:09 +08:00
|
|
|
// DRM_IOCTL_GEM_CLOSE
|
2022-03-16 23:52:08 +08:00
|
|
|
int storedRetValForGemClose = 0;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2022-05-27 23:13:55 +08:00
|
|
|
GemVmControl receivedGemVmControl{};
|
|
|
|
uint32_t latestCreatedVmId = 0u;
|
|
|
|
|
2024-03-28 16:46:55 +08:00
|
|
|
uint64_t storedGTTSize = defaultHwInfo->capabilityTable.gpuAddressSpace + 1;
|
2019-08-21 18:50:47 +08:00
|
|
|
uint64_t storedParamSseu = ULONG_MAX;
|
2019-04-23 21:42:33 +08:00
|
|
|
|
2022-03-16 23:52:08 +08:00
|
|
|
Ioctls ioctlCount{};
|
|
|
|
Ioctls ioctlTearDownExpected{};
|
|
|
|
bool ioctlTearDownExpects = false;
|
|
|
|
|
|
|
|
bool expectIoctlCallsOnDestruction = false;
|
|
|
|
uint32_t expectedIoctlCallsOnDestruction = 0u;
|
|
|
|
|
2022-09-12 20:50:07 +08:00
|
|
|
virtual int handleRemainingRequests(DrmIoctl request, void *arg);
|
2022-02-11 23:03:58 +08:00
|
|
|
|
|
|
|
struct WaitUserFenceParams {
|
|
|
|
uint32_t ctxId;
|
|
|
|
uint64_t address;
|
|
|
|
uint64_t value;
|
|
|
|
ValueWidth dataWidth;
|
|
|
|
int64_t timeout;
|
|
|
|
uint16_t flags;
|
|
|
|
};
|
|
|
|
StackVec<WaitUserFenceParams, 1> waitUserFenceParams;
|
2022-06-30 16:04:45 +08:00
|
|
|
|
|
|
|
bool storedGetDeviceMemoryMaxClockRateInMhzStatus = true;
|
|
|
|
bool useBaseGetDeviceMemoryMaxClockRateInMhz = true;
|
|
|
|
bool getDeviceMemoryMaxClockRateInMhz(uint32_t tileId, uint32_t &clkRate) override {
|
|
|
|
|
|
|
|
if (useBaseGetDeviceMemoryMaxClockRateInMhz == true) {
|
|
|
|
return Drm::getDeviceMemoryMaxClockRateInMhz(tileId, clkRate);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (storedGetDeviceMemoryMaxClockRateInMhzStatus == true) {
|
|
|
|
clkRate = 800;
|
|
|
|
}
|
|
|
|
return storedGetDeviceMemoryMaxClockRateInMhzStatus;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool storedGetDeviceMemoryPhysicalSizeInBytesStatus = true;
|
|
|
|
bool useBaseGetDeviceMemoryPhysicalSizeInBytes = true;
|
|
|
|
bool getDeviceMemoryPhysicalSizeInBytes(uint32_t tileId, uint64_t &physicalSize) override {
|
|
|
|
if (useBaseGetDeviceMemoryPhysicalSizeInBytes == true) {
|
|
|
|
return Drm::getDeviceMemoryPhysicalSizeInBytes(tileId, physicalSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (storedGetDeviceMemoryPhysicalSizeInBytesStatus == true) {
|
|
|
|
physicalSize = 1024;
|
|
|
|
}
|
|
|
|
return storedGetDeviceMemoryPhysicalSizeInBytesStatus;
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
2020-08-11 20:00:41 +08:00
|
|
|
|
|
|
|
class DrmMockNonFailing : public DrmMock {
|
|
|
|
public:
|
|
|
|
using DrmMock::DrmMock;
|
2022-05-26 01:05:52 +08:00
|
|
|
int handleRemainingRequests(DrmIoctl request, void *arg) override { return 0; }
|
2020-08-11 20:00:41 +08:00
|
|
|
};
|
2020-08-25 01:08:59 +08:00
|
|
|
|
2021-10-12 09:32:45 +08:00
|
|
|
class DrmMockReturnErrorNotSupported : public DrmMock {
|
|
|
|
public:
|
|
|
|
using DrmMock::DrmMock;
|
2022-05-26 01:05:52 +08:00
|
|
|
int ioctl(DrmIoctl request, void *arg) override {
|
2023-12-12 16:48:32 +08:00
|
|
|
if (request == DrmIoctl::gemExecbuffer2) {
|
2021-10-12 09:32:45 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
int getErrno() override { return EOPNOTSUPP; }
|
|
|
|
};
|
|
|
|
|
2020-08-25 01:08:59 +08:00
|
|
|
class DrmMockEngine : public DrmMock {
|
|
|
|
public:
|
|
|
|
uint32_t i915QuerySuccessCount = std::numeric_limits<uint32_t>::max();
|
|
|
|
uint32_t queryEngineInfoSuccessCount = std::numeric_limits<uint32_t>::max();
|
|
|
|
|
2023-01-24 23:33:52 +08:00
|
|
|
DrmMockEngine(RootDeviceEnvironment &rootDeviceEnvironment);
|
2020-09-11 20:18:23 +08:00
|
|
|
|
2022-05-26 01:05:52 +08:00
|
|
|
int handleRemainingRequests(DrmIoctl request, void *arg) override;
|
2020-08-25 01:08:59 +08:00
|
|
|
|
2022-05-18 05:40:34 +08:00
|
|
|
void handleQueryItem(QueryItem *queryItem);
|
2021-11-13 01:34:33 +08:00
|
|
|
bool failQueryDeviceBlob = false;
|
2020-08-25 01:08:59 +08:00
|
|
|
};
|
2020-09-14 19:28:47 +08:00
|
|
|
|
|
|
|
class DrmMockResources : public DrmMock {
|
|
|
|
public:
|
2020-11-23 22:31:20 +08:00
|
|
|
DrmMockResources(RootDeviceEnvironment &rootDeviceEnvironment) : DrmMock(mockFd, rootDeviceEnvironment) {
|
|
|
|
setBindAvailable();
|
2022-04-22 00:59:48 +08:00
|
|
|
callBaseIsVmBindAvailable = true;
|
2020-11-23 22:31:20 +08:00
|
|
|
}
|
2020-09-14 19:28:47 +08:00
|
|
|
|
|
|
|
bool registerResourceClasses() override {
|
|
|
|
registerClassesCalled = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-05-09 23:52:12 +08:00
|
|
|
uint32_t registerResource(DrmResourceClass classType, const void *data, size_t size) override {
|
2020-09-14 19:28:47 +08:00
|
|
|
registeredClass = classType;
|
2020-09-17 19:27:32 +08:00
|
|
|
memcpy_s(registeredData, sizeof(registeredData), data, size);
|
|
|
|
registeredDataSize = size;
|
2020-09-14 19:28:47 +08:00
|
|
|
return registerResourceReturnHandle;
|
|
|
|
}
|
|
|
|
|
|
|
|
void unregisterResource(uint32_t handle) override {
|
|
|
|
unregisterCalledCount++;
|
|
|
|
unregisteredHandle = handle;
|
|
|
|
}
|
|
|
|
|
2020-10-26 21:48:20 +08:00
|
|
|
uint32_t registerIsaCookie(uint32_t isaHanlde) override {
|
|
|
|
return currentCookie++;
|
|
|
|
}
|
|
|
|
|
2020-11-23 22:31:20 +08:00
|
|
|
bool isVmBindAvailable() override {
|
|
|
|
return bindAvailable;
|
|
|
|
}
|
|
|
|
|
2022-07-22 20:07:36 +08:00
|
|
|
uint32_t notifyFirstCommandQueueCreated(const void *data, size_t size) override {
|
2022-02-10 19:13:59 +08:00
|
|
|
ioctlCallsCount++;
|
2022-08-30 16:42:06 +08:00
|
|
|
capturedCmdQData = std::make_unique<uint64_t[]>((size + sizeof(uint64_t) - 1) / sizeof(uint64_t));
|
|
|
|
capturedCmdQSize = size;
|
|
|
|
memcpy(capturedCmdQData.get(), data, size);
|
2022-02-10 19:13:59 +08:00
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
void notifyLastCommandQueueDestroyed(uint32_t handle) override {
|
|
|
|
unregisterResource(handle);
|
|
|
|
}
|
|
|
|
|
2020-09-14 19:28:47 +08:00
|
|
|
static const uint32_t registerResourceReturnHandle;
|
|
|
|
|
|
|
|
uint32_t unregisteredHandle = 0;
|
|
|
|
uint32_t unregisterCalledCount = 0;
|
2023-12-19 18:42:58 +08:00
|
|
|
DrmResourceClass registeredClass = DrmResourceClass::maxSize;
|
2020-09-14 19:28:47 +08:00
|
|
|
bool registerClassesCalled = false;
|
2020-09-17 19:27:32 +08:00
|
|
|
uint64_t registeredData[128];
|
|
|
|
size_t registeredDataSize;
|
2020-10-26 21:48:20 +08:00
|
|
|
uint32_t currentCookie = 2;
|
2022-08-30 16:42:06 +08:00
|
|
|
std::unique_ptr<uint64_t[]> capturedCmdQData = nullptr;
|
|
|
|
size_t capturedCmdQSize = 0;
|
2020-09-14 19:28:47 +08:00
|
|
|
};
|