2020-09-14 19:28:47 +08:00
|
|
|
/*
|
2022-02-10 00:07:36 +08:00
|
|
|
* Copyright (C) 2020-2022 Intel Corporation
|
2020-09-14 19:28:47 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2022-06-15 05:24:58 +08:00
|
|
|
#include "shared/source/debugger/debugger_l0.h"
|
2020-09-14 19:28:47 +08:00
|
|
|
#include "shared/source/device/device.h"
|
|
|
|
#include "shared/source/helpers/hw_helper.h"
|
2020-10-17 06:52:18 +08:00
|
|
|
#include "shared/source/kernel/debug_data.h"
|
|
|
|
#include "shared/source/os_interface/linux/drm_allocation.h"
|
2020-09-14 19:28:47 +08:00
|
|
|
#include "shared/source/os_interface/linux/drm_neo.h"
|
2021-05-21 07:17:57 +08:00
|
|
|
#include "shared/source/os_interface/os_interface.h"
|
2022-06-15 05:24:58 +08:00
|
|
|
namespace NEO {
|
2020-11-23 22:31:20 +08:00
|
|
|
bool DebuggerL0::initDebuggingInOs(NEO::OSInterface *osInterface) {
|
2020-11-19 22:11:37 +08:00
|
|
|
if (osInterface != nullptr) {
|
2021-05-21 07:17:57 +08:00
|
|
|
auto drm = osInterface->getDriverModel()->as<NEO::Drm>();
|
2020-11-23 22:31:20 +08:00
|
|
|
if (drm->isVmBindAvailable() && drm->isPerContextVMRequired()) {
|
|
|
|
drm->registerResourceClasses();
|
|
|
|
return true;
|
|
|
|
}
|
2020-09-14 19:28:47 +08:00
|
|
|
}
|
2020-11-23 22:31:20 +08:00
|
|
|
return false;
|
2020-09-14 19:28:47 +08:00
|
|
|
}
|
2020-10-17 06:52:18 +08:00
|
|
|
|
2022-05-28 07:37:00 +08:00
|
|
|
void DebuggerL0::initSbaTrackingMode() {
|
|
|
|
singleAddressSpaceSbaTracking = false;
|
|
|
|
}
|
|
|
|
|
2020-10-17 06:52:18 +08:00
|
|
|
void DebuggerL0::registerElf(NEO::DebugData *debugData, NEO::GraphicsAllocation *isaAllocation) {
|
|
|
|
if (device->getRootDeviceEnvironment().osInterface.get() != nullptr) {
|
2021-05-21 07:17:57 +08:00
|
|
|
auto drm = device->getRootDeviceEnvironment().osInterface->getDriverModel()->as<NEO::Drm>();
|
2022-05-09 23:52:12 +08:00
|
|
|
auto handle = drm->registerResource(NEO::DrmResourceClass::Elf, debugData->vIsa, debugData->vIsaSize);
|
2020-10-17 06:52:18 +08:00
|
|
|
static_cast<NEO::DrmAllocation *>(isaAllocation)->linkWithRegisteredHandle(handle);
|
|
|
|
}
|
|
|
|
}
|
2022-02-10 00:07:36 +08:00
|
|
|
|
|
|
|
bool DebuggerL0::attachZebinModuleToSegmentAllocations(const StackVec<NEO::GraphicsAllocation *, 32> &allocs, uint32_t &moduleHandle) {
|
|
|
|
if (device->getRootDeviceEnvironment().osInterface == nullptr) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
auto drm = device->getRootDeviceEnvironment().osInterface->getDriverModel()->as<NEO::Drm>();
|
|
|
|
uint32_t segmentCount = static_cast<uint32_t>(allocs.size());
|
2022-05-09 23:52:12 +08:00
|
|
|
moduleHandle = drm->registerResource(NEO::DrmResourceClass::L0ZebinModule, &segmentCount, sizeof(uint32_t));
|
2022-02-10 00:07:36 +08:00
|
|
|
|
|
|
|
for (auto &allocation : allocs) {
|
|
|
|
auto drmAllocation = static_cast<NEO::DrmAllocation *>(allocation);
|
|
|
|
drmAllocation->linkWithRegisteredHandle(moduleHandle);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DebuggerL0::removeZebinModule(uint32_t moduleHandle) {
|
2022-02-18 01:05:15 +08:00
|
|
|
if (device->getRootDeviceEnvironment().osInterface == nullptr || moduleHandle == 0) {
|
2022-02-10 00:07:36 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
auto drm = device->getRootDeviceEnvironment().osInterface->getDriverModel()->as<NEO::Drm>();
|
|
|
|
|
|
|
|
drm->unregisterResource(moduleHandle);
|
|
|
|
return true;
|
|
|
|
}
|
2022-02-10 19:13:59 +08:00
|
|
|
|
|
|
|
void DebuggerL0::notifyCommandQueueCreated() {
|
|
|
|
if (device->getRootDeviceEnvironment().osInterface.get() != nullptr) {
|
|
|
|
if (++commandQueueCount == 1) {
|
|
|
|
auto drm = device->getRootDeviceEnvironment().osInterface->getDriverModel()->as<NEO::Drm>();
|
|
|
|
uuidL0CommandQueueHandle = drm->notifyFirstCommandQueueCreated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DebuggerL0::notifyCommandQueueDestroyed() {
|
|
|
|
if (device->getRootDeviceEnvironment().osInterface.get() != nullptr) {
|
|
|
|
if (--commandQueueCount == 0) {
|
|
|
|
auto drm = device->getRootDeviceEnvironment().osInterface->getDriverModel()->as<NEO::Drm>();
|
|
|
|
drm->notifyLastCommandQueueDestroyed(uuidL0CommandQueueHandle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-15 05:24:58 +08:00
|
|
|
} // namespace NEO
|