2020-03-06 11:09:57 +01:00
|
|
|
/*
|
2024-07-04 19:12:51 +00:00
|
|
|
* Copyright (C) 2020-2024 Intel Corporation
|
2020-03-06 11:09:57 +01:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2022-06-14 21:24:58 +00:00
|
|
|
#include "shared/source/debugger/debugger_l0.h"
|
2020-03-06 11:09:57 +01:00
|
|
|
|
2020-07-27 17:37:51 +02:00
|
|
|
#include "shared/source/command_container/cmdcontainer.h"
|
2020-08-18 17:47:12 +02:00
|
|
|
#include "shared/source/debug_settings/debug_settings_manager.h"
|
2020-06-29 16:30:34 +02:00
|
|
|
#include "shared/source/device/device.h"
|
2022-12-15 17:32:03 +00:00
|
|
|
#include "shared/source/execution_environment/root_device_environment.h"
|
2022-07-24 04:21:16 +00:00
|
|
|
#include "shared/source/gmm_helper/gmm_helper.h"
|
2020-06-29 16:30:34 +02:00
|
|
|
#include "shared/source/helpers/constants.h"
|
|
|
|
|
#include "shared/source/memory_manager/allocation_properties.h"
|
2023-10-12 00:51:45 +00:00
|
|
|
#include "shared/source/memory_manager/gfx_partition.h"
|
2020-06-29 16:30:34 +02:00
|
|
|
#include "shared/source/memory_manager/memory_manager.h"
|
2021-05-19 11:52:10 +00:00
|
|
|
#include "shared/source/memory_manager/memory_operations_handler.h"
|
2020-07-22 10:17:18 +02:00
|
|
|
#include "shared/source/os_interface/os_context.h"
|
|
|
|
|
|
2022-06-14 21:24:58 +00:00
|
|
|
namespace NEO {
|
2020-07-27 17:37:51 +02:00
|
|
|
|
|
|
|
|
DebugerL0CreateFn debuggerL0Factory[IGFX_MAX_CORE] = {};
|
|
|
|
|
|
2020-06-29 16:30:34 +02:00
|
|
|
DebuggerL0::DebuggerL0(NEO::Device *device) : device(device) {
|
2022-07-22 12:07:36 +00:00
|
|
|
const auto deviceCount = std::max(1u, device->getNumSubDevices());
|
|
|
|
|
commandQueueCount.resize(deviceCount);
|
|
|
|
|
uuidL0CommandQueueHandle.resize(deviceCount);
|
|
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < deviceCount; i++) {
|
|
|
|
|
commandQueueCount[i] = 0;
|
|
|
|
|
uuidL0CommandQueueHandle[i] = 0;
|
|
|
|
|
}
|
2020-11-19 14:11:37 +00:00
|
|
|
}
|
2020-06-29 16:30:34 +02:00
|
|
|
|
2020-11-19 14:11:37 +00:00
|
|
|
void DebuggerL0::initialize() {
|
2020-07-22 10:17:18 +02:00
|
|
|
|
2022-05-27 23:37:00 +00:00
|
|
|
initSbaTrackingMode();
|
|
|
|
|
|
2023-11-30 08:32:25 +00:00
|
|
|
if (NEO::debugManager.flags.DebuggerForceSbaTrackingMode.get() != -1) {
|
|
|
|
|
setSingleAddressSpaceSbaTracking(NEO::debugManager.flags.DebuggerForceSbaTrackingMode.get());
|
2022-03-23 08:57:31 +00:00
|
|
|
}
|
|
|
|
|
|
2023-04-26 10:36:25 +00:00
|
|
|
auto &engines = device->getMemoryManager()->getRegisteredEngines(device->getRootDeviceIndex());
|
2020-07-22 10:17:18 +02:00
|
|
|
|
2020-06-29 16:30:34 +02:00
|
|
|
NEO::AllocationProperties properties{device->getRootDeviceIndex(), true, MemoryConstants::pageSize,
|
2023-12-11 14:24:36 +00:00
|
|
|
NEO::AllocationType::debugSbaTrackingBuffer,
|
2020-06-29 16:30:34 +02:00
|
|
|
false,
|
2020-10-29 07:23:59 +01:00
|
|
|
device->getDeviceBitfield()};
|
2020-06-29 16:30:34 +02:00
|
|
|
|
2022-03-23 08:57:31 +00:00
|
|
|
if (!singleAddressSpaceSbaTracking) {
|
2023-06-12 13:52:45 +00:00
|
|
|
RootDeviceIndicesContainer rootDeviceIndices;
|
|
|
|
|
rootDeviceIndices.pushUnique(device->getRootDeviceIndex());
|
2022-09-17 00:38:06 +00:00
|
|
|
uint32_t rootDeviceIndexReserved = 0;
|
2023-06-12 13:52:45 +00:00
|
|
|
sbaTrackingGpuVa = device->getMemoryManager()->reserveGpuAddress(0ull, MemoryConstants::pageSize, rootDeviceIndices, &rootDeviceIndexReserved);
|
2023-04-26 20:16:48 +00:00
|
|
|
UNRECOVERABLE_IF(sbaTrackingGpuVa.address == 0u);
|
2022-03-23 08:57:31 +00:00
|
|
|
properties.gpuAddress = sbaTrackingGpuVa.address;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-17 15:43:11 +00:00
|
|
|
SbaTrackedAddresses sbaHeader{};
|
2020-07-22 10:17:18 +02:00
|
|
|
|
|
|
|
|
for (auto &engine : engines) {
|
2022-03-23 08:57:31 +00:00
|
|
|
if (!singleAddressSpaceSbaTracking) {
|
|
|
|
|
properties.osContext = engine.osContext;
|
|
|
|
|
}
|
2022-04-14 19:13:34 +00:00
|
|
|
properties.subDevicesBitfield = engine.osContext->getDeviceBitfield();
|
2020-07-22 10:17:18 +02:00
|
|
|
|
2022-04-14 19:13:34 +00:00
|
|
|
auto sbaAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
|
|
|
|
|
device->getMemoryManager()->copyMemoryToAllocation(sbaAllocation, 0, &sbaHeader, sizeof(sbaHeader));
|
2020-07-22 10:17:18 +02:00
|
|
|
|
|
|
|
|
perContextSbaAllocations[engine.osContext->getContextId()] = sbaAllocation;
|
2022-07-05 13:40:15 +00:00
|
|
|
registerAllocationType(sbaAllocation); // NOLINT(clang-analyzer-optin.cplusplus.VirtualCall)
|
2020-07-22 10:17:18 +02:00
|
|
|
}
|
2020-10-14 16:46:11 +02:00
|
|
|
|
|
|
|
|
{
|
|
|
|
|
auto &hwInfo = device->getHardwareInfo();
|
2023-01-26 16:21:09 +00:00
|
|
|
auto &rootDeviceEnvironment = device->getRootDeviceEnvironment();
|
|
|
|
|
|
2020-10-14 16:46:11 +02:00
|
|
|
NEO::AllocationProperties properties{device->getRootDeviceIndex(), true, MemoryConstants::pageSize64k,
|
2023-12-11 14:24:36 +00:00
|
|
|
NEO::AllocationType::debugModuleArea,
|
2020-10-14 16:46:11 +02:00
|
|
|
false,
|
|
|
|
|
device->getDeviceBitfield()};
|
|
|
|
|
moduleDebugArea = device->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
|
|
|
|
|
|
|
|
|
|
DebugAreaHeader debugArea = {};
|
2022-04-26 15:32:10 +00:00
|
|
|
debugArea.reserved1 = 1;
|
2020-10-14 16:46:11 +02:00
|
|
|
debugArea.size = sizeof(DebugAreaHeader);
|
|
|
|
|
debugArea.pgsize = 1;
|
2021-05-19 11:52:10 +00:00
|
|
|
debugArea.isShared = moduleDebugArea->storageInfo.getNumBanks() == 1;
|
2020-10-14 16:46:11 +02:00
|
|
|
debugArea.scratchBegin = sizeof(DebugAreaHeader);
|
|
|
|
|
debugArea.scratchEnd = MemoryConstants::pageSize64k - sizeof(DebugAreaHeader);
|
|
|
|
|
|
2024-09-12 22:23:28 +00:00
|
|
|
const auto &productHelper = device->getProductHelper();
|
|
|
|
|
NEO::MemoryTransferHelper::transferMemoryToAllocation(productHelper.isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, *moduleDebugArea),
|
|
|
|
|
*device, moduleDebugArea, 0, &debugArea,
|
|
|
|
|
sizeof(DebugAreaHeader));
|
|
|
|
|
|
2023-01-26 16:21:09 +00:00
|
|
|
NEO::MemoryOperationsHandler *memoryOperationsIface = rootDeviceEnvironment.memoryOperationsInterface.get();
|
2021-05-19 11:52:10 +00:00
|
|
|
if (memoryOperationsIface) {
|
2024-09-23 12:46:37 +00:00
|
|
|
memoryOperationsIface->makeResident(device, ArrayRef<NEO::GraphicsAllocation *>(&moduleDebugArea, 1), false);
|
2024-06-28 21:29:44 +00:00
|
|
|
auto numSubDevices = device->getNumSubDevices();
|
|
|
|
|
for (uint32_t i = 0; i < numSubDevices; i++) {
|
|
|
|
|
auto subDevice = device->getSubDevice(i);
|
2024-09-23 12:46:37 +00:00
|
|
|
memoryOperationsIface->makeResident(subDevice, ArrayRef<NEO::GraphicsAllocation *>(&moduleDebugArea, 1), false);
|
2024-06-28 21:29:44 +00:00
|
|
|
}
|
2021-05-19 11:52:10 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-29 15:18:31 +00:00
|
|
|
if (productHelper.disableL3CacheForDebug(hwInfo)) {
|
2022-02-21 13:33:41 +00:00
|
|
|
device->getGmmHelper()->forceAllResourcesUncached();
|
2021-12-07 15:32:00 +00:00
|
|
|
}
|
2022-07-05 13:40:15 +00:00
|
|
|
|
|
|
|
|
registerAllocationType(moduleDebugArea); // NOLINT(clang-analyzer-optin.cplusplus.VirtualCall)
|
2020-10-14 16:46:11 +02:00
|
|
|
}
|
2020-06-29 16:30:34 +02:00
|
|
|
}
|
|
|
|
|
|
2020-08-18 17:47:12 +02:00
|
|
|
void DebuggerL0::printTrackedAddresses(uint32_t contextId) {
|
|
|
|
|
auto memory = perContextSbaAllocations[contextId]->getUnderlyingBuffer();
|
|
|
|
|
auto sba = reinterpret_cast<SbaTrackedAddresses *>(memory);
|
|
|
|
|
|
2021-04-02 12:16:22 +00:00
|
|
|
PRINT_DEBUGGER_INFO_LOG("Debugger: SBA ssh = %" SCNx64
|
|
|
|
|
" gsba = %" SCNx64
|
|
|
|
|
" dsba = %" SCNx64
|
|
|
|
|
" ioba = %" SCNx64
|
|
|
|
|
" iba = %" SCNx64
|
|
|
|
|
" bsurfsba = %" SCNx64 "\n",
|
2023-04-27 09:50:55 +00:00
|
|
|
sba->surfaceStateBaseAddress, sba->generalStateBaseAddress, sba->dynamicStateBaseAddress,
|
|
|
|
|
sba->indirectObjectBaseAddress, sba->instructionBaseAddress, sba->bindlessSurfaceStateBaseAddress);
|
2020-08-18 17:47:12 +02:00
|
|
|
}
|
|
|
|
|
|
2020-06-29 16:30:34 +02:00
|
|
|
DebuggerL0 ::~DebuggerL0() {
|
2020-07-22 10:17:18 +02:00
|
|
|
for (auto &alloc : perContextSbaAllocations) {
|
|
|
|
|
device->getMemoryManager()->freeGraphicsMemory(alloc.second);
|
|
|
|
|
}
|
2022-03-23 08:57:31 +00:00
|
|
|
if (sbaTrackingGpuVa.size != 0) {
|
|
|
|
|
device->getMemoryManager()->freeGpuAddress(sbaTrackingGpuVa, device->getRootDeviceIndex());
|
|
|
|
|
}
|
2020-10-14 16:46:11 +02:00
|
|
|
device->getMemoryManager()->freeGraphicsMemory(moduleDebugArea);
|
2020-06-29 16:30:34 +02:00
|
|
|
}
|
|
|
|
|
|
2022-08-30 18:06:04 +00:00
|
|
|
void DebuggerL0::notifyModuleLoadAllocations(Device *device, const StackVec<NEO::GraphicsAllocation *, 32> &allocs) {
|
2022-04-07 16:50:41 +00:00
|
|
|
NEO::MemoryOperationsHandler *memoryOperationsIface = device->getRootDeviceEnvironment().memoryOperationsInterface.get();
|
|
|
|
|
if (memoryOperationsIface) {
|
|
|
|
|
for (auto gfxAlloc : allocs) {
|
2024-09-23 12:46:37 +00:00
|
|
|
memoryOperationsIface->makeResident(device, ArrayRef<NEO::GraphicsAllocation *>(&gfxAlloc, 1), false);
|
2022-04-07 16:50:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-06-14 21:24:58 +00:00
|
|
|
} // namespace NEO
|