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