mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
Call ioctl to obtain file handle from prime bo
Related-To: NEO-3252 Change-Id: I8d976ae29875db83dd75802e0309cb4438d1332b Signed-off-by: Mrozek, Michal <michal.mrozek@intel.com>
This commit is contained in:
@@ -100,6 +100,7 @@ DECLARE_DEBUG_VARIABLE(bool, EnableExtendedVaFormats, false, "Enable more format
|
||||
DECLARE_DEBUG_VARIABLE(bool, AddClGlSharing, false, "Add cl-gl extension")
|
||||
DECLARE_DEBUG_VARIABLE(bool, EnablePassInlineData, false, "Enable passing of inline data")
|
||||
DECLARE_DEBUG_VARIABLE(bool, EnableFormatQuery, false, "Enable sharing format querying")
|
||||
DECLARE_DEBUG_VARIABLE(bool, AllowOpenFdOperations, false, "When enabled driver is allowed to call DRM_IOCTL_PRIME_HANDLE_TO_FD.")
|
||||
DECLARE_DEBUG_VARIABLE(bool, EnableBlitterOperationsForReadWriteBuffers, false, "Use Blitter engine for Read/Write Buffers operations")
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, EnableCacheFlushAfterWalker, 0, "-1: platform behavior, 0: disabled, 1: enabled. Adds dedicated cache flush command after WALKER command when surfaces used by kernel require to flush the cache")
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, EnableLocalMemory, -1, "-1: default behavior, 0: disabled, 1: enabled, Allows allocating graphics memory in Local Memory")
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "runtime/os_interface/linux/drm_allocation.h"
|
||||
|
||||
#include "runtime/os_interface/linux/drm_buffer_object.h"
|
||||
#include "runtime/os_interface/linux/drm_memory_manager.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
@@ -20,5 +21,12 @@ std::string DrmAllocation::getAllocationInfoString() const {
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
uint64_t DrmAllocation::peekInternalHandle() { return static_cast<uint64_t>(getBO()->peekHandle()); }
|
||||
uint64_t DrmAllocation::peekInternalHandle(MemoryManager *memoryManager) {
|
||||
auto drmMemoryManager = static_cast<DrmMemoryManager *>(memoryManager);
|
||||
if (DebugManager.flags.AllowOpenFdOperations.get()) {
|
||||
return static_cast<uint64_t>(drmMemoryManager->obtainFdFromHandle(getBO()->peekHandle()));
|
||||
} else {
|
||||
return 0llu;
|
||||
}
|
||||
}
|
||||
} // namespace NEO
|
||||
|
||||
@@ -35,7 +35,7 @@ class DrmAllocation : public GraphicsAllocation {
|
||||
}
|
||||
return this->bo;
|
||||
}
|
||||
uint64_t peekInternalHandle() override;
|
||||
uint64_t peekInternalHandle(MemoryManager *memoryManager) override;
|
||||
|
||||
protected:
|
||||
BufferObject *bo;
|
||||
|
||||
@@ -768,4 +768,14 @@ void *DrmMemoryManager::reserveCpuAddressRange(size_t size) {
|
||||
void DrmMemoryManager::releaseReservedCpuAddressRange(void *reserved, size_t size) {
|
||||
munmapFunction(reserved, size);
|
||||
}
|
||||
int DrmMemoryManager::obtainFdFromHandle(int boHandle) {
|
||||
drm_prime_handle openFd = {0, 0, 0};
|
||||
|
||||
openFd.flags = DRM_CLOEXEC | DRM_RDWR;
|
||||
openFd.handle = boHandle;
|
||||
|
||||
drm->ioctl(DRM_IOCTL_PRIME_HANDLE_TO_FD, &openFd);
|
||||
|
||||
return openFd.fd;
|
||||
}
|
||||
} // namespace NEO
|
||||
|
||||
@@ -57,6 +57,8 @@ class DrmMemoryManager : public MemoryManager {
|
||||
void *reserveCpuAddressRange(size_t size) override;
|
||||
void releaseReservedCpuAddressRange(void *reserved, size_t size) override;
|
||||
|
||||
int obtainFdFromHandle(int boHandle);
|
||||
|
||||
protected:
|
||||
BufferObject *findAndReferenceSharedBufferObject(int boHandle);
|
||||
BufferObject *createSharedBufferObject(int boHandle, size_t size, bool requireSpecificBitness);
|
||||
|
||||
Reference in New Issue
Block a user