diff --git a/level_zero/core/test/unit_tests/sources/debugger/linux/test_l0_debugger_linux.cpp b/level_zero/core/test/unit_tests/sources/debugger/linux/test_l0_debugger_linux.cpp index 6cddaf2e9f..698dc61a24 100644 --- a/level_zero/core/test/unit_tests/sources/debugger/linux/test_l0_debugger_linux.cpp +++ b/level_zero/core/test/unit_tests/sources/debugger/linux/test_l0_debugger_linux.cpp @@ -267,6 +267,38 @@ TEST_F(L0DebuggerLinuxTest, givenAllocationsWhenAttachingZebinModuleThenAllAlloc 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 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) { uint32_t handle = 20; diff --git a/level_zero/tools/source/debug/linux/prelim/debug_session.cpp b/level_zero/tools/source/debug/linux/prelim/debug_session.cpp index b364840234..e55d581553 100644 --- a/level_zero/tools/source/debug/linux/prelim/debug_session.cpp +++ b/level_zero/tools/source/debug/linux/prelim/debug_session.cpp @@ -754,6 +754,7 @@ bool DebugSessionLinux::checkAllEventsCollected() { allEventsCollected = true; } } + PRINT_DEBUGGER_INFO_LOG("checkAllEventsCollected() returned %d, clientHandle = %ull\n", static_cast(allEventsCollected), this->clientHandle); 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) { perKernelModules = false; moduleUUIDindex = static_cast(uuidIter); + PRINT_DEBUGGER_INFO_LOG("Zebin module uuid = %ull", (uint64_t)vmBind->uuids[uuidIter]); } 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(); if (perKernelModules) { + PRINT_DEBUGGER_INFO_LOG("New per-kernel module\n", ""); debugEvent.flags = apiEventNeedsAck ? ZET_DEBUG_EVENT_FLAG_NEED_ACK : 0; if (tileSessionsEnabled) { @@ -1100,6 +1103,8 @@ bool DebugSessionLinux::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *v } } } else { + PRINT_DEBUGGER_INFO_LOG("Zebin module = %ull has load addresses = %d", static_cast(vmBind->uuids[uuidIter]), static_cast(module.loadAddresses[tileIndex].size())); + if (canTriggerEvent && module.loadAddresses[tileIndex].size() == module.segmentCount) { auto gmmHelper = connectedDevice->getNEODevice()->getGmmHelper(); 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; memcpy_s(&segmentCount, sizeof(uint32_t), uuidData.data.get(), uuidData.dataSize); clientHandleToConnection[client]->uuidToModule[uuidData.handle].segmentCount = segmentCount; + PRINT_DEBUGGER_INFO_LOG("Zebin module = %ull, segment count = %ul", uuidData.handle, segmentCount); } } diff --git a/shared/source/os_interface/linux/drm_allocation.cpp b/shared/source/os_interface/linux/drm_allocation.cpp index 08073f557b..923f463aa1 100644 --- a/shared/source/os_interface/linux/drm_allocation.cpp +++ b/shared/source/os_interface/linux/drm_allocation.cpp @@ -349,6 +349,7 @@ void DrmAllocation::linkWithRegisteredHandle(uint32_t handle) { for (auto bo : bos) { if (bo) { bo->addBindExtHandle(handle); + bo->requireImmediateBinding(true); } } }