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