Skip to content

Commit e6f198b

Browse files
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 <[email protected]> Source: 6205cca
1 parent 70fa971 commit e6f198b

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

level_zero/core/test/unit_tests/sources/debugger/linux/test_l0_debugger_linux.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,38 @@ TEST_F(L0DebuggerLinuxTest, givenAllocationsWhenAttachingZebinModuleThenAllAlloc
267267
EXPECT_TRUE(containsElfHandle(bo2));
268268
}
269269

270+
TEST_F(L0DebuggerLinuxTest, givenModuleAllocationsWhenAttachingZebinModuleThenBosRequireImmediateBind) {
271+
MockDrmAllocation isaAllocation(rootDeviceIndex, AllocationType::KERNEL_ISA, MemoryPool::System4KBPages);
272+
MockBufferObject bo(rootDeviceIndex, drmMock, 3, 0, 0, 1);
273+
isaAllocation.bufferObjects[0] = &bo;
274+
275+
MockDrmAllocation isaAllocation2(rootDeviceIndex, AllocationType::CONSTANT_SURFACE, MemoryPool::System4KBPages);
276+
MockBufferObject bo2(rootDeviceIndex, drmMock, 3, 0, 0, 1);
277+
isaAllocation2.bufferObjects[0] = &bo2;
278+
279+
uint32_t handle = 0;
280+
const uint32_t elfHandle = 198;
281+
282+
StackVec<NEO::GraphicsAllocation *, 32> kernelAllocs;
283+
kernelAllocs.push_back(&isaAllocation);
284+
kernelAllocs.push_back(&isaAllocation2);
285+
286+
drmMock->registeredDataSize = 0;
287+
drmMock->registeredClass = NEO::DrmResourceClass::MaxSize;
288+
289+
EXPECT_TRUE(device->getL0Debugger()->attachZebinModuleToSegmentAllocations(kernelAllocs, handle, elfHandle));
290+
291+
const auto containsModuleHandle = [handle](const auto &bufferObject) {
292+
const auto &bindExtHandles = bufferObject.getBindExtHandles();
293+
return std::find(bindExtHandles.begin(), bindExtHandles.end(), handle) != bindExtHandles.end();
294+
};
295+
296+
EXPECT_TRUE(containsModuleHandle(bo));
297+
EXPECT_TRUE(containsModuleHandle(bo2));
298+
EXPECT_TRUE(bo.isImmediateBindingRequired());
299+
EXPECT_TRUE(bo2.isImmediateBindingRequired());
300+
}
301+
270302
TEST_F(L0DebuggerLinuxTest, givenModuleHandleWhenRemoveZebinModuleIsCalledThenHandleIsUnregistered) {
271303
uint32_t handle = 20;
272304

level_zero/tools/source/debug/linux/prelim/debug_session.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,7 @@ bool DebugSessionLinux::checkAllEventsCollected() {
754754
allEventsCollected = true;
755755
}
756756
}
757+
PRINT_DEBUGGER_INFO_LOG("checkAllEventsCollected() returned %d, clientHandle = %ull\n", static_cast<int>(allEventsCollected), this->clientHandle);
757758
return allEventsCollected;
758759
}
759760

@@ -893,6 +894,7 @@ bool DebugSessionLinux::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *v
893894
if (connection->uuidMap[vmBind->uuids[uuidIter]].classIndex == NEO::DrmResourceClass::L0ZebinModule) {
894895
perKernelModules = false;
895896
moduleUUIDindex = static_cast<int>(uuidIter);
897+
PRINT_DEBUGGER_INFO_LOG("Zebin module uuid = %ull", (uint64_t)vmBind->uuids[uuidIter]);
896898
}
897899

898900
if (connection->uuidMap[vmBind->uuids[uuidIter]].classHandle == isaUuidHandle) {
@@ -972,6 +974,7 @@ bool DebugSessionLinux::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *v
972974
memLock.unlock();
973975

974976
if (perKernelModules) {
977+
PRINT_DEBUGGER_INFO_LOG("New per-kernel module\n", "");
975978
debugEvent.flags = apiEventNeedsAck ? ZET_DEBUG_EVENT_FLAG_NEED_ACK : 0;
976979

977980
if (tileSessionsEnabled) {
@@ -1100,6 +1103,8 @@ bool DebugSessionLinux::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *v
11001103
}
11011104
}
11021105
} else {
1106+
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()));
1107+
11031108
if (canTriggerEvent && module.loadAddresses[tileIndex].size() == module.segmentCount) {
11041109
auto gmmHelper = connectedDevice->getNEODevice()->getGmmHelper();
11051110
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
14011406
uint32_t segmentCount = 0;
14021407
memcpy_s(&segmentCount, sizeof(uint32_t), uuidData.data.get(), uuidData.dataSize);
14031408
clientHandleToConnection[client]->uuidToModule[uuidData.handle].segmentCount = segmentCount;
1409+
PRINT_DEBUGGER_INFO_LOG("Zebin module = %ull, segment count = %ul", uuidData.handle, segmentCount);
14041410
}
14051411
}
14061412

shared/source/os_interface/linux/drm_allocation.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ void DrmAllocation::linkWithRegisteredHandle(uint32_t handle) {
349349
for (auto bo : bos) {
350350
if (bo) {
351351
bo->addBindExtHandle(handle);
352+
bo->requireImmediateBinding(true);
352353
}
353354
}
354355
}

0 commit comments

Comments
 (0)