mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-18 13:54:58 +08:00
feature: Add SW FIFO implementation
Related-To: NEO-7990 Signed-off-by: Jitendra Sharma <jitendra.sharma@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
4404d0c6b8
commit
6df6e4bbb0
@@ -1638,4 +1638,92 @@ void DebugSessionImp::getNotStoppedThreads(const std::vector<EuThread::ThreadId>
|
||||
}
|
||||
}
|
||||
|
||||
bool DebugSessionImp::isValidNode(uint64_t vmHandle, uint64_t gpuVa, SIP::fifo_node &node) {
|
||||
constexpr uint32_t failsafeTimeoutMax = 100, failsafeTimeoutWait = 50;
|
||||
uint32_t timeCount = 0;
|
||||
while (!node.valid && (timeCount < failsafeTimeoutMax)) {
|
||||
auto retVal = readGpuMemory(vmHandle, reinterpret_cast<char *>(&node), sizeof(SIP::fifo_node), gpuVa);
|
||||
if (retVal != ZE_RESULT_SUCCESS) {
|
||||
PRINT_DEBUGGER_ERROR_LOG("Reading FIFO failed, error = %d\n", retVal);
|
||||
return false;
|
||||
}
|
||||
NEO::sleep(std::chrono::milliseconds(failsafeTimeoutWait));
|
||||
timeCount += failsafeTimeoutWait;
|
||||
}
|
||||
if (!node.valid) {
|
||||
PRINT_DEBUGGER_ERROR_LOG("%S", "Invalid entry in SW FIFO\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ze_result_t DebugSessionImp::readFifo(uint64_t vmHandle, std::vector<EuThread::ThreadId> &threadsWithAttention) {
|
||||
auto stateSaveAreaHeader = getStateSaveAreaHeader();
|
||||
if (stateSaveAreaHeader->versionHeader.version.major < 3) {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
auto gpuVa = getContextStateSaveAreaGpuVa(vmHandle);
|
||||
|
||||
// Drain the fifo
|
||||
uint32_t drainRetries = 2, lastHead = ~0u;
|
||||
uint64_t offsetTail = (sizeof(SIP::StateSaveArea)) + offsetof(struct SIP::intelgt_state_save_area_V3, fifo_tail);
|
||||
uint64_t offsetHead = (sizeof(SIP::StateSaveArea)) + offsetof(struct SIP::intelgt_state_save_area_V3, fifo_head);
|
||||
const uint64_t offsetFifo = gpuVa + (stateSaveAreaHeader->versionHeader.size * 8) + stateSaveAreaHeader->regHeaderV3.fifo_offset;
|
||||
|
||||
while (drainRetries--) {
|
||||
constexpr uint32_t failsafeTimeoutWait = 50;
|
||||
std::vector<uint32_t> fifoIndices(2);
|
||||
uint32_t fifoHeadIndex = 0, fifoTailIndex = 0;
|
||||
|
||||
readGpuMemory(vmHandle, reinterpret_cast<char *>(fifoIndices.data()), fifoIndices.size() * sizeof(uint32_t), gpuVa + offsetHead);
|
||||
fifoHeadIndex = fifoIndices[0];
|
||||
fifoTailIndex = fifoIndices[1];
|
||||
|
||||
if (lastHead != fifoHeadIndex) {
|
||||
drainRetries++;
|
||||
}
|
||||
|
||||
while (fifoTailIndex != fifoHeadIndex) {
|
||||
uint32_t readSize = fifoTailIndex < fifoHeadIndex ? fifoHeadIndex - fifoTailIndex : stateSaveAreaHeader->regHeaderV3.fifo_size - fifoTailIndex;
|
||||
std::vector<SIP::fifo_node> nodes(readSize);
|
||||
uint64_t currentFifoOffset = offsetFifo + (sizeof(SIP::fifo_node) * fifoTailIndex);
|
||||
|
||||
auto retVal = readGpuMemory(vmHandle, reinterpret_cast<char *>(nodes.data()), readSize * sizeof(SIP::fifo_node), currentFifoOffset);
|
||||
if (retVal != ZE_RESULT_SUCCESS) {
|
||||
PRINT_DEBUGGER_ERROR_LOG("Reading FIFO failed, error = %d\n", retVal);
|
||||
return retVal;
|
||||
}
|
||||
for (uint32_t i = 0; i < readSize; i++) {
|
||||
PRINT_DEBUGGER_INFO_LOG("Validate entry at index %u in SW Fifo\n", (i + fifoTailIndex));
|
||||
UNRECOVERABLE_IF(!isValidNode(vmHandle, currentFifoOffset + (i * sizeof(SIP::fifo_node)), nodes[i]));
|
||||
threadsWithAttention.emplace_back(0, nodes[i].slice_id, nodes[i].subslice_id, nodes[i].eu_id, nodes[i].thread_id);
|
||||
nodes[i].valid = 0;
|
||||
}
|
||||
retVal = writeGpuMemory(vmHandle, reinterpret_cast<char *>(nodes.data()), readSize * sizeof(SIP::fifo_node), currentFifoOffset);
|
||||
if (retVal != ZE_RESULT_SUCCESS) {
|
||||
PRINT_DEBUGGER_ERROR_LOG("Writing FIFO failed, error = %d\n", retVal);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
if (fifoTailIndex < fifoHeadIndex) {
|
||||
// then we read to the head and are done
|
||||
fifoTailIndex = fifoHeadIndex;
|
||||
retVal = writeGpuMemory(vmHandle, reinterpret_cast<char *>(&fifoTailIndex), sizeof(uint32_t), gpuVa + offsetTail);
|
||||
if (retVal != ZE_RESULT_SUCCESS) {
|
||||
PRINT_DEBUGGER_ERROR_LOG("Writing FIFO failed, error = %d\n", retVal);
|
||||
return retVal;
|
||||
}
|
||||
} else {
|
||||
// wrap around
|
||||
fifoTailIndex = 0;
|
||||
}
|
||||
}
|
||||
lastHead = stateSaveAreaHeader->regHeaderV3.fifo_head;
|
||||
NEO::sleep(std::chrono::milliseconds(failsafeTimeoutWait));
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
|
||||
@@ -119,6 +119,8 @@ struct DebugSessionImp : DebugSession {
|
||||
const NEO::StateSaveAreaHeader *getStateSaveAreaHeader();
|
||||
void validateAndSetStateSaveAreaHeader(uint64_t vmHandle, uint64_t gpuVa);
|
||||
virtual void readStateSaveAreaHeader(){};
|
||||
MOCKABLE_VIRTUAL ze_result_t readFifo(uint64_t vmHandle, std::vector<EuThread::ThreadId> &threadsWithAttention);
|
||||
MOCKABLE_VIRTUAL bool isValidNode(uint64_t vmHandle, uint64_t gpuVa, SIP::fifo_node &node);
|
||||
|
||||
virtual uint64_t getContextStateSaveAreaGpuVa(uint64_t memoryHandle) = 0;
|
||||
virtual size_t getContextStateSaveAreaSize(uint64_t memoryHandle) = 0;
|
||||
|
||||
@@ -24,6 +24,7 @@ if(UNIX)
|
||||
target_sources(${L0_STATIC_LIB_NAME}
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/xe/debug_session.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/xe/${BRANCH_DIR_SUFFIX}handle_event_helper.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/xe/debug_session.h
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -205,7 +205,7 @@ struct DebugSessionLinux : DebugSessionImp {
|
||||
apiEventCondition.notify_all();
|
||||
}
|
||||
|
||||
void updateStoppedThreadsAndCheckTriggerEvents(AttentionEventFields &attention, uint32_t tileIndex, std::vector<EuThread::ThreadId> &threadsWithAttention);
|
||||
MOCKABLE_VIRTUAL void updateStoppedThreadsAndCheckTriggerEvents(AttentionEventFields &attention, uint32_t tileIndex, std::vector<EuThread::ThreadId> &threadsWithAttention);
|
||||
virtual void updateContextAndLrcHandlesForThreadsWithAttention(EuThread::ThreadId threadId, AttentionEventFields &attention) = 0;
|
||||
virtual uint64_t getVmHandleFromClientAndlrcHandle(uint64_t clientHandle, uint64_t lrcHandle) = 0;
|
||||
virtual std::unique_lock<std::mutex> getThreadStateMutexForTileSession(uint32_t tileIndex) = 0;
|
||||
|
||||
@@ -126,7 +126,7 @@ void DebugSessionLinuxXe::readInternalEventsAsync() {
|
||||
|
||||
if (result == ZE_RESULT_SUCCESS) {
|
||||
std::lock_guard<std::mutex> lock(internalEventThreadMutex);
|
||||
if (event->type == DRM_XE_EUDEBUG_EVENT_EU_ATTENTION) {
|
||||
if (eventTypeIsAttention(event->type)) {
|
||||
newestAttSeqNo.store(event->seqno);
|
||||
}
|
||||
|
||||
@@ -343,7 +343,7 @@ void DebugSessionLinuxXe::handleEvent(drm_xe_eudebug_event *event) {
|
||||
} break;
|
||||
|
||||
default:
|
||||
PRINT_DEBUGGER_INFO_LOG("DRM_XE_EUDEBUG_IOCTL_READ_EVENT type: UNHANDLED %u flags = %u len = %lu\n", (uint16_t)event->type, (uint16_t)event->flags, (uint32_t)event->len);
|
||||
additionalEvents(event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,6 +136,8 @@ struct DebugSessionLinuxXe : DebugSessionLinux {
|
||||
std::vector<std::unique_ptr<uint64_t[]>> pendingVmBindEvents;
|
||||
bool checkAllEventsCollected();
|
||||
MOCKABLE_VIRTUAL void handleEvent(drm_xe_eudebug_event *event);
|
||||
void additionalEvents(drm_xe_eudebug_event *event);
|
||||
MOCKABLE_VIRTUAL bool eventTypeIsAttention(uint16_t eventType);
|
||||
void readInternalEventsAsync() override;
|
||||
std::atomic<bool> detached{false};
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
|
||||
#include "level_zero/tools/source/debug/linux/xe/debug_session.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
void DebugSessionLinuxXe::additionalEvents(drm_xe_eudebug_event *event) {
|
||||
PRINT_DEBUGGER_INFO_LOG("DRM_XE_EUDEBUG_IOCTL_READ_EVENT type: UNHANDLED %u flags = %u len = %lu\n", (uint16_t)event->type, (uint16_t)event->flags, (uint32_t)event->len);
|
||||
}
|
||||
|
||||
bool DebugSessionLinuxXe::eventTypeIsAttention(uint16_t eventType) {
|
||||
return (eventType == DRM_XE_EUDEBUG_EVENT_EU_ATTENTION);
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
@@ -1843,6 +1843,163 @@ TEST(DebugSessionTest, GivenBindlessSipVersion2WhenResumingThreadThenCheckIfThre
|
||||
EXPECT_EQ(1u, sessionMock->checkThreadIsResumedCalled);
|
||||
}
|
||||
|
||||
struct DebugSessionTestSwFifoFixture : public ::testing::Test {
|
||||
void SetUp() override {
|
||||
auto stateSaveAreaHeader = MockSipData::createStateSaveAreaHeader(3);
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
auto hwInfo = *NEO::defaultHwInfo.get();
|
||||
NEO::MockDevice *neoDevice(NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(&hwInfo, 0));
|
||||
MockDeviceImp deviceImp(neoDevice, neoDevice->getExecutionEnvironment());
|
||||
session = std::make_unique<MockDebugSession>(config, &deviceImp);
|
||||
|
||||
stateSaveAreaHeaderPtr = reinterpret_cast<NEO::StateSaveAreaHeader *>(stateSaveAreaHeader.data());
|
||||
stateSaveAreaHeaderPtr->regHeaderV3.fifo_head = fifoHead;
|
||||
stateSaveAreaHeaderPtr->regHeaderV3.fifo_tail = fifoTail;
|
||||
|
||||
offsetFifo = (stateSaveAreaHeaderPtr->versionHeader.size * 8) + stateSaveAreaHeaderPtr->regHeaderV3.fifo_offset;
|
||||
stateSaveAreaHeader.resize(offsetFifo + stateSaveAreaHeaderPtr->regHeaderV3.fifo_size * (sizeof(SIP::fifo_node)));
|
||||
memcpy_s(stateSaveAreaHeader.data() + offsetFifo,
|
||||
fifoVecTillHead.size() * sizeof(SIP::fifo_node),
|
||||
fifoVecTillHead.data(),
|
||||
fifoVecTillHead.size() * sizeof(SIP::fifo_node));
|
||||
memcpy_s(stateSaveAreaHeader.data() + offsetFifo + fifoTail * sizeof(SIP::fifo_node),
|
||||
fifoVecFromTail.size() * sizeof(SIP::fifo_node),
|
||||
fifoVecFromTail.data(),
|
||||
fifoVecFromTail.size() * sizeof(SIP::fifo_node));
|
||||
session->stateSaveAreaHeader = std::move(stateSaveAreaHeader);
|
||||
}
|
||||
void TearDown() override {
|
||||
}
|
||||
|
||||
const std::vector<SIP::fifo_node> fifoVecTillHead = {{1, 0, 0, 0, 0}, {1, 1, 0, 0, 0}, {1, 2, 0, 0, 0}, {1, 3, 0, 0, 0}, {1, 4, 0, 0, 0}};
|
||||
const std::vector<SIP::fifo_node> fifoVecFromTail = {{1, 0, 1, 0, 0}, {1, 1, 1, 0, 0}, {1, 2, 1, 0, 0}, {1, 3, 1, 0, 0}, {1, 4, 1, 0, 0}, {1, 5, 1, 0, 0}};
|
||||
const uint32_t fifoHead = 5;
|
||||
const uint32_t fifoTail = 50;
|
||||
std::unique_ptr<L0::ult::MockDebugSession> session;
|
||||
NEO::StateSaveAreaHeader *stateSaveAreaHeaderPtr = nullptr;
|
||||
uint64_t offsetFifo = 0u;
|
||||
};
|
||||
|
||||
TEST_F(DebugSessionTestSwFifoFixture, GivenSwFifoWhenReadingSwFifoThenFifoIsCorrectlyReadAndDrained) {
|
||||
EXPECT_FALSE(session->stateSaveAreaHeader.empty());
|
||||
std::vector<EuThread::ThreadId> threadsWithAttention;
|
||||
session->readFifo(0, threadsWithAttention);
|
||||
|
||||
stateSaveAreaHeaderPtr = reinterpret_cast<NEO::StateSaveAreaHeader *>(session->stateSaveAreaHeader.data());
|
||||
std::vector<SIP::fifo_node> readFifoForValidation(stateSaveAreaHeaderPtr->regHeaderV3.fifo_size);
|
||||
session->readGpuMemory(0, reinterpret_cast<char *>(readFifoForValidation.data()), readFifoForValidation.size() * sizeof(SIP::fifo_node),
|
||||
reinterpret_cast<uint64_t>(session->stateSaveAreaHeader.data()) + offsetFifo);
|
||||
for (size_t i = 0; i < readFifoForValidation.size(); i++) {
|
||||
EXPECT_EQ(readFifoForValidation[i].valid, 0);
|
||||
}
|
||||
EXPECT_EQ(stateSaveAreaHeaderPtr->regHeaderV3.fifo_head, stateSaveAreaHeaderPtr->regHeaderV3.fifo_tail);
|
||||
|
||||
EXPECT_EQ(threadsWithAttention.size(), fifoVecFromTail.size() + fifoVecTillHead.size());
|
||||
size_t index = 0;
|
||||
for (; index < fifoVecFromTail.size(); index++) {
|
||||
EXPECT_EQ(threadsWithAttention[index].slice, fifoVecFromTail[index].slice_id);
|
||||
EXPECT_EQ(threadsWithAttention[index].subslice, fifoVecFromTail[index].subslice_id);
|
||||
EXPECT_EQ(threadsWithAttention[index].eu, fifoVecFromTail[index].eu_id);
|
||||
EXPECT_EQ(threadsWithAttention[index].thread, fifoVecFromTail[index].thread_id);
|
||||
}
|
||||
for (; index < fifoVecTillHead.size(); index++) {
|
||||
EXPECT_EQ(threadsWithAttention[index].slice, fifoVecTillHead[index].slice_id);
|
||||
EXPECT_EQ(threadsWithAttention[index].subslice, fifoVecTillHead[index].subslice_id);
|
||||
EXPECT_EQ(threadsWithAttention[index].eu, fifoVecTillHead[index].eu_id);
|
||||
EXPECT_EQ(threadsWithAttention[index].thread, fifoVecTillHead[index].thread_id);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(DebugSessionTestSwFifoFixture, GivenSwFifoWhenWriteGpuMemoryFailsWhileInValidatingNodeDuringFifoReadThenErrorReturned) {
|
||||
EXPECT_FALSE(session->stateSaveAreaHeader.empty());
|
||||
session->writeMemoryResult = ZE_RESULT_ERROR_UNKNOWN;
|
||||
std::vector<EuThread::ThreadId> threadsWithAttention;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, session->readFifo(0, threadsWithAttention));
|
||||
}
|
||||
|
||||
TEST_F(DebugSessionTestSwFifoFixture, GivenSwFifoWhenWriteGpuMemoryFailsWhileUpdatingTailIndexDuringFifoReadThenErrorReturned) {
|
||||
|
||||
EXPECT_FALSE(session->stateSaveAreaHeader.empty());
|
||||
session->forceWriteGpuMemoryFailOnCount = 3;
|
||||
std::vector<EuThread::ThreadId> threadsWithAttention;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, session->readFifo(0, threadsWithAttention));
|
||||
}
|
||||
|
||||
TEST_F(DebugSessionTestSwFifoFixture, GivenSwFifoWhenReadGpuMemoryFailsDuringFifoReadingThenErrorReturned) {
|
||||
|
||||
EXPECT_FALSE(session->stateSaveAreaHeader.empty());
|
||||
session->forcereadGpuMemoryFailOnCount = 3;
|
||||
std::vector<EuThread::ThreadId> threadsWithAttention;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, session->readFifo(0, threadsWithAttention));
|
||||
}
|
||||
|
||||
TEST(DebugSessionTest, GivenSwFifoWhenStateSaveAreaVersionIsLessThanThreeDuringFifoReadThenFifoIsNotReadAndSuccessIsReturned) {
|
||||
auto stateSaveAreaHeader = MockSipData::createStateSaveAreaHeader(2);
|
||||
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
auto hwInfo = *NEO::defaultHwInfo.get();
|
||||
NEO::MockDevice *neoDevice(NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(&hwInfo, 0));
|
||||
MockDeviceImp deviceImp(neoDevice, neoDevice->getExecutionEnvironment());
|
||||
auto session = std::make_unique<MockDebugSession>(config, &deviceImp);
|
||||
|
||||
session->stateSaveAreaHeader.clear();
|
||||
session->stateSaveAreaHeader.resize(stateSaveAreaHeader.size());
|
||||
memcpy_s(session->stateSaveAreaHeader.data(), session->stateSaveAreaHeader.size(), stateSaveAreaHeader.data(), stateSaveAreaHeader.size());
|
||||
|
||||
std::vector<EuThread::ThreadId> threadsWithAttention;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, session->readFifo(0, threadsWithAttention));
|
||||
}
|
||||
|
||||
TEST_F(DebugSessionTest, GivenSwFifoNodeWhenCheckingIsValidNodeThenAfterCheckingValidityOfNodeTrueOrFalseReturned) {
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
auto hwInfo = *NEO::defaultHwInfo.get();
|
||||
NEO::MockDevice *neoDevice(NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(&hwInfo, 0));
|
||||
MockDeviceImp deviceImp(neoDevice, neoDevice->getExecutionEnvironment());
|
||||
auto session = std::make_unique<MockDebugSession>(config, &deviceImp);
|
||||
|
||||
SIP::fifo_node node1 = {0, 1, 1, 0, 0};
|
||||
EXPECT_FALSE(session->isValidNode(0, 0, node1));
|
||||
|
||||
SIP::fifo_node node2 = {1, 1, 1, 0, 0};
|
||||
EXPECT_TRUE(session->isValidNode(0, 0, node2));
|
||||
}
|
||||
|
||||
TEST_F(DebugSessionTest, GivenInvalidSwFifoNodeWhenCheckingIsValidNodeAndOnReadingMemoryAgainNodeTurnsValidThenTrueReturned) {
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
auto hwInfo = *NEO::defaultHwInfo.get();
|
||||
NEO::MockDevice *neoDevice(NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(&hwInfo, 0));
|
||||
MockDeviceImp deviceImp(neoDevice, neoDevice->getExecutionEnvironment());
|
||||
auto session = std::make_unique<MockDebugSession>(config, &deviceImp);
|
||||
|
||||
// Declare node whose valid field is 0
|
||||
SIP::fifo_node invalidNode = {0, 1, 1, 0, 0};
|
||||
EXPECT_FALSE(session->isValidNode(0, reinterpret_cast<uint64_t>(session->readMemoryBuffer.data()), invalidNode));
|
||||
|
||||
SIP::fifo_node correctedNode = {1, 1, 1, 0, 0};
|
||||
session->readMemoryBuffer.resize(sizeof(SIP::fifo_node));
|
||||
memcpy_s(session->readMemoryBuffer.data(), session->readMemoryBuffer.size(), reinterpret_cast<void *>(&correctedNode), sizeof(SIP::fifo_node));
|
||||
|
||||
EXPECT_TRUE(session->isValidNode(0, reinterpret_cast<uint64_t>(session->readMemoryBuffer.data()), invalidNode));
|
||||
}
|
||||
|
||||
TEST_F(DebugSessionTest, GivenInvalidSwFifoNodeWhenCheckingIsValidNodeAndOnReadingMemoryAgainReadMemoryFailsThenFalseReturned) {
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
auto hwInfo = *NEO::defaultHwInfo.get();
|
||||
NEO::MockDevice *neoDevice(NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(&hwInfo, 0));
|
||||
MockDeviceImp deviceImp(neoDevice, neoDevice->getExecutionEnvironment());
|
||||
auto session = std::make_unique<MockDebugSession>(config, &deviceImp);
|
||||
|
||||
// Declare node whose valid field is 0
|
||||
SIP::fifo_node invalidNode = {0, 1, 1, 0, 0};
|
||||
session->readMemoryResult = ZE_RESULT_ERROR_UNKNOWN;
|
||||
EXPECT_FALSE(session->isValidNode(0, reinterpret_cast<uint64_t>(session->readMemoryBuffer.data()), invalidNode));
|
||||
}
|
||||
|
||||
TEST_F(DebugSessionTest, givenTssMagicCorruptedWhenStateSaveAreIsReadThenHeaderIsNotSet) {
|
||||
auto stateSaveAreaHeader = MockSipData::createStateSaveAreaHeader(2);
|
||||
auto versionHeader = &reinterpret_cast<SIP::StateSaveAreaHeader *>(stateSaveAreaHeader.data())->versionHeader;
|
||||
|
||||
@@ -15,4 +15,4 @@ if(UNIX)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
add_subdirectories()
|
||||
|
||||
@@ -150,9 +150,11 @@ struct MockDebugSessionLinuxXe : public L0::DebugSessionLinuxXe {
|
||||
using L0::DebugSessionImp::apiEvents;
|
||||
using L0::DebugSessionImp::expectedAttentionEvents;
|
||||
using L0::DebugSessionImp::interruptSent;
|
||||
using L0::DebugSessionImp::readFifo;
|
||||
using L0::DebugSessionImp::stateSaveAreaHeader;
|
||||
using L0::DebugSessionImp::triggerEvents;
|
||||
using L0::DebugSessionLinux::getClientConnection;
|
||||
using L0::DebugSessionLinux::updateStoppedThreadsAndCheckTriggerEvents;
|
||||
using L0::DebugSessionLinuxXe::addThreadToNewlyStoppedFromRaisedAttentionForTileSession;
|
||||
using L0::DebugSessionLinuxXe::asyncThread;
|
||||
using L0::DebugSessionLinuxXe::asyncThreadFunction;
|
||||
@@ -163,6 +165,7 @@ struct MockDebugSessionLinuxXe : public L0::DebugSessionLinuxXe {
|
||||
using L0::DebugSessionLinuxXe::clientHandleToConnection;
|
||||
using L0::DebugSessionLinuxXe::debugArea;
|
||||
using L0::DebugSessionLinuxXe::euControlInterruptSeqno;
|
||||
using L0::DebugSessionLinuxXe::eventTypeIsAttention;
|
||||
using L0::DebugSessionLinuxXe::getThreadStateMutexForTileSession;
|
||||
using L0::DebugSessionLinuxXe::getVmHandleFromClientAndlrcHandle;
|
||||
using L0::DebugSessionLinuxXe::handleEvent;
|
||||
|
||||
@@ -160,8 +160,10 @@ struct MockDebugSession : public L0::DebugSessionImp {
|
||||
using L0::DebugSessionImp::generateEventsForStoppedThreads;
|
||||
using L0::DebugSessionImp::getRegisterSize;
|
||||
using L0::DebugSessionImp::getStateSaveAreaHeader;
|
||||
using L0::DebugSessionImp::isValidNode;
|
||||
using L0::DebugSessionImp::newAttentionRaised;
|
||||
using L0::DebugSessionImp::readDebugScratchRegisters;
|
||||
using L0::DebugSessionImp::readFifo;
|
||||
using L0::DebugSessionImp::readModeFlags;
|
||||
using L0::DebugSessionImp::readSbaRegisters;
|
||||
using L0::DebugSessionImp::readThreadScratchRegisters;
|
||||
@@ -314,6 +316,10 @@ struct MockDebugSession : public L0::DebugSessionImp {
|
||||
return readMemoryResult;
|
||||
}
|
||||
ze_result_t writeGpuMemory(uint64_t memoryHandle, const char *input, size_t size, uint64_t gpuVa) override {
|
||||
writeGpuMemoryCallCount++;
|
||||
if (forceWriteGpuMemoryFailOnCount == writeGpuMemoryCallCount) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
if (gpuVa != 0 && gpuVa >= reinterpret_cast<uint64_t>(stateSaveAreaHeader.data()) &&
|
||||
((gpuVa + size) <= reinterpret_cast<uint64_t>(stateSaveAreaHeader.data() + stateSaveAreaHeader.size()))) {
|
||||
@@ -539,6 +545,9 @@ struct MockDebugSession : public L0::DebugSessionImp {
|
||||
uint32_t readGpuMemoryCallCount = 0;
|
||||
uint32_t forcereadGpuMemoryFailOnCount = 0;
|
||||
|
||||
uint32_t writeGpuMemoryCallCount = 0;
|
||||
uint32_t forceWriteGpuMemoryFailOnCount = 0;
|
||||
|
||||
bool skipWriteResumeCommand = true;
|
||||
uint32_t writeResumeCommandCalled = 0;
|
||||
|
||||
|
||||
@@ -191,7 +191,15 @@ std::vector<char> createStateSaveAreaHeader(uint32_t version, uint16_t grfNum, u
|
||||
begin = reinterpret_cast<char *>(&stateSaveAreaHeader2);
|
||||
sizeOfHeader = offsetof(SIP::StateSaveAreaHeader, regHeader.dbg_reg) + sizeof(SIP::StateSaveAreaHeader::regHeader.dbg_reg);
|
||||
} else if (version == 3) {
|
||||
stateSaveAreaHeader3.versionHeader.size = sizeof(stateSaveAreaHeader3) / 8;
|
||||
begin = reinterpret_cast<char *>(&stateSaveAreaHeader3);
|
||||
stateSaveAreaHeader3.regHeaderV3.fifo_size = 56;
|
||||
|
||||
stateSaveAreaHeader3.regHeaderV3.fifo_offset = (stateSaveAreaHeader3.regHeaderV3.num_slices *
|
||||
stateSaveAreaHeader3.regHeaderV3.num_subslices_per_slice *
|
||||
stateSaveAreaHeader3.regHeaderV3.num_eus_per_subslice *
|
||||
stateSaveAreaHeader3.regHeaderV3.num_threads_per_eu *
|
||||
stateSaveAreaHeader3.regHeaderV3.state_save_size);
|
||||
sizeOfHeader = offsetof(NEO::StateSaveAreaHeader, regHeaderV3.msg) + sizeof(NEO::StateSaveAreaHeader::regHeaderV3.msg);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user