mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-30 01:35:20 +08:00
L0Debug - tile attach - add missing implementation
- interrupt / resume - read/write registers Related-To: NEO-5784 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
835174c076
commit
4bd53be195
@@ -284,7 +284,7 @@ void DebugSessionLinux::createTileSessionsIfEnabled() {
|
||||
|
||||
for (uint32_t i = 0; i < numTiles; i++) {
|
||||
auto subDevice = connectedDevice->getNEODevice()->getSubDevice(i)->getSpecializedDevice<Device>();
|
||||
tileSessions[i] = std::pair<DebugSession *, bool>{createTileSession(config, subDevice, this), false};
|
||||
tileSessions[i] = std::pair<DebugSessionImp *, bool>{createTileSession(config, subDevice, this), false};
|
||||
}
|
||||
tileSessionsEnabled = true;
|
||||
}
|
||||
@@ -301,8 +301,15 @@ void *DebugSessionLinux::asyncThreadFunction(void *arg) {
|
||||
while (self->asyncThread.threadActive) {
|
||||
self->handleEventsAsync();
|
||||
|
||||
self->sendInterrupts();
|
||||
self->generateEventsAndResumeStoppedThreads();
|
||||
if (self->tileSessionsEnabled) {
|
||||
for (size_t tileIndex = 0; tileIndex < self->tileSessions.size(); tileIndex++) {
|
||||
static_cast<TileDebugSessionLinux *>(self->tileSessions[tileIndex].first)->sendInterrupts();
|
||||
static_cast<TileDebugSessionLinux *>(self->tileSessions[tileIndex].first)->generateEventsAndResumeStoppedThreads();
|
||||
}
|
||||
} else {
|
||||
self->sendInterrupts();
|
||||
self->generateEventsAndResumeStoppedThreads();
|
||||
}
|
||||
}
|
||||
|
||||
PRINT_DEBUGGER_INFO_LOG("Debugger async thread closing\n", "");
|
||||
@@ -382,8 +389,8 @@ void DebugSessionLinux::readInternalEventsAsync() {
|
||||
if (tileSessionsEnabled) {
|
||||
auto numTiles = connectedDevice->getNEODevice()->getNumSubDevices();
|
||||
for (uint32_t tileIndex = 0; tileIndex < numTiles; tileIndex++) {
|
||||
reinterpret_cast<TileDebugSessionLinux *>(tileSessions[tileIndex].first)->pushApiEvent(debugEvent, nullptr);
|
||||
reinterpret_cast<TileDebugSessionLinux *>(tileSessions[tileIndex].first)->detached = true;
|
||||
static_cast<TileDebugSessionLinux *>(tileSessions[tileIndex].first)->pushApiEvent(debugEvent, nullptr);
|
||||
static_cast<TileDebugSessionLinux *>(tileSessions[tileIndex].first)->detached = true;
|
||||
}
|
||||
} else {
|
||||
pushApiEvent(debugEvent, nullptr);
|
||||
@@ -502,7 +509,7 @@ void DebugSessionLinux::handleEvent(prelim_drm_i915_debug_event *event) {
|
||||
debugEvent.type = ZET_DEBUG_EVENT_TYPE_PROCESS_EXIT;
|
||||
|
||||
if (tileSessionsEnabled) {
|
||||
reinterpret_cast<TileDebugSessionLinux *>(tileSessions[deviceIndex].first)->pushApiEvent(debugEvent, nullptr);
|
||||
static_cast<TileDebugSessionLinux *>(tileSessions[deviceIndex].first)->pushApiEvent(debugEvent, nullptr);
|
||||
} else if (uuidL0CommandQueueHandleToDevice.size() == 0) {
|
||||
pushApiEvent(debugEvent, nullptr);
|
||||
}
|
||||
@@ -546,7 +553,7 @@ void DebugSessionLinux::handleEvent(prelim_drm_i915_debug_event *event) {
|
||||
if (tileSessionsEnabled) {
|
||||
UNRECOVERABLE_IF(uuidL0CommandQueueHandleToDevice.find(uuid->handle) != uuidL0CommandQueueHandleToDevice.end());
|
||||
|
||||
reinterpret_cast<TileDebugSessionLinux *>(tileSessions[deviceIndex].first)->pushApiEvent(debugEvent, nullptr);
|
||||
static_cast<TileDebugSessionLinux *>(tileSessions[deviceIndex].first)->pushApiEvent(debugEvent, nullptr);
|
||||
} else if (uuidL0CommandQueueHandleToDevice.size() == 0) {
|
||||
pushApiEvent(debugEvent, nullptr);
|
||||
}
|
||||
@@ -781,7 +788,7 @@ void DebugSessionLinux::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *v
|
||||
}
|
||||
|
||||
if (connection->uuidMap[uuid].classIndex == NEO::DrmResourceClass::Isa) {
|
||||
PRINT_DEBUGGER_INFO_LOG("ISA vm_handle = %llu", (uint64_t)vmHandle);
|
||||
PRINT_DEBUGGER_INFO_LOG("ISA vm_handle = %llu, tileIndex = %lu", (uint64_t)vmHandle, tileIndex);
|
||||
|
||||
const auto isaUuidHandle = connection->uuidMap[uuid].handle;
|
||||
bool perKernelModules = true;
|
||||
@@ -858,17 +865,20 @@ void DebugSessionLinux::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *v
|
||||
|
||||
if (tileSessionsEnabled) {
|
||||
auto tileAttached = tileSessions[tileIndex].second;
|
||||
|
||||
if (!tileAttached) {
|
||||
isaMap[vmBind->va_start]->moduleLoadEventAck = true;
|
||||
apiEventNeedsAck = false;
|
||||
}
|
||||
|
||||
PRINT_DEBUGGER_INFO_LOG("TileDebugSession attached = %d, tileIndex = %lu, apiEventNeedsAck = %d", (int)tileAttached, tileIndex, (int)apiEventNeedsAck);
|
||||
}
|
||||
memLock.unlock();
|
||||
|
||||
if (perKernelModules) {
|
||||
debugEvent.flags = apiEventNeedsAck ? ZET_DEBUG_EVENT_FLAG_NEED_ACK : 0;
|
||||
if (tileSessionsEnabled) {
|
||||
reinterpret_cast<TileDebugSessionLinux *>(tileSessions[tileIndex].first)->pushApiEvent(debugEvent, nullptr);
|
||||
static_cast<TileDebugSessionLinux *>(tileSessions[tileIndex].first)->pushApiEvent(debugEvent, nullptr);
|
||||
} else {
|
||||
pushApiEvent(debugEvent, nullptr);
|
||||
}
|
||||
@@ -905,7 +915,7 @@ void DebugSessionLinux::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *v
|
||||
|
||||
if (perKernelModules) {
|
||||
if (tileSessionsEnabled) {
|
||||
reinterpret_cast<TileDebugSessionLinux *>(tileSessions[tileIndex].first)->pushApiEvent(debugEvent, nullptr);
|
||||
static_cast<TileDebugSessionLinux *>(tileSessions[tileIndex].first)->pushApiEvent(debugEvent, nullptr);
|
||||
} else {
|
||||
pushApiEvent(debugEvent, nullptr);
|
||||
}
|
||||
@@ -947,9 +957,9 @@ void DebugSessionLinux::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *v
|
||||
} else {
|
||||
auto tileAttached = tileSessions[tileIndex].second;
|
||||
if (!tileAttached) {
|
||||
reinterpret_cast<TileDebugSessionLinux *>(tileSessions[tileIndex].first)->pushApiEvent(debugEvent, nullptr);
|
||||
static_cast<TileDebugSessionLinux *>(tileSessions[tileIndex].first)->pushApiEvent(debugEvent, nullptr);
|
||||
} else {
|
||||
reinterpret_cast<TileDebugSessionLinux *>(tileSessions[tileIndex].first)->pushApiEvent(debugEvent, &vmBind->base);
|
||||
static_cast<TileDebugSessionLinux *>(tileSessions[tileIndex].first)->pushApiEvent(debugEvent, &vmBind->base);
|
||||
shouldAckEvent = false;
|
||||
}
|
||||
}
|
||||
@@ -971,7 +981,7 @@ void DebugSessionLinux::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *v
|
||||
debugEvent.info.module.moduleEnd = connection->uuidMap[module.elfUuidHandle].ptr + connection->uuidMap[module.elfUuidHandle].dataSize;
|
||||
|
||||
if (tileSessionsEnabled) {
|
||||
reinterpret_cast<TileDebugSessionLinux *>(tileSessions[tileIndex].first)->pushApiEvent(debugEvent, nullptr);
|
||||
static_cast<TileDebugSessionLinux *>(tileSessions[tileIndex].first)->pushApiEvent(debugEvent, nullptr);
|
||||
} else {
|
||||
pushApiEvent(debugEvent, nullptr);
|
||||
}
|
||||
@@ -1083,10 +1093,18 @@ void DebugSessionLinux::handleAttentionEvent(prelim_drm_i915_debug_event_eu_atte
|
||||
for (auto &threadId : threadsWithAttention) {
|
||||
PRINT_DEBUGGER_THREAD_LOG("ATTENTION event for thread: %s\n", EuThread::toString(threadId).c_str());
|
||||
|
||||
markPendingInterruptsOrAddToNewlyStoppedFromRaisedAttention(threadId, vmHandle);
|
||||
if (tileSessionsEnabled) {
|
||||
static_cast<TileDebugSessionLinux *>(tileSessions[tileIndex].first)->markPendingInterruptsOrAddToNewlyStoppedFromRaisedAttention(threadId, vmHandle);
|
||||
} else {
|
||||
markPendingInterruptsOrAddToNewlyStoppedFromRaisedAttention(threadId, vmHandle);
|
||||
}
|
||||
}
|
||||
|
||||
checkTriggerEventsForAttention();
|
||||
if (tileSessionsEnabled) {
|
||||
static_cast<TileDebugSessionLinux *>(tileSessions[tileIndex].first)->checkTriggerEventsForAttention();
|
||||
} else {
|
||||
checkTriggerEventsForAttention();
|
||||
}
|
||||
}
|
||||
|
||||
void DebugSessionLinux::handleEnginesEvent(prelim_drm_i915_debug_event_engines *engines) {
|
||||
@@ -1672,21 +1690,4 @@ void TileDebugSessionLinux::readStateSaveAreaHeader() {
|
||||
}
|
||||
};
|
||||
|
||||
ze_result_t TileDebugSessionLinux::interrupt(ze_device_thread_t thread) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
};
|
||||
|
||||
ze_result_t TileDebugSessionLinux::resume(ze_device_thread_t thread) {
|
||||
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
};
|
||||
|
||||
ze_result_t TileDebugSessionLinux::readRegisters(ze_device_thread_t thread, uint32_t type, uint32_t start, uint32_t count, void *pRegisterValues) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
};
|
||||
|
||||
ze_result_t TileDebugSessionLinux::writeRegisters(ze_device_thread_t thread, uint32_t type, uint32_t start, uint32_t count, void *pRegisterValues) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
|
||||
@@ -258,7 +258,7 @@ struct DebugSessionLinux : DebugSessionImp {
|
||||
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;
|
||||
uint64_t getSbaBufferGpuVa(uint64_t memoryHandle);
|
||||
virtual uint64_t getSbaBufferGpuVa(uint64_t memoryHandle);
|
||||
void printContextVms();
|
||||
|
||||
ThreadHelper internalEventThread;
|
||||
@@ -282,16 +282,14 @@ struct DebugSessionLinux : DebugSessionImp {
|
||||
|
||||
struct TileDebugSessionLinux : DebugSessionLinux {
|
||||
TileDebugSessionLinux(zet_debug_config_t config, Device *device, DebugSessionImp *rootDebugSession) : DebugSessionLinux(config, device, 0),
|
||||
rootDebugSession(reinterpret_cast<DebugSessionLinux *>(rootDebugSession)){};
|
||||
rootDebugSession(reinterpret_cast<DebugSessionLinux *>(rootDebugSession)) {
|
||||
tileIndex = Math::log2(static_cast<uint32_t>(connectedDevice->getNEODevice()->getDeviceBitfield().to_ulong()));
|
||||
}
|
||||
|
||||
~TileDebugSessionLinux() override = default;
|
||||
|
||||
bool closeConnection() override { return true; };
|
||||
ze_result_t initialize() override { return ZE_RESULT_SUCCESS; };
|
||||
|
||||
ze_result_t interrupt(ze_device_thread_t thread) override;
|
||||
ze_result_t resume(ze_device_thread_t thread) override;
|
||||
ze_result_t readRegisters(ze_device_thread_t thread, uint32_t type, uint32_t start, uint32_t count, void *pRegisterValues) override;
|
||||
ze_result_t writeRegisters(ze_device_thread_t thread, uint32_t type, uint32_t start, uint32_t count, void *pRegisterValues) override;
|
||||
bool closeConnection() override { return true; }
|
||||
ze_result_t initialize() override { return ZE_RESULT_SUCCESS; }
|
||||
|
||||
protected:
|
||||
void startAsyncThread() override { UNRECOVERABLE_IF(true); };
|
||||
@@ -304,6 +302,10 @@ struct TileDebugSessionLinux : DebugSessionLinux {
|
||||
|
||||
void readStateSaveAreaHeader() override;
|
||||
|
||||
uint64_t getSbaBufferGpuVa(uint64_t memoryHandle) override {
|
||||
return rootDebugSession->getSbaBufferGpuVa(memoryHandle);
|
||||
}
|
||||
|
||||
int ioctl(unsigned long request, void *arg) override {
|
||||
return rootDebugSession->ioctl(request, arg);
|
||||
}
|
||||
@@ -322,22 +324,27 @@ struct TileDebugSessionLinux : DebugSessionLinux {
|
||||
}
|
||||
|
||||
bool ackIsaEvents(uint32_t deviceIndex, uint64_t isaVa) override {
|
||||
auto tile = Math::log2(static_cast<uint32_t>(connectedDevice->getNEODevice()->getDeviceBitfield().to_ulong()));
|
||||
return rootDebugSession->ackIsaEvents(tile, isaVa);
|
||||
return rootDebugSession->ackIsaEvents(this->tileIndex, isaVa);
|
||||
}
|
||||
|
||||
ze_result_t readGpuMemory(uint64_t vmHandle, char *output, size_t size, uint64_t gpuVa) override {
|
||||
return rootDebugSession->readGpuMemory(vmHandle, output, size, gpuVa);
|
||||
};
|
||||
}
|
||||
|
||||
ze_result_t writeGpuMemory(uint64_t vmHandle, const char *input, size_t size, uint64_t gpuVa) override {
|
||||
return rootDebugSession->writeGpuMemory(vmHandle, input, size, gpuVa);
|
||||
};
|
||||
}
|
||||
|
||||
ze_result_t readSbaBuffer(EuThread::ThreadId threadId, NEO::SbaTrackedAddresses &sbaBuffer) override {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
};
|
||||
ze_result_t resumeImp(const std::vector<EuThread::ThreadId> &threads, uint32_t deviceIndex) override {
|
||||
return rootDebugSession->resumeImp(threads, this->tileIndex);
|
||||
}
|
||||
|
||||
ze_result_t interruptImp(uint32_t deviceIndex) override {
|
||||
return rootDebugSession->interruptImp(this->tileIndex);
|
||||
}
|
||||
|
||||
DebugSessionLinux *rootDebugSession = nullptr;
|
||||
uint32_t tileIndex = std::numeric_limits<uint32_t>::max();
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
|
||||
Reference in New Issue
Block a user