Skip to content

Commit

Permalink
feature: add optional support for Xe drm driver
Browse files Browse the repository at this point in the history
xe_drm.h header is taken from commit 9cb016ebbb6a275f57b1cb512b95d5a842391ad7
https://cgit.freedesktop.org/drm/drm-xe/tree/include/uapi/drm/xe_drm.h

Related-To: NEO-7578

Co-authored-by: Philippe Lecluse <philippe.lecluse@intel.com>
Co-authored-by: Francois Dugast <francois.dugast@intel.com>

Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
  • Loading branch information
JablonskiMateusz authored and Compute-Runtime-Automation committed Jan 16, 2023
1 parent 6dd7feb commit 50b8069
Show file tree
Hide file tree
Showing 8 changed files with 3,105 additions and 2 deletions.
10 changes: 8 additions & 2 deletions shared/source/os_interface/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (C) 2019-2022 Intel Corporation
# Copyright (C) 2019-2023 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
Expand Down Expand Up @@ -41,7 +41,7 @@ set(NEO_CORE_OS_INTERFACE_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler_default.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler_default.h
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager_create_multi_host_allocation.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_version.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_version.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_wrappers_checks.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_wrappers.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_wrappers.h
Expand Down Expand Up @@ -132,5 +132,11 @@ if("${BRANCH_TYPE}" STREQUAL "")
endif()
endif()

if(NEO_ENABLE_XE_DRM_DETECTION)
list(REMOVE_ITEM NEO_CORE_OS_INTERFACE_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/drm_version.cpp
)
endif()

set_property(GLOBAL PROPERTY NEO_CORE_OS_INTERFACE_LINUX ${NEO_CORE_OS_INTERFACE_LINUX})
add_subdirectories()
16 changes: 16 additions & 0 deletions shared/source/os_interface/linux/xe/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# Copyright (C) 2023 Intel Corporation
#
# SPDX-License-Identifier: MIT
#

if(NEO_ENABLE_XE_DRM_DETECTION)
set(NEO_CORE_OS_INTERFACE_LINUX_XE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/drm_version_xe.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ioctl_helper_xe.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ioctl_helper_xe.h
)

set_property(GLOBAL APPEND PROPERTY NEO_CORE_OS_INTERFACE_LINUX ${NEO_CORE_OS_INTERFACE_LINUX_XE})
endif()
28 changes: 28 additions & 0 deletions shared/source/os_interface/linux/xe/drm_version_xe.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/

#include "shared/source/os_interface/linux/drm_neo.h"
#include "shared/source/os_interface/linux/xe/ioctl_helper_xe.h"

namespace NEO {
bool Drm::isDrmSupported(int fileDescriptor) {
auto drmVersion = Drm::getDrmVersion(fileDescriptor);
return "i915" == drmVersion || "xe" == drmVersion;
}

bool Drm::queryDeviceIdAndRevision() {
auto drmVersion = Drm::getDrmVersion(getFileDescriptor());
if ("xe" == drmVersion) {
this->ioctlHelper = std::make_unique<IoctlHelperXe>(*this);
auto xeIoctlHelperPtr = static_cast<IoctlHelperXe *>(this->ioctlHelper.get());
this->setPerContextVMRequired(false);
return xeIoctlHelperPtr->initialize();
}
return queryI915DeviceIdAndRevision();
}

} // namespace NEO
Loading

0 comments on commit 50b8069

Please sign in to comment.