fix(debugger): require immediate binding for Module's allocations

- all bos from Module must have requireImmediateBinding
flag set
- this change fixes hang in debugger - where MODULE LOAD event
was not sent

Resolves: NEO-8121

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2023-07-06 14:15:23 +00:00
committed by Compute-Runtime-Automation
parent 25482ebff1
commit 6205cca038
3 changed files with 39 additions and 0 deletions

View File

@@ -267,6 +267,38 @@ TEST_F(L0DebuggerLinuxTest, givenAllocationsWhenAttachingZebinModuleThenAllAlloc
EXPECT_TRUE(containsElfHandle(bo2)); EXPECT_TRUE(containsElfHandle(bo2));
} }
TEST_F(L0DebuggerLinuxTest, givenModuleAllocationsWhenAttachingZebinModuleThenBosRequireImmediateBind) {
MockDrmAllocation isaAllocation(rootDeviceIndex, AllocationType::KERNEL_ISA, MemoryPool::System4KBPages);
MockBufferObject bo(rootDeviceIndex, drmMock, 3, 0, 0, 1);
isaAllocation.bufferObjects[0] = &bo;
MockDrmAllocation isaAllocation2(rootDeviceIndex, AllocationType::CONSTANT_SURFACE, MemoryPool::System4KBPages);
MockBufferObject bo2(rootDeviceIndex, drmMock, 3, 0, 0, 1);
isaAllocation2.bufferObjects[0] = &bo2;
uint32_t handle = 0;
const uint32_t elfHandle = 198;
StackVec<NEO::GraphicsAllocation *, 32> kernelAllocs;
kernelAllocs.push_back(&isaAllocation);
kernelAllocs.push_back(&isaAllocation2);
drmMock->registeredDataSize = 0;
drmMock->registeredClass = NEO::DrmResourceClass::MaxSize;
EXPECT_TRUE(device->getL0Debugger()->attachZebinModuleToSegmentAllocations(kernelAllocs, handle, elfHandle));
const auto containsModuleHandle = [handle](const auto &bufferObject) {
const auto &bindExtHandles = bufferObject.getBindExtHandles();
return std::find(bindExtHandles.begin(), bindExtHandles.end(), handle) != bindExtHandles.end();
};
EXPECT_TRUE(containsModuleHandle(bo));
EXPECT_TRUE(containsModuleHandle(bo2));
EXPECT_TRUE(bo.isImmediateBindingRequired());
EXPECT_TRUE(bo2.isImmediateBindingRequired());
}
TEST_F(L0DebuggerLinuxTest, givenModuleHandleWhenRemoveZebinModuleIsCalledThenHandleIsUnregistered) { TEST_F(L0DebuggerLinuxTest, givenModuleHandleWhenRemoveZebinModuleIsCalledThenHandleIsUnregistered) {
uint32_t handle = 20; uint32_t handle = 20;

View File

@@ -754,6 +754,7 @@ bool DebugSessionLinux::checkAllEventsCollected() {
allEventsCollected = true; allEventsCollected = true;
} }
} }
PRINT_DEBUGGER_INFO_LOG("checkAllEventsCollected() returned %d, clientHandle = %ull\n", static_cast<int>(allEventsCollected), this->clientHandle);
return allEventsCollected; return allEventsCollected;
} }
@@ -893,6 +894,7 @@ bool DebugSessionLinux::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *v
if (connection->uuidMap[vmBind->uuids[uuidIter]].classIndex == NEO::DrmResourceClass::L0ZebinModule) { if (connection->uuidMap[vmBind->uuids[uuidIter]].classIndex == NEO::DrmResourceClass::L0ZebinModule) {
perKernelModules = false; perKernelModules = false;
moduleUUIDindex = static_cast<int>(uuidIter); moduleUUIDindex = static_cast<int>(uuidIter);
PRINT_DEBUGGER_INFO_LOG("Zebin module uuid = %ull", (uint64_t)vmBind->uuids[uuidIter]);
} }
if (connection->uuidMap[vmBind->uuids[uuidIter]].classHandle == isaUuidHandle) { if (connection->uuidMap[vmBind->uuids[uuidIter]].classHandle == isaUuidHandle) {
@@ -972,6 +974,7 @@ bool DebugSessionLinux::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *v
memLock.unlock(); memLock.unlock();
if (perKernelModules) { if (perKernelModules) {
PRINT_DEBUGGER_INFO_LOG("New per-kernel module\n", "");
debugEvent.flags = apiEventNeedsAck ? ZET_DEBUG_EVENT_FLAG_NEED_ACK : 0; debugEvent.flags = apiEventNeedsAck ? ZET_DEBUG_EVENT_FLAG_NEED_ACK : 0;
if (tileSessionsEnabled) { if (tileSessionsEnabled) {
@@ -1100,6 +1103,8 @@ bool DebugSessionLinux::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *v
} }
} }
} else { } else {
PRINT_DEBUGGER_INFO_LOG("Zebin module = %ull has load addresses = %d", static_cast<uint64_t>(vmBind->uuids[uuidIter]), static_cast<int>(module.loadAddresses[tileIndex].size()));
if (canTriggerEvent && module.loadAddresses[tileIndex].size() == module.segmentCount) { if (canTriggerEvent && module.loadAddresses[tileIndex].size() == module.segmentCount) {
auto gmmHelper = connectedDevice->getNEODevice()->getGmmHelper(); auto gmmHelper = connectedDevice->getNEODevice()->getGmmHelper();
loadAddress = gmmHelper->canonize(*std::min_element(module.loadAddresses[tileIndex].begin(), module.loadAddresses[tileIndex].end())); loadAddress = gmmHelper->canonize(*std::min_element(module.loadAddresses[tileIndex].begin(), module.loadAddresses[tileIndex].end()));
@@ -1401,6 +1406,7 @@ void DebugSessionLinux::extractUuidData(uint64_t client, const UuidData &uuidDat
uint32_t segmentCount = 0; uint32_t segmentCount = 0;
memcpy_s(&segmentCount, sizeof(uint32_t), uuidData.data.get(), uuidData.dataSize); memcpy_s(&segmentCount, sizeof(uint32_t), uuidData.data.get(), uuidData.dataSize);
clientHandleToConnection[client]->uuidToModule[uuidData.handle].segmentCount = segmentCount; clientHandleToConnection[client]->uuidToModule[uuidData.handle].segmentCount = segmentCount;
PRINT_DEBUGGER_INFO_LOG("Zebin module = %ull, segment count = %ul", uuidData.handle, segmentCount);
} }
} }

View File

@@ -349,6 +349,7 @@ void DrmAllocation::linkWithRegisteredHandle(uint32_t handle) {
for (auto bo : bos) { for (auto bo : bos) {
if (bo) { if (bo) {
bo->addBindExtHandle(handle); bo->addBindExtHandle(handle);
bo->requireImmediateBinding(true);
} }
} }
} }