feature(debugger): Add initial Xe debugger skeleton

sync xe_drm.h for debugger to 1d2144ed from
https://gitlab.freedesktop.org/miku/kernel/-/tree/eudebug-dev

Related-to: NEO-8402

Signed-off-by: Brandon Yates <brandon.yates@intel.com>
This commit is contained in:
Brandon Yates 2023-11-07 02:58:12 +00:00 committed by Compute-Runtime-Automation
parent 104310b113
commit fd48de3da9
8 changed files with 3884 additions and 0 deletions

View File

@ -499,6 +499,16 @@ if(UNIX)
set(NEO_ENABLE_XE_DRM_DETECTION FALSE)
endif()
message(STATUS "Xe drm detection: ${NEO_ENABLE_XE_DRM_DETECTION}")
# drm-xe debugger support
if(NOT DEFINED NEO_ENABLE_XE_DEBUGGER)
set(NEO_ENABLE_XE_DEBUGGER FALSE)
endif()
if(NEO_ENABLE_XE_DEBUGGER)
get_filename_component(XE_DEBUG_HEADERS_DIR "${NEO_SOURCE_DIR}/third_party${BRANCH_DIR_SUFFIX}uapi-eudebug" ABSOLUTE)
include_directories(BEFORE ${XE_DEBUG_HEADERS_DIR})
endif()
message(STATUS "Xe Debugger enabled: ${NEO_ENABLE_XE_DEBUGGER}")
endif()
if(NOT DEFINED I915_HEADERS_DIR OR I915_HEADERS_DIR STREQUAL "")
get_filename_component(I915_HEADERS_DIR "${NEO_SOURCE_DIR}/third_party${BRANCH_DIR_SUFFIX}uapi" ABSOLUTE)

View File

@ -20,6 +20,14 @@ if(UNIX)
)
endif()
if(NEO_ENABLE_XE_DEBUGGER)
target_sources(${L0_STATIC_LIB_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/xe/debug_session.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xe/debug_session.h
)
endif()
add_subdirectories()
endif()

View File

@ -0,0 +1,29 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/tools/source/debug/linux/xe/debug_session.h"
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "level_zero/tools/source/debug/debug_session.h"
#include "level_zero/tools/source/debug/linux/drm_helper.h"
#include "drm/xe_drm.h"
#include "drm/xe_drm_tmp.h"
namespace L0 {
static DebugSessionLinuxPopulateFactory<DEBUG_SESSION_LINUX_TYPE_XE, DebugSessionLinuxXe>
populateXeDebugger;
DebugSession *DebugSessionLinuxXe::createLinuxSession(const zet_debug_config_t &config, Device *device, ze_result_t &result, bool isRootAttach) {
result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
return nullptr;
}
} // namespace L0

View File

@ -0,0 +1,20 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/tools/source/debug/debug_session.h"
#include "level_zero/tools/source/debug/debug_session_imp.h"
#include "level_zero/tools/source/debug/linux/debug_session.h"
#include "level_zero/tools/source/debug/linux/debug_session_factory.h"
namespace L0 {
struct DebugSessionLinuxXe : DebugSessionLinux {
static DebugSession *createLinuxSession(const zet_debug_config_t &config, Device *device, ze_result_t &result, bool isRootAttach);
};
} // namespace L0

1221
third_party/uapi-eudebug/drm/drm.h vendored Normal file

File diff suppressed because it is too large Load Diff

1222
third_party/uapi-eudebug/drm/drm_mode.h vendored Normal file

File diff suppressed because it is too large Load Diff

1202
third_party/uapi-eudebug/drm/xe_drm.h vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,172 @@
/* SPDX-License-Identifier: MIT */
/*
* Copyright © 2023 Intel Corporation
*/
#ifndef _UAPI_XE_DRM_TMP_H_
#define _UAPI_XE_DRM_TMP_H_
#include "xe_drm.h"
#if defined(__cplusplus)
extern "C" {
#endif
#define DRM_XE_EUDEBUG_CONNECT 0x5f
#define DRM_IOCTL_XE_EUDEBUG_CONNECT DRM_IOWR(DRM_COMMAND_BASE + DRM_XE_EUDEBUG_CONNECT, struct drm_xe_eudebug_connect)
/**
* Do a eudebug event read for a debugger connection.
*
* This ioctl is available in debug version 1.
*/
#define DRM_XE_EUDEBUG_IOCTL_READ_EVENT _IO('j', 0x0)
#define DRM_XE_EUDEBUG_IOCTL_EU_CONTROL _IOWR('j', 0x2, struct drm_xe_eudebug_eu_control)
#define DRM_XE_EUDEBUG_IOCTL_VM_OPEN _IOW('j', 0x1, struct drm_xe_eudebug_vm_open)
/* XXX: Document events to match their internal counterparts when moved to xe_drm.h */
struct drm_xe_eudebug_event {
__u32 len;
__u16 type;
#define DRM_XE_EUDEBUG_EVENT_NONE 0
#define DRM_XE_EUDEBUG_EVENT_READ 1
#define DRM_XE_EUDEBUG_EVENT_OPEN 2
#define DRM_XE_EUDEBUG_EVENT_VM 3
#define DRM_XE_EUDEBUG_EVENT_EXEC_QUEUE 4
#define DRM_XE_EUDEBUG_EVENT_EU_ATTENTION 5
#define DRM_XE_EUDEBUG_EVENT_VM_BIND 6
#define DRM_XE_EUDEBUG_EVENT_MAX_EVENT DRM_XE_EUDEBUG_EVENT_VM_BIND
__u16 flags;
#define DRM_XE_EUDEBUG_EVENT_CREATE BIT(0)
#define DRM_XE_EUDEBUG_EVENT_DESTROY BIT(1)
#define DRM_XE_EUDEBUG_EVENT_STATE_CHANGE BIT(2)
__u64 seqno;
__u64 reserved;
} __attribute__((packed));
struct drm_xe_eudebug_event_client {
struct drm_xe_eudebug_event base;
__u64 client_handle; /* This is unique per debug connection */
} __attribute__((packed));
struct drm_xe_eudebug_event_vm {
struct drm_xe_eudebug_event base;
__u64 client_handle;
__u64 vm_handle;
} __attribute__((packed));
struct drm_xe_eudebug_event_exec_queue {
struct drm_xe_eudebug_event base;
__u64 client_handle;
__u64 vm_handle;
__u64 exec_queue_handle;
__u16 engine_class;
__u16 width;
__u64 lrc_handle[0];
} __attribute__((packed));
struct drm_xe_eudebug_event_eu_attention {
struct drm_xe_eudebug_event base;
__u64 client_handle;
__u64 exec_queue_handle;
__u64 lrc_handle;
__u32 flags;
__u32 bitmask_size;
__u8 bitmask[0];
} __attribute__((packed));
struct drm_xe_eudebug_event_vm_bind {
struct drm_xe_eudebug_event base;
__u64 client_handle;
__u64 vm_handle;
__u64 va_start;
__u64 va_length;
} __attribute__((packed));
struct drm_xe_eudebug_event_metadata {
struct drm_xe_eudebug_event base;
__u64 client_handle;
/* XXX: Refer to xe_drm.h for fields */
__u64 type;
__u64 user_addr;
__u64 len;
__u64 id;
} __attribute__((packed));
struct drm_xe_eudebug_event_vm_set_metadata {
struct drm_xe_eudebug_event base;
__u64 client_handle;
__u64 vm_handle;
/* XXX: Refer to xe_drm.h for fields */
__u64 type;
union {
__u64 cookie;
__u64 offset;
};
__u64 len;
} __attribute__((packed));
/*
* Debugger ABI (ioctl and events) Version History:
* 0 - No debugger available
* 1 - Initial version
*/
#define DRM_XE_EUDEBUG_VERSION 1
struct drm_xe_eudebug_connect {
/** @extensions: Pointer to the first extension struct, if any */
__u64 extensions;
__u64 pid; /* input: Target process ID */
__u32 flags; /* MBZ */
__u32 version; /* output: current ABI (ioctl / events) version */
};
struct drm_xe_eudebug_eu_control {
__u64 client_handle;
__u32 cmd;
#define DRM_XE_EUDEBUG_EU_CONTROL_CMD_INTERRUPT_ALL 0
#define DRM_XE_EUDEBUG_EU_CONTROL_CMD_STOPPED 1
#define DRM_XE_EUDEBUG_EU_CONTROL_CMD_RESUME 2
__u32 flags;
__u64 seqno;
struct drm_xe_engine_class_instance ci;
__u32 bitmask_size;
__u64 bitmask_ptr;
} __attribute__((packed));
struct drm_xe_eudebug_vm_open {
/** @extensions: Pointer to the first extension struct, if any */
__u64 extensions;
/** @client_handle: id of client */
__u64 client_handle;
/** @vm_handle: id of vm */
__u64 vm_handle;
/** @flags: flags */
__u64 flags;
/** @timeout_ns: Timeout value in nanoseconds operations (fsync) */
__u64 timeout_ns;
};
#if defined(__cplusplus)
}
#endif
#endif /* _UAPI_XE_DRM_TMP_H_ */