refactor: include xe header in dedicated namespace

avoid redefinition issue in case of integrating multiple xe drm versions

define mock drm xe in inl file to provide xe definitions for mock members

Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2024-08-01 09:59:15 +00:00
committed by Compute-Runtime-Automation
parent ee2a688323
commit 07a11e640f
12 changed files with 124 additions and 87 deletions

View File

@@ -7,14 +7,13 @@
#include "shared/source/os_interface/linux/drm_neo.h"
#include "shared/source/os_interface/linux/engine_info.h"
#include "shared/source/os_interface/linux/xe/xedrm.h"
#include "level_zero/sysman/source/shared/linux/kmd_interface/sysman_kmd_interface.h"
#include "level_zero/sysman/source/shared/linux/pmu/sysman_pmu_imp.h"
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h"
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
#include "xe_drm.h"
namespace L0 {
namespace Sysman {

View File

@@ -8,13 +8,12 @@
#pragma once
#include "shared/source/os_interface/linux/engine_info.h"
#include "shared/source/os_interface/linux/xe/xedrm.h"
#include "level_zero/sysman/source/api/scheduler/linux/sysman_os_scheduler_imp.h"
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
#include "level_zero/sysman/test/unit_tests/sources/linux/mock_sysman_hw_device_id.h"
#include "xe_drm.h"
namespace L0 {
namespace Sysman {
namespace ult {

View File

@@ -26,10 +26,9 @@
#include "shared/source/os_interface/linux/memory_info.h"
#include "shared/source/os_interface/linux/os_context_linux.h"
#include "shared/source/os_interface/linux/sys_calls.h"
#include "shared/source/os_interface/linux/xe/xedrm.h"
#include "shared/source/os_interface/os_time.h"
#include "xe_drm.h"
#include <algorithm>
#include <iostream>
#include <limits>
@@ -178,7 +177,10 @@ bool IoctlHelperXe::initialize() {
hwInfo->platform.usRevId = static_cast<int>((config->info[DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID] >> 16) & 0xff);
hwInfo->capabilityTable.gpuAddressSpace = (1ull << config->info[DRM_XE_QUERY_CONFIG_VA_BITS]) - 1;
hwInfo->capabilityTable.cxlType = getCxlType(config);
hwInfo->capabilityTable.cxlType = 0;
if (getCxlType() && config->num_params > *getCxlType()) {
hwInfo->capabilityTable.cxlType = static_cast<uint32_t>(config->info[*getCxlType()]);
}
queryGtListData = queryData<uint64_t>(DRM_XE_DEVICE_QUERY_GT_LIST);

View File

@@ -15,11 +15,13 @@
#include <mutex>
#include <optional>
namespace NEO {
namespace XeDrm {
struct drm_xe_engine_class_instance;
struct drm_xe_query_gt_list;
struct drm_xe_query_config;
namespace NEO {
} // namespace XeDrm
enum class EngineClass : uint16_t;
@@ -151,7 +153,7 @@ class IoctlHelperXe : public IoctlHelper {
int debuggerMetadataDestroyIoctl(DrmIoctl request, void *arg);
int getRunaloneExtProperty();
virtual bool isExtraEngineClassAllowed(uint16_t engineClass) const { return false; }
virtual uint32_t getCxlType(struct drm_xe_query_config *config) { return 0u; }
virtual std::optional<uint32_t> getCxlType() { return {}; }
struct UserFenceExtension {
static constexpr uint32_t tagValue = 0x123987;
@@ -176,15 +178,15 @@ class IoctlHelperXe : public IoctlHelper {
std::mutex xeLock;
std::vector<BindInfo> bindInfo;
std::vector<uint32_t> hwconfig;
std::vector<drm_xe_engine_class_instance> contextParamEngine;
std::vector<XeDrm::drm_xe_engine_class_instance> contextParamEngine;
std::vector<uint64_t> queryGtListData;
constexpr static int invalidIndex = -1;
StackVec<int, 2> gtIdToTileId;
StackVec<int, 2> tileIdToGtId;
drm_xe_query_gt_list *xeGtListData = nullptr;
XeDrm::drm_xe_query_gt_list *xeGtListData = nullptr;
std::unique_ptr<drm_xe_engine_class_instance> defaultEngine;
std::unique_ptr<XeDrm::drm_xe_engine_class_instance> defaultEngine;
struct DebugMetadata {
DrmResourceClass type;
uint64_t offset;

View File

@@ -7,8 +7,7 @@
#include "shared/source/os_interface/linux/sys_calls.h"
#include "shared/source/os_interface/linux/xe/ioctl_helper_xe.h"
#include "xe_drm.h"
#include "shared/source/os_interface/linux/xe/xedrm.h"
namespace NEO {

View File

@@ -0,0 +1,20 @@
/*
* Copyright (C) 2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#ifndef _XE_DRM_H_
#include <linux/types.h>
#include <sys/ioctl.h>
namespace NEO {
namespace XeDrm {
#include "xe_drm.h"
}
} // namespace NEO
using namespace NEO::XeDrm;
#endif

View File

@@ -8,7 +8,6 @@ set(NEO_CORE_OS_INTERFACE_TESTS_LINUX_XE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/ioctl_helper_xe_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/ioctl_helper_xe_perf_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ioctl_helper_xe_tests.h
)
if(NEO_ENABLE_XE_EU_DEBUG_SUPPORT)
list(APPEND NEO_CORE_OS_INTERFACE_TESTS_LINUX_XE

View File

@@ -9,7 +9,8 @@
#include "shared/test/common/helpers/engine_descriptor_helper.h"
#include "shared/test/common/mocks/linux/mock_drm_memory_manager.h"
#include "shared/test/common/mocks/linux/mock_os_context_linux.h"
#include "shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.h"
#include "shared/test/common/test_macros/test.h"
#include "shared/test/unit_test/os_interface/linux/xe/mock_drm_xe.h"
using namespace NEO;

View File

@@ -5,12 +5,17 @@
*
*/
#include "shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.h"
#include "shared/source/helpers/compiler_product_helper.h"
#include "shared/source/os_interface/linux/memory_info.h"
#include "shared/source/os_interface/linux/os_context_linux.h"
#include "shared/source/os_interface/product_helper.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/engine_descriptor_helper.h"
#include "shared/test/common/mocks/linux/mock_drm_memory_manager.h"
#include "shared/test/common/mocks/linux/mock_os_context_linux.h"
#include "shared/test/common/mocks/linux/mock_os_time_linux.h"
#include "shared/test/common/test_macros/test.h"
#include "shared/test/unit_test/os_interface/linux/xe/mock_drm_xe.h"
using namespace NEO;

View File

@@ -0,0 +1,18 @@
/*
* Copyright (C) 2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/os_interface/linux/xe/xedrm.h"
#include "shared/test/common/libult/linux/drm_mock.h"
#include "shared/test/unit_test/os_interface/linux/xe/mock_ioctl_helper_xe.h"
namespace NEO {
namespace XeDrm {
#include "shared/test/unit_test/os_interface/linux/xe/mock_drm_xe.inl"
}
} // namespace NEO
using NEO::XeDrm::DrmMockXe;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023-2024 Intel Corporation
* Copyright (C) 2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -7,72 +7,6 @@
#pragma once
#include "shared/source/helpers/common_types.h"
#include "shared/source/helpers/compiler_product_helper.h"
#include "shared/source/helpers/register_offsets.h"
#include "shared/source/os_interface/linux/engine_info.h"
#include "shared/source/os_interface/linux/ioctl_helper.h"
#include "shared/source/os_interface/linux/memory_info.h"
#include "shared/source/os_interface/linux/xe/ioctl_helper_xe.h"
#include "shared/source/os_interface/product_helper.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/default_hw_info.h"
#include "shared/test/common/libult/linux/drm_mock.h"
#include "shared/test/common/mocks/linux/mock_os_time_linux.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/common/test_macros/test.h"
#include "xe_drm.h"
using namespace NEO;
struct MockIoctlHelperXe : IoctlHelperXe {
using IoctlHelperXe::bindInfo;
using IoctlHelperXe::contextParamEngine;
using IoctlHelperXe::defaultEngine;
using IoctlHelperXe::getDefaultEngineClass;
using IoctlHelperXe::getFdFromVmExport;
using IoctlHelperXe::ioctl;
using IoctlHelperXe::IoctlHelperXe;
using IoctlHelperXe::maxContextSetProperties;
using IoctlHelperXe::maxExecQueuePriority;
using IoctlHelperXe::queryGtListData;
using IoctlHelperXe::setContextProperties;
using IoctlHelperXe::supportedFeatures;
using IoctlHelperXe::tileIdToGtId;
using IoctlHelperXe::UserFenceExtension;
using IoctlHelperXe::xeGetBindFlagNames;
using IoctlHelperXe::xeGetBindOperationName;
using IoctlHelperXe::xeGetClassName;
using IoctlHelperXe::xeGetengineClassName;
using IoctlHelperXe::xeGtListData;
using IoctlHelperXe::xeShowBindTable;
int perfOpenIoctl(DrmIoctl request, void *arg) override {
if (failPerfOpen) {
return -1;
}
return IoctlHelperXe::perfOpenIoctl(request, arg);
}
int ioctl(int fd, DrmIoctl request, void *arg) override {
if (request == DrmIoctl::perfDisable) {
if (failPerfDisable) {
return -1;
}
}
if (request == DrmIoctl::perfEnable) {
if (failPerfEnable) {
return -1;
}
}
return IoctlHelperXe::ioctl(fd, request, arg);
}
bool failPerfDisable = false;
bool failPerfEnable = false;
bool failPerfOpen = false;
};
inline constexpr int testValueVmId = 0x5764;
inline constexpr int testValueMapOff = 0x7788;
inline constexpr int testValuePrime = 0x4321;

View File

@@ -0,0 +1,59 @@
/*
* Copyright (C) 2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/os_interface/linux/xe/ioctl_helper_xe.h"
using namespace NEO;
struct MockIoctlHelperXe : IoctlHelperXe {
using IoctlHelperXe::bindInfo;
using IoctlHelperXe::contextParamEngine;
using IoctlHelperXe::defaultEngine;
using IoctlHelperXe::getDefaultEngineClass;
using IoctlHelperXe::getFdFromVmExport;
using IoctlHelperXe::ioctl;
using IoctlHelperXe::IoctlHelperXe;
using IoctlHelperXe::maxContextSetProperties;
using IoctlHelperXe::maxExecQueuePriority;
using IoctlHelperXe::queryGtListData;
using IoctlHelperXe::setContextProperties;
using IoctlHelperXe::supportedFeatures;
using IoctlHelperXe::tileIdToGtId;
using IoctlHelperXe::UserFenceExtension;
using IoctlHelperXe::xeGetBindFlagNames;
using IoctlHelperXe::xeGetBindOperationName;
using IoctlHelperXe::xeGetClassName;
using IoctlHelperXe::xeGetengineClassName;
using IoctlHelperXe::xeGtListData;
using IoctlHelperXe::xeShowBindTable;
int perfOpenIoctl(DrmIoctl request, void *arg) override {
if (failPerfOpen) {
return -1;
}
return IoctlHelperXe::perfOpenIoctl(request, arg);
}
int ioctl(int fd, DrmIoctl request, void *arg) override {
if (request == DrmIoctl::perfDisable) {
if (failPerfDisable) {
return -1;
}
}
if (request == DrmIoctl::perfEnable) {
if (failPerfEnable) {
return -1;
}
}
return IoctlHelperXe::ioctl(fd, request, arg);
}
bool failPerfDisable = false;
bool failPerfEnable = false;
bool failPerfOpen = false;
};