mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-25 13:33:02 +08:00
refactor: add separate function to create IoctlHelperXe
unify ioctl helper xe logic Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
9903009889
commit
15d7a31148
@@ -6,13 +6,9 @@
|
||||
|
||||
set(NEO_CORE_OS_INTERFACE_LINUX_XE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/create_ioctl_helper_xe.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_version_xe.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ioctl_helper_xe.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}ioctl_helper_xe_string_value_getter.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}ioctl_helper_xe_vm_export.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}ioctl_helper_xe_context.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}ioctl_helper_xe_perf.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}ioctl_helper_xe_vm_bind_flag.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ioctl_helper_xe.h
|
||||
)
|
||||
|
||||
@@ -27,3 +23,4 @@ else()
|
||||
endif()
|
||||
|
||||
set_property(GLOBAL APPEND PROPERTY NEO_CORE_OS_INTERFACE_LINUX ${NEO_CORE_OS_INTERFACE_LINUX_XE})
|
||||
add_subdirectories()
|
||||
|
||||
@@ -8,9 +8,7 @@
|
||||
#include "shared/source/os_interface/linux/xe/ioctl_helper_xe.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
uint64_t IoctlHelperXe::getExtraFlagsForVmBind(bool bindCapture, bool bindImmediate, bool bindMakeResident, bool bindLock, bool readOnlyResource) {
|
||||
return 0;
|
||||
std::unique_ptr<IoctlHelperXe> IoctlHelperXe::create(Drm &drmArg) {
|
||||
return std::make_unique<IoctlHelperXe>(drmArg);
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
@@ -1453,4 +1453,116 @@ void IoctlHelperXe::registerBOBindHandle(Drm *drm, DrmAllocation *drmAllocation)
|
||||
}
|
||||
}
|
||||
|
||||
bool IoctlHelperXe::getFdFromVmExport(uint32_t vmId, uint32_t flags, int32_t *fd) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void IoctlHelperXe::setContextProperties(const OsContextLinux &osContext, void *extProperties, uint32_t &extIndexInOut) {
|
||||
|
||||
auto &ext = *reinterpret_cast<std::array<drm_xe_ext_set_property, maxContextSetProperties> *>(extProperties);
|
||||
|
||||
if (osContext.isLowPriority()) {
|
||||
ext[extIndexInOut].base.name = DRM_XE_EXEC_QUEUE_EXTENSION_SET_PROPERTY;
|
||||
ext[extIndexInOut].property = DRM_XE_EXEC_QUEUE_SET_PROPERTY_PRIORITY;
|
||||
ext[extIndexInOut].value = 0;
|
||||
if (extIndexInOut > 0) {
|
||||
ext[extIndexInOut - 1].base.next_extension = castToUint64(&ext[extIndexInOut]);
|
||||
}
|
||||
extIndexInOut++;
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t IoctlHelperXe::getExtraFlagsForVmBind(bool bindCapture, bool bindImmediate, bool bindMakeResident, bool bindLock, bool readOnlyResource) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool IoctlHelperXe::perfOpenEuStallStream(uint32_t euStallFdParameter, std::array<uint64_t, 12u> &properties, int32_t *stream) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IoctlHelperXe::perfDisableEuStallStream(int32_t *stream) {
|
||||
return false;
|
||||
}
|
||||
bool IoctlHelperXe::getEuStallProperties(std::array<uint64_t, 12u> &properties, uint64_t dssBufferSize, uint64_t samplingRate,
|
||||
uint64_t pollPeriod, uint64_t engineInstance, uint64_t notifyNReports) {
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int IoctlHelperXe::getIoctlRequestValue(DrmIoctl ioctlRequest) const {
|
||||
xeLog(" -> IoctlHelperXe::%s 0x%x\n", __FUNCTION__, ioctlRequest);
|
||||
switch (ioctlRequest) {
|
||||
case DrmIoctl::gemClose:
|
||||
RETURN_ME(DRM_IOCTL_GEM_CLOSE);
|
||||
case DrmIoctl::gemVmCreate:
|
||||
RETURN_ME(DRM_IOCTL_XE_VM_CREATE);
|
||||
case DrmIoctl::gemVmDestroy:
|
||||
RETURN_ME(DRM_IOCTL_XE_VM_DESTROY);
|
||||
case DrmIoctl::gemMmapOffset:
|
||||
RETURN_ME(DRM_IOCTL_XE_GEM_MMAP_OFFSET);
|
||||
case DrmIoctl::gemCreate:
|
||||
RETURN_ME(DRM_IOCTL_XE_GEM_CREATE);
|
||||
case DrmIoctl::gemExecbuffer2:
|
||||
RETURN_ME(DRM_IOCTL_XE_EXEC);
|
||||
case DrmIoctl::gemVmBind:
|
||||
RETURN_ME(DRM_IOCTL_XE_VM_BIND);
|
||||
case DrmIoctl::query:
|
||||
RETURN_ME(DRM_IOCTL_XE_DEVICE_QUERY);
|
||||
case DrmIoctl::gemContextCreateExt:
|
||||
RETURN_ME(DRM_IOCTL_XE_EXEC_QUEUE_CREATE);
|
||||
case DrmIoctl::gemContextDestroy:
|
||||
RETURN_ME(DRM_IOCTL_XE_EXEC_QUEUE_DESTROY);
|
||||
case DrmIoctl::gemWaitUserFence:
|
||||
RETURN_ME(DRM_IOCTL_XE_WAIT_USER_FENCE);
|
||||
case DrmIoctl::primeFdToHandle:
|
||||
RETURN_ME(DRM_IOCTL_PRIME_FD_TO_HANDLE);
|
||||
case DrmIoctl::primeHandleToFd:
|
||||
RETURN_ME(DRM_IOCTL_PRIME_HANDLE_TO_FD);
|
||||
case DrmIoctl::debuggerOpen:
|
||||
case DrmIoctl::metadataCreate:
|
||||
case DrmIoctl::metadataDestroy:
|
||||
return getIoctlRequestValueDebugger(ioctlRequest);
|
||||
default:
|
||||
UNRECOVERABLE_IF(true);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
std::string IoctlHelperXe::getIoctlString(DrmIoctl ioctlRequest) const {
|
||||
switch (ioctlRequest) {
|
||||
case DrmIoctl::gemClose:
|
||||
STRINGIFY_ME(DRM_IOCTL_GEM_CLOSE);
|
||||
case DrmIoctl::gemVmCreate:
|
||||
STRINGIFY_ME(DRM_IOCTL_XE_VM_CREATE);
|
||||
case DrmIoctl::gemVmDestroy:
|
||||
STRINGIFY_ME(DRM_IOCTL_XE_VM_DESTROY);
|
||||
case DrmIoctl::gemMmapOffset:
|
||||
STRINGIFY_ME(DRM_IOCTL_XE_GEM_MMAP_OFFSET);
|
||||
case DrmIoctl::gemCreate:
|
||||
STRINGIFY_ME(DRM_IOCTL_XE_GEM_CREATE);
|
||||
case DrmIoctl::gemExecbuffer2:
|
||||
STRINGIFY_ME(DRM_IOCTL_XE_EXEC);
|
||||
case DrmIoctl::gemVmBind:
|
||||
STRINGIFY_ME(DRM_IOCTL_XE_VM_BIND);
|
||||
case DrmIoctl::query:
|
||||
STRINGIFY_ME(DRM_IOCTL_XE_DEVICE_QUERY);
|
||||
case DrmIoctl::gemContextCreateExt:
|
||||
STRINGIFY_ME(DRM_IOCTL_XE_EXEC_QUEUE_CREATE);
|
||||
case DrmIoctl::gemContextDestroy:
|
||||
STRINGIFY_ME(DRM_IOCTL_XE_EXEC_QUEUE_DESTROY);
|
||||
case DrmIoctl::gemWaitUserFence:
|
||||
STRINGIFY_ME(DRM_IOCTL_XE_WAIT_USER_FENCE);
|
||||
case DrmIoctl::primeFdToHandle:
|
||||
STRINGIFY_ME(DRM_IOCTL_PRIME_FD_TO_HANDLE);
|
||||
case DrmIoctl::primeHandleToFd:
|
||||
STRINGIFY_ME(DRM_IOCTL_PRIME_HANDLE_TO_FD);
|
||||
case DrmIoctl::debuggerOpen:
|
||||
STRINGIFY_ME(DRM_IOCTL_XE_EUDEBUG_CONNECT);
|
||||
case DrmIoctl::metadataCreate:
|
||||
STRINGIFY_ME(DRM_IOCTL_XE_DEBUG_METADATA_CREATE);
|
||||
case DrmIoctl::metadataDestroy:
|
||||
STRINGIFY_ME(DRM_IOCTL_XE_DEBUG_METADATA_DESTROY);
|
||||
default:
|
||||
return "???";
|
||||
}
|
||||
}
|
||||
} // namespace NEO
|
||||
|
||||
@@ -32,7 +32,7 @@ struct BindInfo {
|
||||
class IoctlHelperXe : public IoctlHelper {
|
||||
public:
|
||||
using IoctlHelper::IoctlHelper;
|
||||
|
||||
static std::unique_ptr<IoctlHelperXe> create(Drm &drmArg);
|
||||
IoctlHelperXe(Drm &drmArg);
|
||||
~IoctlHelperXe() override;
|
||||
int ioctl(DrmIoctl request, void *arg) override;
|
||||
@@ -135,7 +135,7 @@ class IoctlHelperXe : public IoctlHelper {
|
||||
const char *xeGetBindOperationName(int bindOperation);
|
||||
const char *xeGetBindFlagsName(int bindFlags);
|
||||
|
||||
uint64_t getExtraFlagsForVmBind(bool bindCapture, bool bindImmediate, bool bindMakeResident, bool bindLock, bool readOnlyResource);
|
||||
virtual uint64_t getExtraFlagsForVmBind(bool bindCapture, bool bindImmediate, bool bindMakeResident, bool bindLock, bool readOnlyResource);
|
||||
const char *xeGetengineClassName(uint32_t engineClass);
|
||||
template <typename DataType>
|
||||
std::vector<DataType> queryData(uint32_t queryId);
|
||||
@@ -181,7 +181,6 @@ class IoctlHelperXe : public IoctlHelper {
|
||||
};
|
||||
std::vector<DebugMetadata> debugMetadata;
|
||||
|
||||
private:
|
||||
template <typename... XeLogArgs>
|
||||
void xeLog(XeLogArgs &&...args) const;
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/ptr_math.h"
|
||||
#include "shared/source/os_interface/linux/os_context_linux.h"
|
||||
#include "shared/source/os_interface/linux/xe/ioctl_helper_xe.h"
|
||||
|
||||
#include "xe_drm.h"
|
||||
|
||||
namespace NEO {
|
||||
void IoctlHelperXe::setContextProperties(const OsContextLinux &osContext, void *extProperties, uint32_t &extIndexInOut) {
|
||||
|
||||
auto &ext = *reinterpret_cast<std::array<drm_xe_ext_set_property, maxContextSetProperties> *>(extProperties);
|
||||
|
||||
if (osContext.isLowPriority()) {
|
||||
ext[extIndexInOut].base.name = DRM_XE_EXEC_QUEUE_EXTENSION_SET_PROPERTY;
|
||||
ext[extIndexInOut].property = DRM_XE_EXEC_QUEUE_SET_PROPERTY_PRIORITY;
|
||||
ext[extIndexInOut].value = 0;
|
||||
if (extIndexInOut > 0) {
|
||||
ext[extIndexInOut - 1].base.next_extension = castToUint64(&ext[extIndexInOut]);
|
||||
}
|
||||
extIndexInOut++;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/os_interface/linux/xe/ioctl_helper_xe.h"
|
||||
|
||||
#include "xe_drm.h"
|
||||
|
||||
namespace NEO {
|
||||
bool IoctlHelperXe::perfOpenEuStallStream(uint32_t euStallFdParameter, std::array<uint64_t, 12u> &properties, int32_t *stream) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IoctlHelperXe::perfDisableEuStallStream(int32_t *stream) {
|
||||
return false;
|
||||
}
|
||||
bool IoctlHelperXe::getEuStallProperties(std::array<uint64_t, 12u> &properties, uint64_t dssBufferSize, uint64_t samplingRate,
|
||||
uint64_t pollPeriod, uint64_t engineInstance, uint64_t notifyNReports) {
|
||||
return false;
|
||||
}
|
||||
} // namespace NEO
|
||||
@@ -1,93 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/os_interface/linux/xe/ioctl_helper_xe.h"
|
||||
|
||||
#include "xe_drm.h"
|
||||
|
||||
#define STRINGIFY_ME(X) return #X
|
||||
#define RETURN_ME(X) return X
|
||||
|
||||
namespace NEO {
|
||||
unsigned int IoctlHelperXe::getIoctlRequestValue(DrmIoctl ioctlRequest) const {
|
||||
xeLog(" -> IoctlHelperXe::%s 0x%x\n", __FUNCTION__, ioctlRequest);
|
||||
switch (ioctlRequest) {
|
||||
case DrmIoctl::gemClose:
|
||||
RETURN_ME(DRM_IOCTL_GEM_CLOSE);
|
||||
case DrmIoctl::gemVmCreate:
|
||||
RETURN_ME(DRM_IOCTL_XE_VM_CREATE);
|
||||
case DrmIoctl::gemVmDestroy:
|
||||
RETURN_ME(DRM_IOCTL_XE_VM_DESTROY);
|
||||
case DrmIoctl::gemMmapOffset:
|
||||
RETURN_ME(DRM_IOCTL_XE_GEM_MMAP_OFFSET);
|
||||
case DrmIoctl::gemCreate:
|
||||
RETURN_ME(DRM_IOCTL_XE_GEM_CREATE);
|
||||
case DrmIoctl::gemExecbuffer2:
|
||||
RETURN_ME(DRM_IOCTL_XE_EXEC);
|
||||
case DrmIoctl::gemVmBind:
|
||||
RETURN_ME(DRM_IOCTL_XE_VM_BIND);
|
||||
case DrmIoctl::query:
|
||||
RETURN_ME(DRM_IOCTL_XE_DEVICE_QUERY);
|
||||
case DrmIoctl::gemContextCreateExt:
|
||||
RETURN_ME(DRM_IOCTL_XE_EXEC_QUEUE_CREATE);
|
||||
case DrmIoctl::gemContextDestroy:
|
||||
RETURN_ME(DRM_IOCTL_XE_EXEC_QUEUE_DESTROY);
|
||||
case DrmIoctl::gemWaitUserFence:
|
||||
RETURN_ME(DRM_IOCTL_XE_WAIT_USER_FENCE);
|
||||
case DrmIoctl::primeFdToHandle:
|
||||
RETURN_ME(DRM_IOCTL_PRIME_FD_TO_HANDLE);
|
||||
case DrmIoctl::primeHandleToFd:
|
||||
RETURN_ME(DRM_IOCTL_PRIME_HANDLE_TO_FD);
|
||||
case DrmIoctl::debuggerOpen:
|
||||
case DrmIoctl::metadataCreate:
|
||||
case DrmIoctl::metadataDestroy:
|
||||
return getIoctlRequestValueDebugger(ioctlRequest);
|
||||
default:
|
||||
UNRECOVERABLE_IF(true);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
std::string IoctlHelperXe::getIoctlString(DrmIoctl ioctlRequest) const {
|
||||
switch (ioctlRequest) {
|
||||
case DrmIoctl::gemClose:
|
||||
STRINGIFY_ME(DRM_IOCTL_GEM_CLOSE);
|
||||
case DrmIoctl::gemVmCreate:
|
||||
STRINGIFY_ME(DRM_IOCTL_XE_VM_CREATE);
|
||||
case DrmIoctl::gemVmDestroy:
|
||||
STRINGIFY_ME(DRM_IOCTL_XE_VM_DESTROY);
|
||||
case DrmIoctl::gemMmapOffset:
|
||||
STRINGIFY_ME(DRM_IOCTL_XE_GEM_MMAP_OFFSET);
|
||||
case DrmIoctl::gemCreate:
|
||||
STRINGIFY_ME(DRM_IOCTL_XE_GEM_CREATE);
|
||||
case DrmIoctl::gemExecbuffer2:
|
||||
STRINGIFY_ME(DRM_IOCTL_XE_EXEC);
|
||||
case DrmIoctl::gemVmBind:
|
||||
STRINGIFY_ME(DRM_IOCTL_XE_VM_BIND);
|
||||
case DrmIoctl::query:
|
||||
STRINGIFY_ME(DRM_IOCTL_XE_DEVICE_QUERY);
|
||||
case DrmIoctl::gemContextCreateExt:
|
||||
STRINGIFY_ME(DRM_IOCTL_XE_EXEC_QUEUE_CREATE);
|
||||
case DrmIoctl::gemContextDestroy:
|
||||
STRINGIFY_ME(DRM_IOCTL_XE_EXEC_QUEUE_DESTROY);
|
||||
case DrmIoctl::gemWaitUserFence:
|
||||
STRINGIFY_ME(DRM_IOCTL_XE_WAIT_USER_FENCE);
|
||||
case DrmIoctl::primeFdToHandle:
|
||||
STRINGIFY_ME(DRM_IOCTL_PRIME_FD_TO_HANDLE);
|
||||
case DrmIoctl::primeHandleToFd:
|
||||
STRINGIFY_ME(DRM_IOCTL_PRIME_HANDLE_TO_FD);
|
||||
case DrmIoctl::debuggerOpen:
|
||||
STRINGIFY_ME(DRM_IOCTL_XE_EUDEBUG_CONNECT);
|
||||
case DrmIoctl::metadataCreate:
|
||||
STRINGIFY_ME(DRM_IOCTL_XE_DEBUG_METADATA_CREATE);
|
||||
case DrmIoctl::metadataDestroy:
|
||||
STRINGIFY_ME(DRM_IOCTL_XE_DEBUG_METADATA_DESTROY);
|
||||
default:
|
||||
return "???";
|
||||
}
|
||||
}
|
||||
} // namespace NEO
|
||||
@@ -1,14 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/os_interface/linux/xe/ioctl_helper_xe.h"
|
||||
|
||||
namespace NEO {
|
||||
bool IoctlHelperXe::getFdFromVmExport(uint32_t vmId, uint32_t flags, int32_t *fd) {
|
||||
return false;
|
||||
}
|
||||
} // namespace NEO
|
||||
Reference in New Issue
Block a user