mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-06 08:50:09 +01:00
intel: move debug identifier out of libintel_dev
The debug identifier is put into the captured buffers for error capture. This helps us figure out what version of the driver people are running when encountering a GPU hang. This identifier has the git-sha1 + driver name. libintel_dev is also a dependency of the compiler so any change to the git-sha1 also triggers recompile which we want to avoid. This changes moves the debug identifier to src/intel/common which drivers already depend on, so the compiler is not affected anymore. Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11136 Reviewed-by: Ivan Briano <ivan.briano@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29128>
This commit is contained in:
parent
4882f49e6b
commit
36c043e2eb
19 changed files with 227 additions and 174 deletions
|
|
@ -34,6 +34,7 @@
|
|||
#include "crocus_resource.h"
|
||||
#include "crocus_screen.h"
|
||||
#include "common/i915/intel_defines.h"
|
||||
#include "common/intel_debug_identifier.h"
|
||||
#include "common/intel_sample_positions.h"
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@
|
|||
#include "crocus_resource.h"
|
||||
#include "crocus_screen.h"
|
||||
#include "intel/compiler/elk/elk_compiler.h"
|
||||
#include "intel/common/intel_debug_identifier.h"
|
||||
#include "intel/common/intel_gem.h"
|
||||
#include "intel/common/intel_l3_config.h"
|
||||
#include "intel/common/intel_uuid.h"
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include "common/intel_debug_identifier.h"
|
||||
#include "common/intel_gem.h"
|
||||
#include "common/i915/intel_gem.h"
|
||||
#include "dev/intel_debug.h"
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@
|
|||
#include "iris_resource.h"
|
||||
#include "iris_screen.h"
|
||||
#include "compiler/glsl_types.h"
|
||||
#include "intel/common/intel_debug_identifier.h"
|
||||
#include "intel/common/intel_gem.h"
|
||||
#include "intel/common/intel_l3_config.h"
|
||||
#include "intel/common/intel_uuid.h"
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include "common/intel_debug_identifier.h"
|
||||
#include "common/intel_gem.h"
|
||||
#include "dev/intel_debug.h"
|
||||
#include "iris/iris_bufmgr.h"
|
||||
|
|
|
|||
141
src/intel/common/intel_debug_identifier.c
Normal file
141
src/intel/common/intel_debug_identifier.c
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
/**
|
||||
* \file intel_debug_identifier.c
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "git_sha1.h"
|
||||
|
||||
#include "common/intel_debug_identifier.h"
|
||||
#include "dev/intel_debug.h"
|
||||
#include "util/macros.h"
|
||||
#include "util/u_math.h"
|
||||
|
||||
static uint64_t debug_identifier[4] = {
|
||||
0xffeeddccbbaa9988,
|
||||
0x7766554433221100,
|
||||
0xffeeddccbbaa9988,
|
||||
0x7766554433221100,
|
||||
};
|
||||
|
||||
void *
|
||||
intel_debug_identifier(void)
|
||||
{
|
||||
return debug_identifier;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
intel_debug_identifier_size(void)
|
||||
{
|
||||
return sizeof(debug_identifier);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
intel_debug_write_identifiers(void *_output,
|
||||
uint32_t output_size,
|
||||
const char *driver_name)
|
||||
{
|
||||
void *output = _output, *output_end = _output + output_size;
|
||||
|
||||
assert(output_size > intel_debug_identifier_size());
|
||||
|
||||
memcpy(output, intel_debug_identifier(), intel_debug_identifier_size());
|
||||
output += intel_debug_identifier_size();
|
||||
|
||||
for (uint32_t id = INTEL_DEBUG_BLOCK_TYPE_DRIVER; id < INTEL_DEBUG_BLOCK_TYPE_MAX; id++) {
|
||||
switch (id) {
|
||||
case INTEL_DEBUG_BLOCK_TYPE_DRIVER: {
|
||||
struct intel_debug_block_driver driver_desc = {
|
||||
.base = {
|
||||
.type = id,
|
||||
},
|
||||
};
|
||||
int len = snprintf(output + sizeof(driver_desc),
|
||||
output_end - (output + sizeof(driver_desc)),
|
||||
"%s " PACKAGE_VERSION " build " MESA_GIT_SHA1,
|
||||
driver_name);
|
||||
driver_desc.base.length = sizeof(driver_desc) + len + 1;
|
||||
memcpy(output, &driver_desc, sizeof(driver_desc));
|
||||
output += driver_desc.base.length;
|
||||
break;
|
||||
}
|
||||
|
||||
case INTEL_DEBUG_BLOCK_TYPE_FRAME: {
|
||||
struct intel_debug_block_frame frame_desc = {
|
||||
.base = {
|
||||
.type = INTEL_DEBUG_BLOCK_TYPE_FRAME,
|
||||
.length = sizeof(frame_desc),
|
||||
},
|
||||
};
|
||||
memcpy(output, &frame_desc, sizeof(frame_desc));
|
||||
output += sizeof(frame_desc);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
unreachable("Missing identifier write");
|
||||
}
|
||||
|
||||
assert(output < output_end);
|
||||
}
|
||||
|
||||
struct intel_debug_block_base end = {
|
||||
.type = INTEL_DEBUG_BLOCK_TYPE_END,
|
||||
.length = sizeof(end),
|
||||
};
|
||||
memcpy(output, &end, sizeof(end));
|
||||
output += sizeof(end);
|
||||
|
||||
assert(output < output_end);
|
||||
|
||||
/* Add at least a full aligned uint64_t of zero padding at the end
|
||||
* to make the identifiers easier to spot.
|
||||
*/
|
||||
const unsigned unpadded_len = output - _output;
|
||||
const unsigned padding = align(unpadded_len + 8, 8) - unpadded_len;
|
||||
memset(output, 0, padding);
|
||||
output += padding;
|
||||
|
||||
assert(output < output_end);
|
||||
|
||||
/* Return the how many bytes where written, so that the rest of the buffer
|
||||
* can be used for other things.
|
||||
*/
|
||||
return output - _output;
|
||||
}
|
||||
|
||||
void *
|
||||
intel_debug_get_identifier_block(void *_buffer,
|
||||
uint32_t buffer_size,
|
||||
enum intel_debug_block_type type)
|
||||
{
|
||||
void *buffer = _buffer + intel_debug_identifier_size(),
|
||||
*end_buffer = _buffer + buffer_size;
|
||||
|
||||
while (buffer < end_buffer) {
|
||||
struct intel_debug_block_base *item = buffer;
|
||||
|
||||
if (item->type == type)
|
||||
return item;
|
||||
if (item->type == INTEL_DEBUG_BLOCK_TYPE_END)
|
||||
return NULL;
|
||||
|
||||
buffer += item->length;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if in valid frame range for batch dumping
|
||||
*/
|
||||
bool
|
||||
intel_debug_batch_in_range(uint64_t frame_id)
|
||||
{
|
||||
return frame_id >= intel_debug_batch_frame_start &&
|
||||
frame_id < intel_debug_batch_frame_stop;
|
||||
}
|
||||
62
src/intel/common/intel_debug_identifier.h
Normal file
62
src/intel/common/intel_debug_identifier.h
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/**
|
||||
* \file intel_debug_identifier.h
|
||||
*
|
||||
* Debug identifier to put into the driver debug buffers. Helps figure out
|
||||
* information about the driver that generated a hang.
|
||||
*/
|
||||
|
||||
/* Below is a list of structure located in the identifier buffer. The driver
|
||||
* can fill those in for debug purposes.
|
||||
*/
|
||||
|
||||
enum intel_debug_block_type {
|
||||
/* End of the debug blocks */
|
||||
INTEL_DEBUG_BLOCK_TYPE_END = 1,
|
||||
|
||||
/* Driver identifier (struct intel_debug_block_driver) */
|
||||
INTEL_DEBUG_BLOCK_TYPE_DRIVER,
|
||||
|
||||
/* Frame identifier (struct intel_debug_block_frame) */
|
||||
INTEL_DEBUG_BLOCK_TYPE_FRAME,
|
||||
|
||||
/* Internal, never to be written out */
|
||||
INTEL_DEBUG_BLOCK_TYPE_MAX,
|
||||
};
|
||||
|
||||
struct intel_debug_block_base {
|
||||
uint32_t type; /* enum intel_debug_block_type */
|
||||
uint32_t length; /* inclusive of this structure size */
|
||||
};
|
||||
|
||||
struct intel_debug_block_driver {
|
||||
struct intel_debug_block_base base;
|
||||
uint8_t description[];
|
||||
};
|
||||
|
||||
struct intel_debug_block_frame {
|
||||
struct intel_debug_block_base base;
|
||||
uint64_t frame_id;
|
||||
};
|
||||
|
||||
extern void *intel_debug_identifier(void);
|
||||
extern uint32_t intel_debug_identifier_size(void);
|
||||
|
||||
extern uint32_t intel_debug_write_identifiers(void *output,
|
||||
uint32_t output_size,
|
||||
const char *driver_name);
|
||||
|
||||
extern void *intel_debug_get_identifier_block(void *buffer,
|
||||
uint32_t buffer_size,
|
||||
enum intel_debug_block_type type);
|
||||
|
||||
bool intel_debug_batch_in_range(uint64_t frame_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
@ -36,6 +36,8 @@ files_libintel_common = files(
|
|||
'intel_bind_timeline.c',
|
||||
'intel_bind_timeline.h',
|
||||
'intel_buffer_alloc.h',
|
||||
'intel_debug_identifier.h',
|
||||
'intel_debug_identifier.c',
|
||||
'intel_engine.c',
|
||||
'intel_engine.h',
|
||||
'intel_gem.c',
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "dev/intel_debug.h"
|
||||
#include "git_sha1.h"
|
||||
#include "util/macros.h"
|
||||
#include "util/u_debug.h"
|
||||
#include "util/u_math.h"
|
||||
|
|
@ -186,8 +185,8 @@ intel_debug_flag_for_shader_stage(gl_shader_stage stage)
|
|||
DEBUG_MS_SIMD32 | \
|
||||
DEBUG_RT_SIMD32)
|
||||
|
||||
static uint64_t intel_debug_batch_frame_start = 0;
|
||||
static uint64_t intel_debug_batch_frame_stop = -1;
|
||||
uint64_t intel_debug_batch_frame_start = 0;
|
||||
uint64_t intel_debug_batch_frame_stop = -1;
|
||||
|
||||
uint32_t intel_debug_bkp_before_draw_count = 0;
|
||||
uint32_t intel_debug_bkp_after_draw_count = 0;
|
||||
|
|
@ -235,128 +234,3 @@ process_intel_debug_variable(void)
|
|||
call_once(&process_intel_debug_variable_flag,
|
||||
process_intel_debug_variable_once);
|
||||
}
|
||||
|
||||
static uint64_t debug_identifier[4] = {
|
||||
0xffeeddccbbaa9988,
|
||||
0x7766554433221100,
|
||||
0xffeeddccbbaa9988,
|
||||
0x7766554433221100,
|
||||
};
|
||||
|
||||
void *
|
||||
intel_debug_identifier(void)
|
||||
{
|
||||
return debug_identifier;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
intel_debug_identifier_size(void)
|
||||
{
|
||||
return sizeof(debug_identifier);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
intel_debug_write_identifiers(void *_output,
|
||||
uint32_t output_size,
|
||||
const char *driver_name)
|
||||
{
|
||||
void *output = _output, *output_end = _output + output_size;
|
||||
|
||||
assert(output_size > intel_debug_identifier_size());
|
||||
|
||||
memcpy(output, intel_debug_identifier(), intel_debug_identifier_size());
|
||||
output += intel_debug_identifier_size();
|
||||
|
||||
for (uint32_t id = INTEL_DEBUG_BLOCK_TYPE_DRIVER; id < INTEL_DEBUG_BLOCK_TYPE_MAX; id++) {
|
||||
switch (id) {
|
||||
case INTEL_DEBUG_BLOCK_TYPE_DRIVER: {
|
||||
struct intel_debug_block_driver driver_desc = {
|
||||
.base = {
|
||||
.type = id,
|
||||
},
|
||||
};
|
||||
int len = snprintf(output + sizeof(driver_desc),
|
||||
output_end - (output + sizeof(driver_desc)),
|
||||
"%s " PACKAGE_VERSION " build " MESA_GIT_SHA1,
|
||||
driver_name);
|
||||
driver_desc.base.length = sizeof(driver_desc) + len + 1;
|
||||
memcpy(output, &driver_desc, sizeof(driver_desc));
|
||||
output += driver_desc.base.length;
|
||||
break;
|
||||
}
|
||||
|
||||
case INTEL_DEBUG_BLOCK_TYPE_FRAME: {
|
||||
struct intel_debug_block_frame frame_desc = {
|
||||
.base = {
|
||||
.type = INTEL_DEBUG_BLOCK_TYPE_FRAME,
|
||||
.length = sizeof(frame_desc),
|
||||
},
|
||||
};
|
||||
memcpy(output, &frame_desc, sizeof(frame_desc));
|
||||
output += sizeof(frame_desc);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
unreachable("Missing identifier write");
|
||||
}
|
||||
|
||||
assert(output < output_end);
|
||||
}
|
||||
|
||||
struct intel_debug_block_base end = {
|
||||
.type = INTEL_DEBUG_BLOCK_TYPE_END,
|
||||
.length = sizeof(end),
|
||||
};
|
||||
memcpy(output, &end, sizeof(end));
|
||||
output += sizeof(end);
|
||||
|
||||
assert(output < output_end);
|
||||
|
||||
/* Add at least a full aligned uint64_t of zero padding at the end
|
||||
* to make the identifiers easier to spot.
|
||||
*/
|
||||
const unsigned unpadded_len = output - _output;
|
||||
const unsigned padding = ALIGN(unpadded_len + 8, 8) - unpadded_len;
|
||||
memset(output, 0, padding);
|
||||
output += padding;
|
||||
|
||||
assert(output < output_end);
|
||||
|
||||
/* Return the how many bytes where written, so that the rest of the buffer
|
||||
* can be used for other things.
|
||||
*/
|
||||
return output - _output;
|
||||
}
|
||||
|
||||
void *
|
||||
intel_debug_get_identifier_block(void *_buffer,
|
||||
uint32_t buffer_size,
|
||||
enum intel_debug_block_type type)
|
||||
{
|
||||
void *buffer = _buffer + intel_debug_identifier_size(),
|
||||
*end_buffer = _buffer + buffer_size;
|
||||
|
||||
while (buffer < end_buffer) {
|
||||
struct intel_debug_block_base *item = buffer;
|
||||
|
||||
if (item->type == type)
|
||||
return item;
|
||||
if (item->type == INTEL_DEBUG_BLOCK_TYPE_END)
|
||||
return NULL;
|
||||
|
||||
buffer += item->length;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if in valid frame range for batch dumping
|
||||
*/
|
||||
bool
|
||||
intel_debug_batch_in_range(uint64_t frame_id)
|
||||
{
|
||||
return frame_id >= intel_debug_batch_frame_start &&
|
||||
frame_id < intel_debug_batch_frame_stop;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,6 +110,8 @@ extern uint64_t intel_debug;
|
|||
extern uint64_t intel_simd;
|
||||
extern uint32_t intel_debug_bkp_before_draw_count;
|
||||
extern uint32_t intel_debug_bkp_after_draw_count;
|
||||
extern uint64_t intel_debug_batch_frame_start;
|
||||
extern uint64_t intel_debug_batch_frame_stop;
|
||||
|
||||
#define INTEL_SIMD(type, size) (!!(intel_simd & (DEBUG_ ## type ## _SIMD ## size)))
|
||||
|
||||
|
|
@ -163,52 +165,6 @@ extern uint64_t intel_debug_flag_for_shader_stage(gl_shader_stage stage);
|
|||
|
||||
extern void process_intel_debug_variable(void);
|
||||
|
||||
/* Below is a list of structure located in the identifier buffer. The driver
|
||||
* can fill those in for debug purposes.
|
||||
*/
|
||||
|
||||
enum intel_debug_block_type {
|
||||
/* End of the debug blocks */
|
||||
INTEL_DEBUG_BLOCK_TYPE_END = 1,
|
||||
|
||||
/* Driver identifier (struct intel_debug_block_driver) */
|
||||
INTEL_DEBUG_BLOCK_TYPE_DRIVER,
|
||||
|
||||
/* Frame identifier (struct intel_debug_block_frame) */
|
||||
INTEL_DEBUG_BLOCK_TYPE_FRAME,
|
||||
|
||||
/* Internal, never to be written out */
|
||||
INTEL_DEBUG_BLOCK_TYPE_MAX,
|
||||
};
|
||||
|
||||
struct intel_debug_block_base {
|
||||
uint32_t type; /* enum intel_debug_block_type */
|
||||
uint32_t length; /* inclusive of this structure size */
|
||||
};
|
||||
|
||||
struct intel_debug_block_driver {
|
||||
struct intel_debug_block_base base;
|
||||
uint8_t description[];
|
||||
};
|
||||
|
||||
struct intel_debug_block_frame {
|
||||
struct intel_debug_block_base base;
|
||||
uint64_t frame_id;
|
||||
};
|
||||
|
||||
extern void *intel_debug_identifier(void);
|
||||
extern uint32_t intel_debug_identifier_size(void);
|
||||
|
||||
extern uint32_t intel_debug_write_identifiers(void *output,
|
||||
uint32_t output_size,
|
||||
const char *driver_name);
|
||||
|
||||
extern void *intel_debug_get_identifier_block(void *buffer,
|
||||
uint32_t buffer_size,
|
||||
enum intel_debug_block_type type);
|
||||
|
||||
bool intel_debug_batch_in_range(uint64_t frame_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
|
||||
#include "aubinator_error_decode_lib.h"
|
||||
#include "aubinator_error_decode_xe.h"
|
||||
#include "common/intel_debug_identifier.h"
|
||||
#include "compiler/brw_compiler.h"
|
||||
#include "compiler/elk/elk_compiler.h"
|
||||
#include "decoder/intel_decoder.h"
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@
|
|||
#include "c11/threads.h"
|
||||
#include "dev/intel_debug.h"
|
||||
#include "dev/intel_device_info.h"
|
||||
#include "common/intel_debug_identifier.h"
|
||||
#include "common/intel_gem.h"
|
||||
#include "util/macros.h"
|
||||
#include "util/u_math.h"
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@
|
|||
#include "anv_private.h"
|
||||
#include "anv_measure.h"
|
||||
|
||||
#include "common/intel_debug_identifier.h"
|
||||
|
||||
#include "genxml/gen9_pack.h"
|
||||
#include "genxml/genX_bits.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@
|
|||
#include "vk_deferred_operation.h"
|
||||
#include "vk_drm_syncobj.h"
|
||||
#include "common/intel_aux_map.h"
|
||||
#include "common/intel_debug_identifier.h"
|
||||
#include "common/intel_uuid.h"
|
||||
#include "perf/intel_perf.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include "anv_private.h"
|
||||
#include "anv_internal_kernels.h"
|
||||
|
||||
#include "common/intel_debug_identifier.h"
|
||||
#include "ds/intel_tracepoints.h"
|
||||
#include "genxml/gen9_pack.h"
|
||||
#include "perf/intel_perf.h"
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@
|
|||
#include "vk_semaphore.h"
|
||||
#include "vk_util.h"
|
||||
|
||||
#include "common/intel_debug_identifier.h"
|
||||
|
||||
static PFN_vkVoidFunction
|
||||
anv_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char *pName)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@
|
|||
#include "anv_private.h"
|
||||
#include "anv_measure.h"
|
||||
|
||||
#include "common/intel_debug_identifier.h"
|
||||
|
||||
#include "genxml/gen8_pack.h"
|
||||
#include "genxml/genX_bits.h"
|
||||
#include "perf/intel_perf.h"
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@
|
|||
#include "vk_deferred_operation.h"
|
||||
#include "vk_drm_syncobj.h"
|
||||
#include "common/i915/intel_defines.h"
|
||||
#include "common/intel_debug_identifier.h"
|
||||
#include "common/intel_uuid.h"
|
||||
#include "perf/intel_perf.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@
|
|||
#include "vk_semaphore.h"
|
||||
#include "vk_util.h"
|
||||
|
||||
#include "common/intel_debug_identifier.h"
|
||||
|
||||
static PFN_vkVoidFunction
|
||||
anv_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char *pName)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue