2016-12-24 13:08:00 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright 2015 Advanced Micro Devices, Inc.
|
|
|
|
|
*
|
2023-05-18 17:22:27 -04:00
|
|
|
* SPDX-License-Identifier: MIT
|
2016-12-24 13:08:00 +01:00
|
|
|
*/
|
2017-10-31 18:45:18 +01:00
|
|
|
|
2016-12-24 13:08:00 +01:00
|
|
|
#ifndef AC_DEBUG_H
|
|
|
|
|
#define AC_DEBUG_H
|
|
|
|
|
|
2020-09-07 09:58:36 +02:00
|
|
|
#include "amd_family.h"
|
2023-08-09 11:53:04 +02:00
|
|
|
#include "ac_gpu_info.h"
|
2020-09-07 09:58:36 +02:00
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
2016-12-24 13:08:00 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
2020-09-07 09:58:36 +02:00
|
|
|
#define AC_ENCODE_TRACE_POINT(id) (0xcafe0000 | ((id)&0xffff))
|
|
|
|
|
#define AC_IS_TRACE_POINT(x) (((x)&0xcafe0000) == 0xcafe0000)
|
|
|
|
|
#define AC_GET_TRACE_POINT_ID(x) ((x)&0xffff)
|
2016-12-24 13:08:00 +01:00
|
|
|
|
2017-09-07 11:05:29 +02:00
|
|
|
#define AC_MAX_WAVES_PER_CHIP (64 * 40)
|
|
|
|
|
|
2019-09-27 09:26:14 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-11-24 04:14:34 -05:00
|
|
|
struct si_reg;
|
|
|
|
|
|
2017-09-07 11:05:29 +02:00
|
|
|
struct ac_wave_info {
|
2020-09-07 09:58:36 +02:00
|
|
|
unsigned se; /* shader engine */
|
|
|
|
|
unsigned sh; /* shader array */
|
|
|
|
|
unsigned cu; /* compute unit */
|
|
|
|
|
unsigned simd;
|
|
|
|
|
unsigned wave;
|
|
|
|
|
uint32_t status;
|
2024-04-15 10:51:38 +02:00
|
|
|
union {
|
|
|
|
|
uint64_t pc; /* program counter */
|
|
|
|
|
struct {
|
|
|
|
|
uint32_t pc_lo;
|
|
|
|
|
uint32_t pc_hi;
|
|
|
|
|
};
|
|
|
|
|
};
|
2020-09-07 09:58:36 +02:00
|
|
|
uint32_t inst_dw0;
|
|
|
|
|
uint32_t inst_dw1;
|
2024-04-15 10:51:38 +02:00
|
|
|
union {
|
|
|
|
|
uint64_t exec;
|
|
|
|
|
struct {
|
|
|
|
|
uint32_t exec_lo;
|
|
|
|
|
uint32_t exec_hi;
|
|
|
|
|
};
|
|
|
|
|
};
|
2020-09-07 09:58:36 +02:00
|
|
|
bool matched; /* whether the wave is used by a currently-bound shader */
|
2017-09-07 11:05:29 +02:00
|
|
|
};
|
|
|
|
|
|
2024-01-27 17:35:31 +01:00
|
|
|
struct ac_addr_info {
|
|
|
|
|
void *cpu_addr;
|
|
|
|
|
bool valid;
|
|
|
|
|
bool use_after_free;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef void (*ac_debug_addr_callback)(void *data, uint64_t addr, struct ac_addr_info *info);
|
2017-01-01 16:47:12 +01:00
|
|
|
|
2023-11-24 04:14:34 -05:00
|
|
|
/* ac_debug.c */
|
|
|
|
|
const struct si_reg *ac_find_register(enum amd_gfx_level gfx_level, enum radeon_family family,
|
|
|
|
|
unsigned offset);
|
2022-10-21 15:30:53 -04:00
|
|
|
const char *ac_get_register_name(enum amd_gfx_level gfx_level, enum radeon_family family,
|
|
|
|
|
unsigned offset);
|
2023-06-10 20:45:57 -04:00
|
|
|
bool ac_register_exists(enum amd_gfx_level gfx_level, enum radeon_family family,
|
|
|
|
|
unsigned offset);
|
2023-11-24 04:14:34 -05:00
|
|
|
bool ac_vm_fault_occurred(enum amd_gfx_level gfx_level, uint64_t *old_dmesg_timestamp,
|
|
|
|
|
uint64_t *out_addr);
|
2024-04-20 11:09:41 +02:00
|
|
|
char *ac_get_umr_waves(const struct radeon_info *info, enum amd_ip_type ring);
|
2023-11-24 04:14:34 -05:00
|
|
|
unsigned ac_get_wave_info(enum amd_gfx_level gfx_level, const struct radeon_info *info,
|
2024-04-20 11:09:41 +02:00
|
|
|
const char *wave_dump,
|
2023-11-24 04:14:34 -05:00
|
|
|
struct ac_wave_info waves[AC_MAX_WAVES_PER_CHIP]);
|
|
|
|
|
void ac_print_gpuvm_fault_status(FILE *output, enum amd_gfx_level gfx_level,
|
|
|
|
|
uint32_t status);
|
|
|
|
|
|
2023-11-24 04:52:18 -05:00
|
|
|
/* ac_gather_context_rolls.c */
|
2024-02-16 18:00:06 +01:00
|
|
|
struct hash_table;
|
2023-11-24 04:52:18 -05:00
|
|
|
void ac_gather_context_rolls(FILE *f, uint32_t **ibs, uint32_t *ib_dw_sizes, unsigned num_ibs,
|
2024-02-16 18:00:06 +01:00
|
|
|
struct hash_table *annotations, const struct radeon_info *info);
|
2023-11-24 04:52:18 -05:00
|
|
|
|
2023-11-24 04:14:34 -05:00
|
|
|
/* ac_parse_ib.c */
|
2024-02-04 14:38:32 +01:00
|
|
|
|
|
|
|
|
struct ac_ib_parser {
|
|
|
|
|
/* Arguments to ac_parse_ib.* */
|
|
|
|
|
FILE *f;
|
|
|
|
|
uint32_t *ib;
|
|
|
|
|
unsigned num_dw;
|
|
|
|
|
const int *trace_ids;
|
|
|
|
|
unsigned trace_id_count;
|
|
|
|
|
enum amd_gfx_level gfx_level;
|
2024-09-19 15:28:18 +02:00
|
|
|
enum vcn_version vcn_version;
|
2024-02-04 14:38:32 +01:00
|
|
|
enum radeon_family family;
|
|
|
|
|
enum amd_ip_type ip_type;
|
|
|
|
|
ac_debug_addr_callback addr_callback;
|
|
|
|
|
void *addr_callback_data;
|
2024-02-04 18:07:08 +01:00
|
|
|
struct hash_table *annotations;
|
2024-02-04 14:38:32 +01:00
|
|
|
|
|
|
|
|
/* Internal */
|
|
|
|
|
unsigned cur_dw;
|
|
|
|
|
};
|
|
|
|
|
|
2022-10-21 15:30:53 -04:00
|
|
|
void ac_dump_reg(FILE *file, enum amd_gfx_level gfx_level, enum radeon_family family,
|
|
|
|
|
unsigned offset, uint32_t value, uint32_t field_mask);
|
2024-02-04 14:38:32 +01:00
|
|
|
void ac_parse_ib_chunk(struct ac_ib_parser *ib);
|
|
|
|
|
void ac_parse_ib(struct ac_ib_parser *ib, const char *name);
|
2016-12-24 13:08:00 +01:00
|
|
|
|
2019-09-27 09:26:14 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-12-24 13:08:00 +01:00
|
|
|
#endif
|