2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2025-01-31 19:20:34 +08:00
|
|
|
* Copyright (C) 2018-2025 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
|
2024-09-23 20:46:37 +08:00
|
|
|
#include "shared/source/command_stream/submission_status.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/memory_manager/memory_manager.h"
|
2023-02-01 23:58:22 +08:00
|
|
|
#include "shared/source/os_interface/linux/drm_buffer_object.h"
|
2024-10-04 07:10:54 +08:00
|
|
|
#include "shared/source/os_interface/os_memory.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#include <map>
|
|
|
|
#include <sys/mman.h>
|
2022-07-27 00:39:17 +08:00
|
|
|
#include <unistd.h>
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
class BufferObject;
|
|
|
|
class Drm;
|
2022-07-27 00:39:17 +08:00
|
|
|
class DrmGemCloseWorker;
|
|
|
|
class DrmAllocation;
|
2023-04-26 18:36:25 +08:00
|
|
|
class OsContextLinux;
|
2023-09-21 06:34:19 +08:00
|
|
|
enum class AtomicAccessMode : uint32_t;
|
2022-07-27 00:39:17 +08:00
|
|
|
|
2023-12-19 20:39:07 +08:00
|
|
|
enum class GemCloseWorkerMode;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2024-09-10 08:41:25 +08:00
|
|
|
struct BoHandleDeviceIndexPairComparer {
|
|
|
|
bool operator()(std::pair<int, uint32_t> const &lhs, std::pair<int, uint32_t> const &rhs) const {
|
|
|
|
return (lhs.first < rhs.first) || (lhs.second < rhs.second);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
class DrmMemoryManager : public MemoryManager {
|
|
|
|
public:
|
2023-12-19 20:39:07 +08:00
|
|
|
DrmMemoryManager(GemCloseWorkerMode mode,
|
2019-03-12 06:06:30 +08:00
|
|
|
bool forcePinAllowed,
|
|
|
|
bool validateHostPtrMemory,
|
|
|
|
ExecutionEnvironment &executionEnvironment);
|
2017-12-21 07:45:38 +08:00
|
|
|
~DrmMemoryManager() override;
|
|
|
|
|
2023-12-19 20:39:07 +08:00
|
|
|
void initialize(GemCloseWorkerMode mode);
|
2018-05-08 16:00:23 +08:00
|
|
|
void addAllocationToHostPtrManager(GraphicsAllocation *gfxAllocation) override;
|
|
|
|
void removeAllocationFromHostPtrManager(GraphicsAllocation *gfxAllocation) override;
|
2017-12-21 07:45:38 +08:00
|
|
|
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) override;
|
2022-03-02 11:43:59 +08:00
|
|
|
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation, bool isImportedAllocation) override;
|
2019-03-04 21:50:26 +08:00
|
|
|
void handleFenceCompletion(GraphicsAllocation *allocation) override;
|
2020-10-21 16:50:53 +08:00
|
|
|
GraphicsAllocation *createGraphicsAllocationFromExistingStorage(AllocationProperties &properties, void *ptr, MultiGraphicsAllocation &multiGraphicsAllocation) override;
|
2023-05-04 09:40:52 +08:00
|
|
|
GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector<osHandle> &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override;
|
2024-06-07 00:56:16 +08:00
|
|
|
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(const OsHandleData &osHandleData, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override;
|
2021-03-18 23:16:58 +08:00
|
|
|
void closeSharedHandle(GraphicsAllocation *gfxAllocation) override;
|
2023-04-07 10:57:37 +08:00
|
|
|
void closeInternalHandle(uint64_t &handle, uint32_t handleId, GraphicsAllocation *graphicsAllocation) override;
|
2022-06-08 00:30:59 +08:00
|
|
|
|
2020-01-07 14:42:40 +08:00
|
|
|
uint64_t getSystemSharedMemory(uint32_t rootDeviceIndex) override;
|
2020-10-30 17:27:48 +08:00
|
|
|
uint64_t getLocalMemorySize(uint32_t rootDeviceIndex, uint32_t deviceBitfield) override;
|
2021-07-27 22:24:20 +08:00
|
|
|
double getPercentOfGlobalMemoryAvailable(uint32_t rootDeviceIndex) override;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-01-07 14:42:40 +08:00
|
|
|
AllocationStatus populateOsHandles(OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override;
|
2019-11-15 16:59:48 +08:00
|
|
|
void cleanOsHandles(OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override;
|
2020-02-12 00:48:40 +08:00
|
|
|
void commonCleanup() override;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
// drm/i915 ioctl wrappers
|
2019-08-27 21:33:58 +08:00
|
|
|
MOCKABLE_VIRTUAL uint32_t unreference(BufferObject *bo, bool synchronousDestroy);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2023-02-01 23:58:22 +08:00
|
|
|
void registerIpcExportedAllocation(GraphicsAllocation *graphicsAllocation) override;
|
|
|
|
|
2018-02-28 19:09:48 +08:00
|
|
|
bool isValidateHostMemoryEnabled() const {
|
|
|
|
return validateHostPtrMemory;
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2025-04-23 22:40:09 +08:00
|
|
|
static bool isGemCloseWorkerSupported();
|
2019-02-25 21:11:34 +08:00
|
|
|
DrmGemCloseWorker *peekGemCloseWorker() const { return this->gemCloseWorker.get(); }
|
2020-10-07 21:32:03 +08:00
|
|
|
bool copyMemoryToAllocation(GraphicsAllocation *graphicsAllocation, size_t destinationOffset, const void *memoryToCopy, size_t sizeToCopy) override;
|
2021-10-21 19:16:19 +08:00
|
|
|
bool copyMemoryToAllocationBanks(GraphicsAllocation *graphicsAllocation, size_t destinationOffset, const void *memoryToCopy, size_t sizeToCopy, DeviceBitfield handleMask) override;
|
2018-05-11 15:57:59 +08:00
|
|
|
|
2021-05-24 14:14:30 +08:00
|
|
|
MOCKABLE_VIRTUAL int obtainFdFromHandle(int boHandle, uint32_t rootDeviceindex);
|
2024-12-17 20:00:36 +08:00
|
|
|
AddressRange reserveGpuAddress(const uint64_t requiredStartAddress, size_t size, const RootDeviceIndicesContainer &rootDeviceIndices, uint32_t *reservedOnRootDeviceIndex) override;
|
|
|
|
AddressRange reserveGpuAddressOnHeap(const uint64_t requiredStartAddress, size_t size, const RootDeviceIndicesContainer &rootDeviceIndices, uint32_t *reservedOnRootDeviceIndex, HeapIndex heap, size_t alignment) override;
|
2023-10-12 08:51:45 +08:00
|
|
|
size_t selectAlignmentAndHeap(size_t size, HeapIndex *heap) override;
|
2020-07-01 16:38:19 +08:00
|
|
|
void freeGpuAddress(AddressRange addressRange, uint32_t rootDeviceIndex) override;
|
2024-10-04 07:10:54 +08:00
|
|
|
AddressRange reserveCpuAddress(const uint64_t requiredStartAddress, size_t size) override;
|
|
|
|
void freeCpuAddress(AddressRange addressRange) override;
|
2023-04-26 18:36:25 +08:00
|
|
|
MOCKABLE_VIRTUAL BufferObject *createBufferObjectInMemoryRegion(uint32_t rootDeviceIndex, Gmm *gmm, AllocationType allocationType, uint64_t gpuAddress, size_t size,
|
2024-05-14 00:35:40 +08:00
|
|
|
DeviceBitfield memoryBanks, size_t maxOsContextCount, int32_t pairHandle, bool isSystemMemoryPool, bool isUsmHostAllocation);
|
2019-06-06 22:26:47 +08:00
|
|
|
|
2023-02-28 08:20:17 +08:00
|
|
|
bool hasPageFaultsEnabled(const Device &neoDevice) override;
|
2021-02-03 22:53:13 +08:00
|
|
|
bool isKmdMigrationAvailable(uint32_t rootDeviceIndex) override;
|
|
|
|
|
2021-10-11 17:27:26 +08:00
|
|
|
bool setMemAdvise(GraphicsAllocation *gfxAllocation, MemAdviseFlags flags, uint32_t rootDeviceIndex) override;
|
2025-02-14 06:26:10 +08:00
|
|
|
bool setSharedSystemMemAdvise(const void *ptr, const size_t size, MemAdvise memAdviseOp, uint32_t rootDeviceIndex) override;
|
2022-11-30 08:48:56 +08:00
|
|
|
bool setMemPrefetch(GraphicsAllocation *gfxAllocation, SubDeviceIdsVec &subDeviceIds, uint32_t rootDeviceIndex) override;
|
2025-03-13 06:47:22 +08:00
|
|
|
bool prefetchSharedSystemAlloc(const void *ptr, const size_t size, SubDeviceIdsVec &subDeviceIds, uint32_t rootDeviceIndex) override;
|
2023-09-21 06:34:19 +08:00
|
|
|
bool setAtomicAccess(GraphicsAllocation *gfxAllocation, size_t size, AtomicAccessMode mode, uint32_t rootDeviceIndex) override;
|
2022-09-01 23:54:57 +08:00
|
|
|
[[nodiscard]] std::unique_lock<std::mutex> acquireAllocLock();
|
2020-09-10 18:36:44 +08:00
|
|
|
std::vector<GraphicsAllocation *> &getSysMemAllocs();
|
|
|
|
std::vector<GraphicsAllocation *> &getLocalMemAllocs(uint32_t rootDeviceIndex);
|
2022-11-15 22:34:44 +08:00
|
|
|
AllocationStatus registerSysMemAlloc(GraphicsAllocation *allocation) override;
|
|
|
|
AllocationStatus registerLocalMemAlloc(GraphicsAllocation *allocation, uint32_t rootDeviceIndex) override;
|
2024-10-02 22:47:22 +08:00
|
|
|
MOCKABLE_VIRTUAL void unregisterAllocation(GraphicsAllocation *allocation);
|
2020-09-10 18:36:44 +08:00
|
|
|
|
2021-05-28 01:44:47 +08:00
|
|
|
static std::unique_ptr<MemoryManager> create(ExecutionEnvironment &executionEnvironment);
|
|
|
|
|
2024-01-16 22:15:07 +08:00
|
|
|
DrmAllocation *createUSMHostAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, void *mappedPtr, bool reuseSharedAllocation);
|
2021-10-07 15:26:03 +08:00
|
|
|
void releaseDeviceSpecificMemResources(uint32_t rootDeviceIndex) override;
|
|
|
|
void createDeviceSpecificMemResources(uint32_t rootDeviceIndex) override;
|
2024-12-12 20:38:40 +08:00
|
|
|
void releaseDeviceSpecificGfxPartition(uint32_t rootDeviceIndex) override;
|
|
|
|
bool reInitDeviceSpecificGfxPartition(uint32_t rootDeviceIndex) override;
|
2022-07-27 00:39:17 +08:00
|
|
|
bool allowIndirectAllocationsAsPack(uint32_t rootDeviceIndex) override;
|
2023-07-26 08:59:11 +08:00
|
|
|
Drm &getDrm(uint32_t rootDeviceIndex) const;
|
2023-12-04 04:04:30 +08:00
|
|
|
size_t getSizeOfChunk(size_t allocSize);
|
|
|
|
bool checkAllocationForChunking(size_t allocSize, size_t minSize, bool subDeviceEnabled, bool debugDisabled, bool modeEnabled, bool bufferEnabled);
|
2021-05-24 14:14:30 +08:00
|
|
|
|
2024-02-26 17:53:24 +08:00
|
|
|
MOCKABLE_VIRTUAL void checkUnexpectedGpuPageFault();
|
|
|
|
|
2024-06-04 00:23:41 +08:00
|
|
|
bool allocateInterrupt(uint32_t &outHandle, uint32_t rootDeviceIndex) override;
|
|
|
|
bool releaseInterrupt(uint32_t outHandle, uint32_t rootDeviceIndex) override;
|
|
|
|
|
2024-10-14 20:07:50 +08:00
|
|
|
bool createMediaContext(uint32_t rootDeviceIndex, void *controlSharedMemoryBuffer, uint32_t controlSharedMemoryBufferSize, void *controlBatchBuffer, uint32_t controlBatchBufferSize, void *&outDoorbell) override;
|
|
|
|
bool releaseMediaContext(uint32_t rootDeviceIndex, void *doorbellHandle) override;
|
2024-07-03 19:23:58 +08:00
|
|
|
|
2024-08-08 02:41:38 +08:00
|
|
|
uint32_t getNumMediaDecoders(uint32_t rootDeviceIndex) const override;
|
|
|
|
uint32_t getNumMediaEncoders(uint32_t rootDeviceIndex) const override;
|
|
|
|
|
2024-07-16 00:27:23 +08:00
|
|
|
bool isCompressionSupportedForShareable(bool isShareable) override;
|
2024-09-23 20:46:37 +08:00
|
|
|
MOCKABLE_VIRTUAL SubmissionStatus emitPinningRequestForBoContainer(BufferObject **bo, uint32_t boCount, uint32_t rootDeviceIndex) const;
|
2024-07-16 00:27:23 +08:00
|
|
|
|
2024-10-28 21:57:32 +08:00
|
|
|
void getExtraDeviceProperties(uint32_t rootDeviceIndex, uint32_t *moduleId, uint16_t *serverType) override;
|
|
|
|
|
2024-11-08 21:42:15 +08:00
|
|
|
MOCKABLE_VIRTUAL uint64_t acquireGpuRange(size_t &size, uint32_t rootDeviceIndex, HeapIndex heapIndex);
|
|
|
|
MOCKABLE_VIRTUAL void releaseGpuRange(void *address, size_t size, uint32_t rootDeviceIndex);
|
|
|
|
|
2025-03-04 21:40:44 +08:00
|
|
|
BufferObject *allocUserptr(uintptr_t address, size_t size, const AllocationType allocationType, uint32_t rootDeviceIndex);
|
2024-11-23 01:02:47 +08:00
|
|
|
size_t getUserptrAlignment();
|
2024-11-16 04:48:49 +08:00
|
|
|
|
2025-02-13 20:58:30 +08:00
|
|
|
void drainGemCloseWorker() const override;
|
2025-02-14 20:57:12 +08:00
|
|
|
void disableForcePin();
|
2025-02-13 20:58:30 +08:00
|
|
|
|
2024-11-08 21:42:15 +08:00
|
|
|
decltype(&mmap) mmapFunction = mmap;
|
|
|
|
decltype(&munmap) munmapFunction = munmap;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
protected:
|
2023-02-01 23:58:22 +08:00
|
|
|
void registerSharedBoHandleAllocation(DrmAllocation *drmAllocation);
|
2024-09-10 08:41:25 +08:00
|
|
|
BufferObjectHandleWrapper tryToGetBoHandleWrapperWithSharedOwnership(int boHandle, uint32_t rootDeviceIndex);
|
|
|
|
void eraseSharedBoHandleWrapper(int boHandle, uint32_t rootDeviceIndex);
|
2023-02-01 23:58:22 +08:00
|
|
|
|
2022-02-01 07:29:01 +08:00
|
|
|
MOCKABLE_VIRTUAL BufferObject *findAndReferenceSharedBufferObject(int boHandle, uint32_t rootDeviceIndex);
|
2017-12-21 07:45:38 +08:00
|
|
|
void eraseSharedBufferObject(BufferObject *bo);
|
|
|
|
void pushSharedBufferObject(BufferObject *bo);
|
2018-02-27 06:23:43 +08:00
|
|
|
bool setDomainCpu(GraphicsAllocation &graphicsAllocation, bool writeEnable);
|
2024-01-26 22:19:48 +08:00
|
|
|
MOCKABLE_VIRTUAL uint64_t acquireGpuRangeWithCustomAlignment(size_t &size, uint32_t rootDeviceIndex, HeapIndex heapIndex, size_t alignment);
|
2019-02-25 21:11:34 +08:00
|
|
|
void emitPinningRequest(BufferObject *bo, const AllocationData &allocationData) const;
|
2021-04-20 20:24:04 +08:00
|
|
|
uint32_t getDefaultDrmContextId(uint32_t rootDeviceIndex) const;
|
2023-04-26 18:36:25 +08:00
|
|
|
OsContextLinux *getDefaultOsContext(uint32_t rootDeviceIndex) const;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2024-05-15 18:39:00 +08:00
|
|
|
StorageInfo createStorageInfoFromProperties(const AllocationProperties &properties) override;
|
2022-07-27 00:39:17 +08:00
|
|
|
GraphicsAllocation *createGraphicsAllocation(OsHandleStorage &handleStorage, const AllocationData &allocationData) override;
|
|
|
|
GraphicsAllocation *allocateGraphicsMemoryForNonSvmHostPtr(const AllocationData &allocationData) override;
|
|
|
|
GraphicsAllocation *allocateGraphicsMemoryWithAlignment(const AllocationData &allocationData) override;
|
2021-05-05 02:17:30 +08:00
|
|
|
DrmAllocation *allocateGraphicsMemoryWithAlignmentImpl(const AllocationData &allocationData);
|
2020-10-05 15:57:50 +08:00
|
|
|
DrmAllocation *createAllocWithAlignmentFromUserptr(const AllocationData &allocationData, size_t size, size_t alignment, size_t alignedSVMSize, uint64_t gpuAddress);
|
2020-10-13 20:24:49 +08:00
|
|
|
DrmAllocation *createAllocWithAlignment(const AllocationData &allocationData, size_t size, size_t alignment, size_t alignedSize, uint64_t gpuAddress);
|
2021-05-05 02:17:30 +08:00
|
|
|
DrmAllocation *createMultiHostAllocation(const AllocationData &allocationData);
|
2020-10-05 15:57:50 +08:00
|
|
|
void obtainGpuAddress(const AllocationData &allocationData, BufferObject *bo, uint64_t gpuAddress);
|
2022-07-27 00:39:17 +08:00
|
|
|
GraphicsAllocation *allocateUSMHostGraphicsMemory(const AllocationData &allocationData) override;
|
|
|
|
GraphicsAllocation *allocateGraphicsMemoryWithHostPtr(const AllocationData &allocationData) override;
|
|
|
|
GraphicsAllocation *allocateGraphicsMemory64kb(const AllocationData &allocationData) override;
|
2021-08-11 18:36:04 +08:00
|
|
|
GraphicsAllocation *allocateMemoryByKMD(const AllocationData &allocationData) override;
|
2022-12-07 06:36:12 +08:00
|
|
|
GraphicsAllocation *allocatePhysicalDeviceMemory(const AllocationData &allocationData, AllocationStatus &status) override;
|
|
|
|
GraphicsAllocation *allocatePhysicalLocalDeviceMemory(const AllocationData &allocationData, AllocationStatus &status) override;
|
2024-09-12 11:01:48 +08:00
|
|
|
GraphicsAllocation *allocatePhysicalHostMemory(const AllocationData &allocationData, AllocationStatus &status) override;
|
|
|
|
bool mapPhysicalDeviceMemoryToVirtualMemory(GraphicsAllocation *physicalAllocation, uint64_t gpuRange, size_t bufferSize) override;
|
|
|
|
bool mapPhysicalHostMemoryToVirtualMemory(RootDeviceIndicesContainer &rootDeviceIndices, MultiGraphicsAllocation &multiGraphicsAllocation, GraphicsAllocation *physicalAllocation, uint64_t gpuRange, size_t bufferSize) override;
|
|
|
|
void unMapPhysicalDeviceMemoryFromVirtualMemory(GraphicsAllocation *physicalAllocation, uint64_t gpuRange, size_t bufferSize, OsContext *osContext, uint32_t rootDeviceIndex) override;
|
|
|
|
void unMapPhysicalHostMemoryFromVirtualMemory(MultiGraphicsAllocation &multiGraphicsAllocation, GraphicsAllocation *physicalAllocation, uint64_t gpuRange, size_t bufferSize) override;
|
2019-01-22 19:40:17 +08:00
|
|
|
GraphicsAllocation *allocateGraphicsMemoryForImageImpl(const AllocationData &allocationData, std::unique_ptr<Gmm> gmm) override;
|
2020-07-01 16:38:19 +08:00
|
|
|
GraphicsAllocation *allocateGraphicsMemoryWithGpuVa(const AllocationData &allocationData) override;
|
2020-10-22 20:13:44 +08:00
|
|
|
GraphicsAllocation *createSharedUnifiedMemoryAllocation(const AllocationData &allocationData);
|
2018-11-30 18:01:33 +08:00
|
|
|
|
2019-01-24 18:51:33 +08:00
|
|
|
void *lockResourceImpl(GraphicsAllocation &graphicsAllocation) override;
|
2022-06-07 01:43:28 +08:00
|
|
|
MOCKABLE_VIRTUAL void *lockBufferObject(BufferObject *bo);
|
|
|
|
MOCKABLE_VIRTUAL void unlockBufferObject(BufferObject *bo);
|
2019-01-24 18:51:33 +08:00
|
|
|
void unlockResourceImpl(GraphicsAllocation &graphicsAllocation) override;
|
2023-09-16 01:20:28 +08:00
|
|
|
GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) override;
|
2022-04-11 11:40:18 +08:00
|
|
|
void cleanupBeforeReturn(const AllocationData &allocationData, GfxPartition *gfxPartition, DrmAllocation *drmAllocation, GraphicsAllocation *graphicsAllocation, uint64_t &gpuAddress, size_t &sizeAllocated);
|
2019-02-27 04:12:26 +08:00
|
|
|
GraphicsAllocation *allocateGraphicsMemoryInDevicePool(const AllocationData &allocationData, AllocationStatus &status) override;
|
2023-03-08 12:06:00 +08:00
|
|
|
bool createDrmChunkedAllocation(Drm *drm, DrmAllocation *allocation, uint64_t boAddress, size_t boSize, size_t maxOsContextCount);
|
2025-01-31 19:20:34 +08:00
|
|
|
bool createDrmAllocation(Drm *drm, DrmAllocation *allocation, uint64_t gpuAddress, size_t maxOsContextCount, size_t preferredAlignment);
|
2020-10-09 16:48:37 +08:00
|
|
|
void registerAllocationInOs(GraphicsAllocation *allocation) override;
|
2022-01-20 02:14:10 +08:00
|
|
|
void waitOnCompletionFence(GraphicsAllocation *allocation);
|
2022-02-04 21:59:01 +08:00
|
|
|
bool allocationTypeForCompletionFence(AllocationType allocationType);
|
2022-11-15 22:34:44 +08:00
|
|
|
bool makeAllocationResident(GraphicsAllocation *allocation);
|
2019-01-24 18:51:33 +08:00
|
|
|
|
2023-03-28 17:13:07 +08:00
|
|
|
inline std::unique_ptr<Gmm> makeGmmIfSingleHandle(const AllocationData &allocationData, size_t sizeAligned);
|
|
|
|
inline std::unique_ptr<DrmAllocation> makeDrmAllocation(const AllocationData &allocationData, std::unique_ptr<Gmm> gmm, uint64_t gpuAddress, size_t sizeAligned);
|
2020-03-19 17:41:35 +08:00
|
|
|
uint32_t getRootDeviceIndex(const Drm *drm);
|
2021-10-07 15:26:03 +08:00
|
|
|
BufferObject *createRootDeviceBufferObject(uint32_t rootDeviceIndex);
|
|
|
|
void releaseBufferObject(uint32_t rootDeviceIndex);
|
2021-11-30 01:48:55 +08:00
|
|
|
bool retrieveMmapOffsetForBufferObject(uint32_t rootDeviceIndex, BufferObject &bo, uint64_t flags, uint64_t &offset);
|
2024-02-17 00:26:30 +08:00
|
|
|
BufferObject::BOType getBOTypeFromPatIndex(uint64_t patIndex, bool isPatIndexSupported) const;
|
2024-05-15 18:39:00 +08:00
|
|
|
void setLocalMemBanksCount(uint32_t rootDeviceIndex);
|
2025-04-02 02:09:02 +08:00
|
|
|
bool getLocalOnlyRequired(AllocationType allocationType, const ProductHelper &productHelper, const ReleaseHelper *releaseHelper, bool preferCompressed) const override;
|
2020-01-07 14:42:40 +08:00
|
|
|
|
2020-02-21 20:41:02 +08:00
|
|
|
std::vector<BufferObject *> pinBBs;
|
|
|
|
std::vector<void *> memoryForPinBBs;
|
2017-12-21 07:45:38 +08:00
|
|
|
size_t pinThreshold = 8 * 1024 * 1024;
|
2018-02-28 19:09:48 +08:00
|
|
|
bool forcePinEnabled = false;
|
2020-10-01 14:13:09 +08:00
|
|
|
const bool validateHostPtrMemory;
|
2017-12-21 07:45:38 +08:00
|
|
|
std::unique_ptr<DrmGemCloseWorker> gemCloseWorker;
|
2024-10-04 07:10:54 +08:00
|
|
|
std::unique_ptr<OSMemory> osMemory;
|
2017-12-21 07:45:38 +08:00
|
|
|
decltype(&close) closeFunction = close;
|
|
|
|
std::vector<BufferObject *> sharingBufferObjects;
|
2018-08-01 20:47:14 +08:00
|
|
|
std::mutex mtx;
|
2020-09-10 18:36:44 +08:00
|
|
|
|
2024-09-10 08:41:25 +08:00
|
|
|
std::map<std::pair<int, uint32_t>, BufferObjectHandleWrapper, BoHandleDeviceIndexPairComparer> sharedBoHandles;
|
2020-09-10 18:36:44 +08:00
|
|
|
std::vector<std::vector<GraphicsAllocation *>> localMemAllocs;
|
2024-05-15 18:39:00 +08:00
|
|
|
std::vector<size_t> localMemBanksCount;
|
2020-09-10 18:36:44 +08:00
|
|
|
std::vector<GraphicsAllocation *> sysMemAllocs;
|
|
|
|
std::mutex allocMutex;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|