mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-25 05:24:02 +08:00
feature: Register critical section metadata for xe debugger
Related-to: NEO-9161 Signed-off-by: Brandon Yates <brandon.yates@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
97ce15614b
commit
87022c31d3
@@ -336,71 +336,7 @@ void DrmAllocation::registerBOBindExtHandle(Drm *drm) {
|
||||
return;
|
||||
}
|
||||
|
||||
DrmResourceClass resourceClass = DrmResourceClass::maxSize;
|
||||
|
||||
switch (this->allocationType) {
|
||||
case AllocationType::debugContextSaveArea:
|
||||
resourceClass = DrmResourceClass::contextSaveArea;
|
||||
break;
|
||||
case AllocationType::debugSbaTrackingBuffer:
|
||||
resourceClass = DrmResourceClass::sbaTrackingBuffer;
|
||||
break;
|
||||
case AllocationType::kernelIsa:
|
||||
resourceClass = DrmResourceClass::isa;
|
||||
break;
|
||||
case AllocationType::debugModuleArea:
|
||||
resourceClass = DrmResourceClass::moduleHeapDebugArea;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (resourceClass != DrmResourceClass::maxSize) {
|
||||
auto handle = 0;
|
||||
if (resourceClass == DrmResourceClass::isa) {
|
||||
auto deviceBitfiled = static_cast<uint32_t>(this->storageInfo.subDeviceBitfield.to_ulong());
|
||||
handle = drm->registerResource(resourceClass, &deviceBitfiled, sizeof(deviceBitfiled));
|
||||
} else {
|
||||
uint64_t gpuAddress = getGpuAddress();
|
||||
handle = drm->registerResource(resourceClass, &gpuAddress, sizeof(gpuAddress));
|
||||
}
|
||||
|
||||
registeredBoBindHandles.push_back(handle);
|
||||
|
||||
auto &bos = getBOs();
|
||||
uint32_t boIndex = 0u;
|
||||
|
||||
for (auto bo : bos) {
|
||||
if (bo) {
|
||||
bo->addBindExtHandle(handle);
|
||||
bo->markForCapture();
|
||||
if (resourceClass == DrmResourceClass::isa && storageInfo.tileInstanced == true) {
|
||||
auto cookieHandle = drm->registerIsaCookie(handle);
|
||||
bo->addBindExtHandle(cookieHandle);
|
||||
registeredBoBindHandles.push_back(cookieHandle);
|
||||
}
|
||||
|
||||
if (resourceClass == DrmResourceClass::sbaTrackingBuffer && getOsContext()) {
|
||||
auto deviceIndex = [=]() -> uint32_t {
|
||||
if (storageInfo.tileInstanced == true) {
|
||||
return boIndex;
|
||||
}
|
||||
auto deviceBitfield = this->storageInfo.subDeviceBitfield;
|
||||
return deviceBitfield.any() ? static_cast<uint32_t>(Math::log2(static_cast<uint32_t>(deviceBitfield.to_ulong()))) : 0u;
|
||||
}();
|
||||
|
||||
auto contextId = getOsContext()->getOfflineDumpContextId(deviceIndex);
|
||||
auto externalHandle = drm->registerResource(resourceClass, &contextId, sizeof(uint64_t));
|
||||
|
||||
bo->addBindExtHandle(externalHandle);
|
||||
registeredBoBindHandles.push_back(externalHandle);
|
||||
}
|
||||
|
||||
bo->requireImmediateBinding(true);
|
||||
}
|
||||
boIndex++;
|
||||
}
|
||||
}
|
||||
drm->getIoctlHelper()->registerBOBindHandle(drm, this);
|
||||
}
|
||||
|
||||
void DrmAllocation::linkWithRegisteredHandle(uint32_t handle) {
|
||||
|
||||
@@ -142,6 +142,7 @@ class DrmAllocation : public GraphicsAllocation {
|
||||
MOCKABLE_VIRTUAL int bindBOs(OsContext *osContext, uint32_t vmHandleId, std::vector<BufferObject *> *bufferObjects, bool bind);
|
||||
MOCKABLE_VIRTUAL bool prefetchBO(BufferObject *bo, uint32_t vmHandleId, uint32_t subDeviceId);
|
||||
MOCKABLE_VIRTUAL void registerBOBindExtHandle(Drm *drm);
|
||||
void addRegisteredBoBindHandle(uint32_t handle) { registeredBoBindHandles.push_back(handle); }
|
||||
void freeRegisteredBOBindExtHandles(Drm *drm);
|
||||
void linkWithRegisteredHandle(uint32_t handle);
|
||||
MOCKABLE_VIRTUAL void markForCapture();
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#pragma once
|
||||
#include "shared/source/command_stream/task_count_helper.h"
|
||||
#include "shared/source/helpers/topology_map.h"
|
||||
#include "shared/source/os_interface/linux/drm_allocation.h"
|
||||
#include "shared/source/os_interface/linux/drm_debug.h"
|
||||
#include "shared/source/os_interface/linux/drm_wrappers.h"
|
||||
#include "shared/source/utilities/stackvec.h"
|
||||
@@ -192,6 +193,7 @@ class IoctlHelper {
|
||||
|
||||
virtual bool validPageFault(uint16_t flags) { return false; }
|
||||
virtual uint32_t getStatusForResetStats(bool banned) { return 0u; }
|
||||
virtual void registerBOBindHandle(Drm *drm, DrmAllocation *drmAllocation) { return; }
|
||||
|
||||
virtual void insertEngineToContextParams(ContextParamEngines<> &contextParamEngines, uint32_t engineId, const EngineClassInstance *engineClassInstance, uint32_t tileId, bool hasVirtualEngines) = 0;
|
||||
|
||||
@@ -388,6 +390,7 @@ class IoctlHelperPrelim20 : public IoctlHelperI915 {
|
||||
|
||||
bool validPageFault(uint16_t flags) override;
|
||||
uint32_t getStatusForResetStats(bool banned) override;
|
||||
void registerBOBindHandle(Drm *drm, DrmAllocation *drmAllocation) override;
|
||||
|
||||
protected:
|
||||
bool queryHwIpVersion(EngineClassInstance &engineInfo, HardwareIpVersion &ipVersion, int &ret);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/execution_environment/root_device_environment.h"
|
||||
#include "shared/source/helpers/aligned_memory.h"
|
||||
#include "shared/source/helpers/basic_math.h"
|
||||
#include "shared/source/helpers/common_types.h"
|
||||
#include "shared/source/helpers/constants.h"
|
||||
#include "shared/source/helpers/debug_helpers.h"
|
||||
@@ -15,12 +16,15 @@
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/helpers/ptr_math.h"
|
||||
#include "shared/source/helpers/string.h"
|
||||
#include "shared/source/memory_manager/graphics_allocation.h"
|
||||
#include "shared/source/os_interface/linux/cache_info.h"
|
||||
#include "shared/source/os_interface/linux/drm_buffer_object.h"
|
||||
#include "shared/source/os_interface/linux/drm_neo.h"
|
||||
#include "shared/source/os_interface/linux/drm_wrappers.h"
|
||||
#include "shared/source/os_interface/linux/engine_info.h"
|
||||
#include "shared/source/os_interface/linux/i915_prelim.h"
|
||||
#include "shared/source/os_interface/linux/ioctl_helper.h"
|
||||
#include "shared/source/os_interface/linux/os_context_linux.h"
|
||||
#include "shared/source/os_interface/linux/sys_calls.h"
|
||||
#include "shared/source/os_interface/product_helper.h"
|
||||
|
||||
@@ -1173,6 +1177,74 @@ uint32_t IoctlHelperPrelim20::getStatusForResetStats(bool banned) {
|
||||
return retVal;
|
||||
}
|
||||
|
||||
void IoctlHelperPrelim20::registerBOBindHandle(Drm *drm, DrmAllocation *drmAllocation) {
|
||||
DrmResourceClass resourceClass = DrmResourceClass::maxSize;
|
||||
|
||||
switch (drmAllocation->getAllocationType()) {
|
||||
case AllocationType::debugContextSaveArea:
|
||||
resourceClass = DrmResourceClass::contextSaveArea;
|
||||
break;
|
||||
case AllocationType::debugSbaTrackingBuffer:
|
||||
resourceClass = DrmResourceClass::sbaTrackingBuffer;
|
||||
break;
|
||||
case AllocationType::kernelIsa:
|
||||
resourceClass = DrmResourceClass::isa;
|
||||
break;
|
||||
case AllocationType::debugModuleArea:
|
||||
resourceClass = DrmResourceClass::moduleHeapDebugArea;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (resourceClass != DrmResourceClass::maxSize) {
|
||||
auto handle = 0;
|
||||
if (resourceClass == DrmResourceClass::isa) {
|
||||
auto deviceBitfiled = static_cast<uint32_t>(drmAllocation->storageInfo.subDeviceBitfield.to_ulong());
|
||||
handle = drm->registerResource(resourceClass, &deviceBitfiled, sizeof(deviceBitfiled));
|
||||
} else {
|
||||
uint64_t gpuAddress = drmAllocation->getGpuAddress();
|
||||
handle = drm->registerResource(resourceClass, &gpuAddress, sizeof(gpuAddress));
|
||||
}
|
||||
|
||||
drmAllocation->addRegisteredBoBindHandle(handle);
|
||||
|
||||
auto &bos = drmAllocation->getBOs();
|
||||
uint32_t boIndex = 0u;
|
||||
|
||||
for (auto bo : bos) {
|
||||
if (bo) {
|
||||
bo->addBindExtHandle(handle);
|
||||
bo->markForCapture();
|
||||
if (resourceClass == DrmResourceClass::isa && drmAllocation->storageInfo.tileInstanced == true) {
|
||||
auto cookieHandle = drm->registerIsaCookie(handle);
|
||||
bo->addBindExtHandle(cookieHandle);
|
||||
drmAllocation->addRegisteredBoBindHandle(cookieHandle);
|
||||
}
|
||||
auto storageInfo = drmAllocation->storageInfo;
|
||||
if (resourceClass == DrmResourceClass::sbaTrackingBuffer && drmAllocation->getOsContext()) {
|
||||
auto deviceIndex = [=]() -> uint32_t {
|
||||
if (storageInfo.tileInstanced == true) {
|
||||
return boIndex;
|
||||
}
|
||||
auto deviceBitfield = storageInfo.subDeviceBitfield;
|
||||
return deviceBitfield.any() ? static_cast<uint32_t>(Math::log2(static_cast<uint32_t>(deviceBitfield.to_ulong()))) : 0u;
|
||||
}();
|
||||
|
||||
auto contextId = drmAllocation->getOsContext()->getOfflineDumpContextId(deviceIndex);
|
||||
auto externalHandle = drm->registerResource(resourceClass, &contextId, sizeof(uint64_t));
|
||||
|
||||
bo->addBindExtHandle(externalHandle);
|
||||
drmAllocation->addRegisteredBoBindHandle(externalHandle);
|
||||
}
|
||||
|
||||
bo->requireImmediateBinding(true);
|
||||
}
|
||||
boIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static_assert(sizeof(MemoryClassInstance) == sizeof(prelim_drm_i915_gem_memory_class_instance));
|
||||
static_assert(offsetof(MemoryClassInstance, memoryClass) == offsetof(prelim_drm_i915_gem_memory_class_instance, memory_class));
|
||||
static_assert(offsetof(MemoryClassInstance, memoryInstance) == offsetof(prelim_drm_i915_gem_memory_class_instance, memory_instance));
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "shared/source/helpers/ptr_math.h"
|
||||
#include "shared/source/helpers/register_offsets.h"
|
||||
#include "shared/source/helpers/string.h"
|
||||
#include "shared/source/os_interface/linux/drm_buffer_object.h"
|
||||
#include "shared/source/os_interface/linux/drm_neo.h"
|
||||
#include "shared/source/os_interface/linux/engine_info.h"
|
||||
#include "shared/source/os_interface/linux/memory_info.h"
|
||||
@@ -1435,4 +1436,37 @@ void IoctlHelperXe::insertEngineToContextParams(ContextParamEngines<> &contextPa
|
||||
contextParamEngines.numEnginesInContext = std::max(contextParamEngines.numEnginesInContext, engineId + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void IoctlHelperXe::registerBOBindHandle(Drm *drm, DrmAllocation *drmAllocation) {
|
||||
DrmResourceClass resourceClass = DrmResourceClass::maxSize;
|
||||
|
||||
switch (drmAllocation->getAllocationType()) {
|
||||
case AllocationType::debugContextSaveArea:
|
||||
resourceClass = DrmResourceClass::contextSaveArea;
|
||||
break;
|
||||
case AllocationType::debugSbaTrackingBuffer:
|
||||
resourceClass = DrmResourceClass::sbaTrackingBuffer;
|
||||
break;
|
||||
case AllocationType::debugModuleArea:
|
||||
resourceClass = DrmResourceClass::moduleHeapDebugArea;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
uint64_t gpuAddress = drmAllocation->getGpuAddress();
|
||||
auto handle = drm->registerResource(resourceClass, &gpuAddress, sizeof(gpuAddress));
|
||||
drmAllocation->addRegisteredBoBindHandle(handle);
|
||||
auto &bos = drmAllocation->getBOs();
|
||||
for (auto bo : bos) {
|
||||
if (!bo) {
|
||||
continue;
|
||||
}
|
||||
bo->addBindExtHandle(handle);
|
||||
bo->markForCapture();
|
||||
bo->requireImmediateBinding(true);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -142,6 +142,8 @@ class IoctlHelperXe : public IoctlHelper {
|
||||
uint32_t registerResource(DrmResourceClass classType, const void *data, size_t size) override;
|
||||
void unregisterResource(uint32_t handle) override;
|
||||
void insertEngineToContextParams(ContextParamEngines<> &contextParamEngines, uint32_t engineId, const EngineClassInstance *engineClassInstance, uint32_t tileId, bool hasVirtualEngines) override;
|
||||
void registerBOBindHandle(Drm *drm, DrmAllocation *drmAllocation) override;
|
||||
bool resourceRegistrationEnabled() override { return true; }
|
||||
|
||||
protected:
|
||||
static constexpr uint32_t maxContextSetProperties = 4;
|
||||
|
||||
@@ -164,6 +164,18 @@ uint32_t IoctlHelperXe::registerResource(DrmResourceClass classType, const void
|
||||
metadata.type = DRM_XE_DEBUG_METADATA_PROGRAM_MODULE;
|
||||
metadata.user_addr = reinterpret_cast<uintptr_t>(data);
|
||||
metadata.len = size;
|
||||
} else if (classType == DrmResourceClass::contextSaveArea) {
|
||||
metadata.type = WORK_IN_PROGRESS_DRM_XE_DEBUG_METADATA_SIP_AREA;
|
||||
metadata.user_addr = reinterpret_cast<uintptr_t>(data);
|
||||
metadata.len = size;
|
||||
} else if (classType == DrmResourceClass::sbaTrackingBuffer) {
|
||||
metadata.type = WORK_IN_PROGRESS_DRM_XE_DEBUG_METADATA_SBA_AREA;
|
||||
metadata.user_addr = reinterpret_cast<uintptr_t>(data);
|
||||
metadata.len = size;
|
||||
} else if (classType == DrmResourceClass::moduleHeapDebugArea) {
|
||||
metadata.type = WORK_IN_PROGRESS_DRM_XE_DEBUG_METADATA_MODULE_AREA;
|
||||
metadata.user_addr = reinterpret_cast<uintptr_t>(data);
|
||||
metadata.len = size;
|
||||
} else {
|
||||
UNRECOVERABLE_IF(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user