[PATCH umr] Add trap temp SGPRs to the read_gpr call
Tom St Denis
tom.stdenis at amd.com
Mon Apr 9 11:24:26 UTC 2018
If trap_en and priv are set in the SQ_WAVE_STATUS
then read 12 or 16 words from 0x6C (SQ_WAVE_TTMP0...)
and display inline with rest of SGPRs.
Signed-off-by: Tom St Denis <tom.stdenis at amd.com>
---
src/app/print_waves.c | 33 ++++++++++++++++++++++++++++++---
src/lib/read_gpr.c | 16 +++++++++++++++-
src/lib/wave_status.c | 1 +
src/umr.h | 1 +
4 files changed, 47 insertions(+), 4 deletions(-)
diff --git a/src/app/print_waves.c b/src/app/print_waves.c
index e4e6b87566fb..851b08b3d3d4 100644
--- a/src/app/print_waves.c
+++ b/src/app/print_waves.c
@@ -35,7 +35,7 @@
void umr_print_waves(struct umr_asic *asic)
{
- uint32_t x, se, sh, cu, simd, wave, sgprs[1024], shift, opcodes[8];
+ uint32_t x, y, se, sh, cu, simd, wave, sgprs[1024], shift, opcodes[8];
uint32_t vgprs[64 * 256];
uint32_t thread;
uint64_t pgm_addr;
@@ -93,7 +93,7 @@ void umr_print_waves(struct umr_asic *asic)
(unsigned long)ws.hw_id.value, (unsigned long)ws.gpr_alloc.value, (unsigned long)ws.lds_alloc.value, (unsigned long)ws.trapsts.value, (unsigned long)ws.ib_sts.value,
(unsigned long)ws.tba_hi, (unsigned long)ws.tba_lo, (unsigned long)ws.tma_hi, (unsigned long)ws.tma_lo, (unsigned long)ws.ib_dbg0, (unsigned long)ws.m0
);
- if (ws.wave_status.halt)
+ if (ws.wave_status.halt) {
for (x = 0; x < ((ws.gpr_alloc.sgpr_size + 1) << shift); x += 4)
printf(">SGPRS[%u..%u] = { %08lx, %08lx, %08lx, %08lx }\n",
(unsigned)(x),
@@ -102,6 +102,19 @@ void umr_print_waves(struct umr_asic *asic)
(unsigned long)sgprs[x+1],
(unsigned long)sgprs[x+2],
(unsigned long)sgprs[x+3]);
+ if (ws.wave_status.trap_en && ws.wave_status.priv) {
+ y = asic->family <= FAMILY_VI ? 12 : 16;
+ for (x = 0x6C; x < (y + 0x6C); x += 4) {
+ printf(">SGPRS[%u..%u] = { %08lx, %08lx, %08lx, %08lx }\n",
+ (unsigned)(x),
+ (unsigned)(x + 3),
+ (unsigned long)sgprs[x],
+ (unsigned long)sgprs[x+1],
+ (unsigned long)sgprs[x+2],
+ (unsigned long)sgprs[x+3]);
+ }
+ }
+ }
pgm_addr = (((uint64_t)ws.pc_hi << 32) | ws.pc_lo) - (sizeof(opcodes)/2);
umr_read_vram(asic, ws.hw_id.vm_id, pgm_addr, sizeof(opcodes), opcodes);
@@ -139,11 +152,12 @@ void umr_print_waves(struct umr_asic *asic)
PP(wave_status, valid);
PP(wave_status, spi_prio);
PP(wave_status, wave_prio);
+ PP(wave_status, priv);
PP(wave_status, trap_en);
+ PP(wave_status, trap);
PP(wave_status, ttrace_en);
PP(wave_status, export_rdy);
PP(wave_status, in_barrier);
- PP(wave_status, trap);
PP(wave_status, ecc_err);
PP(wave_status, skip_export);
PP(wave_status, perf_en);
@@ -183,6 +197,19 @@ void umr_print_waves(struct umr_asic *asic)
(unsigned long)sgprs[x+1],
(unsigned long)sgprs[x+2],
(unsigned long)sgprs[x+3]);
+
+ if (ws.wave_status.trap_en && ws.wave_status.priv) {
+ y = asic->family <= FAMILY_VI ? 12 : 16;
+ for (x = 0x6C; x < (y + 0x6C); x += 4) {
+ printf("\t[%4u..%4u] = { %08lx, %08lx, %08lx, %08lx }\n",
+ (unsigned)(x),
+ (unsigned)(x + 3),
+ (unsigned long)sgprs[x],
+ (unsigned long)sgprs[x+1],
+ (unsigned long)sgprs[x+2],
+ (unsigned long)sgprs[x+3]);
+ }
+ }
}
diff --git a/src/lib/read_gpr.c b/src/lib/read_gpr.c
index 4d9cdd72b04c..7384f92beda5 100644
--- a/src/lib/read_gpr.c
+++ b/src/lib/read_gpr.c
@@ -54,6 +54,7 @@ static void wave_read_regs_via_mmio(struct umr_asic *asic, uint32_t simd,
int umr_read_sgprs(struct umr_asic *asic, struct umr_wave_status *ws, uint32_t *dst)
{
uint64_t addr, shift;
+ int r;
if (asic->family <= FAMILY_CIK)
shift = 3; // on SI..CIK allocations were done in 8-dword blocks
@@ -72,11 +73,24 @@ int umr_read_sgprs(struct umr_asic *asic, struct umr_wave_status *ws, uint32_t *
(0ULL << 52); // thread_id
lseek(asic->fd.gpr, addr, SEEK_SET);
- return read(asic->fd.gpr, dst, 4 * ((ws->gpr_alloc.sgpr_size + 1) << shift));
+ r = read(asic->fd.gpr, dst, 4 * ((ws->gpr_alloc.sgpr_size + 1) << shift));
+ if (r < 0)
+ return r;
+
+ // read trap if any
+ if (ws->wave_status.trap_en && ws->wave_status.priv) {
+ addr += 0x6C;
+ lseek(asic->fd.gpr, addr, SEEK_SET);
+ r = read(asic->fd.gpr, &dst[0x6C], 4 * (asic->family <= FAMILY_VI ? 12 : 16));
+ }
+ return r;
} else {
umr_grbm_select_index(asic, ws->hw_id.se_id, ws->hw_id.sh_id, ws->hw_id.cu_id);
wave_read_regs_via_mmio(asic, ws->hw_id.simd_id, ws->hw_id.wave_id, 0, 0x200,
(ws->gpr_alloc.sgpr_size + 1) << shift, dst);
+ if (ws->wave_status.trap_en && ws->wave_status.priv)
+ wave_read_regs_via_mmio(asic, ws->hw_id.simd_id, ws->hw_id.wave_id, 0, 0x26C,
+ asic->family <= FAMILY_VI ? 12 : 16, &dst[0x6C]);
umr_grbm_select_index(asic, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
return 0;
}
diff --git a/src/lib/wave_status.c b/src/lib/wave_status.c
index 3f4d33b66c4a..667fa8d6a9d0 100644
--- a/src/lib/wave_status.c
+++ b/src/lib/wave_status.c
@@ -129,6 +129,7 @@ static int umr_get_wave_status_vi(struct umr_asic *asic, unsigned se, unsigned s
x = 1;
ws->wave_status.value = value = buf[x++];
ws->wave_status.scc = (value & 1);
+ ws->wave_status.priv = (value >> 5) & 1;
ws->wave_status.execz = (value >> 9) & 1;
ws->wave_status.vccz = (value >> 10) & 1;
ws->wave_status.in_tg = (value >> 11) & 1;
diff --git a/src/umr.h b/src/umr.h
index 7a214bfb565e..309b5e33b9a1 100644
--- a/src/umr.h
+++ b/src/umr.h
@@ -271,6 +271,7 @@ struct umr_wave_status {
struct {
uint32_t
value,
+ priv,
scc,
execz,
vccz,
--
2.14.3
More information about the amd-gfx
mailing list