mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-27 15:53:13 +08:00
Revert "feature: Implement thread control and att event handling for xe"
This reverts commit fb73fad6d7.
Signed-off-by: Compute-Runtime-Validation <compute-runtime-validation@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
9f1648b57a
commit
40cea2f6fe
@@ -168,20 +168,7 @@ class EuThread {
|
||||
}
|
||||
bool getPageFault() {
|
||||
return hasPageFault;
|
||||
}
|
||||
void setContextHandle(uint64_t contextHandleParam) {
|
||||
contextHandle = contextHandleParam;
|
||||
}
|
||||
void getContextHandle(uint64_t &contextHandleParam) const {
|
||||
DEBUG_BREAK_IF(state != State::stopped);
|
||||
contextHandleParam = contextHandle;
|
||||
}
|
||||
void setLrcHandle(uint64_t lrcHandleParam) {
|
||||
lrcHandle = lrcHandleParam;
|
||||
}
|
||||
void getLrcHandle(uint64_t &lrcHandleParam) const {
|
||||
DEBUG_BREAK_IF(state != State::stopped);
|
||||
lrcHandleParam = lrcHandle;
|
||||
;
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -194,8 +181,6 @@ class EuThread {
|
||||
std::atomic<uint64_t> memoryHandle = invalidHandle;
|
||||
std::atomic<bool> reportedAsStopped = false;
|
||||
bool hasPageFault = false;
|
||||
uint64_t contextHandle = 0;
|
||||
uint64_t lrcHandle = 0;
|
||||
};
|
||||
|
||||
static_assert(sizeof(EuThread::ThreadId) == sizeof(uint64_t));
|
||||
|
||||
@@ -351,6 +351,49 @@ ze_result_t DebugSessionLinux::writeGpuMemory(uint64_t vmHandle, const char *inp
|
||||
return (retVal == 0) ? ZE_RESULT_SUCCESS : ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
int DebugSessionLinux::threadControl(const std::vector<EuThread::ThreadId> &threads, uint32_t tile, ThreadControlCmd threadCmd, std::unique_ptr<uint8_t[]> &bitmaskOut, size_t &bitmaskSizeOut) {
|
||||
|
||||
auto hwInfo = connectedDevice->getHwInfo();
|
||||
auto classInstance = DrmHelper::getEngineInstance(connectedDevice, tile, hwInfo.capabilityTable.defaultEngineType);
|
||||
UNRECOVERABLE_IF(!classInstance);
|
||||
|
||||
auto &l0GfxCoreHelper = connectedDevice->getL0GfxCoreHelper();
|
||||
|
||||
bitmaskSizeOut = 0;
|
||||
std::unique_ptr<uint8_t[]> bitmask;
|
||||
size_t bitmaskSize = 0;
|
||||
|
||||
if (threadCmd == ThreadControlCmd::interrupt ||
|
||||
threadCmd == ThreadControlCmd::resume ||
|
||||
threadCmd == ThreadControlCmd::stopped) {
|
||||
l0GfxCoreHelper.getAttentionBitmaskForSingleThreads(threads, hwInfo, bitmask, bitmaskSize);
|
||||
}
|
||||
|
||||
uint64_t seqnoRet = 0;
|
||||
uint64_t bitmaskSizeRet = 0;
|
||||
auto euControlRetVal = euControlIoctl(threadCmd, classInstance, bitmask, bitmaskSize, seqnoRet, bitmaskSizeRet);
|
||||
if (euControlRetVal != 0) {
|
||||
PRINT_DEBUGGER_ERROR_LOG("euControl IOCTL failed: retCode: %d errno = %d threadCmd = %d\n", euControlRetVal, errno, threadCmd);
|
||||
} else {
|
||||
PRINT_DEBUGGER_INFO_LOG("euControl IOCTL: seqno = %llu threadCmd = %u\n", seqnoRet, threadCmd);
|
||||
}
|
||||
|
||||
if (threadCmd == ThreadControlCmd::interrupt ||
|
||||
threadCmd == ThreadControlCmd::interruptAll) {
|
||||
if (euControlRetVal == 0) {
|
||||
euControlInterruptSeqno[tile] = seqnoRet;
|
||||
} else {
|
||||
euControlInterruptSeqno[tile] = invalidHandle;
|
||||
}
|
||||
}
|
||||
|
||||
if (threadCmd == ThreadControlCmd::stopped) {
|
||||
bitmaskOut = std::move(bitmask);
|
||||
bitmaskSizeOut = bitmaskSizeRet;
|
||||
}
|
||||
return euControlRetVal;
|
||||
}
|
||||
|
||||
ze_result_t DebugSessionLinux::readElfSpace(const zet_debug_memory_space_desc_t *desc, size_t size, void *buffer,
|
||||
const char *&elfData, const uint64_t offset) {
|
||||
|
||||
@@ -606,7 +649,7 @@ ze_result_t DebugSessionLinux::getElfOffset(const zet_debug_memory_space_desc_t
|
||||
return status;
|
||||
}
|
||||
|
||||
void DebugSessionLinux::updateStoppedThreadsAndCheckTriggerEvents(AttentionEventFields &attention, uint32_t tileIndex, std::vector<EuThread::ThreadId> &threadsWithAttention) {
|
||||
void DebugSessionLinux::updateStoppedThreadsAndCheckTriggerEvents(AttentionEventFields &attention, uint32_t tileIndex) {
|
||||
auto vmHandle = getVmHandleFromClientAndlrcHandle(attention.clientHandle, attention.lrcHandle);
|
||||
if (vmHandle == invalidHandle) {
|
||||
return;
|
||||
@@ -615,6 +658,16 @@ void DebugSessionLinux::updateStoppedThreadsAndCheckTriggerEvents(AttentionEvent
|
||||
auto hwInfo = connectedDevice->getHwInfo();
|
||||
auto &l0GfxCoreHelper = connectedDevice->getL0GfxCoreHelper();
|
||||
|
||||
std::vector<EuThread::ThreadId> threadsWithAttention;
|
||||
if (interruptSent) {
|
||||
std::unique_ptr<uint8_t[]> bitmask;
|
||||
size_t bitmaskSize;
|
||||
auto attReadResult = threadControl({}, tileIndex, ThreadControlCmd::stopped, bitmask, bitmaskSize);
|
||||
if (attReadResult == 0) {
|
||||
threadsWithAttention = l0GfxCoreHelper.getThreadsFromAttentionBitmask(hwInfo, tileIndex, bitmask.get(), bitmaskSize);
|
||||
}
|
||||
}
|
||||
|
||||
if (threadsWithAttention.size() == 0) {
|
||||
threadsWithAttention = l0GfxCoreHelper.getThreadsFromAttentionBitmask(hwInfo, tileIndex, attention.bitmask, attention.bitmaskSize);
|
||||
printBitmask(attention.bitmask, attention.bitmaskSize);
|
||||
@@ -652,8 +705,6 @@ void DebugSessionLinux::updateStoppedThreadsAndCheckTriggerEvents(AttentionEvent
|
||||
if (stateSaveReadResult == ZE_RESULT_SUCCESS) {
|
||||
for (auto &threadId : threadsWithAttention) {
|
||||
PRINT_DEBUGGER_THREAD_LOG("ATTENTION event for thread: %s\n", EuThread::toString(threadId).c_str());
|
||||
allThreads[threadId]->setContextHandle(attention.contextHandle);
|
||||
allThreads[threadId]->setLrcHandle(attention.lrcHandle);
|
||||
|
||||
if (tileSessionsEnabled) {
|
||||
addThreadToNewlyStoppedFromRaisedAttentionForTileSession(threadId, vmHandle, stateSaveAreaMemory.data(), tileIndex);
|
||||
|
||||
@@ -152,7 +152,7 @@ struct DebugSessionLinux : DebugSessionImp {
|
||||
uint8_t *bitmask;
|
||||
};
|
||||
|
||||
void updateStoppedThreadsAndCheckTriggerEvents(AttentionEventFields &attention, uint32_t tileIndex, std::vector<EuThread::ThreadId> &threadsWithAttention);
|
||||
void updateStoppedThreadsAndCheckTriggerEvents(AttentionEventFields &attention, uint32_t tileIndex);
|
||||
virtual uint64_t getVmHandleFromClientAndlrcHandle(uint64_t clientHandle, uint64_t lrcHandle) = 0;
|
||||
virtual std::unique_lock<std::mutex> getThreadStateMutexForTileSession(uint32_t tileIndex) = 0;
|
||||
virtual void checkTriggerEventsForAttentionForTileSession(uint32_t tileIndex) = 0;
|
||||
@@ -161,7 +161,11 @@ struct DebugSessionLinux : DebugSessionImp {
|
||||
const void *stateSaveArea,
|
||||
uint32_t tileIndex) = 0;
|
||||
|
||||
virtual int threadControl(const std::vector<EuThread::ThreadId> &threads, uint32_t tile, ThreadControlCmd threadCmd, std::unique_ptr<uint8_t[]> &bitmask, size_t &bitmaskSize) = 0;
|
||||
virtual int euControlIoctl(ThreadControlCmd threadCmd,
|
||||
const NEO::EngineClassInstance *classInstance,
|
||||
std::unique_ptr<uint8_t[]> &bitmask,
|
||||
size_t bitmaskSize, uint64_t &seqnoOut, uint64_t &bitmaskSizeOut) = 0;
|
||||
MOCKABLE_VIRTUAL int threadControl(const std::vector<EuThread::ThreadId> &threads, uint32_t tile, ThreadControlCmd threadCmd, std::unique_ptr<uint8_t[]> &bitmask, size_t &bitmaskSize);
|
||||
void checkStoppedThreadsAndGenerateEvents(const std::vector<EuThread::ThreadId> &threads, uint64_t memoryHandle, uint32_t deviceIndex) override;
|
||||
MOCKABLE_VIRTUAL bool checkForceExceptionBit(uint64_t memoryHandle, EuThread::ThreadId threadId, uint32_t *cr0, const SIP::regset_desc *regDesc);
|
||||
ze_result_t resumeImp(const std::vector<EuThread::ThreadId> &threads, uint32_t deviceIndex) override;
|
||||
@@ -186,5 +190,6 @@ struct DebugSessionLinux : DebugSessionImp {
|
||||
virtual std::vector<uint64_t> getAllMemoryHandles();
|
||||
|
||||
std::unique_ptr<IoctlHandler> ioctlHandler;
|
||||
uint64_t euControlInterruptSeqno[NEO::EngineLimits::maxHandleCount];
|
||||
};
|
||||
} // namespace L0
|
||||
@@ -1101,18 +1101,6 @@ void DebugSessionLinuxi915::handleAttentionEvent(prelim_drm_i915_debug_event_eu_
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<EuThread::ThreadId> threadsWithAttention;
|
||||
auto hwInfo = connectedDevice->getHwInfo();
|
||||
auto &l0GfxCoreHelper = connectedDevice->getL0GfxCoreHelper();
|
||||
if (interruptSent) {
|
||||
std::unique_ptr<uint8_t[]> bitmask;
|
||||
size_t bitmaskSize;
|
||||
auto attReadResult = threadControl({}, tileIndex, ThreadControlCmd::stopped, bitmask, bitmaskSize);
|
||||
if (attReadResult == 0) {
|
||||
threadsWithAttention = l0GfxCoreHelper.getThreadsFromAttentionBitmask(hwInfo, tileIndex, bitmask.get(), bitmaskSize);
|
||||
}
|
||||
}
|
||||
|
||||
AttentionEventFields attentionEventFields;
|
||||
attentionEventFields.bitmask = attention->bitmask;
|
||||
attentionEventFields.bitmaskSize = attention->bitmask_size;
|
||||
@@ -1120,7 +1108,7 @@ void DebugSessionLinuxi915::handleAttentionEvent(prelim_drm_i915_debug_event_eu_
|
||||
attentionEventFields.contextHandle = attention->ctx_handle;
|
||||
attentionEventFields.lrcHandle = attention->lrc_handle;
|
||||
|
||||
return updateStoppedThreadsAndCheckTriggerEvents(attentionEventFields, tileIndex, threadsWithAttention);
|
||||
return updateStoppedThreadsAndCheckTriggerEvents(attentionEventFields, tileIndex);
|
||||
}
|
||||
|
||||
std::unique_lock<std::mutex> DebugSessionLinuxi915::getThreadStateMutexForTileSession(uint32_t tileIndex) {
|
||||
@@ -1281,22 +1269,17 @@ uint64_t DebugSessionLinuxi915::extractVaFromUuidString(std::string &uuid) {
|
||||
return parts[0];
|
||||
}
|
||||
|
||||
int DebugSessionLinuxi915::threadControl(const std::vector<EuThread::ThreadId> &threads, uint32_t tile, ThreadControlCmd threadCmd, std::unique_ptr<uint8_t[]> &bitmaskOut, size_t &bitmaskSizeOut) {
|
||||
|
||||
auto hwInfo = connectedDevice->getHwInfo();
|
||||
auto classInstance = DrmHelper::getEngineInstance(connectedDevice, tile, hwInfo.capabilityTable.defaultEngineType);
|
||||
UNRECOVERABLE_IF(!classInstance);
|
||||
|
||||
auto &l0GfxCoreHelper = connectedDevice->getL0GfxCoreHelper();
|
||||
|
||||
bitmaskSizeOut = 0;
|
||||
|
||||
int DebugSessionLinuxi915::euControlIoctl(ThreadControlCmd threadCmd,
|
||||
const NEO::EngineClassInstance *classInstance,
|
||||
std::unique_ptr<uint8_t[]> &bitmask,
|
||||
size_t bitmaskSize, uint64_t &seqnoOut, uint64_t &bitmaskSizeOut) {
|
||||
struct prelim_drm_i915_debug_eu_control euControl = {};
|
||||
euControl.client_handle = clientHandle;
|
||||
euControl.ci.engine_class = classInstance->engineClass;
|
||||
euControl.ci.engine_instance = classInstance->engineInstance;
|
||||
euControl.bitmask_size = 0;
|
||||
euControl.bitmask_ptr = 0;
|
||||
|
||||
decltype(prelim_drm_i915_debug_eu_control::cmd) command = 0;
|
||||
switch (threadCmd) {
|
||||
case ThreadControlCmd::interruptAll:
|
||||
@@ -1314,17 +1297,8 @@ int DebugSessionLinuxi915::threadControl(const std::vector<EuThread::ThreadId> &
|
||||
}
|
||||
euControl.cmd = command;
|
||||
|
||||
std::unique_ptr<uint8_t[]> bitmask;
|
||||
size_t bitmaskSize = 0;
|
||||
|
||||
if (command == PRELIM_I915_DEBUG_EU_THREADS_CMD_INTERRUPT ||
|
||||
command == PRELIM_I915_DEBUG_EU_THREADS_CMD_RESUME ||
|
||||
command == PRELIM_I915_DEBUG_EU_THREADS_CMD_STOPPED) {
|
||||
l0GfxCoreHelper.getAttentionBitmaskForSingleThreads(threads, hwInfo, bitmask, bitmaskSize);
|
||||
euControl.bitmask_size = static_cast<uint32_t>(bitmaskSize);
|
||||
euControl.bitmask_ptr = reinterpret_cast<uint64_t>(bitmask.get());
|
||||
}
|
||||
|
||||
euControl.bitmask_size = static_cast<uint32_t>(bitmaskSize);
|
||||
euControl.bitmask_ptr = reinterpret_cast<uint64_t>(bitmask.get());
|
||||
if (command == PRELIM_I915_DEBUG_EU_THREADS_CMD_RESUME) {
|
||||
applyResumeWa(bitmask.get(), bitmaskSize);
|
||||
}
|
||||
@@ -1332,25 +1306,8 @@ int DebugSessionLinuxi915::threadControl(const std::vector<EuThread::ThreadId> &
|
||||
printBitmask(bitmask.get(), bitmaskSize);
|
||||
|
||||
auto euControlRetVal = ioctl(PRELIM_I915_DEBUG_IOCTL_EU_CONTROL, &euControl);
|
||||
if (euControlRetVal != 0) {
|
||||
PRINT_DEBUGGER_ERROR_LOG("PRELIM_I915_DEBUG_IOCTL_EU_CONTROL failed: retCode: %d errno = %d command = %d\n", euControlRetVal, errno, command);
|
||||
} else {
|
||||
PRINT_DEBUGGER_INFO_LOG("PRELIM_I915_DEBUG_IOCTL_EU_CONTROL: seqno = %llu command = %u\n", (uint64_t)euControl.seqno, command);
|
||||
}
|
||||
|
||||
if (command == PRELIM_I915_DEBUG_EU_THREADS_CMD_INTERRUPT ||
|
||||
command == PRELIM_I915_DEBUG_EU_THREADS_CMD_INTERRUPT_ALL) {
|
||||
if (euControlRetVal == 0) {
|
||||
euControlInterruptSeqno[tile] = euControl.seqno;
|
||||
} else {
|
||||
euControlInterruptSeqno[tile] = invalidHandle;
|
||||
}
|
||||
}
|
||||
|
||||
if (threadCmd == ThreadControlCmd::stopped) {
|
||||
bitmaskOut = std::move(bitmask);
|
||||
bitmaskSizeOut = euControl.bitmask_size;
|
||||
}
|
||||
seqnoOut = euControl.seqno;
|
||||
bitmaskSizeOut = euControl.bitmask_size;
|
||||
return euControlRetVal;
|
||||
}
|
||||
|
||||
|
||||
@@ -189,7 +189,10 @@ struct DebugSessionLinuxi915 : DebugSessionLinux {
|
||||
void readStateSaveAreaHeader() override;
|
||||
int openVmFd(uint64_t vmHandle, bool readOnly) override;
|
||||
|
||||
int threadControl(const std::vector<EuThread::ThreadId> &threads, uint32_t tile, ThreadControlCmd threadCmd, std::unique_ptr<uint8_t[]> &bitmask, size_t &bitmaskSize) override;
|
||||
int euControlIoctl(ThreadControlCmd threadCmd,
|
||||
const NEO::EngineClassInstance *classInstance,
|
||||
std::unique_ptr<uint8_t[]> &bitmask,
|
||||
size_t bitmaskSize, uint64_t &seqnoOut, uint64_t &bitmaskSizeOut) override;
|
||||
uint64_t getContextStateSaveAreaGpuVa(uint64_t memoryHandle) override;
|
||||
size_t getContextStateSaveAreaSize(uint64_t memoryHandle) override;
|
||||
virtual uint64_t getSbaBufferGpuVa(uint64_t memoryHandle);
|
||||
@@ -259,7 +262,6 @@ struct DebugSessionLinuxi915 : DebugSessionLinux {
|
||||
std::atomic<bool> detached{false};
|
||||
|
||||
std::unordered_map<uint64_t, uint32_t> uuidL0CommandQueueHandleToDevice;
|
||||
uint64_t euControlInterruptSeqno[NEO::EngineLimits::maxHandleCount];
|
||||
void readInternalEventsAsync() override;
|
||||
|
||||
bool blockOnFenceMode = false; // false - blocking VM_BIND on CPU - autoack events until last blocking event
|
||||
|
||||
@@ -237,7 +237,6 @@ void DebugSessionLinuxXe::handleEvent(drm_xe_eudebug_event *event) {
|
||||
UNRECOVERABLE_IF(clientHandleToConnection.find(execQueue->client_handle) == clientHandleToConnection.end());
|
||||
|
||||
if (!processEntryEventGenerated) {
|
||||
clientHandle = execQueue->client_handle;
|
||||
zet_debug_event_t debugEvent = {};
|
||||
debugEvent.type = ZET_DEBUG_EVENT_TYPE_PROCESS_ENTRY;
|
||||
pushApiEvent(debugEvent);
|
||||
@@ -247,9 +246,7 @@ void DebugSessionLinuxXe::handleEvent(drm_xe_eudebug_event *event) {
|
||||
clientHandleToConnection[execQueue->client_handle]->execQueues[execQueue->exec_queue_handle].vmHandle = execQueue->vm_handle;
|
||||
clientHandleToConnection[execQueue->client_handle]->execQueues[execQueue->exec_queue_handle].engineClass = execQueue->engine_class;
|
||||
for (uint16_t idx = 0; idx < execQueue->width; idx++) {
|
||||
uint64_t lrcHandle = execQueue->lrc_handle[idx];
|
||||
clientHandleToConnection[execQueue->client_handle]->execQueues[execQueue->exec_queue_handle].lrcHandles.push_back(lrcHandle);
|
||||
clientHandleToConnection[execQueue->client_handle]->lrcHandleToVmHandle[lrcHandle] = execQueue->vm_handle;
|
||||
clientHandleToConnection[execQueue->client_handle]->lrcHandleToVmHandle[execQueue->lrc_handle[idx]] = execQueue->vm_handle;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,17 +278,6 @@ void DebugSessionLinuxXe::handleEvent(drm_xe_eudebug_event *event) {
|
||||
(uint64_t)execQueue->exec_queue_handle, (uint16_t)execQueue->engine_class);
|
||||
} break;
|
||||
|
||||
case DRM_XE_EUDEBUG_EVENT_EU_ATTENTION: {
|
||||
drm_xe_eudebug_event_eu_attention *attention = reinterpret_cast<drm_xe_eudebug_event_eu_attention *>(event);
|
||||
|
||||
PRINT_DEBUGGER_INFO_LOG("DRM_XE_EUDEBUG_IOCTL_READ_EVENT type: DRM_XE_EUDEBUG_EVENT_EU_ATTENTION flags = %d, seqno = %llu, len = %lu"
|
||||
" client_handle = %llu flags = %llu bitmask_size = %lu exec_queue_handle = %llu lrc_handle = %llu\n",
|
||||
(int)attention->base.flags, (uint64_t)attention->base.seqno, (uint32_t)attention->base.len,
|
||||
(uint64_t)attention->client_handle, (uint64_t)attention->flags,
|
||||
(uint32_t)attention->bitmask_size, uint64_t(attention->exec_queue_handle), uint64_t(attention->lrc_handle));
|
||||
handleAttentionEvent(attention);
|
||||
} 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);
|
||||
break;
|
||||
@@ -331,111 +317,43 @@ uint64_t DebugSessionLinuxXe::getVmHandleFromClientAndlrcHandle(uint64_t clientH
|
||||
return clientConnection->lrcHandleToVmHandle[lrcHandle];
|
||||
}
|
||||
|
||||
void DebugSessionLinuxXe::handleAttentionEvent(drm_xe_eudebug_event_eu_attention *attention) {
|
||||
if (interruptSent) {
|
||||
if (attention->base.seqno <= euControlInterruptSeqno) {
|
||||
PRINT_DEBUGGER_INFO_LOG("Discarding EU ATTENTION event for interrupt request. Event seqno == %llu <= %llu == interrupt seqno\n",
|
||||
static_cast<uint64_t>(attention->base.seqno), euControlInterruptSeqno);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
newAttentionRaised();
|
||||
std::vector<EuThread::ThreadId> threadsWithAttention;
|
||||
AttentionEventFields attentionEventFields;
|
||||
attentionEventFields.bitmask = attention->bitmask;
|
||||
attentionEventFields.bitmaskSize = attention->bitmask_size;
|
||||
attentionEventFields.clientHandle = attention->client_handle;
|
||||
attentionEventFields.contextHandle = attention->exec_queue_handle;
|
||||
attentionEventFields.lrcHandle = attention->lrc_handle;
|
||||
|
||||
return updateStoppedThreadsAndCheckTriggerEvents(attentionEventFields, 0, threadsWithAttention);
|
||||
}
|
||||
|
||||
int DebugSessionLinuxXe::threadControlInterruptAll(drm_xe_eudebug_eu_control &euControl) {
|
||||
int euControlRetVal = -1;
|
||||
|
||||
DEBUG_BREAK_IF(clientHandleToConnection.find(clientHandle) == clientHandleToConnection.end());
|
||||
for (const auto &execQueue : clientHandleToConnection[clientHandle]->execQueues) {
|
||||
euControl.exec_queue_handle = execQueue.first;
|
||||
for (const auto &lrcHandle : execQueue.second.lrcHandles) {
|
||||
euControl.lrc_handle = lrcHandle;
|
||||
euControlRetVal = ioctl(DRM_XE_EUDEBUG_IOCTL_EU_CONTROL, &euControl);
|
||||
if (euControlRetVal != 0) {
|
||||
PRINT_DEBUGGER_ERROR_LOG("DRM_XE_EUDEBUG_IOCTL_EU_CONTROL failed: retCode: %d errno = %d command = %d, execQueueHandle = %llu lrcHandle = %llu\n",
|
||||
euControlRetVal, errno, static_cast<uint32_t>(euControl.cmd), static_cast<uint64_t>(euControl.exec_queue_handle),
|
||||
static_cast<uint64_t>(euControl.lrc_handle));
|
||||
} else {
|
||||
DEBUG_BREAK_IF(euControlInterruptSeqno >= euControl.seqno);
|
||||
euControlInterruptSeqno = euControl.seqno;
|
||||
PRINT_DEBUGGER_INFO_LOG("DRM_XE_EUDEBUG_IOCTL_EU_CONTROL: seqno = %llu command = %u\n", static_cast<uint64_t>(euControl.seqno),
|
||||
static_cast<uint32_t>(euControl.cmd));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return euControlRetVal;
|
||||
}
|
||||
|
||||
int DebugSessionLinuxXe::threadControlResumeAndStopped(const std::vector<EuThread::ThreadId> &threads, drm_xe_eudebug_eu_control &euControl,
|
||||
std::unique_ptr<uint8_t[]> &bitmaskOut, size_t &bitmaskSizeOut) {
|
||||
int euControlRetVal = -1;
|
||||
auto hwInfo = connectedDevice->getHwInfo();
|
||||
auto &l0GfxCoreHelper = connectedDevice->getL0GfxCoreHelper();
|
||||
|
||||
std::unique_ptr<uint8_t[]> bitmask;
|
||||
size_t bitmaskSize = 0;
|
||||
l0GfxCoreHelper.getAttentionBitmaskForSingleThreads(threads, hwInfo, bitmask, bitmaskSize);
|
||||
euControl.bitmask_size = static_cast<uint32_t>(bitmaskSize);
|
||||
euControl.bitmask_ptr = reinterpret_cast<uint64_t>(bitmask.get());
|
||||
printBitmask(bitmask.get(), bitmaskSize);
|
||||
uint64_t execQueueHandle{0};
|
||||
uint64_t lrcHandle{0};
|
||||
allThreads[threads[0]]->getContextHandle(execQueueHandle);
|
||||
allThreads[threads[0]]->getLrcHandle(lrcHandle);
|
||||
euControl.exec_queue_handle = execQueueHandle;
|
||||
euControl.lrc_handle = lrcHandle;
|
||||
|
||||
euControlRetVal = ioctl(DRM_XE_EUDEBUG_IOCTL_EU_CONTROL, &euControl);
|
||||
if (euControlRetVal != 0) {
|
||||
PRINT_DEBUGGER_ERROR_LOG("DRM_XE_EUDEBUG_IOCTL_EU_CONTROL failed: retCode: %d errno = %d command = %d, execQueueHandle = %llu lrcHandle = %llu\n",
|
||||
euControlRetVal, errno, static_cast<uint32_t>(euControl.cmd), static_cast<uint64_t>(euControl.exec_queue_handle),
|
||||
static_cast<uint64_t>(euControl.lrc_handle));
|
||||
} else {
|
||||
PRINT_DEBUGGER_INFO_LOG("DRM_XE_EUDEBUG_IOCTL_EU_CONTROL: seqno = %llu command = %u\n", static_cast<uint64_t>(euControl.seqno), static_cast<uint32_t>(euControl.cmd));
|
||||
}
|
||||
|
||||
if (euControl.cmd == DRM_XE_EUDEBUG_EU_CONTROL_CMD_STOPPED) {
|
||||
bitmaskOut = std::move(bitmask);
|
||||
bitmaskSizeOut = euControl.bitmask_size;
|
||||
}
|
||||
|
||||
return euControlRetVal;
|
||||
}
|
||||
|
||||
int DebugSessionLinuxXe::threadControl(const std::vector<EuThread::ThreadId> &threads, uint32_t tile,
|
||||
ThreadControlCmd threadCmd, std::unique_ptr<uint8_t[]> &bitmaskOut, size_t &bitmaskSizeOut) {
|
||||
|
||||
bitmaskSizeOut = 0;
|
||||
int DebugSessionLinuxXe::euControlIoctl(ThreadControlCmd threadCmd,
|
||||
const NEO::EngineClassInstance *classInstance,
|
||||
std::unique_ptr<uint8_t[]> &bitmask,
|
||||
size_t bitmaskSize, uint64_t &seqnoOut, uint64_t &bitmaskSizeOut) {
|
||||
struct drm_xe_eudebug_eu_control euControl = {};
|
||||
euControl.client_handle = clientHandle;
|
||||
euControl.ci.engine_class = classInstance->engineClass;
|
||||
euControl.ci.engine_instance = classInstance->engineInstance;
|
||||
euControl.bitmask_size = 0;
|
||||
euControl.bitmask_ptr = 0;
|
||||
|
||||
decltype(drm_xe_eudebug_eu_control::cmd) command = 0;
|
||||
switch (threadCmd) {
|
||||
case ThreadControlCmd::interruptAll:
|
||||
euControl.cmd = DRM_XE_EUDEBUG_EU_CONTROL_CMD_INTERRUPT_ALL;
|
||||
return threadControlInterruptAll(euControl);
|
||||
command = DRM_XE_EUDEBUG_EU_CONTROL_CMD_INTERRUPT_ALL;
|
||||
break;
|
||||
case ThreadControlCmd::resume:
|
||||
euControl.cmd = DRM_XE_EUDEBUG_EU_CONTROL_CMD_RESUME;
|
||||
return threadControlResumeAndStopped(threads, euControl, bitmaskOut, bitmaskSizeOut);
|
||||
command = DRM_XE_EUDEBUG_EU_CONTROL_CMD_RESUME;
|
||||
break;
|
||||
case ThreadControlCmd::stopped:
|
||||
euControl.cmd = DRM_XE_EUDEBUG_EU_CONTROL_CMD_STOPPED;
|
||||
return threadControlResumeAndStopped(threads, euControl, bitmaskOut, bitmaskSizeOut);
|
||||
command = DRM_XE_EUDEBUG_EU_CONTROL_CMD_STOPPED;
|
||||
break;
|
||||
default:
|
||||
command = 0xFFFFFFFF;
|
||||
break;
|
||||
}
|
||||
return -1;
|
||||
euControl.cmd = command;
|
||||
|
||||
euControl.bitmask_size = static_cast<uint32_t>(bitmaskSize);
|
||||
euControl.bitmask_ptr = reinterpret_cast<uint64_t>(bitmask.get());
|
||||
|
||||
printBitmask(bitmask.get(), bitmaskSize);
|
||||
|
||||
auto euControlRetVal = ioctl(DRM_XE_EUDEBUG_IOCTL_EU_CONTROL, &euControl);
|
||||
seqnoOut = euControl.seqno;
|
||||
bitmaskSizeOut = euControl.bitmask_size;
|
||||
return euControlRetVal;
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
@@ -64,13 +64,18 @@ struct DebugSessionLinuxXe : DebugSessionLinux {
|
||||
}
|
||||
};
|
||||
|
||||
using ContextHandle = uint64_t;
|
||||
using ExecQueueHandle = uint64_t;
|
||||
using LrcHandle = uint64_t;
|
||||
|
||||
struct ContextParams {
|
||||
ContextHandle handle = 0;
|
||||
uint64_t vm = UINT64_MAX;
|
||||
std::vector<drm_xe_engine_class_instance> engines;
|
||||
};
|
||||
|
||||
struct ExecQueueParams {
|
||||
uint64_t vmHandle = 0;
|
||||
uint16_t engineClass = UINT16_MAX;
|
||||
std::vector<LrcHandle> lrcHandles;
|
||||
};
|
||||
|
||||
uint32_t xeDebuggerVersion = 0;
|
||||
@@ -80,10 +85,10 @@ struct DebugSessionLinuxXe : DebugSessionLinux {
|
||||
};
|
||||
|
||||
protected:
|
||||
int threadControl(const std::vector<EuThread::ThreadId> &threads, uint32_t tile, ThreadControlCmd threadCmd, std::unique_ptr<uint8_t[]> &bitmask, size_t &bitmaskSize) override;
|
||||
int threadControlInterruptAll(drm_xe_eudebug_eu_control &euControl);
|
||||
int threadControlResumeAndStopped(const std::vector<EuThread::ThreadId> &threads, drm_xe_eudebug_eu_control &euControl, std::unique_ptr<uint8_t[]> &bitmaskOut, size_t &bitmaskSizeOut);
|
||||
void handleAttentionEvent(drm_xe_eudebug_event_eu_attention *attention);
|
||||
int euControlIoctl(ThreadControlCmd threadCmd,
|
||||
const NEO::EngineClassInstance *classInstance,
|
||||
std::unique_ptr<uint8_t[]> &bitmask,
|
||||
size_t bitmaskSize, uint64_t &seqnoOut, uint64_t &bitmaskSizeOut) override;
|
||||
|
||||
void startAsyncThread() override;
|
||||
static void *asyncThreadFunction(void *arg);
|
||||
@@ -167,8 +172,6 @@ struct DebugSessionLinuxXe : DebugSessionLinux {
|
||||
const void *stateSaveArea,
|
||||
uint32_t tileIndex) override {}
|
||||
|
||||
uint64_t euControlInterruptSeqno = 0;
|
||||
|
||||
ze_result_t readEventImp(drm_xe_eudebug_event *drmDebugEvent);
|
||||
int ioctl(unsigned long request, void *arg);
|
||||
std::atomic<bool> processEntryEventGenerated = false;
|
||||
|
||||
Reference in New Issue
Block a user