2020-03-06 11:09:57 +01:00
|
|
|
/*
|
2022-01-05 12:06:14 +00:00
|
|
|
* Copyright (C) 2020-2022 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-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"
|
|
|
|
|
#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"
|
|
|
|
|
|
|
|
|
|
#include <cstring>
|
2020-06-29 16:30:34 +02:00
|
|
|
|
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) {
|
|
|
|
|
isLegacyMode = false;
|
2022-03-23 08:57:31 +00:00
|
|
|
|
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
|
|
|
initialize();
|
|
|
|
|
}
|
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();
|
|
|
|
|
|
2022-03-23 08:57:31 +00:00
|
|
|
if (NEO::DebugManager.flags.DebuggerForceSbaTrackingMode.get() != -1) {
|
|
|
|
|
setSingleAddressSpaceSbaTracking(NEO::DebugManager.flags.DebuggerForceSbaTrackingMode.get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto &engines = device->getMemoryManager()->getRegisteredEngines();
|
2020-07-22 10:17:18 +02:00
|
|
|
|
2020-06-29 16:30:34 +02:00
|
|
|
NEO::AllocationProperties properties{device->getRootDeviceIndex(), true, MemoryConstants::pageSize,
|
2022-02-04 13:59:01 +00:00
|
|
|
NEO::AllocationType::DEBUG_SBA_TRACKING_BUFFER,
|
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) {
|
|
|
|
|
sbaTrackingGpuVa = device->getMemoryManager()->reserveGpuAddress(MemoryConstants::pageSize, device->getRootDeviceIndex());
|
|
|
|
|
properties.gpuAddress = sbaTrackingGpuVa.address;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-22 10:17:18 +02:00
|
|
|
SbaTrackedAddresses sbaHeader;
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
auto &hwHelper = NEO::HwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
|
|
|
|
NEO::AllocationProperties properties{device->getRootDeviceIndex(), true, MemoryConstants::pageSize64k,
|
2022-02-04 13:59:01 +00:00
|
|
|
NEO::AllocationType::DEBUG_MODULE_AREA,
|
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);
|
|
|
|
|
|
2021-05-19 11:52:10 +00:00
|
|
|
NEO::MemoryOperationsHandler *memoryOperationsIface = device->getRootDeviceEnvironment().memoryOperationsInterface.get();
|
|
|
|
|
if (memoryOperationsIface) {
|
|
|
|
|
memoryOperationsIface->makeResident(device, ArrayRef<NEO::GraphicsAllocation *>(&moduleDebugArea, 1));
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-02 13:54:24 +00:00
|
|
|
const auto &hwInfoConfig = *NEO::HwInfoConfig::get(hwInfo.platform.eProductFamily);
|
|
|
|
|
NEO::MemoryTransferHelper::transferMemoryToAllocation(hwInfoConfig.isBlitCopyRequiredForLocalMemory(hwInfo, *moduleDebugArea),
|
2020-10-14 16:46:11 +02:00
|
|
|
*device, moduleDebugArea, 0, &debugArea,
|
|
|
|
|
sizeof(DebugAreaHeader));
|
2022-01-05 12:06:14 +00:00
|
|
|
if (hwHelper.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",
|
|
|
|
|
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) {
|
|
|
|
|
memoryOperationsIface->makeResident(device, ArrayRef<NEO::GraphicsAllocation *>(&gfxAlloc, 1));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-06-14 21:24:58 +00:00
|
|
|
} // namespace NEO
|