mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
L0 Debugger - DebugSession linux implementation
- new feature, enabled with PRELIM build - implementation of debug session for linux - move ResourceClass enum from Drm to drm_debug.h Resolves: NEO-6814 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
4e4560fe91
commit
c021e2ec5e
@ -448,6 +448,16 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
|||||||
# Get available platfroms
|
# Get available platfroms
|
||||||
include(platforms.cmake)
|
include(platforms.cmake)
|
||||||
|
|
||||||
|
if(UNIX)
|
||||||
|
# prelim headers detection
|
||||||
|
if(NOT ("${BRANCH_TYPE}" STREQUAL ""))
|
||||||
|
set(NEO_ENABLE_i915_PRELIM_DETECTION TRUE)
|
||||||
|
elseif(NOT DEFINED NEO_ENABLE_i915_PRELIM_DETECTION)
|
||||||
|
set(NEO_ENABLE_i915_PRELIM_DETECTION FALSE)
|
||||||
|
endif()
|
||||||
|
message(STATUS "i915 prelim headers detection: ${NEO_ENABLE_i915_PRELIM_DETECTION}")
|
||||||
|
endif()
|
||||||
|
|
||||||
get_filename_component(I915_INCLUDES_DIR "${NEO_SOURCE_DIR}/third_party${BRANCH_DIR_SUFFIX}uapi" ABSOLUTE)
|
get_filename_component(I915_INCLUDES_DIR "${NEO_SOURCE_DIR}/third_party${BRANCH_DIR_SUFFIX}uapi" ABSOLUTE)
|
||||||
message(STATUS "i915 includes dir: ${I915_INCLUDES_DIR}")
|
message(STATUS "i915 includes dir: ${I915_INCLUDES_DIR}")
|
||||||
|
|
||||||
@ -793,15 +803,6 @@ else()
|
|||||||
set(NEO_EXTRA_LIBS dl pthread rt)
|
set(NEO_EXTRA_LIBS dl pthread rt)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(UNIX)
|
|
||||||
# prelim headers detection
|
|
||||||
if(NOT ("${BRANCH_TYPE}" STREQUAL ""))
|
|
||||||
set(NEO_ENABLE_i915_PRELIM_DETECTION TRUE)
|
|
||||||
elseif(NOT DEFINED NEO_ENABLE_i915_PRELIM_DETECTION)
|
|
||||||
set(NEO_ENABLE_i915_PRELIM_DETECTION FALSE)
|
|
||||||
endif()
|
|
||||||
message(STATUS "i915 prelim headers detection: ${NEO_ENABLE_i915_PRELIM_DETECTION}")
|
|
||||||
endif()
|
|
||||||
add_subdirectory_unique(shared)
|
add_subdirectory_unique(shared)
|
||||||
|
|
||||||
if(NEO_BUILD_WITH_OCL)
|
if(NEO_BUILD_WITH_OCL)
|
||||||
|
@ -28,7 +28,7 @@ bool DebuggerL0::initDebuggingInOs(NEO::OSInterface *osInterface) {
|
|||||||
void DebuggerL0::registerElf(NEO::DebugData *debugData, NEO::GraphicsAllocation *isaAllocation) {
|
void DebuggerL0::registerElf(NEO::DebugData *debugData, NEO::GraphicsAllocation *isaAllocation) {
|
||||||
if (device->getRootDeviceEnvironment().osInterface.get() != nullptr) {
|
if (device->getRootDeviceEnvironment().osInterface.get() != nullptr) {
|
||||||
auto drm = device->getRootDeviceEnvironment().osInterface->getDriverModel()->as<NEO::Drm>();
|
auto drm = device->getRootDeviceEnvironment().osInterface->getDriverModel()->as<NEO::Drm>();
|
||||||
auto handle = drm->registerResource(NEO::Drm::ResourceClass::Elf, debugData->vIsa, debugData->vIsaSize);
|
auto handle = drm->registerResource(NEO::DrmResourceClass::Elf, debugData->vIsa, debugData->vIsaSize);
|
||||||
static_cast<NEO::DrmAllocation *>(isaAllocation)->linkWithRegisteredHandle(handle);
|
static_cast<NEO::DrmAllocation *>(isaAllocation)->linkWithRegisteredHandle(handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ bool DebuggerL0::attachZebinModuleToSegmentAllocations(const StackVec<NEO::Graph
|
|||||||
}
|
}
|
||||||
auto drm = device->getRootDeviceEnvironment().osInterface->getDriverModel()->as<NEO::Drm>();
|
auto drm = device->getRootDeviceEnvironment().osInterface->getDriverModel()->as<NEO::Drm>();
|
||||||
uint32_t segmentCount = static_cast<uint32_t>(allocs.size());
|
uint32_t segmentCount = static_cast<uint32_t>(allocs.size());
|
||||||
moduleHandle = drm->registerResource(NEO::Drm::ResourceClass::L0ZebinModule, &segmentCount, sizeof(uint32_t));
|
moduleHandle = drm->registerResource(NEO::DrmResourceClass::L0ZebinModule, &segmentCount, sizeof(uint32_t));
|
||||||
|
|
||||||
for (auto &allocation : allocs) {
|
for (auto &allocation : allocs) {
|
||||||
auto drmAllocation = static_cast<NEO::DrmAllocation *>(allocation);
|
auto drmAllocation = static_cast<NEO::DrmAllocation *>(allocation);
|
||||||
|
@ -7,7 +7,16 @@
|
|||||||
set(L0_SRCS_DLL_LINUX
|
set(L0_SRCS_DLL_LINUX
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/debugger_l0_linux.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/debugger_l0_linux.cpp
|
||||||
${NEO_SOURCE_DIR}/level_zero/tools/source/debug/linux/${BRANCH_DIR_SUFFIX}debug_session_linux_helper.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(NEO_ENABLE_i915_PRELIM_DETECTION)
|
||||||
|
list(APPEND L0_SRCS_DLL_LINUX
|
||||||
|
${NEO_SOURCE_DIR}/level_zero/tools/source/debug/linux/prelim/debug_session_linux_helper.cpp
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
list(APPEND L0_SRCS_DLL_LINUX
|
||||||
|
${NEO_SOURCE_DIR}/level_zero/tools/source/debug/linux/debug_session_linux_helper.cpp
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
set_property(GLOBAL PROPERTY L0_SRCS_DLL_LINUX ${L0_SRCS_DLL_LINUX})
|
set_property(GLOBAL PROPERTY L0_SRCS_DLL_LINUX ${L0_SRCS_DLL_LINUX})
|
||||||
|
@ -198,12 +198,12 @@ TEST_F(L0DebuggerLinuxTest, givenAllocationsWhenAttachingZebinModuleThenAllAlloc
|
|||||||
kernelAllocs.push_back(&isaAllocation2);
|
kernelAllocs.push_back(&isaAllocation2);
|
||||||
|
|
||||||
drmMock->registeredDataSize = 0;
|
drmMock->registeredDataSize = 0;
|
||||||
drmMock->registeredClass = NEO::Drm::ResourceClass::MaxSize;
|
drmMock->registeredClass = NEO::DrmResourceClass::MaxSize;
|
||||||
|
|
||||||
EXPECT_TRUE(device->getL0Debugger()->attachZebinModuleToSegmentAllocations(kernelAllocs, handle));
|
EXPECT_TRUE(device->getL0Debugger()->attachZebinModuleToSegmentAllocations(kernelAllocs, handle));
|
||||||
|
|
||||||
EXPECT_EQ(sizeof(uint32_t), drmMock->registeredDataSize);
|
EXPECT_EQ(sizeof(uint32_t), drmMock->registeredDataSize);
|
||||||
EXPECT_EQ(NEO::Drm::ResourceClass::L0ZebinModule, drmMock->registeredClass);
|
EXPECT_EQ(NEO::DrmResourceClass::L0ZebinModule, drmMock->registeredClass);
|
||||||
|
|
||||||
const auto containsModuleHandle = [handle](const auto &bufferObject) {
|
const auto containsModuleHandle = [handle](const auto &bufferObject) {
|
||||||
const auto &bindExtHandles = bufferObject.getBindExtHandles();
|
const auto &bindExtHandles = bufferObject.getBindExtHandles();
|
||||||
|
@ -8,8 +8,20 @@ if(UNIX)
|
|||||||
target_sources(${L0_STATIC_LIB_NAME}
|
target_sources(${L0_STATIC_LIB_NAME}
|
||||||
PRIVATE
|
PRIVATE
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/${BRANCH_DIR_SUFFIX}/debug_session.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
add_subdirectories()
|
if(NEO_ENABLE_i915_PRELIM_DETECTION)
|
||||||
|
target_sources(${L0_STATIC_LIB_NAME}
|
||||||
|
PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/prelim/debug_session.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/prelim/debug_session.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/prelim/drm_helper.cpp
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
target_sources(${L0_STATIC_LIB_NAME}
|
||||||
|
PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/debug_session.cpp
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
1485
level_zero/tools/source/debug/linux/prelim/debug_session.cpp
Normal file
1485
level_zero/tools/source/debug/linux/prelim/debug_session.cpp
Normal file
File diff suppressed because it is too large
Load Diff
248
level_zero/tools/source/debug/linux/prelim/debug_session.h
Normal file
248
level_zero/tools/source/debug/linux/prelim/debug_session.h
Normal file
@ -0,0 +1,248 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "shared/source/helpers/topology_map.h"
|
||||||
|
#include "shared/source/os_interface/linux/drm_debug.h"
|
||||||
|
#include "shared/source/os_interface/linux/sys_calls.h"
|
||||||
|
|
||||||
|
#include "level_zero/core/source/device/device.h"
|
||||||
|
#include "level_zero/tools/source/debug/debug_session.h"
|
||||||
|
#include "level_zero/tools/source/debug/debug_session_imp.h"
|
||||||
|
|
||||||
|
#include "third_party/uapi/prelim/drm/i915_drm.h"
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
#include <condition_variable>
|
||||||
|
#include <mutex>
|
||||||
|
#include <queue>
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
|
namespace NEO {
|
||||||
|
class Thread;
|
||||||
|
struct EngineClassInstance;
|
||||||
|
} // namespace NEO
|
||||||
|
|
||||||
|
namespace L0 {
|
||||||
|
|
||||||
|
struct DebugSessionLinux : DebugSessionImp {
|
||||||
|
~DebugSessionLinux() override;
|
||||||
|
DebugSessionLinux(const zet_debug_config_t &config, Device *device, int debugFd);
|
||||||
|
|
||||||
|
ze_result_t initialize() override;
|
||||||
|
|
||||||
|
bool closeConnection() override;
|
||||||
|
ze_result_t readEvent(uint64_t timeout, zet_debug_event_t *event) override;
|
||||||
|
ze_result_t readMemory(ze_device_thread_t thread, const zet_debug_memory_space_desc_t *desc, size_t size, void *buffer) override;
|
||||||
|
ze_result_t writeMemory(ze_device_thread_t thread, const zet_debug_memory_space_desc_t *desc, size_t size, const void *buffer) override;
|
||||||
|
ze_result_t acknowledgeEvent(const zet_debug_event_t *event) override;
|
||||||
|
|
||||||
|
ze_device_thread_t convertToPhysical(ze_device_thread_t thread, uint32_t &deviceIndex) override;
|
||||||
|
EuThread::ThreadId convertToThreadId(ze_device_thread_t thread) override;
|
||||||
|
ze_device_thread_t convertToApi(EuThread::ThreadId threadId) override;
|
||||||
|
|
||||||
|
struct IoctlHandler {
|
||||||
|
MOCKABLE_VIRTUAL ~IoctlHandler() = default;
|
||||||
|
MOCKABLE_VIRTUAL int ioctl(int fd, unsigned long request, void *arg) {
|
||||||
|
int ret = 0;
|
||||||
|
do {
|
||||||
|
ret = NEO::SysCalls::ioctl(fd, request, arg);
|
||||||
|
} while (ret == -1 && (errno == EINTR || errno == EAGAIN || errno == EBUSY));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
MOCKABLE_VIRTUAL int poll(pollfd *pollFd, unsigned long int numberOfFds, int timeout) {
|
||||||
|
return NEO::SysCalls::poll(pollFd, numberOfFds, timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
MOCKABLE_VIRTUAL int64_t pread(int fd, void *buf, size_t count, off_t offset) {
|
||||||
|
return NEO::SysCalls::pread(fd, buf, count, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
MOCKABLE_VIRTUAL int64_t pwrite(int fd, const void *buf, size_t count, off_t offset) {
|
||||||
|
return NEO::SysCalls::pwrite(fd, buf, count, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
MOCKABLE_VIRTUAL void *mmap(void *addr, size_t size, int prot, int flags, int fd, off_t off) {
|
||||||
|
return NEO::SysCalls::mmap(addr, size, prot, flags, fd, off);
|
||||||
|
}
|
||||||
|
|
||||||
|
MOCKABLE_VIRTUAL int munmap(void *addr, size_t size) {
|
||||||
|
return NEO::SysCalls::munmap(addr, size);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
static constexpr size_t maxEventSize = 4096;
|
||||||
|
|
||||||
|
using ContextHandle = uint64_t;
|
||||||
|
using ApiEventQueue = std::queue<zet_debug_event_t>;
|
||||||
|
|
||||||
|
struct ContextParams {
|
||||||
|
ContextHandle handle = 0;
|
||||||
|
uint64_t vm = UINT64_MAX;
|
||||||
|
std::vector<i915_engine_class_instance> engines;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct UuidData {
|
||||||
|
uint64_t handle = 0;
|
||||||
|
uint64_t classHandle = 0;
|
||||||
|
NEO::DrmResourceClass classIndex = NEO::DrmResourceClass::MaxSize;
|
||||||
|
std::unique_ptr<char[]> data;
|
||||||
|
size_t dataSize = 0;
|
||||||
|
|
||||||
|
uint64_t ptr = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BindInfo {
|
||||||
|
uint64_t gpuVa = 0;
|
||||||
|
uint64_t size = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct IsaAllocation {
|
||||||
|
BindInfo bindInfo;
|
||||||
|
uint64_t elfUuidHandle;
|
||||||
|
uint64_t vmHandle;
|
||||||
|
|
||||||
|
uint64_t moduleBegin;
|
||||||
|
uint64_t moduleEnd;
|
||||||
|
|
||||||
|
std::unordered_set<uint64_t> cookies;
|
||||||
|
int vmBindCounter = 0;
|
||||||
|
bool moduleLoadEventAck = false;
|
||||||
|
std::vector<prelim_drm_i915_debug_event> ackEvents;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Module {
|
||||||
|
std::unordered_set<uint64_t> loadAddresses;
|
||||||
|
uint64_t elfUuidHandle;
|
||||||
|
uint32_t segmentCount;
|
||||||
|
int segmentVmBindCounter;
|
||||||
|
};
|
||||||
|
|
||||||
|
static bool apiEventCompare(const zet_debug_event_t &event1, const zet_debug_event_t &event2) {
|
||||||
|
return memcmp(&event1, &event2, sizeof(zet_debug_event_t)) == 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ClientConnection {
|
||||||
|
prelim_drm_i915_debug_event_client client = {};
|
||||||
|
|
||||||
|
std::unordered_map<ContextHandle, ContextParams> contextsCreated;
|
||||||
|
std::unordered_map<uint64_t, std::pair<std::string, uint32_t>> classHandleToIndex;
|
||||||
|
std::unordered_map<uint64_t, UuidData> uuidMap;
|
||||||
|
std::unordered_set<uint64_t> vmIds;
|
||||||
|
|
||||||
|
std::unordered_map<uint64_t, BindInfo> vmToModuleDebugAreaBindInfo;
|
||||||
|
std::unordered_map<uint64_t, BindInfo> vmToContextStateSaveAreaBindInfo;
|
||||||
|
std::unordered_map<uint64_t, BindInfo> vmToStateBaseAreaBindInfo;
|
||||||
|
|
||||||
|
std::unordered_map<uint64_t, std::unique_ptr<IsaAllocation>> isaMap;
|
||||||
|
std::unordered_map<uint64_t, uint64_t> elfMap;
|
||||||
|
std::unordered_map<uint64_t, ContextHandle> lrcToContextHandle;
|
||||||
|
|
||||||
|
uint64_t moduleDebugAreaGpuVa = 0;
|
||||||
|
uint64_t contextStateSaveAreaGpuVa = 0;
|
||||||
|
uint64_t stateBaseAreaGpuVa = 0;
|
||||||
|
|
||||||
|
ApiEventQueue apiEvents;
|
||||||
|
std::vector<std::pair<zet_debug_event_t, prelim_drm_i915_debug_event_ack>> eventsToAck;
|
||||||
|
|
||||||
|
std::unordered_map<uint64_t, Module> uuidToModule;
|
||||||
|
};
|
||||||
|
|
||||||
|
static ze_result_t translateDebuggerOpenErrno(int error);
|
||||||
|
constexpr static uint64_t invalidClientHandle = std::numeric_limits<uint64_t>::max();
|
||||||
|
constexpr static uint64_t invalidHandle = std::numeric_limits<uint64_t>::max();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
enum class ThreadControlCmd {
|
||||||
|
Interrupt,
|
||||||
|
Resume,
|
||||||
|
Stopped,
|
||||||
|
InterruptAll
|
||||||
|
};
|
||||||
|
MOCKABLE_VIRTUAL void handleEvent(prelim_drm_i915_debug_event *event);
|
||||||
|
bool checkAllEventsCollected();
|
||||||
|
ze_result_t readEventImp(prelim_drm_i915_debug_event *drmDebugEvent);
|
||||||
|
ze_result_t resumeImp(std::vector<ze_device_thread_t> threads, uint32_t deviceIndex) override;
|
||||||
|
ze_result_t interruptImp(uint32_t deviceIndex) override;
|
||||||
|
|
||||||
|
void enqueueApiEvent(zet_debug_event_t &debugEvent) override {
|
||||||
|
pushApiEvent(debugEvent, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void pushApiEvent(zet_debug_event_t &debugEvent, prelim_drm_i915_debug_event *baseEvent) {
|
||||||
|
std::unique_lock<std::mutex> lock(asyncThreadMutex);
|
||||||
|
|
||||||
|
if (baseEvent && (baseEvent->flags & PRELIM_DRM_I915_DEBUG_EVENT_NEED_ACK)) {
|
||||||
|
prelim_drm_i915_debug_event_ack eventToAck = {};
|
||||||
|
eventToAck.type = baseEvent->type;
|
||||||
|
eventToAck.seqno = baseEvent->seqno;
|
||||||
|
eventToAck.flags = 0;
|
||||||
|
debugEvent.flags = ZET_DEBUG_EVENT_FLAG_NEED_ACK;
|
||||||
|
|
||||||
|
clientHandleToConnection[clientHandle]->eventsToAck.push_back(
|
||||||
|
std::pair<zet_debug_event_t, prelim_drm_i915_debug_event_ack>(debugEvent, eventToAck));
|
||||||
|
}
|
||||||
|
|
||||||
|
clientHandleToConnection[clientHandle]->apiEvents.push(debugEvent);
|
||||||
|
|
||||||
|
readEventCondition.notify_all();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *asyncThread(void *arg);
|
||||||
|
void startAsyncThread() override;
|
||||||
|
void closeAsyncThread();
|
||||||
|
void handleEventsAsync(prelim_drm_i915_debug_event *event);
|
||||||
|
|
||||||
|
void handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *vmBind);
|
||||||
|
void handleContextParamEvent(prelim_drm_i915_debug_event_context_param *contextParam);
|
||||||
|
void handleAttentionEvent(prelim_drm_i915_debug_event_eu_attention *attention);
|
||||||
|
void handleEnginesEvent(prelim_drm_i915_debug_event_engines *engines);
|
||||||
|
|
||||||
|
void extractUuidData(uint64_t client, const UuidData &uuidData);
|
||||||
|
uint64_t extractVaFromUuidString(std::string &uuid);
|
||||||
|
|
||||||
|
bool readModuleDebugArea() override;
|
||||||
|
ze_result_t readSbaBuffer(EuThread::ThreadId, SbaTrackedAddresses &sbaBuffer) override;
|
||||||
|
void readStateSaveAreaHeader() override;
|
||||||
|
|
||||||
|
void applyResumeWa(std::vector<ze_device_thread_t> threads, uint8_t *bitmask, size_t bitmaskSize);
|
||||||
|
|
||||||
|
ze_result_t readGpuMemory(uint64_t vmHandle, char *output, size_t size, uint64_t gpuVa) override;
|
||||||
|
ze_result_t writeGpuMemory(uint64_t vmHandle, const char *input, size_t size, uint64_t gpuVa) override;
|
||||||
|
ze_result_t getISAVMHandle(const zet_debug_memory_space_desc_t *desc, size_t size, uint64_t &vmHandle);
|
||||||
|
ze_result_t getElfOffset(const zet_debug_memory_space_desc_t *desc, size_t size, const char *&elfData, uint64_t &offset);
|
||||||
|
ze_result_t readElfSpace(const zet_debug_memory_space_desc_t *desc, size_t size, void *buffer,
|
||||||
|
const char *&elfData, const uint64_t offset);
|
||||||
|
|
||||||
|
bool readSystemRoutineIdent(EuThread *thread, uint64_t vmHandle, SIP::sr_ident &srIdent) override;
|
||||||
|
|
||||||
|
MOCKABLE_VIRTUAL int threadControl(std::vector<ze_device_thread_t> threads, uint32_t tile, ThreadControlCmd threadCmd, std::unique_ptr<uint8_t[]> &bitmask, size_t &bitmaskSize);
|
||||||
|
|
||||||
|
uint64_t getContextStateSaveAreaGpuVa(uint64_t memoryHandle) override;
|
||||||
|
uint64_t getSbaBufferGpuVa(uint64_t memoryHandle);
|
||||||
|
void printContextVms();
|
||||||
|
|
||||||
|
std::atomic<bool> asyncThreadActive{true};
|
||||||
|
std::atomic<bool> asyncThreadFinished{false};
|
||||||
|
std::mutex asyncThreadMutex;
|
||||||
|
std::condition_variable readEventCondition;
|
||||||
|
std::unique_ptr<NEO::Thread> thread;
|
||||||
|
|
||||||
|
int fd = 0;
|
||||||
|
int ioctl(unsigned long request, void *arg);
|
||||||
|
std::unique_ptr<IoctlHandler> ioctlHandler;
|
||||||
|
std::atomic<bool> detached{false};
|
||||||
|
|
||||||
|
uint64_t clientHandle = invalidClientHandle;
|
||||||
|
uint64_t clientHandleClosed = invalidClientHandle;
|
||||||
|
uint64_t uuidL0CommandQueueHandle = invalidClientHandle;
|
||||||
|
uint64_t euControlInterruptSeqno[NEO::EngineLimits::maxHandleCount];
|
||||||
|
|
||||||
|
std::unordered_map<uint64_t, std::unique_ptr<ClientConnection>> clientHandleToConnection;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace L0
|
@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "level_zero/tools/source/debug/linux/prelim/debug_session.h"
|
||||||
|
#include <level_zero/ze_api.h>
|
||||||
|
namespace L0 {
|
||||||
|
|
||||||
|
DebugSession *createDebugSessionHelper(const zet_debug_config_t &config, Device *device, int debugFd) {
|
||||||
|
return new DebugSessionLinux(config, device, debugFd);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace L0
|
41
level_zero/tools/source/debug/linux/prelim/drm_helper.cpp
Normal file
41
level_zero/tools/source/debug/linux/prelim/drm_helper.cpp
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "level_zero/tools/source/debug/linux/prelim/drm_helper.h"
|
||||||
|
|
||||||
|
#include "shared/source/os_interface/linux/drm_neo.h"
|
||||||
|
|
||||||
|
namespace L0 {
|
||||||
|
|
||||||
|
int DrmHelper::ioctl(Device *device, unsigned long request, void *arg) {
|
||||||
|
auto drm = device->getOsInterface().getDriverModel()->as<NEO::Drm>();
|
||||||
|
return drm->ioctl(request, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
int DrmHelper::getErrno(Device *device) {
|
||||||
|
auto drm = device->getOsInterface().getDriverModel()->as<NEO::Drm>();
|
||||||
|
return drm->getErrno();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t DrmHelper::getEngineTileIndex(Device *device, const NEO::EngineClassInstance &engine) {
|
||||||
|
auto drm = device->getOsInterface().getDriverModel()->as<NEO::Drm>();
|
||||||
|
auto engineInfo = drm->getEngineInfo();
|
||||||
|
return engineInfo->getEngineTileIndex(engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
const NEO::EngineClassInstance *DrmHelper::getEngineInstance(Device *device, uint32_t tile, aub_stream::EngineType engineType) {
|
||||||
|
auto drm = device->getOsInterface().getDriverModel()->as<NEO::Drm>();
|
||||||
|
auto engineInfo = drm->getEngineInfo();
|
||||||
|
return engineInfo->getEngineInstance(tile, engineType);
|
||||||
|
}
|
||||||
|
|
||||||
|
const NEO::TopologyMap &DrmHelper::getTopologyMap(Device *device) {
|
||||||
|
auto drm = device->getOsInterface().getDriverModel()->as<NEO::Drm>();
|
||||||
|
return drm->getTopologyMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace L0
|
25
level_zero/tools/source/debug/linux/prelim/drm_helper.h
Normal file
25
level_zero/tools/source/debug/linux/prelim/drm_helper.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "shared/source/helpers/topology_map.h"
|
||||||
|
|
||||||
|
#include "level_zero/core/source/device/device.h"
|
||||||
|
|
||||||
|
namespace NEO {
|
||||||
|
struct EngineClassInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace L0 {
|
||||||
|
struct DrmHelper {
|
||||||
|
static int ioctl(Device *device, unsigned long request, void *arg);
|
||||||
|
static int getErrno(Device *device);
|
||||||
|
static uint32_t getEngineTileIndex(Device *device, const NEO::EngineClassInstance &engine);
|
||||||
|
static const NEO::EngineClassInstance *getEngineInstance(Device *device, uint32_t tile, aub_stream::EngineType engineType);
|
||||||
|
static const NEO::TopologyMap &getTopologyMap(Device *device);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace L0
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (C) 2020-2021 Intel Corporation
|
# Copyright (C) 2020-2022 Intel Corporation
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
#
|
#
|
||||||
@ -46,6 +46,7 @@ set_target_properties(${TARGET_NAME} PROPERTIES FOLDER ${TARGET_NAME_L0})
|
|||||||
add_subdirectoriesL0(${CMAKE_CURRENT_SOURCE_DIR} "*")
|
add_subdirectoriesL0(${CMAKE_CURRENT_SOURCE_DIR} "*")
|
||||||
|
|
||||||
target_compile_definitions(${TARGET_NAME} PRIVATE $<TARGET_PROPERTY:${L0_MOCKABLE_LIB_NAME},INTERFACE_COMPILE_DEFINITIONS>)
|
target_compile_definitions(${TARGET_NAME} PRIVATE $<TARGET_PROPERTY:${L0_MOCKABLE_LIB_NAME},INTERFACE_COMPILE_DEFINITIONS>)
|
||||||
|
target_include_directories(${TARGET_NAME} PRIVATE $<TARGET_PROPERTY:${L0_MOCKABLE_LIB_NAME},INTERFACE_INCLUDE_DIRECTORIES>)
|
||||||
|
|
||||||
target_include_directories(${TARGET_NAME}
|
target_include_directories(${TARGET_NAME}
|
||||||
BEFORE
|
BEFORE
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
#
|
||||||
|
# Copyright (C) 2022 Intel Corporation
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
#
|
||||||
|
|
||||||
|
if(UNIX)
|
||||||
|
if(NEO_ENABLE_i915_PRELIM_DETECTION)
|
||||||
|
target_sources(${TARGET_NAME} PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/test_debug_api_linux.cpp
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
File diff suppressed because it is too large
Load Diff
@ -4185,7 +4185,7 @@ TEST(DrmMemoryMangerTest, givenMultipleRootDeviceWhenMemoryManagerGetsDrmThenDrm
|
|||||||
TEST_F(DrmAllocationTests, givenResourceRegistrationEnabledWhenAllocationTypeShouldBeRegisteredThenBoHasBindExtHandleAdded) {
|
TEST_F(DrmAllocationTests, givenResourceRegistrationEnabledWhenAllocationTypeShouldBeRegisteredThenBoHasBindExtHandleAdded) {
|
||||||
DrmMockResources drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
DrmMockResources drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||||
|
|
||||||
for (uint32_t i = 3; i < 3 + static_cast<uint32_t>(Drm::ResourceClass::MaxSize); i++) {
|
for (uint32_t i = 3; i < 3 + static_cast<uint32_t>(DrmResourceClass::MaxSize); i++) {
|
||||||
drm.classHandles.push_back(i);
|
drm.classHandles.push_back(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4195,9 +4195,9 @@ TEST_F(DrmAllocationTests, givenResourceRegistrationEnabledWhenAllocationTypeSho
|
|||||||
allocation.bufferObjects[0] = &bo;
|
allocation.bufferObjects[0] = &bo;
|
||||||
allocation.registerBOBindExtHandle(&drm);
|
allocation.registerBOBindExtHandle(&drm);
|
||||||
EXPECT_EQ(DrmMockResources::registerResourceReturnHandle, bo.bindExtHandles[0]);
|
EXPECT_EQ(DrmMockResources::registerResourceReturnHandle, bo.bindExtHandles[0]);
|
||||||
EXPECT_EQ(Drm::ResourceClass::ContextSaveArea, drm.registeredClass);
|
EXPECT_EQ(DrmResourceClass::ContextSaveArea, drm.registeredClass);
|
||||||
}
|
}
|
||||||
drm.registeredClass = Drm::ResourceClass::MaxSize;
|
drm.registeredClass = DrmResourceClass::MaxSize;
|
||||||
|
|
||||||
{
|
{
|
||||||
MockBufferObject bo(&drm, 3, 0, 0, 1);
|
MockBufferObject bo(&drm, 3, 0, 0, 1);
|
||||||
@ -4205,9 +4205,9 @@ TEST_F(DrmAllocationTests, givenResourceRegistrationEnabledWhenAllocationTypeSho
|
|||||||
allocation.bufferObjects[0] = &bo;
|
allocation.bufferObjects[0] = &bo;
|
||||||
allocation.registerBOBindExtHandle(&drm);
|
allocation.registerBOBindExtHandle(&drm);
|
||||||
EXPECT_EQ(DrmMockResources::registerResourceReturnHandle, bo.bindExtHandles[0]);
|
EXPECT_EQ(DrmMockResources::registerResourceReturnHandle, bo.bindExtHandles[0]);
|
||||||
EXPECT_EQ(Drm::ResourceClass::SbaTrackingBuffer, drm.registeredClass);
|
EXPECT_EQ(DrmResourceClass::SbaTrackingBuffer, drm.registeredClass);
|
||||||
}
|
}
|
||||||
drm.registeredClass = Drm::ResourceClass::MaxSize;
|
drm.registeredClass = DrmResourceClass::MaxSize;
|
||||||
|
|
||||||
{
|
{
|
||||||
MockBufferObject bo(&drm, 3, 0, 0, 1);
|
MockBufferObject bo(&drm, 3, 0, 0, 1);
|
||||||
@ -4215,9 +4215,9 @@ TEST_F(DrmAllocationTests, givenResourceRegistrationEnabledWhenAllocationTypeSho
|
|||||||
allocation.bufferObjects[0] = &bo;
|
allocation.bufferObjects[0] = &bo;
|
||||||
allocation.registerBOBindExtHandle(&drm);
|
allocation.registerBOBindExtHandle(&drm);
|
||||||
EXPECT_EQ(DrmMockResources::registerResourceReturnHandle, bo.bindExtHandles[0]);
|
EXPECT_EQ(DrmMockResources::registerResourceReturnHandle, bo.bindExtHandles[0]);
|
||||||
EXPECT_EQ(Drm::ResourceClass::Isa, drm.registeredClass);
|
EXPECT_EQ(DrmResourceClass::Isa, drm.registeredClass);
|
||||||
}
|
}
|
||||||
drm.registeredClass = Drm::ResourceClass::MaxSize;
|
drm.registeredClass = DrmResourceClass::MaxSize;
|
||||||
|
|
||||||
{
|
{
|
||||||
MockBufferObject bo(&drm, 3, 0, 0, 1);
|
MockBufferObject bo(&drm, 3, 0, 0, 1);
|
||||||
@ -4225,10 +4225,10 @@ TEST_F(DrmAllocationTests, givenResourceRegistrationEnabledWhenAllocationTypeSho
|
|||||||
allocation.bufferObjects[0] = &bo;
|
allocation.bufferObjects[0] = &bo;
|
||||||
allocation.registerBOBindExtHandle(&drm);
|
allocation.registerBOBindExtHandle(&drm);
|
||||||
EXPECT_EQ(DrmMockResources::registerResourceReturnHandle, bo.bindExtHandles[0]);
|
EXPECT_EQ(DrmMockResources::registerResourceReturnHandle, bo.bindExtHandles[0]);
|
||||||
EXPECT_EQ(Drm::ResourceClass::ModuleHeapDebugArea, drm.registeredClass);
|
EXPECT_EQ(DrmResourceClass::ModuleHeapDebugArea, drm.registeredClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
drm.registeredClass = Drm::ResourceClass::MaxSize;
|
drm.registeredClass = DrmResourceClass::MaxSize;
|
||||||
|
|
||||||
{
|
{
|
||||||
MockBufferObject bo(&drm, 3, 0, 0, 1);
|
MockBufferObject bo(&drm, 3, 0, 0, 1);
|
||||||
@ -4236,16 +4236,16 @@ TEST_F(DrmAllocationTests, givenResourceRegistrationEnabledWhenAllocationTypeSho
|
|||||||
allocation.bufferObjects[0] = &bo;
|
allocation.bufferObjects[0] = &bo;
|
||||||
allocation.registerBOBindExtHandle(&drm);
|
allocation.registerBOBindExtHandle(&drm);
|
||||||
EXPECT_EQ(0u, bo.bindExtHandles.size());
|
EXPECT_EQ(0u, bo.bindExtHandles.size());
|
||||||
EXPECT_EQ(Drm::ResourceClass::MaxSize, drm.registeredClass);
|
EXPECT_EQ(DrmResourceClass::MaxSize, drm.registeredClass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DrmAllocationTests, givenResourceRegistrationEnabledWhenAllocationTypeShouldNotBeRegisteredThenNoBindHandleCreated) {
|
TEST_F(DrmAllocationTests, givenResourceRegistrationEnabledWhenAllocationTypeShouldNotBeRegisteredThenNoBindHandleCreated) {
|
||||||
DrmMockResources drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
DrmMockResources drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||||
|
|
||||||
drm.registeredClass = Drm::ResourceClass::MaxSize;
|
drm.registeredClass = DrmResourceClass::MaxSize;
|
||||||
|
|
||||||
for (uint32_t i = 3; i < 3 + static_cast<uint32_t>(Drm::ResourceClass::MaxSize); i++) {
|
for (uint32_t i = 3; i < 3 + static_cast<uint32_t>(DrmResourceClass::MaxSize); i++) {
|
||||||
drm.classHandles.push_back(i);
|
drm.classHandles.push_back(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4256,7 +4256,7 @@ TEST_F(DrmAllocationTests, givenResourceRegistrationEnabledWhenAllocationTypeSho
|
|||||||
allocation.registerBOBindExtHandle(&drm);
|
allocation.registerBOBindExtHandle(&drm);
|
||||||
EXPECT_EQ(0u, bo.bindExtHandles.size());
|
EXPECT_EQ(0u, bo.bindExtHandles.size());
|
||||||
}
|
}
|
||||||
EXPECT_EQ(Drm::ResourceClass::MaxSize, drm.registeredClass);
|
EXPECT_EQ(DrmResourceClass::MaxSize, drm.registeredClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DrmAllocationTests, givenResourceRegistrationNotEnabledWhenRegisteringBindExtHandleThenHandleIsNotAddedToBo) {
|
TEST_F(DrmAllocationTests, givenResourceRegistrationNotEnabledWhenRegisteringBindExtHandleThenHandleIsNotAddedToBo) {
|
||||||
@ -4268,7 +4268,7 @@ TEST_F(DrmAllocationTests, givenResourceRegistrationNotEnabledWhenRegisteringBin
|
|||||||
allocation.bufferObjects[0] = &bo;
|
allocation.bufferObjects[0] = &bo;
|
||||||
allocation.registerBOBindExtHandle(&drm);
|
allocation.registerBOBindExtHandle(&drm);
|
||||||
EXPECT_EQ(0u, bo.bindExtHandles.size());
|
EXPECT_EQ(0u, bo.bindExtHandles.size());
|
||||||
EXPECT_EQ(Drm::ResourceClass::MaxSize, drm.registeredClass);
|
EXPECT_EQ(DrmResourceClass::MaxSize, drm.registeredClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(DrmMemoryManager, givenTrackedAllocationTypeAndDisabledRegistrationInDrmWhenAllocatingThenRegisterBoBindExtHandleIsNotCalled) {
|
TEST(DrmMemoryManager, givenTrackedAllocationTypeAndDisabledRegistrationInDrmWhenAllocatingThenRegisterBoBindExtHandleIsNotCalled) {
|
||||||
@ -4289,7 +4289,7 @@ TEST(DrmMemoryManager, givenTrackedAllocationTypeAndDisabledRegistrationInDrmWhe
|
|||||||
memoryManager->registerAllocationInOs(&allocation);
|
memoryManager->registerAllocationInOs(&allocation);
|
||||||
|
|
||||||
EXPECT_FALSE(allocation.registerBOBindExtHandleCalled);
|
EXPECT_FALSE(allocation.registerBOBindExtHandleCalled);
|
||||||
EXPECT_EQ(Drm::ResourceClass::MaxSize, mockDrm->registeredClass);
|
EXPECT_EQ(DrmResourceClass::MaxSize, mockDrm->registeredClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(DrmMemoryManager, givenResourceRegistrationEnabledAndAllocTypeToCaptureWhenRegisteringAllocationInOsThenItIsMarkedForCapture) {
|
TEST(DrmMemoryManager, givenResourceRegistrationEnabledAndAllocTypeToCaptureWhenRegisteringAllocationInOsThenItIsMarkedForCapture) {
|
||||||
@ -4328,7 +4328,7 @@ TEST(DrmMemoryManager, givenTrackedAllocationTypeWhenAllocatingThenAllocationIsR
|
|||||||
executionEnvironment->rootDeviceEnvironments[0]->initGmm();
|
executionEnvironment->rootDeviceEnvironments[0]->initGmm();
|
||||||
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(false, false, false, *executionEnvironment);
|
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(false, false, false, *executionEnvironment);
|
||||||
|
|
||||||
for (uint32_t i = 3; i < 3 + static_cast<uint32_t>(Drm::ResourceClass::MaxSize); i++) {
|
for (uint32_t i = 3; i < 3 + static_cast<uint32_t>(DrmResourceClass::MaxSize); i++) {
|
||||||
mockDrm->classHandles.push_back(i);
|
mockDrm->classHandles.push_back(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4340,7 +4340,7 @@ TEST(DrmMemoryManager, givenTrackedAllocationTypeWhenAllocatingThenAllocationIsR
|
|||||||
|
|
||||||
properties.gpuAddress = 0x20000;
|
properties.gpuAddress = 0x20000;
|
||||||
auto sbaAllocation = memoryManager->allocateGraphicsMemoryWithProperties(properties);
|
auto sbaAllocation = memoryManager->allocateGraphicsMemoryWithProperties(properties);
|
||||||
EXPECT_EQ(Drm::ResourceClass::SbaTrackingBuffer, mockDrm->registeredClass);
|
EXPECT_EQ(DrmResourceClass::SbaTrackingBuffer, mockDrm->registeredClass);
|
||||||
|
|
||||||
EXPECT_EQ(sizeof(uint64_t), mockDrm->registeredDataSize);
|
EXPECT_EQ(sizeof(uint64_t), mockDrm->registeredDataSize);
|
||||||
uint64_t *data = reinterpret_cast<uint64_t *>(mockDrm->registeredData);
|
uint64_t *data = reinterpret_cast<uint64_t *>(mockDrm->registeredData);
|
||||||
@ -4359,7 +4359,7 @@ TEST(DrmMemoryManager, givenTrackedAllocationTypeWhenFreeingThenRegisteredHandle
|
|||||||
executionEnvironment->rootDeviceEnvironments[0]->initGmm();
|
executionEnvironment->rootDeviceEnvironments[0]->initGmm();
|
||||||
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(false, false, false, *executionEnvironment);
|
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(false, false, false, *executionEnvironment);
|
||||||
|
|
||||||
for (uint32_t i = 3; i < 3 + static_cast<uint32_t>(Drm::ResourceClass::MaxSize); i++) {
|
for (uint32_t i = 3; i < 3 + static_cast<uint32_t>(DrmResourceClass::MaxSize); i++) {
|
||||||
mockDrm->classHandles.push_back(i);
|
mockDrm->classHandles.push_back(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4386,7 +4386,7 @@ TEST(DrmMemoryManager, givenNullBoWhenRegisteringBindExtHandleThenEarlyReturn) {
|
|||||||
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
|
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
|
||||||
auto mockDrm = std::make_unique<DrmMockResources>(*executionEnvironment->rootDeviceEnvironments[0]);
|
auto mockDrm = std::make_unique<DrmMockResources>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||||
|
|
||||||
for (uint32_t i = 3; i < 3 + static_cast<uint32_t>(Drm::ResourceClass::MaxSize); i++) {
|
for (uint32_t i = 3; i < 3 + static_cast<uint32_t>(DrmResourceClass::MaxSize); i++) {
|
||||||
mockDrm->classHandles.push_back(i);
|
mockDrm->classHandles.push_back(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4416,11 +4416,11 @@ TEST_F(DrmAllocationTests, givenResourceRegistrationEnabledWhenAllocationIsRegis
|
|||||||
TEST_F(DrmAllocationTests, givenResourceRegistrationEnabledWhenIsaIsRegisteredThenCookieIsAddedToBoHandle) {
|
TEST_F(DrmAllocationTests, givenResourceRegistrationEnabledWhenIsaIsRegisteredThenCookieIsAddedToBoHandle) {
|
||||||
DrmMockResources drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
DrmMockResources drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||||
|
|
||||||
for (uint32_t i = 3; i < 3 + static_cast<uint32_t>(Drm::ResourceClass::MaxSize); i++) {
|
for (uint32_t i = 3; i < 3 + static_cast<uint32_t>(DrmResourceClass::MaxSize); i++) {
|
||||||
drm.classHandles.push_back(i);
|
drm.classHandles.push_back(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
drm.registeredClass = Drm::ResourceClass::MaxSize;
|
drm.registeredClass = DrmResourceClass::MaxSize;
|
||||||
|
|
||||||
MockBufferObject bo(&drm, 3, 0, 0, 1);
|
MockBufferObject bo(&drm, 3, 0, 0, 1);
|
||||||
MockDrmAllocation allocation(AllocationType::KERNEL_ISA, MemoryPool::System4KBPages);
|
MockDrmAllocation allocation(AllocationType::KERNEL_ISA, MemoryPool::System4KBPages);
|
||||||
|
@ -34,7 +34,7 @@ TEST(DrmUuidTest, GivenDrmWhenGeneratingElfUUIDThenCorrectStringsAreReturned) {
|
|||||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||||
|
|
||||||
std::string elfClassUuid = classNamesToUuid[static_cast<uint32_t>(Drm::ResourceClass::Elf)].second;
|
std::string elfClassUuid = classNamesToUuid[static_cast<uint32_t>(DrmResourceClass::Elf)].second;
|
||||||
std::string Uuid1stElfClass = elfClassUuid.substr(0, 18);
|
std::string Uuid1stElfClass = elfClassUuid.substr(0, 18);
|
||||||
|
|
||||||
char data[] = "abc";
|
char data[] = "abc";
|
||||||
@ -53,25 +53,25 @@ TEST(DrmUuidTest, GivenDrmWhenGeneratingElfUUIDThenCorrectStringsAreReturned) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(DrmUuidTest, whenResourceClassIsUsedToIndexClassNamesThenCorrectNamesAreReturned) {
|
TEST(DrmUuidTest, whenResourceClassIsUsedToIndexClassNamesThenCorrectNamesAreReturned) {
|
||||||
EXPECT_STREQ(classNamesToUuid[static_cast<uint32_t>(Drm::ResourceClass::Elf)].first, "I915_UUID_CLASS_ELF_BINARY");
|
EXPECT_STREQ(classNamesToUuid[static_cast<uint32_t>(DrmResourceClass::Elf)].first, "I915_UUID_CLASS_ELF_BINARY");
|
||||||
EXPECT_STREQ(classNamesToUuid[static_cast<uint32_t>(Drm::ResourceClass::Isa)].first, "I915_UUID_CLASS_ISA_BYTECODE");
|
EXPECT_STREQ(classNamesToUuid[static_cast<uint32_t>(DrmResourceClass::Isa)].first, "I915_UUID_CLASS_ISA_BYTECODE");
|
||||||
EXPECT_STREQ(classNamesToUuid[static_cast<uint32_t>(Drm::ResourceClass::ContextSaveArea)].first, "I915_UUID_L0_SIP_AREA");
|
EXPECT_STREQ(classNamesToUuid[static_cast<uint32_t>(DrmResourceClass::ContextSaveArea)].first, "I915_UUID_L0_SIP_AREA");
|
||||||
EXPECT_STREQ(classNamesToUuid[static_cast<uint32_t>(Drm::ResourceClass::ModuleHeapDebugArea)].first, "I915_UUID_L0_MODULE_AREA");
|
EXPECT_STREQ(classNamesToUuid[static_cast<uint32_t>(DrmResourceClass::ModuleHeapDebugArea)].first, "I915_UUID_L0_MODULE_AREA");
|
||||||
EXPECT_STREQ(classNamesToUuid[static_cast<uint32_t>(Drm::ResourceClass::SbaTrackingBuffer)].first, "I915_UUID_L0_SBA_AREA");
|
EXPECT_STREQ(classNamesToUuid[static_cast<uint32_t>(DrmResourceClass::SbaTrackingBuffer)].first, "I915_UUID_L0_SBA_AREA");
|
||||||
EXPECT_STREQ(classNamesToUuid[static_cast<uint32_t>(Drm::ResourceClass::L0ZebinModule)].first, "L0_ZEBIN_MODULE");
|
EXPECT_STREQ(classNamesToUuid[static_cast<uint32_t>(DrmResourceClass::L0ZebinModule)].first, "L0_ZEBIN_MODULE");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(DrmUuidTest, givenUuidStringWhenGettingClassIndexThenCorrectIndexForValidStringsIsReturned) {
|
TEST(DrmUuidTest, givenUuidStringWhenGettingClassIndexThenCorrectIndexForValidStringsIsReturned) {
|
||||||
uint32_t index = 100;
|
uint32_t index = 100;
|
||||||
auto validUuid = DrmUuid::getClassUuidIndex(classNamesToUuid[static_cast<uint32_t>(Drm::ResourceClass::ContextSaveArea)].second, index);
|
auto validUuid = DrmUuid::getClassUuidIndex(classNamesToUuid[static_cast<uint32_t>(DrmResourceClass::ContextSaveArea)].second, index);
|
||||||
|
|
||||||
EXPECT_TRUE(validUuid);
|
EXPECT_TRUE(validUuid);
|
||||||
EXPECT_EQ(static_cast<uint32_t>(Drm::ResourceClass::ContextSaveArea), index);
|
EXPECT_EQ(static_cast<uint32_t>(DrmResourceClass::ContextSaveArea), index);
|
||||||
|
|
||||||
validUuid = DrmUuid::getClassUuidIndex(classNamesToUuid[static_cast<uint32_t>(Drm::ResourceClass::ModuleHeapDebugArea)].second, index);
|
validUuid = DrmUuid::getClassUuidIndex(classNamesToUuid[static_cast<uint32_t>(DrmResourceClass::ModuleHeapDebugArea)].second, index);
|
||||||
|
|
||||||
EXPECT_TRUE(validUuid);
|
EXPECT_TRUE(validUuid);
|
||||||
EXPECT_EQ(static_cast<uint32_t>(Drm::ResourceClass::ModuleHeapDebugArea), index);
|
EXPECT_EQ(static_cast<uint32_t>(DrmResourceClass::ModuleHeapDebugArea), index);
|
||||||
|
|
||||||
index = 100;
|
index = 100;
|
||||||
validUuid = DrmUuid::getClassUuidIndex("invalid", index);
|
validUuid = DrmUuid::getClassUuidIndex("invalid", index);
|
||||||
|
@ -419,4 +419,5 @@ UseContextEndOffsetForEventCompletion = -1
|
|||||||
DirectSubmissionInsertExtraMiMemFenceCommands = -1
|
DirectSubmissionInsertExtraMiMemFenceCommands = -1
|
||||||
DirectSubmissionInsertSfenceInstructionPriorToSubmission = -1
|
DirectSubmissionInsertSfenceInstructionPriorToSubmission = -1
|
||||||
EnableTimestampWaitForEvents = -1
|
EnableTimestampWaitForEvents = -1
|
||||||
ForceWddmLowPriorityContextValue = -1
|
ForceWddmLowPriorityContextValue = -1
|
||||||
|
EnableDebuggerMmapMemoryAccess = 0
|
||||||
|
@ -437,6 +437,7 @@ DECLARE_DEBUG_VARIABLE(bool, ForceDefaultThreadArbitrationPolicyIfNotSpecified,
|
|||||||
DECLARE_DEBUG_VARIABLE(int32_t, ProgramExtendedPipeControlPriorToNonPipelinedStateCommand, -1, "-1: default, 0: disable, 1: enable, Program additional extended version of PIPE CONTROL command before non pipelined state command")
|
DECLARE_DEBUG_VARIABLE(int32_t, ProgramExtendedPipeControlPriorToNonPipelinedStateCommand, -1, "-1: default, 0: disable, 1: enable, Program additional extended version of PIPE CONTROL command before non pipelined state command")
|
||||||
DECLARE_DEBUG_VARIABLE(int32_t, OverrideDrmRegion, -1, "-1: disable, 0+: override to given memory region for all allocations")
|
DECLARE_DEBUG_VARIABLE(int32_t, OverrideDrmRegion, -1, "-1: disable, 0+: override to given memory region for all allocations")
|
||||||
DECLARE_DEBUG_VARIABLE(bool, ForceAllResourcesUncached, false, "When set, all memory operations for all resources are forced to UC. This overrides all caching-related debug variables and globally disables all caches")
|
DECLARE_DEBUG_VARIABLE(bool, ForceAllResourcesUncached, false, "When set, all memory operations for all resources are forced to UC. This overrides all caching-related debug variables and globally disables all caches")
|
||||||
|
DECLARE_DEBUG_VARIABLE(bool, EnableDebuggerMmapMemoryAccess, false, "Mmap used to access memory by debug api, valid only on Linux OS")
|
||||||
|
|
||||||
/* Binary Cache */
|
/* Binary Cache */
|
||||||
DECLARE_DEBUG_VARIABLE(bool, BinaryCacheTrace, false, "enable cl_cache to produce .trace files with information about hash computation")
|
DECLARE_DEBUG_VARIABLE(bool, BinaryCacheTrace, false, "enable cl_cache to produce .trace files with information about hash computation")
|
||||||
|
@ -175,26 +175,26 @@ void DrmAllocation::registerBOBindExtHandle(Drm *drm) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Drm::ResourceClass resourceClass = Drm::ResourceClass::MaxSize;
|
DrmResourceClass resourceClass = DrmResourceClass::MaxSize;
|
||||||
|
|
||||||
switch (this->allocationType) {
|
switch (this->allocationType) {
|
||||||
case AllocationType::DEBUG_CONTEXT_SAVE_AREA:
|
case AllocationType::DEBUG_CONTEXT_SAVE_AREA:
|
||||||
resourceClass = Drm::ResourceClass::ContextSaveArea;
|
resourceClass = DrmResourceClass::ContextSaveArea;
|
||||||
break;
|
break;
|
||||||
case AllocationType::DEBUG_SBA_TRACKING_BUFFER:
|
case AllocationType::DEBUG_SBA_TRACKING_BUFFER:
|
||||||
resourceClass = Drm::ResourceClass::SbaTrackingBuffer;
|
resourceClass = DrmResourceClass::SbaTrackingBuffer;
|
||||||
break;
|
break;
|
||||||
case AllocationType::KERNEL_ISA:
|
case AllocationType::KERNEL_ISA:
|
||||||
resourceClass = Drm::ResourceClass::Isa;
|
resourceClass = DrmResourceClass::Isa;
|
||||||
break;
|
break;
|
||||||
case AllocationType::DEBUG_MODULE_AREA:
|
case AllocationType::DEBUG_MODULE_AREA:
|
||||||
resourceClass = Drm::ResourceClass::ModuleHeapDebugArea;
|
resourceClass = DrmResourceClass::ModuleHeapDebugArea;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resourceClass != Drm::ResourceClass::MaxSize) {
|
if (resourceClass != DrmResourceClass::MaxSize) {
|
||||||
uint64_t gpuAddress = getGpuAddress();
|
uint64_t gpuAddress = getGpuAddress();
|
||||||
auto handle = drm->registerResource(resourceClass, &gpuAddress, sizeof(gpuAddress));
|
auto handle = drm->registerResource(resourceClass, &gpuAddress, sizeof(gpuAddress));
|
||||||
registeredBoBindHandles.push_back(handle);
|
registeredBoBindHandles.push_back(handle);
|
||||||
@ -205,7 +205,7 @@ void DrmAllocation::registerBOBindExtHandle(Drm *drm) {
|
|||||||
if (bo) {
|
if (bo) {
|
||||||
bo->addBindExtHandle(handle);
|
bo->addBindExtHandle(handle);
|
||||||
bo->markForCapture();
|
bo->markForCapture();
|
||||||
if (resourceClass == Drm::ResourceClass::Isa) {
|
if (resourceClass == DrmResourceClass::Isa) {
|
||||||
auto cookieHandle = drm->registerIsaCookie(handle);
|
auto cookieHandle = drm->registerIsaCookie(handle);
|
||||||
bo->addBindExtHandle(cookieHandle);
|
bo->addBindExtHandle(cookieHandle);
|
||||||
registeredBoBindHandles.push_back(cookieHandle);
|
registeredBoBindHandles.push_back(cookieHandle);
|
||||||
|
@ -30,13 +30,13 @@ bool Drm::registerResourceClasses() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Drm::registerResource(ResourceClass classType, const void *data, size_t size) {
|
uint32_t Drm::registerResource(DrmResourceClass classType, const void *data, size_t size) {
|
||||||
if (classHandles.size() < static_cast<uint32_t>(classType)) {
|
if (classHandles.size() < static_cast<uint32_t>(classType)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string uuid;
|
std::string uuid;
|
||||||
if (classType == NEO::Drm::ResourceClass::Elf) {
|
if (classType == NEO::DrmResourceClass::Elf) {
|
||||||
uuid = generateElfUUID(data);
|
uuid = generateElfUUID(data);
|
||||||
} else {
|
} else {
|
||||||
uuid = generateUUID();
|
uuid = generateUUID();
|
||||||
@ -85,7 +85,7 @@ std::string Drm::generateUUID() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string Drm::generateElfUUID(const void *data) {
|
std::string Drm::generateElfUUID(const void *data) {
|
||||||
std::string elf_class_uuid = classNamesToUuid[static_cast<uint32_t>(Drm::ResourceClass::Elf)].second;
|
std::string elf_class_uuid = classNamesToUuid[static_cast<uint32_t>(DrmResourceClass::Elf)].second;
|
||||||
std::string UUID1st = elf_class_uuid.substr(0, 18);
|
std::string UUID1st = elf_class_uuid.substr(0, 18);
|
||||||
|
|
||||||
const char uuidString[] = "%s-%04" SCNx64 "-%012" SCNx64;
|
const char uuidString[] = "%s-%04" SCNx64 "-%012" SCNx64;
|
||||||
|
@ -5,12 +5,22 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "shared/source/os_interface/linux/drm_neo.h"
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace NEO {
|
namespace NEO {
|
||||||
|
enum class DrmResourceClass : uint32_t {
|
||||||
|
Elf,
|
||||||
|
Isa,
|
||||||
|
ModuleHeapDebugArea,
|
||||||
|
ContextSaveArea,
|
||||||
|
SbaTrackingBuffer,
|
||||||
|
L0ZebinModule,
|
||||||
|
MaxSize
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
@ -44,7 +54,7 @@ UUID('285208b2-c5e0-5fcb-90bb-7576ed7a9697')
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using ClassNamesArray = std::array<std::pair<const char *, const std::string>, size_t(Drm::ResourceClass::MaxSize)>;
|
using ClassNamesArray = std::array<std::pair<const char *, const std::string>, size_t(DrmResourceClass::MaxSize)>;
|
||||||
const ClassNamesArray classNamesToUuid = {std::make_pair("I915_UUID_CLASS_ELF_BINARY", "31203221-8069-5a0a-9d43-94a4d3395ee1"),
|
const ClassNamesArray classNamesToUuid = {std::make_pair("I915_UUID_CLASS_ELF_BINARY", "31203221-8069-5a0a-9d43-94a4d3395ee1"),
|
||||||
std::make_pair("I915_UUID_CLASS_ISA_BYTECODE", "53baed0a-12c3-5d19-aa69-ab9c51aa1039"),
|
std::make_pair("I915_UUID_CLASS_ISA_BYTECODE", "53baed0a-12c3-5d19-aa69-ab9c51aa1039"),
|
||||||
std::make_pair("I915_UUID_L0_MODULE_AREA", "a411e82e-16c9-58b7-bfb5-b209b8601d5f"),
|
std::make_pair("I915_UUID_L0_MODULE_AREA", "a411e82e-16c9-58b7-bfb5-b209b8601d5f"),
|
||||||
@ -57,7 +67,7 @@ constexpr auto uuidL0CommandQueueHash = "285208b2-c5e0-5fcb-90bb-7576ed7a9697";
|
|||||||
|
|
||||||
struct DrmUuid {
|
struct DrmUuid {
|
||||||
static bool getClassUuidIndex(std::string uuid, uint32_t &index) {
|
static bool getClassUuidIndex(std::string uuid, uint32_t &index) {
|
||||||
for (uint32_t i = 0; i < uint32_t(Drm::ResourceClass::MaxSize); i++) {
|
for (uint32_t i = 0; i < uint32_t(DrmResourceClass::MaxSize); i++) {
|
||||||
if (uuid == classNamesToUuid[i].second) {
|
if (uuid == classNamesToUuid[i].second) {
|
||||||
index = i;
|
index = i;
|
||||||
return true;
|
return true;
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "shared/source/memory_manager/definitions/engine_limits.h"
|
#include "shared/source/memory_manager/definitions/engine_limits.h"
|
||||||
#include "shared/source/os_interface/driver_info.h"
|
#include "shared/source/os_interface/driver_info.h"
|
||||||
#include "shared/source/os_interface/linux/cache_info.h"
|
#include "shared/source/os_interface/linux/cache_info.h"
|
||||||
|
#include "shared/source/os_interface/linux/drm_debug.h"
|
||||||
#include "shared/source/os_interface/linux/engine_info.h"
|
#include "shared/source/os_interface/linux/engine_info.h"
|
||||||
#include "shared/source/os_interface/linux/hw_device_id.h"
|
#include "shared/source/os_interface/linux/hw_device_id.h"
|
||||||
#include "shared/source/os_interface/linux/memory_info.h"
|
#include "shared/source/os_interface/linux/memory_info.h"
|
||||||
@ -66,16 +67,6 @@ class Drm : public DriverModel {
|
|||||||
static constexpr DriverModelType driverModelType = DriverModelType::DRM;
|
static constexpr DriverModelType driverModelType = DriverModelType::DRM;
|
||||||
static constexpr size_t completionFenceOffset = 1024;
|
static constexpr size_t completionFenceOffset = 1024;
|
||||||
|
|
||||||
enum class ResourceClass : uint32_t {
|
|
||||||
Elf,
|
|
||||||
Isa,
|
|
||||||
ModuleHeapDebugArea,
|
|
||||||
ContextSaveArea,
|
|
||||||
SbaTrackingBuffer,
|
|
||||||
L0ZebinModule,
|
|
||||||
MaxSize
|
|
||||||
};
|
|
||||||
|
|
||||||
struct QueryTopologyData {
|
struct QueryTopologyData {
|
||||||
int sliceCount;
|
int sliceCount;
|
||||||
int subSliceCount;
|
int subSliceCount;
|
||||||
@ -174,7 +165,7 @@ class Drm : public DriverModel {
|
|||||||
MOCKABLE_VIRTUAL void queryPageFaultSupport();
|
MOCKABLE_VIRTUAL void queryPageFaultSupport();
|
||||||
MOCKABLE_VIRTUAL bool hasPageFaultSupport() const;
|
MOCKABLE_VIRTUAL bool hasPageFaultSupport() const;
|
||||||
|
|
||||||
MOCKABLE_VIRTUAL uint32_t registerResource(ResourceClass classType, const void *data, size_t size);
|
MOCKABLE_VIRTUAL uint32_t registerResource(DrmResourceClass classType, const void *data, size_t size);
|
||||||
MOCKABLE_VIRTUAL void unregisterResource(uint32_t handle);
|
MOCKABLE_VIRTUAL void unregisterResource(uint32_t handle);
|
||||||
MOCKABLE_VIRTUAL uint32_t registerIsaCookie(uint32_t isaHandle);
|
MOCKABLE_VIRTUAL uint32_t registerIsaCookie(uint32_t isaHandle);
|
||||||
|
|
||||||
@ -318,7 +309,7 @@ class Drm : public DriverModel {
|
|||||||
std::mutex bindFenceMutex;
|
std::mutex bindFenceMutex;
|
||||||
std::array<uint64_t, EngineLimits::maxHandleCount> pagingFence;
|
std::array<uint64_t, EngineLimits::maxHandleCount> pagingFence;
|
||||||
std::array<uint64_t, EngineLimits::maxHandleCount> fenceVal;
|
std::array<uint64_t, EngineLimits::maxHandleCount> fenceVal;
|
||||||
StackVec<uint32_t, size_t(ResourceClass::MaxSize)> classHandles;
|
StackVec<uint32_t, size_t(DrmResourceClass::MaxSize)> classHandles;
|
||||||
std::vector<uint32_t> virtualMemoryIds;
|
std::vector<uint32_t> virtualMemoryIds;
|
||||||
|
|
||||||
std::unique_ptr<HwDeviceIdDrm> hwDeviceId;
|
std::unique_ptr<HwDeviceIdDrm> hwDeviceId;
|
||||||
|
@ -306,7 +306,7 @@ class DrmMockResources : public DrmMock {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t registerResource(ResourceClass classType, const void *data, size_t size) override {
|
uint32_t registerResource(DrmResourceClass classType, const void *data, size_t size) override {
|
||||||
registeredClass = classType;
|
registeredClass = classType;
|
||||||
memcpy_s(registeredData, sizeof(registeredData), data, size);
|
memcpy_s(registeredData, sizeof(registeredData), data, size);
|
||||||
registeredDataSize = size;
|
registeredDataSize = size;
|
||||||
@ -339,7 +339,7 @@ class DrmMockResources : public DrmMock {
|
|||||||
|
|
||||||
uint32_t unregisteredHandle = 0;
|
uint32_t unregisteredHandle = 0;
|
||||||
uint32_t unregisterCalledCount = 0;
|
uint32_t unregisterCalledCount = 0;
|
||||||
ResourceClass registeredClass = ResourceClass::MaxSize;
|
DrmResourceClass registeredClass = DrmResourceClass::MaxSize;
|
||||||
bool registerClassesCalled = false;
|
bool registerClassesCalled = false;
|
||||||
uint64_t registeredData[128];
|
uint64_t registeredData[128];
|
||||||
size_t registeredDataSize;
|
size_t registeredDataSize;
|
||||||
|
@ -241,6 +241,12 @@ int DrmMockPrelimContext::handlePrelimRequest(unsigned long request, void *arg)
|
|||||||
return uuidControlReturn;
|
return uuidControlReturn;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case PRELIM_DRM_IOCTL_I915_DEBUGGER_OPEN: {
|
||||||
|
auto debugger_open = reinterpret_cast<prelim_drm_i915_debugger_open_param *>(arg);
|
||||||
|
if (debugger_open->pid != 0 && debugger_open->events == 0) {
|
||||||
|
return debuggerOpenRetval;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -135,6 +135,9 @@ struct DrmMockPrelimContext {
|
|||||||
bool failDistanceInfoQuery{false};
|
bool failDistanceInfoQuery{false};
|
||||||
bool disableCcsSupport{false};
|
bool disableCcsSupport{false};
|
||||||
|
|
||||||
|
// Debugger ioctls
|
||||||
|
int debuggerOpenRetval = 10; // debugFd
|
||||||
|
|
||||||
int handlePrelimRequest(unsigned long request, void *arg);
|
int handlePrelimRequest(unsigned long request, void *arg);
|
||||||
bool handlePrelimQueryItem(void *arg);
|
bool handlePrelimQueryItem(void *arg);
|
||||||
void storeVmBindExtensions(uint64_t ptr, bool bind);
|
void storeVmBindExtensions(uint64_t ptr, bool bind);
|
||||||
|
@ -40,6 +40,7 @@ constexpr unsigned long int invalidIoctl = static_cast<unsigned long int>(-1);
|
|||||||
int setErrno = 0;
|
int setErrno = 0;
|
||||||
int fstatFuncRetVal = 0;
|
int fstatFuncRetVal = 0;
|
||||||
uint32_t preadFuncCalled = 0u;
|
uint32_t preadFuncCalled = 0u;
|
||||||
|
uint32_t pwriteFuncCalled = 0u;
|
||||||
uint32_t mmapFuncCalled = 0u;
|
uint32_t mmapFuncCalled = 0u;
|
||||||
uint32_t munmapFuncCalled = 0u;
|
uint32_t munmapFuncCalled = 0u;
|
||||||
bool isInvalidAILTest = false;
|
bool isInvalidAILTest = false;
|
||||||
@ -184,6 +185,7 @@ ssize_t pread(int fd, void *buf, size_t count, off_t offset) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset) {
|
ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset) {
|
||||||
|
pwriteFuncCalled++;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ TEST_F(DrmDebugPrelimTest, GivenUnsupportedUUIDRegisterIoctlWhenRegisteringClass
|
|||||||
TEST_F(DrmDebugPrelimTest, GivenNoClassesRegisteredWhenRegisteringResourceThenRegisterUUIDIoctlIsNotCalledAndZeroHandleReturned) {
|
TEST_F(DrmDebugPrelimTest, GivenNoClassesRegisteredWhenRegisteringResourceThenRegisterUUIDIoctlIsNotCalledAndZeroHandleReturned) {
|
||||||
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||||
|
|
||||||
auto registeredHandle = drm.registerResource(Drm::ResourceClass::Isa, nullptr, 0);
|
auto registeredHandle = drm.registerResource(DrmResourceClass::Isa, nullptr, 0);
|
||||||
EXPECT_EQ(0u, registeredHandle);
|
EXPECT_EQ(0u, registeredHandle);
|
||||||
EXPECT_EQ(0u, drm.ioctlCallsCount);
|
EXPECT_EQ(0u, drm.ioctlCallsCount);
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ TEST_F(DrmDebugPrelimTest, GivenDrmWhenRegisteringResourceWithoutDataThenRegiste
|
|||||||
EXPECT_TRUE(result);
|
EXPECT_TRUE(result);
|
||||||
|
|
||||||
const auto handle = drm.context.uuidHandle;
|
const auto handle = drm.context.uuidHandle;
|
||||||
auto registeredHandle = drm.registerResource(Drm::ResourceClass::Isa, nullptr, 0);
|
auto registeredHandle = drm.registerResource(DrmResourceClass::Isa, nullptr, 0);
|
||||||
|
|
||||||
EXPECT_EQ(handle + 1, drm.context.uuidHandle);
|
EXPECT_EQ(handle + 1, drm.context.uuidHandle);
|
||||||
EXPECT_EQ(handle, registeredHandle);
|
EXPECT_EQ(handle, registeredHandle);
|
||||||
@ -89,7 +89,7 @@ TEST_F(DrmDebugPrelimTest, GivenDrmWhenRegisteringResourceWithoutDataThenRegiste
|
|||||||
EXPECT_EQ(nullptr, receivedUuid->ptr);
|
EXPECT_EQ(nullptr, receivedUuid->ptr);
|
||||||
EXPECT_EQ(0u, receivedUuid->size);
|
EXPECT_EQ(0u, receivedUuid->size);
|
||||||
EXPECT_TRUE(hasSubstr(std::string(receivedUuid->uuid), std::string("00000000-0000-0000")));
|
EXPECT_TRUE(hasSubstr(std::string(receivedUuid->uuid), std::string("00000000-0000-0000")));
|
||||||
EXPECT_EQ(drm.classHandles[static_cast<uint32_t>(Drm::ResourceClass::Isa)], receivedUuid->uuidClass);
|
EXPECT_EQ(drm.classHandles[static_cast<uint32_t>(DrmResourceClass::Isa)], receivedUuid->uuidClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DrmDebugPrelimTest, GivenDrmWhenRegisteringResourceWithDataThenRegisterUUIDIoctlIsCalledWithCorrectData) {
|
TEST_F(DrmDebugPrelimTest, GivenDrmWhenRegisteringResourceWithDataThenRegisterUUIDIoctlIsCalledWithCorrectData) {
|
||||||
@ -101,7 +101,7 @@ TEST_F(DrmDebugPrelimTest, GivenDrmWhenRegisteringResourceWithDataThenRegisterUU
|
|||||||
auto handle = drm.context.uuidHandle;
|
auto handle = drm.context.uuidHandle;
|
||||||
uint64_t data = 0x12345678;
|
uint64_t data = 0x12345678;
|
||||||
|
|
||||||
auto registeredHandle = drm.registerResource(Drm::ResourceClass::Isa, &data, sizeof(uint64_t));
|
auto registeredHandle = drm.registerResource(DrmResourceClass::Isa, &data, sizeof(uint64_t));
|
||||||
|
|
||||||
EXPECT_EQ(handle + 1, drm.context.uuidHandle);
|
EXPECT_EQ(handle + 1, drm.context.uuidHandle);
|
||||||
EXPECT_EQ(handle, registeredHandle);
|
EXPECT_EQ(handle, registeredHandle);
|
||||||
@ -112,7 +112,7 @@ TEST_F(DrmDebugPrelimTest, GivenDrmWhenRegisteringResourceWithDataThenRegisterUU
|
|||||||
EXPECT_EQ(&data, receivedUuid->ptr);
|
EXPECT_EQ(&data, receivedUuid->ptr);
|
||||||
EXPECT_EQ(sizeof(uint64_t), receivedUuid->size);
|
EXPECT_EQ(sizeof(uint64_t), receivedUuid->size);
|
||||||
EXPECT_TRUE(hasSubstr(std::string(receivedUuid->uuid), std::string("00000000-0000-0000")));
|
EXPECT_TRUE(hasSubstr(std::string(receivedUuid->uuid), std::string("00000000-0000-0000")));
|
||||||
EXPECT_EQ(drm.classHandles[static_cast<uint32_t>(Drm::ResourceClass::Isa)], receivedUuid->uuidClass);
|
EXPECT_EQ(drm.classHandles[static_cast<uint32_t>(DrmResourceClass::Isa)], receivedUuid->uuidClass);
|
||||||
EXPECT_EQ(0u, receivedUuid->flags);
|
EXPECT_EQ(0u, receivedUuid->flags);
|
||||||
EXPECT_EQ(0u, receivedUuid->extensions);
|
EXPECT_EQ(0u, receivedUuid->extensions);
|
||||||
}
|
}
|
||||||
@ -124,7 +124,7 @@ TEST_F(DrmDebugPrelimTest, GivenDrmWhenUnregisteringResourceThenUnregisterUUIDIo
|
|||||||
EXPECT_TRUE(result);
|
EXPECT_TRUE(result);
|
||||||
|
|
||||||
uint64_t data = 0x12345678;
|
uint64_t data = 0x12345678;
|
||||||
auto registeredHandle = drm.registerResource(Drm::ResourceClass::Isa, &data, sizeof(uint64_t));
|
auto registeredHandle = drm.registerResource(DrmResourceClass::Isa, &data, sizeof(uint64_t));
|
||||||
|
|
||||||
drm.unregisterResource(registeredHandle);
|
drm.unregisterResource(registeredHandle);
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ TEST_F(DrmDebugPrelimTest, GivenDrmWhenRegisteringElfResourceWithoutDataThenRegi
|
|||||||
EXPECT_TRUE(result);
|
EXPECT_TRUE(result);
|
||||||
|
|
||||||
auto handle = drm.context.uuidHandle;
|
auto handle = drm.context.uuidHandle;
|
||||||
auto registeredHandle = drm.registerResource(Drm::ResourceClass::Elf, nullptr, 0);
|
auto registeredHandle = drm.registerResource(DrmResourceClass::Elf, nullptr, 0);
|
||||||
|
|
||||||
EXPECT_EQ(handle + 1, drm.context.uuidHandle);
|
EXPECT_EQ(handle + 1, drm.context.uuidHandle);
|
||||||
EXPECT_EQ(handle, registeredHandle);
|
EXPECT_EQ(handle, registeredHandle);
|
||||||
|
@ -37,7 +37,7 @@ TEST_F(DrmDebugTest, whenRegisterResourceClassesCalledThenTrueIsReturned) {
|
|||||||
TEST_F(DrmDebugTest, whenRegisterResourceCalledThenImplementationIsEmpty) {
|
TEST_F(DrmDebugTest, whenRegisterResourceCalledThenImplementationIsEmpty) {
|
||||||
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||||
|
|
||||||
auto handle = drmMock.registerResource(Drm::ResourceClass::MaxSize, nullptr, 0);
|
auto handle = drmMock.registerResource(DrmResourceClass::MaxSize, nullptr, 0);
|
||||||
EXPECT_EQ(0u, handle);
|
EXPECT_EQ(0u, handle);
|
||||||
drmMock.unregisterResource(handle);
|
drmMock.unregisterResource(handle);
|
||||||
EXPECT_EQ(0u, drmMock.ioctlCallsCount);
|
EXPECT_EQ(0u, drmMock.ioctlCallsCount);
|
||||||
|
Reference in New Issue
Block a user