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