2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2025-01-24 03:59:30 +00:00
|
|
|
* Copyright (C) 2018-2025 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
|
2021-04-23 14:30:04 +00:00
|
|
|
#include "shared/source/gmm_helper/gmm_lib.h"
|
2023-07-05 21:41:17 +00:00
|
|
|
#include "shared/source/helpers/constants.h"
|
2023-01-23 14:55:52 +00:00
|
|
|
#include "shared/source/helpers/driver_model_type.h"
|
2021-06-29 16:23:56 +00:00
|
|
|
#include "shared/source/memory_manager/definitions/engine_limits.h"
|
2022-05-09 15:52:12 +00:00
|
|
|
#include "shared/source/os_interface/linux/drm_debug.h"
|
2023-01-23 14:55:52 +00:00
|
|
|
#include "shared/source/os_interface/linux/drm_wrappers.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/os_interface/linux/hw_device_id.h"
|
2021-05-21 01:17:57 +02:00
|
|
|
#include "shared/source/os_interface/os_interface.h"
|
2023-01-23 14:55:52 +00:00
|
|
|
#include "shared/source/utilities/stackvec.h"
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2025-05-30 12:56:08 +00:00
|
|
|
#include "neo_igfxfmid.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2020-09-14 13:28:47 +02:00
|
|
|
#include <array>
|
2024-03-15 07:52:00 +00:00
|
|
|
#include <atomic>
|
2023-02-17 17:53:57 +01:00
|
|
|
#include <cstdint>
|
2021-08-19 15:26:34 +00:00
|
|
|
#include <limits>
|
2019-03-19 13:53:55 +01:00
|
|
|
#include <memory>
|
2020-11-19 20:43:01 +00:00
|
|
|
#include <mutex>
|
2017-12-21 00:45:38 +01:00
|
|
|
#include <string>
|
2021-04-21 13:52:11 +00:00
|
|
|
#include <unordered_map>
|
2020-07-07 09:34:31 +02:00
|
|
|
#include <vector>
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-02-05 08:54:46 +01:00
|
|
|
struct GT_SYSTEM_INFO;
|
|
|
|
|
|
2023-01-23 14:55:52 +00:00
|
|
|
namespace aub_stream {
|
|
|
|
|
enum EngineType : uint32_t;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2022-07-27 08:00:15 +00:00
|
|
|
constexpr uint32_t contextPrivateParamBoost = 0x80000000;
|
2023-11-03 15:46:58 +00:00
|
|
|
constexpr uint32_t chunkingModeShared = 1;
|
|
|
|
|
constexpr uint32_t chunkingModeDevice = 2;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2022-04-19 19:24:19 +00:00
|
|
|
enum class AllocationType;
|
2023-01-23 14:55:52 +00:00
|
|
|
enum class CachePolicy : uint32_t;
|
|
|
|
|
enum class CacheRegion : uint16_t;
|
2022-11-04 09:43:54 +00:00
|
|
|
enum class SubmissionStatus : uint32_t;
|
|
|
|
|
|
2020-07-02 11:49:46 +02:00
|
|
|
class BufferObject;
|
2023-11-16 14:24:12 +00:00
|
|
|
class ReleaseHelper;
|
2017-12-21 00:45:38 +01:00
|
|
|
class DeviceFactory;
|
2023-01-23 14:55:52 +00:00
|
|
|
class MemoryInfo;
|
2020-08-11 14:00:41 +02:00
|
|
|
class OsContext;
|
2022-04-25 11:49:22 +00:00
|
|
|
class OsContextLinux;
|
2022-04-19 19:24:19 +00:00
|
|
|
class Gmm;
|
2024-05-07 11:47:34 +00:00
|
|
|
class GraphicsAllocation;
|
2023-01-23 14:55:52 +00:00
|
|
|
struct CacheInfo;
|
|
|
|
|
struct EngineInfo;
|
2018-02-05 08:54:46 +01:00
|
|
|
struct HardwareInfo;
|
2020-01-29 19:10:49 +01:00
|
|
|
struct RootDeviceEnvironment;
|
2020-11-24 16:00:33 +01:00
|
|
|
struct SystemInfo;
|
2018-02-05 08:54:46 +01:00
|
|
|
|
2022-05-09 17:40:30 +00:00
|
|
|
struct DeviceDescriptor {
|
2018-02-05 08:54:46 +01:00
|
|
|
unsigned short deviceId;
|
|
|
|
|
const HardwareInfo *pHwInfo;
|
2023-11-16 14:24:12 +00:00
|
|
|
void (*setupHardwareInfo)(HardwareInfo *, bool, const ReleaseHelper *);
|
2020-11-09 17:35:33 +00:00
|
|
|
const char *devName;
|
2018-02-05 08:54:46 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern const DeviceDescriptor deviceDescriptorTable[];
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2021-05-21 01:17:57 +02:00
|
|
|
class Drm : public DriverModel {
|
2017-12-21 00:45:38 +01:00
|
|
|
friend DeviceFactory;
|
|
|
|
|
|
|
|
|
|
public:
|
2023-12-13 16:09:52 +00:00
|
|
|
static constexpr DriverModelType driverModelType = DriverModelType::drm;
|
2021-05-21 01:17:57 +02:00
|
|
|
|
2022-11-04 09:43:54 +00:00
|
|
|
static SubmissionStatus getSubmissionStatusFromReturnCode(int32_t retCode);
|
|
|
|
|
|
2022-05-09 17:40:30 +00:00
|
|
|
~Drm() override;
|
2019-02-11 16:49:23 +01:00
|
|
|
|
2022-05-25 17:05:52 +00:00
|
|
|
virtual int ioctl(DrmIoctl request, void *arg);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2021-05-21 01:17:57 +02:00
|
|
|
unsigned int getDeviceHandle() const override {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2022-10-14 13:02:37 +00:00
|
|
|
PhysicalDevicePciSpeedInfo getPciSpeedInfo() const override;
|
2017-12-21 00:45:38 +01:00
|
|
|
int enableTurboBoost();
|
|
|
|
|
int getEuTotal(int &euTotal);
|
|
|
|
|
int getSubsliceTotal(int &subsliceTotal);
|
|
|
|
|
|
2020-04-10 13:54:07 +02:00
|
|
|
int getMaxGpuFrequency(HardwareInfo &hwInfo, int &maxGpuFrequency);
|
2017-12-21 00:45:38 +01:00
|
|
|
int getEnabledPooledEu(int &enabled);
|
|
|
|
|
int getMinEuInPool(int &minEUinPool);
|
2021-06-25 12:28:28 +00:00
|
|
|
int getTimestampFrequency(int &frequency);
|
2023-04-18 13:19:12 +00:00
|
|
|
int getOaTimestampFrequency(int &frequency);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2024-03-28 08:46:55 +00:00
|
|
|
MOCKABLE_VIRTUAL int queryGttSize(uint64_t >tSizeOutput, bool alignUpToFullRange);
|
2018-12-07 15:03:23 +01:00
|
|
|
bool isPreemptionSupported() const { return preemptionSupported; }
|
2019-12-24 12:20:23 +01:00
|
|
|
|
2018-12-07 15:03:23 +01:00
|
|
|
MOCKABLE_VIRTUAL void checkPreemptionSupport();
|
2020-02-05 17:43:02 +01:00
|
|
|
inline int getFileDescriptor() const { return hwDeviceId->getFileDescriptor(); }
|
2021-05-31 16:58:10 +00:00
|
|
|
int queryAdapterBDF();
|
2023-03-17 11:50:23 +00:00
|
|
|
MOCKABLE_VIRTUAL int createDrmVirtualMemory(uint32_t &drmVmId);
|
2020-07-07 09:34:31 +02:00
|
|
|
void destroyDrmVirtualMemory(uint32_t drmVmId);
|
2023-02-11 22:03:06 +00:00
|
|
|
MOCKABLE_VIRTUAL int createDrmContext(uint32_t drmVmId, bool isDirectSubmissionRequested, bool isCooperativeContextRequested);
|
2018-12-11 08:21:56 +01:00
|
|
|
void destroyDrmContext(uint32_t drmContextId);
|
2020-08-31 07:04:58 +02:00
|
|
|
int queryVmId(uint32_t drmContextId, uint32_t &vmId);
|
2018-12-11 08:21:56 +01:00
|
|
|
void setLowPriorityContextParam(uint32_t drmContextId);
|
2019-12-24 12:20:23 +01:00
|
|
|
|
2024-10-08 13:23:41 +00:00
|
|
|
MOCKABLE_VIRTUAL unsigned int bindDrmContext(uint32_t drmContextId, uint32_t deviceIndex, aub_stream::EngineType engineType);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-02-28 12:09:48 +01:00
|
|
|
MOCKABLE_VIRTUAL int getErrno();
|
2019-08-21 03:50:47 -07:00
|
|
|
bool setQueueSliceCount(uint64_t sliceCount);
|
|
|
|
|
void checkQueueSliceSupport();
|
|
|
|
|
uint64_t getSliceMask(uint64_t sliceCount);
|
2020-11-24 16:00:33 +01:00
|
|
|
MOCKABLE_VIRTUAL bool querySystemInfo();
|
2020-08-24 13:08:59 -04:00
|
|
|
MOCKABLE_VIRTUAL bool queryEngineInfo();
|
2021-03-31 11:24:22 +05:30
|
|
|
MOCKABLE_VIRTUAL bool sysmanQueryEngineInfo();
|
|
|
|
|
MOCKABLE_VIRTUAL bool queryEngineInfo(bool isSysmanEnabled);
|
2020-06-17 15:17:48 +05:30
|
|
|
MOCKABLE_VIRTUAL bool queryMemoryInfo();
|
2023-06-20 07:34:12 +00:00
|
|
|
bool queryTopology(const HardwareInfo &hwInfo, DrmQueryTopologyData &topologyData);
|
2020-07-07 09:34:31 +02:00
|
|
|
bool createVirtualMemoryAddressSpace(uint32_t vmCount);
|
|
|
|
|
void destroyVirtualMemoryAddressSpace();
|
2022-07-25 11:50:32 +00:00
|
|
|
uint32_t getVirtualMemoryAddressSpace(uint32_t vmId) const;
|
2025-02-05 06:40:13 +00:00
|
|
|
MOCKABLE_VIRTUAL int bindBufferObject(OsContext *osContext, uint32_t vmHandleId, BufferObject *bo, const bool forcePagingFence);
|
2022-02-04 15:28:20 +00:00
|
|
|
MOCKABLE_VIRTUAL int unbindBufferObject(OsContext *osContext, uint32_t vmHandleId, BufferObject *bo);
|
2022-06-07 15:03:52 +00:00
|
|
|
int setupHardwareInfo(const DeviceDescriptor *, bool);
|
2021-06-15 10:43:12 +00:00
|
|
|
void setupSystemInfo(HardwareInfo *hwInfo, SystemInfo *sysInfo);
|
2021-01-29 22:23:06 +00:00
|
|
|
void setupCacheInfo(const HardwareInfo &hwInfo);
|
2021-12-08 10:10:27 +00:00
|
|
|
MOCKABLE_VIRTUAL void getPrelimVersion(std::string &prelimVersion);
|
2024-01-23 22:32:35 +00:00
|
|
|
MOCKABLE_VIRTUAL int getEuDebugSysFsEnable();
|
2019-12-24 12:20:23 +01:00
|
|
|
|
2021-05-25 18:42:36 +02:00
|
|
|
PhysicalDevicePciBusInfo getPciBusInfo() const override;
|
2022-02-04 16:03:36 +00:00
|
|
|
bool isGpuHangDetected(OsContext &osContext) override;
|
2024-02-26 09:53:24 +00:00
|
|
|
MOCKABLE_VIRTUAL bool checkResetStatus(OsContext &osContext);
|
2020-11-05 15:40:03 +03:00
|
|
|
|
2020-02-10 08:05:32 -08:00
|
|
|
bool areNonPersistentContextsSupported() const { return nonPersistentContextsSupported; }
|
|
|
|
|
void checkNonPersistentContextsSupport();
|
2019-12-24 12:20:23 +01:00
|
|
|
void setNonPersistentContext(uint32_t drmContextId);
|
2022-07-25 11:50:32 +00:00
|
|
|
bool isPerContextVMRequired() const {
|
2020-07-15 08:07:53 +02:00
|
|
|
return requirePerContextVM;
|
|
|
|
|
}
|
2020-11-23 14:31:20 +00:00
|
|
|
void setPerContextVMRequired(bool required) {
|
|
|
|
|
requirePerContextVM = required;
|
|
|
|
|
}
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2021-01-25 20:43:48 +00:00
|
|
|
void checkContextDebugSupport();
|
|
|
|
|
bool isContextDebugSupported() { return contextDebugSupported; }
|
|
|
|
|
MOCKABLE_VIRTUAL void setContextDebugFlag(uint32_t drmContextId);
|
|
|
|
|
|
2021-09-09 21:16:11 +00:00
|
|
|
void setUnrecoverableContext(uint32_t drmContextId);
|
|
|
|
|
|
2021-02-05 15:27:21 +00:00
|
|
|
void setDirectSubmissionActive(bool value) { this->directSubmissionActive = value; }
|
2021-11-18 21:36:55 +00:00
|
|
|
bool isDirectSubmissionActive() const { return this->directSubmissionActive; }
|
2025-01-24 03:59:30 +00:00
|
|
|
MOCKABLE_VIRTUAL void setSharedSystemAllocEnable(bool value) { this->sharedSystemAllocEnable = value; }
|
|
|
|
|
MOCKABLE_VIRTUAL bool isSharedSystemAllocEnabled() const { return this->sharedSystemAllocEnable; }
|
2025-05-16 18:59:54 +00:00
|
|
|
void adjustSharedSystemMemCapabilities();
|
2021-11-18 21:36:55 +00:00
|
|
|
|
2022-09-20 07:07:59 +00:00
|
|
|
MOCKABLE_VIRTUAL bool isSetPairAvailable();
|
|
|
|
|
MOCKABLE_VIRTUAL bool getSetPairAvailable() { return setPairAvailable; }
|
2023-03-08 04:06:00 +00:00
|
|
|
MOCKABLE_VIRTUAL bool isChunkingAvailable();
|
|
|
|
|
MOCKABLE_VIRTUAL bool getChunkingAvailable() { return chunkingAvailable; }
|
2023-07-05 21:41:17 +00:00
|
|
|
MOCKABLE_VIRTUAL uint32_t getChunkingMode() { return chunkingMode; }
|
|
|
|
|
uint32_t getMinimalSizeForChunking() { return minimalChunkingSize; }
|
2022-09-20 07:07:59 +00:00
|
|
|
|
2023-04-17 13:56:47 +00:00
|
|
|
MOCKABLE_VIRTUAL bool useVMBindImmediate() const;
|
2021-02-05 15:27:21 +00:00
|
|
|
|
2020-11-23 14:31:20 +00:00
|
|
|
MOCKABLE_VIRTUAL bool isVmBindAvailable();
|
2020-09-14 13:28:47 +02:00
|
|
|
MOCKABLE_VIRTUAL bool registerResourceClasses();
|
2025-03-12 22:47:22 +00:00
|
|
|
MOCKABLE_VIRTUAL void setPageFaultSupported(bool value) { this->pageFaultSupported = value; }
|
2021-11-11 22:11:38 +00:00
|
|
|
MOCKABLE_VIRTUAL void queryPageFaultSupport();
|
2023-01-27 14:09:11 +00:00
|
|
|
bool hasPageFaultSupport() const;
|
2023-05-17 00:17:32 +00:00
|
|
|
bool hasKmdMigrationSupport() const;
|
2024-05-14 14:03:52 +00:00
|
|
|
bool checkToDisableScratchPage() { return disableScratch; }
|
|
|
|
|
unsigned int getGpuFaultCheckThreshold() const { return gpuFaultCheckThreshold; }
|
|
|
|
|
void configureScratchPagePolicy();
|
|
|
|
|
void configureGpuFaultCheckThreshold();
|
2021-11-02 07:54:20 +00:00
|
|
|
|
2024-05-07 16:58:28 +00:00
|
|
|
bool checkGpuPageFaultRequired() {
|
|
|
|
|
return (checkToDisableScratchPage() && getGpuFaultCheckThreshold() != 0);
|
|
|
|
|
}
|
2024-01-09 13:39:18 +00:00
|
|
|
MOCKABLE_VIRTUAL bool resourceRegistrationEnabled();
|
2022-05-09 15:52:12 +00:00
|
|
|
MOCKABLE_VIRTUAL uint32_t registerResource(DrmResourceClass classType, const void *data, size_t size);
|
2020-09-14 13:28:47 +02:00
|
|
|
MOCKABLE_VIRTUAL void unregisterResource(uint32_t handle);
|
2020-10-26 14:48:20 +01:00
|
|
|
MOCKABLE_VIRTUAL uint32_t registerIsaCookie(uint32_t isaHandle);
|
2020-09-14 13:28:47 +02:00
|
|
|
|
2021-02-23 17:57:27 +00:00
|
|
|
MOCKABLE_VIRTUAL bool isDebugAttachAvailable();
|
|
|
|
|
|
2021-05-21 01:17:57 +02:00
|
|
|
void setGmmInputArgs(void *args) override;
|
|
|
|
|
|
2020-11-24 16:00:33 +01:00
|
|
|
SystemInfo *getSystemInfo() const {
|
|
|
|
|
return systemInfo.get();
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-13 17:01:04 +00:00
|
|
|
CacheInfo *getCacheInfo() const {
|
|
|
|
|
return cacheInfo.get();
|
2021-01-29 22:23:06 +00:00
|
|
|
}
|
|
|
|
|
|
2019-04-30 13:09:49 +02:00
|
|
|
MemoryInfo *getMemoryInfo() const {
|
2019-04-10 14:32:41 +02:00
|
|
|
return memoryInfo.get();
|
|
|
|
|
}
|
2020-06-05 15:18:28 +02:00
|
|
|
|
2020-08-24 13:08:59 -04:00
|
|
|
EngineInfo *getEngineInfo() const {
|
|
|
|
|
return engineInfo.get();
|
|
|
|
|
}
|
2021-03-31 11:24:22 +05:30
|
|
|
|
2022-01-21 12:39:11 +00:00
|
|
|
IoctlHelper *getIoctlHelper() const {
|
|
|
|
|
return ioctlHelper.get();
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-25 11:50:32 +00:00
|
|
|
const RootDeviceEnvironment &getRootDeviceEnvironment() const {
|
2020-07-21 17:24:26 +02:00
|
|
|
return rootDeviceEnvironment;
|
|
|
|
|
}
|
2023-10-18 10:00:43 +02:00
|
|
|
const HardwareInfo *getHardwareInfo() const override;
|
2022-05-19 17:22:41 +00:00
|
|
|
static bool isDrmSupported(int fileDescriptor);
|
2020-02-07 14:32:02 +01:00
|
|
|
|
2021-10-21 12:37:31 +00:00
|
|
|
static Drm *create(std::unique_ptr<HwDeviceIdDrm> &&hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment);
|
2020-09-17 14:56:32 +02:00
|
|
|
static void overrideBindSupport(bool &useVmBind);
|
2024-10-14 16:19:25 +00:00
|
|
|
std::string getPciPath() { return hwDeviceId->getPciPath(); }
|
|
|
|
|
std::string getDeviceNode() { return hwDeviceId->getDeviceNode(); }
|
2020-02-11 17:48:40 +01:00
|
|
|
|
2025-02-05 06:40:13 +00:00
|
|
|
std::pair<uint64_t, uint64_t> getFenceAddressAndValToWait(uint32_t vmHandleId, bool isLocked);
|
2021-02-05 15:27:21 +00:00
|
|
|
void waitForBind(uint32_t vmHandleId);
|
2023-04-17 13:56:47 +00:00
|
|
|
uint64_t getNextFenceVal(uint32_t vmHandleId) { return fenceVal[vmHandleId] + 1; }
|
|
|
|
|
void incFenceVal(uint32_t vmHandleId) { fenceVal[vmHandleId]++; }
|
2021-02-05 15:27:21 +00:00
|
|
|
uint64_t *getFenceAddr(uint32_t vmHandleId) { return &pagingFence[vmHandleId]; }
|
|
|
|
|
|
2021-06-15 11:31:12 +00:00
|
|
|
int waitHandle(uint32_t waitHandle, int64_t timeout);
|
2021-06-04 12:23:20 +00:00
|
|
|
enum class ValueWidth : uint32_t {
|
2023-12-19 10:42:58 +00:00
|
|
|
u8,
|
|
|
|
|
u16,
|
|
|
|
|
u32,
|
|
|
|
|
u64
|
2021-06-04 12:23:20 +00:00
|
|
|
};
|
2024-05-07 11:47:34 +00:00
|
|
|
MOCKABLE_VIRTUAL int waitUserFence(uint32_t ctxId, uint64_t address, uint64_t value, ValueWidth dataWidth, int64_t timeout, uint16_t flags, bool userInterrupt,
|
|
|
|
|
uint32_t externalInterruptId, GraphicsAllocation *allocForInterruptWait);
|
2021-06-04 12:23:20 +00:00
|
|
|
|
2024-05-07 16:58:28 +00:00
|
|
|
int waitOnUserFences(OsContextLinux &osContext, uint64_t address, uint64_t value, uint32_t numActiveTiles, int64_t timeout, uint32_t postSyncOffset, bool userInterrupt,
|
2024-05-07 11:47:34 +00:00
|
|
|
uint32_t externalInterruptId, GraphicsAllocation *allocForInterruptWait);
|
2022-04-25 11:49:22 +00:00
|
|
|
|
2023-01-17 14:26:25 +00:00
|
|
|
void setNewResourceBoundToVM(BufferObject *bo, uint32_t vmHandleId);
|
2021-04-14 14:40:23 +00:00
|
|
|
|
2021-05-07 15:29:28 +00:00
|
|
|
const std::vector<int> &getSliceMappings(uint32_t deviceIndex);
|
|
|
|
|
|
2021-05-27 19:44:47 +02:00
|
|
|
static std::vector<std::unique_ptr<HwDeviceId>> discoverDevices(ExecutionEnvironment &executionEnvironment);
|
2021-10-11 15:34:03 +00:00
|
|
|
static std::vector<std::unique_ptr<HwDeviceId>> discoverDevice(ExecutionEnvironment &executionEnvironment, std::string &osPciPath);
|
|
|
|
|
static std::vector<std::unique_ptr<HwDeviceId>> discoverDevices(ExecutionEnvironment &executionEnvironment, std::string &osPciPath);
|
2021-05-27 19:44:47 +02:00
|
|
|
|
2022-09-01 15:54:57 +00:00
|
|
|
[[nodiscard]] std::unique_lock<std::mutex> lockBindFenceMutex();
|
2021-08-09 14:33:44 +00:00
|
|
|
|
2021-10-06 01:57:55 +00:00
|
|
|
void setPciDomain(uint32_t domain) {
|
|
|
|
|
pciDomain = domain;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-02 14:26:33 +00:00
|
|
|
MOCKABLE_VIRTUAL std::vector<uint64_t> getMemoryRegions();
|
2021-10-06 01:57:55 +00:00
|
|
|
|
2022-01-20 18:13:07 +00:00
|
|
|
MOCKABLE_VIRTUAL bool completionFenceSupport();
|
2022-01-19 18:14:10 +00:00
|
|
|
|
2022-07-22 12:07:36 +00:00
|
|
|
MOCKABLE_VIRTUAL uint32_t notifyFirstCommandQueueCreated(const void *data, size_t size);
|
2022-02-10 11:13:59 +00:00
|
|
|
MOCKABLE_VIRTUAL void notifyLastCommandQueueDestroyed(uint32_t handle);
|
|
|
|
|
|
2023-10-12 14:06:59 +00:00
|
|
|
uint64_t getPatIndex(Gmm *gmm, AllocationType allocationType, CacheRegion cacheRegion, CachePolicy cachePolicy, bool closEnabled, bool isSystemMemory) const;
|
2022-05-04 13:59:12 +00:00
|
|
|
bool isVmBindPatIndexProgrammingSupported() const { return vmBindPatIndexProgrammingSupported; }
|
2022-06-30 08:04:45 +00:00
|
|
|
MOCKABLE_VIRTUAL bool getDeviceMemoryMaxClockRateInMhz(uint32_t tileId, uint32_t &clkRate);
|
|
|
|
|
MOCKABLE_VIRTUAL bool getDeviceMemoryPhysicalSizeInBytes(uint32_t tileId, uint64_t &physicalSize);
|
2022-07-19 17:13:51 +00:00
|
|
|
void cleanup() override;
|
2022-10-25 15:44:56 +00:00
|
|
|
bool readSysFsAsString(const std::string &relativeFilePath, std::string &readString);
|
2022-10-25 07:07:49 +00:00
|
|
|
MOCKABLE_VIRTUAL std::string getSysFsPciPath();
|
2025-03-07 13:45:49 +00:00
|
|
|
MOCKABLE_VIRTUAL std::string getSysFsPciPathBaseName();
|
2023-03-01 09:29:12 +00:00
|
|
|
std::unique_ptr<HwDeviceIdDrm> &getHwDeviceId() { return hwDeviceId; }
|
2023-10-02 14:26:33 +00:00
|
|
|
|
|
|
|
|
template <typename DataType>
|
|
|
|
|
std::vector<DataType> query(uint32_t queryId, uint32_t queryItemFlags);
|
2023-07-09 13:27:58 +00:00
|
|
|
static std::string getDrmVersion(int fileDescriptor);
|
2025-01-31 15:26:12 +00:00
|
|
|
MOCKABLE_VIRTUAL uint32_t getAggregatedProcessCount() const;
|
2025-06-20 09:32:34 +00:00
|
|
|
uint32_t getVmIdForContext(OsContext &osContext, uint32_t vmHandleId) const;
|
2022-04-19 19:24:19 +00:00
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
protected:
|
2021-10-21 12:37:31 +00:00
|
|
|
Drm(std::unique_ptr<HwDeviceIdDrm> &&hwDeviceIdIn, RootDeviceEnvironment &rootDeviceEnvironment);
|
2021-05-31 16:58:10 +00:00
|
|
|
|
2024-05-07 16:58:28 +00:00
|
|
|
int waitOnUserFencesImpl(const OsContextLinux &osContext, uint64_t address, uint64_t value, uint32_t numActiveTiles, int64_t timeout, uint32_t postSyncOffset, bool userInterrupt,
|
|
|
|
|
uint32_t externalInterruptId, GraphicsAllocation *allocForInterruptWait);
|
|
|
|
|
|
2022-05-19 12:30:26 +00:00
|
|
|
int getQueueSliceCount(GemContextParamSseu *sseu);
|
2020-09-08 17:33:33 +02:00
|
|
|
std::string generateUUID();
|
2020-12-11 13:28:22 -08:00
|
|
|
std::string generateElfUUID(const void *data);
|
2021-04-21 13:52:11 +00:00
|
|
|
void printIoctlStatistics();
|
2022-01-28 21:00:05 +00:00
|
|
|
void setupIoctlHelper(const PRODUCT_FAMILY productFamily);
|
2022-05-04 13:59:12 +00:00
|
|
|
void queryAndSetVmBindPatIndexProgrammingSupport();
|
2022-06-08 12:43:51 +00:00
|
|
|
bool queryDeviceIdAndRevision();
|
2024-03-28 08:46:55 +00:00
|
|
|
static uint64_t alignUpGttSize(uint64_t inputGttSize);
|
2021-04-21 13:52:11 +00:00
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
#pragma pack(1)
|
|
|
|
|
struct PCIConfig {
|
2023-04-26 10:13:07 +00:00
|
|
|
uint16_t vendorID;
|
|
|
|
|
uint16_t deviceID;
|
|
|
|
|
uint16_t command;
|
|
|
|
|
uint16_t status;
|
|
|
|
|
uint8_t revision;
|
|
|
|
|
uint8_t progIF;
|
|
|
|
|
uint8_t subclass;
|
|
|
|
|
uint8_t classCode;
|
2017-12-21 00:45:38 +01:00
|
|
|
uint8_t cacheLineSize;
|
2023-04-26 10:13:07 +00:00
|
|
|
uint8_t latencyTimer;
|
|
|
|
|
uint8_t headerType;
|
|
|
|
|
uint8_t bist;
|
|
|
|
|
uint32_t bar0[6];
|
|
|
|
|
uint32_t cardbusCISPointer;
|
|
|
|
|
uint16_t subsystemVendorID;
|
|
|
|
|
uint16_t subsystemDeviceID;
|
|
|
|
|
uint32_t rom;
|
|
|
|
|
uint8_t capabilities;
|
|
|
|
|
uint8_t reserved[7];
|
|
|
|
|
uint8_t interruptLine;
|
|
|
|
|
uint8_t interruptPIN;
|
|
|
|
|
uint8_t minGrant;
|
|
|
|
|
uint8_t maxLatency;
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
|
|
|
|
#pragma pack()
|
2021-05-31 16:58:10 +00:00
|
|
|
|
2022-05-19 12:30:26 +00:00
|
|
|
GemContextParamSseu sseu{};
|
2021-05-31 16:58:10 +00:00
|
|
|
ADAPTER_BDF adapterBDF{};
|
2021-10-06 01:57:55 +00:00
|
|
|
uint32_t pciDomain = 0;
|
2021-05-31 16:58:10 +00:00
|
|
|
|
2021-08-19 15:26:34 +00:00
|
|
|
struct IoctlStatisticsEntry {
|
|
|
|
|
long long totalTime = 0;
|
|
|
|
|
uint64_t count = 0;
|
|
|
|
|
long long minTime = std::numeric_limits<long long>::max();
|
|
|
|
|
long long maxTime = 0;
|
|
|
|
|
};
|
2022-05-25 17:05:52 +00:00
|
|
|
std::unordered_map<DrmIoctl, IoctlStatisticsEntry> ioctlStatistics;
|
2021-05-31 16:58:10 +00:00
|
|
|
|
2021-08-09 14:33:44 +00:00
|
|
|
std::mutex bindFenceMutex;
|
2021-05-31 16:58:10 +00:00
|
|
|
std::array<uint64_t, EngineLimits::maxHandleCount> pagingFence;
|
|
|
|
|
std::array<uint64_t, EngineLimits::maxHandleCount> fenceVal;
|
|
|
|
|
std::vector<uint32_t> virtualMemoryIds;
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<HwDeviceIdDrm> hwDeviceId;
|
2022-01-21 12:39:11 +00:00
|
|
|
std::unique_ptr<IoctlHelper> ioctlHelper;
|
2021-05-31 16:58:10 +00:00
|
|
|
std::unique_ptr<SystemInfo> systemInfo;
|
2025-02-13 17:01:04 +00:00
|
|
|
std::unique_ptr<CacheInfo> cacheInfo;
|
2021-05-31 16:58:10 +00:00
|
|
|
std::unique_ptr<EngineInfo> engineInfo;
|
|
|
|
|
std::unique_ptr<MemoryInfo> memoryInfo;
|
|
|
|
|
|
|
|
|
|
std::once_flag checkBindOnce;
|
2022-09-30 10:55:43 -07:00
|
|
|
std::once_flag checkSetPairOnce;
|
2023-03-08 04:06:00 +00:00
|
|
|
std::once_flag checkChunkingOnce;
|
2022-01-20 18:13:07 +00:00
|
|
|
std::once_flag checkCompletionFenceOnce;
|
2021-05-31 16:58:10 +00:00
|
|
|
|
|
|
|
|
RootDeviceEnvironment &rootDeviceEnvironment;
|
|
|
|
|
|
|
|
|
|
bool sliceCountChangeSupported = false;
|
|
|
|
|
bool preemptionSupported = false;
|
|
|
|
|
bool nonPersistentContextsSupported = false;
|
|
|
|
|
bool requirePerContextVM = false;
|
|
|
|
|
bool bindAvailable = false;
|
|
|
|
|
bool directSubmissionActive = false;
|
2025-01-24 03:59:30 +00:00
|
|
|
bool sharedSystemAllocEnable = false;
|
2022-09-20 07:07:59 +00:00
|
|
|
bool setPairAvailable = false;
|
2023-03-08 04:06:00 +00:00
|
|
|
bool chunkingAvailable = false;
|
2023-07-05 21:41:17 +00:00
|
|
|
uint32_t chunkingMode = 0;
|
2023-07-10 18:22:39 +00:00
|
|
|
uint32_t minimalChunkingSize = MemoryConstants::pageSize2M;
|
2021-05-31 16:58:10 +00:00
|
|
|
bool contextDebugSupported = false;
|
2021-11-02 07:54:20 +00:00
|
|
|
bool pageFaultSupported = false;
|
2022-01-19 18:14:10 +00:00
|
|
|
bool completionFenceSupported = false;
|
2022-05-04 13:59:12 +00:00
|
|
|
bool vmBindPatIndexProgrammingSupported = false;
|
2024-04-08 18:37:35 +00:00
|
|
|
bool disableScratch = false;
|
2024-05-14 14:03:52 +00:00
|
|
|
uint32_t gpuFaultCheckThreshold = 10u;
|
2024-02-26 09:53:24 +00:00
|
|
|
|
2024-03-15 07:52:00 +00:00
|
|
|
std::atomic<uint32_t> gpuFaultCheckCounter{0u};
|
2021-05-31 16:58:10 +00:00
|
|
|
|
2024-07-25 13:49:47 +00:00
|
|
|
bool memoryInfoQueried = false;
|
2024-07-25 15:08:16 +00:00
|
|
|
bool engineInfoQueried = false;
|
2024-07-26 11:59:53 +00:00
|
|
|
bool systemInfoQueried = false;
|
2024-07-26 12:53:49 +00:00
|
|
|
bool topologyQueried = false;
|
2024-07-25 13:49:47 +00:00
|
|
|
|
2018-03-12 12:03:20 +01:00
|
|
|
private:
|
2022-06-06 15:48:31 +00:00
|
|
|
int getParamIoctl(DrmParam param, int *dstValue);
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|