Module: Mesa Branch: main Commit: e18c4bca31fd4af25bb32b2f772b069d3027c8e3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e18c4bca31fd4af25bb32b2f772b069d3027c8e3
Author: Samuel Pitoiset <samuel.pitoi...@gmail.com> Date: Mon Oct 23 19:03:57 2023 +0200 ac/debug: add a helper to print GPUVM fault protection status This basically prints the same info as dmesg. Signed-off-by: Samuel Pitoiset <samuel.pitoi...@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25855> --- src/amd/common/ac_debug.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++ src/amd/common/ac_debug.h | 3 +++ 2 files changed, 51 insertions(+) diff --git a/src/amd/common/ac_debug.c b/src/amd/common/ac_debug.c index ea3eba568b2..85cdf1c9bf4 100644 --- a/src/amd/common/ac_debug.c +++ b/src/amd/common/ac_debug.c @@ -1180,3 +1180,51 @@ unsigned ac_get_wave_info(enum amd_gfx_level gfx_level, return num_waves; #endif } + +/* List of GFXHUB clients from AMDGPU source code. */ +static const char *const gfx10_gfxhub_client_ids[] = { + "CB/DB", + "Reserved", + "GE1", + "GE2", + "CPF", + "CPC", + "CPG", + "RLC", + "TCP", + "SQC (inst)", + "SQC (data)", + "SQG", + "Reserved", + "SDMA0", + "SDMA1", + "GCR", + "SDMA2", + "SDMA3", +}; + +static const char * +ac_get_gfx10_gfxhub_client(unsigned cid) +{ + if (cid >= ARRAY_SIZE(gfx10_gfxhub_client_ids)) + return "UNKNOWN"; + return gfx10_gfxhub_client_ids[cid]; +} + +void ac_print_gpuvm_fault_status(FILE *output, enum amd_gfx_level gfx_level, + uint32_t status) +{ + if (gfx_level >= GFX10) { + const uint8_t cid = G_00A130_CID(status); + + fprintf(output, "GCVM_L2_PROTECTION_FAULT_STATUS: 0x%x\n", status); + fprintf(output, "\t CLIENT_ID: (%s) 0x%x\n", ac_get_gfx10_gfxhub_client(cid), cid); + fprintf(output, "\t MORE_FAULTS: %d\n", G_00A130_MORE_FAULTS(status)); + fprintf(output, "\t WALKER_ERROR: %d\n", G_00A130_WALKER_ERROR(status)); + fprintf(output, "\t PERMISSION_FAULTS: %d\n", G_00A130_PERMISSION_FAULTS(status)); + fprintf(output, "\t MAPPING_ERROR: %d\n", G_00A130_MAPPING_ERROR(status)); + fprintf(output, "\t RW: %d\n", G_00A130_RW(status)); + } else { + fprintf(output, "VM_CONTEXT1_PROTECTION_FAULT_STATUS: 0x%x\n", status); + } +} diff --git a/src/amd/common/ac_debug.h b/src/amd/common/ac_debug.h index 411096a76e7..71ee58eea40 100644 --- a/src/amd/common/ac_debug.h +++ b/src/amd/common/ac_debug.h @@ -59,6 +59,9 @@ bool ac_vm_fault_occurred(enum amd_gfx_level gfx_level, uint64_t *old_dmesg_time unsigned ac_get_wave_info(enum amd_gfx_level gfx_level, 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); + #ifdef __cplusplus } #endif