Debugger L0 Win: Attention event handling from UMD

Related-To: NEO-7261

Signed-off-by: Jitendra Sharma <jitendra.sharma@intel.com>
This commit is contained in:
Jitendra Sharma
2022-08-23 11:17:12 +00:00
committed by Compute-Runtime-Automation
parent 22fb71a268
commit 3212a71760
16 changed files with 423 additions and 109 deletions

View File

@@ -627,6 +627,25 @@ void DebugSessionImp::sendInterrupts() {
}
}
bool DebugSessionImp::readSystemRoutineIdent(EuThread *thread, uint64_t memoryHandle, SIP::sr_ident &srIdent) {
auto stateSaveAreaHeader = getStateSaveAreaHeader();
if (!stateSaveAreaHeader) {
return false;
}
auto gpuVa = getContextStateSaveAreaGpuVa(memoryHandle);
if (gpuVa == 0) {
return false;
}
auto threadSlotOffset = calculateThreadSlotOffset(thread->getThreadId());
auto srMagicOffset = threadSlotOffset + getStateSaveAreaHeader()->regHeader.sr_magic_offset;
if (ZE_RESULT_SUCCESS != readGpuMemory(memoryHandle, reinterpret_cast<char *>(&srIdent), sizeof(srIdent), gpuVa + srMagicOffset)) {
return false;
}
return true;
}
void DebugSessionImp::markPendingInterruptsOrAddToNewlyStoppedFromRaisedAttention(EuThread::ThreadId threadId, uint64_t memoryHandle) {
SIP::sr_ident srMagic = {};

View File

@@ -73,7 +73,7 @@ struct DebugSessionImp : DebugSession {
ze_result_t validateThreadAndDescForMemoryAccess(ze_device_thread_t thread, const zet_debug_memory_space_desc_t *desc);
virtual void enqueueApiEvent(zet_debug_event_t &debugEvent) = 0;
virtual bool readSystemRoutineIdent(EuThread *thread, uint64_t vmHandle, SIP::sr_ident &srMagic) = 0;
MOCKABLE_VIRTUAL bool readSystemRoutineIdent(EuThread *thread, uint64_t vmHandle, SIP::sr_ident &srMagic);
ze_result_t readSbaRegisters(EuThread::ThreadId thread, uint32_t start, uint32_t count, void *pRegisterValues);
MOCKABLE_VIRTUAL bool isForceExceptionOrForceExternalHaltOnlyExceptionReason(uint32_t *cr0);
@@ -89,9 +89,7 @@ struct DebugSessionImp : DebugSession {
void validateAndSetStateSaveAreaHeader(const std::vector<char> &data);
virtual void readStateSaveAreaHeader(){};
virtual uint64_t getContextStateSaveAreaGpuVa(uint64_t memoryHandle) {
return 0;
};
virtual uint64_t getContextStateSaveAreaGpuVa(uint64_t memoryHandle) = 0;
ze_result_t registersAccessHelper(const EuThread *thread, const SIP::regset_desc *regdesc,
uint32_t start, uint32_t count, void *pRegisterValues, bool write);

View File

@@ -1580,25 +1580,6 @@ ze_result_t DebugSessionLinux::acknowledgeEvent(const zet_debug_event_t *event)
return ZE_RESULT_ERROR_UNINITIALIZED;
}
bool DebugSessionLinux::readSystemRoutineIdent(EuThread *thread, uint64_t vmHandle, SIP::sr_ident &srIdent) {
auto stateSaveAreaHeader = getStateSaveAreaHeader();
if (!stateSaveAreaHeader) {
return false;
}
auto gpuVa = getContextStateSaveAreaGpuVa(vmHandle);
if (gpuVa == 0) {
return false;
}
auto threadSlotOffset = calculateThreadSlotOffset(thread->getThreadId());
auto srMagicOffset = threadSlotOffset + getStateSaveAreaHeader()->regHeader.sr_magic_offset;
if (ZE_RESULT_SUCCESS != readGpuMemory(vmHandle, reinterpret_cast<char *>(&srIdent), sizeof(srIdent), gpuVa + srMagicOffset)) {
return false;
}
return true;
}
ze_result_t DebugSessionLinux::readSbaBuffer(EuThread::ThreadId threadId, NEO::SbaTrackedAddresses &sbaBuffer) {
auto vmHandle = allThreads[threadId]->getMemoryHandle();

View File

@@ -263,8 +263,6 @@ struct DebugSessionLinux : DebugSessionImp {
virtual bool tryAccessIsa(uint32_t deviceIndex, const zet_debug_memory_space_desc_t *desc, size_t size, void *buffer, bool write, ze_result_t &status);
ze_result_t accessDefaultMemForThreadAll(const zet_debug_memory_space_desc_t *desc, size_t size, void *buffer, bool write);
bool readSystemRoutineIdent(EuThread *thread, uint64_t vmHandle, SIP::sr_ident &srIdent) override;
MOCKABLE_VIRTUAL int threadControl(const std::vector<EuThread::ThreadId> &threads, uint32_t tile, ThreadControlCmd threadCmd, std::unique_ptr<uint8_t[]> &bitmask, size_t &bitmaskSize);
uint64_t getContextStateSaveAreaGpuVa(uint64_t memoryHandle) override;

View File

@@ -11,6 +11,8 @@
#include "shared/source/helpers/register_offsets.h"
#include "shared/source/os_interface/windows/wddm_debug.h"
#include "level_zero/core/source/hw_helpers/l0_hw_helper.h"
#include "common/StateSaveAreaHeader.h"
namespace L0 {
@@ -112,6 +114,8 @@ void *DebugSessionWindows::asyncThreadFunction(void *arg) {
while (self->asyncThread.threadActive) {
self->readAndHandleEvent(100);
self->sendInterrupts();
self->generateEventsAndResumeStoppedThreads();
}
PRINT_DEBUGGER_INFO_LOG("Debugger async thread closing\n", "");
@@ -221,7 +225,38 @@ ze_result_t DebugSessionWindows::handleModuleCreateEvent(uint32_t seqNo, DBGUMD_
}
ze_result_t DebugSessionWindows::handleEuAttentionBitsEvent(DBGUMD_READ_EVENT_EU_ATTN_BIT_SET_PARAMS &euAttentionBitsParams) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
PRINT_DEBUGGER_INFO_LOG("DBGUMD_READ_EVENT_EU_ATTN_BIT_SET_PARAMS: hContextHandle=0x%llX LRCA=%d BitMaskSizeInBytes=%d BitmaskArrayPtr=0x%llX\n",
euAttentionBitsParams.hContextHandle, euAttentionBitsParams.LRCA,
euAttentionBitsParams.BitMaskSizeInBytes, euAttentionBitsParams.BitmaskArrayPtr);
auto hwInfo = connectedDevice->getHwInfo();
auto &l0HwHelper = L0HwHelper::get(hwInfo.platform.eRenderCoreFamily);
auto threadsWithAttention = l0HwHelper.getThreadsFromAttentionBitmask(hwInfo, 0u,
reinterpret_cast<uint8_t *>(euAttentionBitsParams.BitmaskArrayPtr),
euAttentionBitsParams.BitMaskSizeInBytes);
printBitmask(reinterpret_cast<uint8_t *>(euAttentionBitsParams.BitmaskArrayPtr), euAttentionBitsParams.BitMaskSizeInBytes);
PRINT_DEBUGGER_THREAD_LOG("ATTENTION received for thread count = %d\n", (int)threadsWithAttention.size());
uint64_t memoryHandle = DebugSessionWindows::invalidHandle;
{
std::unique_lock<std::mutex> lock(asyncThreadMutex);
if (allContexts.empty()) {
return ZE_RESULT_ERROR_UNINITIALIZED;
}
memoryHandle = *allContexts.begin();
}
for (auto &threadId : threadsWithAttention) {
PRINT_DEBUGGER_THREAD_LOG("ATTENTION event for thread: %s\n", EuThread::toString(threadId).c_str());
markPendingInterruptsOrAddToNewlyStoppedFromRaisedAttention(threadId, memoryHandle);
}
checkTriggerEventsForAttention();
return ZE_RESULT_SUCCESS;
}
ze_result_t DebugSessionWindows::handleAllocationDataEvent(uint32_t seqNo, DBGUMD_READ_EVENT_READ_ALLOCATION_DATA_PARAMS &allocationDataParams) {
@@ -533,10 +568,7 @@ ze_result_t DebugSessionWindows::writeGpuMemory(uint64_t memoryHandle, const cha
}
void DebugSessionWindows::enqueueApiEvent(zet_debug_event_t &debugEvent) {
}
bool DebugSessionWindows::readSystemRoutineIdent(EuThread *thread, uint64_t vmHandle, SIP::sr_ident &srMagic) {
return false;
pushApiEvent(debugEvent, 0, 0);
}
ze_result_t DebugSessionWindows::readSbaBuffer(EuThread::ThreadId threadId, NEO::SbaTrackedAddresses &sbaBuffer) {

View File

@@ -55,6 +55,9 @@ struct DebugSessionWindows : DebugSessionImp {
ze_result_t readElfSpace(const zet_debug_memory_space_desc_t *desc, size_t size, void *buffer);
ze_result_t readSbaBuffer(EuThread::ThreadId, NEO::SbaTrackedAddresses &sbaBuffer) override;
uint64_t getContextStateSaveAreaGpuVa(uint64_t memoryHandle) override {
return this->stateSaveAreaVA.load();
}
void readStateSaveAreaHeader() override;
MOCKABLE_VIRTUAL ze_result_t readAndHandleEvent(uint64_t timeoutMs);
@@ -67,7 +70,6 @@ struct DebugSessionWindows : DebugSessionImp {
ze_result_t readAllocationDebugData(uint32_t seqNo, uint64_t umdDataBufferPtr, void *outBuf, size_t outBufSize);
void enqueueApiEvent(zet_debug_event_t &debugEvent) override;
bool readSystemRoutineIdent(EuThread *thread, uint64_t vmHandle, SIP::sr_ident &srMagic) override;
bool readModuleDebugArea() override;
void startAsyncThread() override;
void closeAsyncThread();