AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH umr 0/4] gfx9: read VGPRs of halted waves
@ 2017-09-09 10:55 Nicolai Hähnle
       [not found] ` <20170909105530.10913-1-nhaehnle-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Nicolai Hähnle @ 2017-09-09 10:55 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Hi all,

it seems that reading wave VGPRs actually works now with gfx9, at least
for halted waves, and that can be pretty powerful for debugging.

Due to the volume of data it prints out, it's only enabled with -O bits.

In order for it to work properly, you'll also need the kernel patch
I just sent out (drm/amdgpu/gfx9: implement wave VGPR reading).

Please review!

Thanks,
Nicolai

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH umr 1/4] Fix wave SGPR reading
       [not found] ` <20170909105530.10913-1-nhaehnle-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2017-09-09 10:55   ` Nicolai Hähnle
       [not found]     ` <20170909105530.10913-2-nhaehnle-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2017-09-09 10:55   ` [PATCH umr 2/4] Rename lib/read_sgpr.c to lib/read_gpr.c Nicolai Hähnle
                     ` (3 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Nicolai Hähnle @ 2017-09-09 10:55 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Nicolai Hähnle

From: Nicolai Hähnle <nicolai.haehnle@amd.com>

The hardware adds the alloc base already, no need to do it in the tool.

Signed-off-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
---
 src/app/print_waves.c | 8 ++++----
 src/lib/read_sgpr.c   | 5 +++--
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/app/print_waves.c b/src/app/print_waves.c
index 1efd8a1..a9aaf39 100644
--- a/src/app/print_waves.c
+++ b/src/app/print_waves.c
@@ -75,22 +75,22 @@ void umr_print_waves(struct umr_asic *asic)
 "\n",
 (unsigned)se, (unsigned)sh, (unsigned)cu, (unsigned)ws.hw_id.simd_id, (unsigned)ws.hw_id.wave_id,
 (unsigned long)ws.wave_status.value, (unsigned long)ws.pc_hi, (unsigned long)ws.pc_lo,
 (unsigned long)ws.wave_inst_dw0, (unsigned long)ws.wave_inst_dw1, (unsigned long)ws.exec_hi, (unsigned long)ws.exec_lo,
 (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)
 							for (x = 0; x < ((ws.gpr_alloc.sgpr_size + 1) << shift); x += 4)
 								printf(">SGPRS[%u..%u] = { %08lx, %08lx, %08lx, %08lx }\n",
-									(unsigned)((ws.gpr_alloc.sgpr_base << shift) + x),
-									(unsigned)((ws.gpr_alloc.sgpr_base << shift) + x + 3),
+									(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);
 						for (x = 0; x < sizeof(opcodes)/4; x++) {
 							printf(">pgm[%lu@%llx] = %08lx\n",
 								(unsigned long)ws.hw_id.vm_id,
@@ -156,22 +156,22 @@ void umr_print_waves(struct umr_asic *asic)
 						Hv("GPR_ALLOC", ws.gpr_alloc.value);
 						PP(gpr_alloc, vgpr_base);
 						PP(gpr_alloc, vgpr_size);
 						PP(gpr_alloc, sgpr_base);
 						PP(gpr_alloc, sgpr_size);
 
 						if (ws.wave_status.halt) {
 							printf("\n\nSGPRS:\n");
 							for (x = 0; x < ((ws.gpr_alloc.sgpr_size + 1) << shift); x += 4)
 								printf("\t[%4u..%4u] = { %08lx, %08lx, %08lx, %08lx }\n",
-									(unsigned)((ws.gpr_alloc.sgpr_base << shift) + x),
-									(unsigned)((ws.gpr_alloc.sgpr_base << shift) + x + 3),
+									(unsigned)(x),
+									(unsigned)(x + 3),
 									(unsigned long)sgprs[x],
 									(unsigned long)sgprs[x+1],
 									(unsigned long)sgprs[x+2],
 									(unsigned long)sgprs[x+3]);
 						}
 
 						printf("\n\nPGM_MEM:\n");
 						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);
 						for (x = 0; x < sizeof(opcodes)/4; x++) {
diff --git a/src/lib/read_sgpr.c b/src/lib/read_sgpr.c
index cceb189..427cfc5 100644
--- a/src/lib/read_sgpr.c
+++ b/src/lib/read_sgpr.c
@@ -56,27 +56,28 @@ int umr_read_sgprs(struct umr_asic *asic, struct umr_wave_status *ws, uint32_t *
 	uint64_t addr, shift;
 
 	if (asic->family <= FAMILY_CIK)
 		shift = 3;  // on SI..CIK allocations were done in 8-dword blocks
 	else
 		shift = 4;  // on VI allocations are in 16-dword blocks
 
 	if (!asic->options.no_kernel) {
 		addr =
 			(1ULL << 60)                             | // reading SGPRs
-			((uint64_t)ws->gpr_alloc.sgpr_base << shift) | // starting address to read from
+			((uint64_t)0)                            | // starting address to read from
 			((uint64_t)ws->hw_id.se_id << 12)        |
 			((uint64_t)ws->hw_id.sh_id << 20)        |
 			((uint64_t)ws->hw_id.cu_id << 28)        |
 			((uint64_t)ws->hw_id.wave_id << 36)      |
 			((uint64_t)ws->hw_id.simd_id << 44)      |
 			(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));
 	} 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, ws->gpr_alloc.sgpr_base << shift, 0, (ws->gpr_alloc.sgpr_size + 1) << shift, dst);
+		wave_read_regs_via_mmio(asic, ws->hw_id.simd_id, ws->hw_id.wave_id, 0, 0,
+					(ws->gpr_alloc.sgpr_size + 1) << shift, dst);
 		umr_grbm_select_index(asic, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
 		return 0;
 	}
 }
-- 
2.11.0

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH umr 2/4] Rename lib/read_sgpr.c to lib/read_gpr.c
       [not found] ` <20170909105530.10913-1-nhaehnle-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2017-09-09 10:55   ` [PATCH umr 1/4] Fix wave SGPR reading Nicolai Hähnle
@ 2017-09-09 10:55   ` Nicolai Hähnle
  2017-09-09 10:55   ` [PATCH umr 3/4] Read VGPRs of halted waves on gfx9 Nicolai Hähnle
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Nicolai Hähnle @ 2017-09-09 10:55 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Nicolai Hähnle

From: Nicolai Hähnle <nicolai.haehnle@amd.com>

We will implement VGPR reading, hence this is a better name.

Signed-off-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
---
 src/lib/CMakeLists.txt              | 2 +-
 src/lib/{read_sgpr.c => read_gpr.c} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename src/lib/{read_sgpr.c => read_gpr.c} (100%)

diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt
index 0675b99..78d827a 100644
--- a/src/lib/CMakeLists.txt
+++ b/src/lib/CMakeLists.txt
@@ -11,21 +11,21 @@ add_library(umrcore STATIC
   create_mmio_accel.c
   discover_by_did.c
   discover_by_name.c
   discover.c
   dump_ib.c
   find_reg.c
   free_maps.c
   mmio.c
   query_drm.c
   read_sensor.c
-  read_sgpr.c
+  read_gpr.c
   read_vram.c
   ring_decode.c
   scan_config.c
   sq_cmd_halt_waves.c
   transfer_soc15.c
   wave_status.c
   update.c
   $<TARGET_OBJECTS:asic> $<TARGET_OBJECTS:ip>
 )
 
diff --git a/src/lib/read_sgpr.c b/src/lib/read_gpr.c
similarity index 100%
rename from src/lib/read_sgpr.c
rename to src/lib/read_gpr.c
-- 
2.11.0

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH umr 3/4] Read VGPRs of halted waves on gfx9
       [not found] ` <20170909105530.10913-1-nhaehnle-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2017-09-09 10:55   ` [PATCH umr 1/4] Fix wave SGPR reading Nicolai Hähnle
  2017-09-09 10:55   ` [PATCH umr 2/4] Rename lib/read_sgpr.c to lib/read_gpr.c Nicolai Hähnle
@ 2017-09-09 10:55   ` Nicolai Hähnle
  2017-09-09 10:55   ` [PATCH umr 4/4] Fix the no-kernel case of wave SGPR reading Nicolai Hähnle
  2017-09-09 12:23   ` [PATCH umr 0/4] gfx9: read VGPRs of halted waves Tom St Denis
  4 siblings, 0 replies; 8+ messages in thread
From: Nicolai Hähnle @ 2017-09-09 10:55 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Nicolai Hähnle

From: Nicolai Hähnle <nicolai.haehnle@amd.com>

Signed-off-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
---
 src/app/print_waves.c | 40 +++++++++++++++++++++++++++++++++++++++-
 src/lib/read_gpr.c    | 30 ++++++++++++++++++++++++++++++
 src/umr.h             |  1 +
 3 files changed, 70 insertions(+), 1 deletion(-)

diff --git a/src/app/print_waves.c b/src/app/print_waves.c
index a9aaf39..a72d224 100644
--- a/src/app/print_waves.c
+++ b/src/app/print_waves.c
@@ -29,20 +29,22 @@
 
 #define P(x) if (col++ == 4) { col = 1; printf("\n\t"); } printf("%20s: %8u | ", #x, (unsigned)ws.x); 
 #define X(x) if (col++ == 4) { col = 1; printf("\n\t"); } printf("%20s: %08lx | ", #x, (unsigned long)ws.x);
 
 #define H(x) if (col) { printf("\n"); }; col = 0; printf("\n\n%s:\n\t", x);
 #define Hv(x, y) if (col) { printf("\n"); }; col = 0; printf("\n\n%s[%08lx]:\n\t", x, (unsigned long)y);
 
 void umr_print_waves(struct umr_asic *asic)
 {
 	uint32_t x, se, sh, cu, simd, wave, sgprs[1024], shift, opcodes[8];
+	uint32_t vgprs[64 * 256];
+	uint32_t thread;
 	uint64_t pgm_addr;
 	struct umr_wave_status ws;
 	int first = 1, col = 0;
 
 	if (asic->options.halt_waves)
 		umr_sq_cmd_halt_waves(asic, UMR_SQ_CMD_HALT);
 
 	if (asic->family <= FAMILY_CIK)
 		shift = 3;  // on SI..CIK allocations were done in 8-dword blocks
 	else
@@ -50,24 +52,36 @@ void umr_print_waves(struct umr_asic *asic)
 
 	for (se = 0; se < asic->config.gfx.max_shader_engines; se++)
 	for (sh = 0; sh < asic->config.gfx.max_sh_per_se; sh++)
 	for (cu = 0; cu < asic->config.gfx.max_cu_per_sh; cu++) {
 		umr_get_wave_sq_info(asic, se, sh, cu, &ws);
 		if (ws.sq_info.busy) {
 			for (simd = 0; simd < 4; simd++)
 			for (wave = 0; wave < 10; wave++) { //both simd/wave are hard coded at the moment...
 				umr_get_wave_status(asic, se, sh, cu, simd, wave, &ws);
 				if (ws.wave_status.halt || ws.wave_status.valid) {
+					unsigned have_vgprs = 0;
+
 					// grab sgprs..
-					if (ws.wave_status.halt)
+					if (ws.wave_status.halt) {
 						umr_read_sgprs(asic, &ws, &sgprs[0]);
 
+						if (options.bitfields) {
+							have_vgprs = 1;
+							for (thread = 0; thread < 64; ++thread) {
+								if (umr_read_vgprs(asic, &ws, thread,
+										   &vgprs[256 * thread]) < 0)
+									have_vgprs = 0;
+							}
+						}
+					}
+
 					if (!options.bitfields && first) {
 						first = 0;
 						printf("SE SH CU SIMD WAVE# WAVE_STATUS PC_HI PC_LO INST_DW0 INST_DW1 EXEC_HI EXEC_LO HW_ID GPRALLOC LDSALLOC TRAPSTS IBSTS TBA_HI TBA_LO TMA_HI TMA_LO IB_DBG0 M0\n");
 					}
 					if (!options.bitfields) {
 					printf(
 "%u %u %u %u %u " // se/sh/cu/simd/wave
 "%08lx %08lx %08lx " // wave_status pc/hi/lo
 "%08lx %08lx %08lx %08lx " // inst0/1 exec hi/lo
 "%08lx %08lx %08lx %08lx %08lx " // HW_ID GPR/LDSALLOC TRAP/IB STS
@@ -164,20 +178,44 @@ void umr_print_waves(struct umr_asic *asic)
 							for (x = 0; x < ((ws.gpr_alloc.sgpr_size + 1) << shift); 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]);
 						}
 
+
+						if (have_vgprs) {
+							printf("\n");
+							for (x = 0; x < ((ws.gpr_alloc.vgpr_size + 1) << 2); ++x) {
+								if (x % 16 == 0) {
+									if (x == 0)
+										printf("VGPRS:       ");
+									else
+										printf("             ");
+									for (thread = 0; thread < 64; ++thread) {
+										unsigned live = thread < 32 ? (ws.exec_lo & (1u << thread))
+													    : (ws.exec_hi & (1u << (thread - 32)));
+										printf(live ? " t%02u     " : " (t%02u)   ", thread);
+									}
+									printf("\n");
+								}
+
+								printf("    [%3u] = {", x);
+								for (thread = 0; thread < 64; ++thread)
+									printf(" %08x", vgprs[thread * 256 + x]);
+								printf(" }\n");
+							}
+						}
+
 						printf("\n\nPGM_MEM:\n");
 						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);
 						for (x = 0; x < sizeof(opcodes)/4; x++) {
 							if (x == (sizeof(opcodes)/8))
 								printf("*\t");
 							else
 								printf("\t");
 							printf("pgm[%lu@%llx] = %08lx\n",
 								(unsigned long)ws.hw_id.vm_id,
diff --git a/src/lib/read_gpr.c b/src/lib/read_gpr.c
index 427cfc5..669a49b 100644
--- a/src/lib/read_gpr.c
+++ b/src/lib/read_gpr.c
@@ -74,10 +74,40 @@ int umr_read_sgprs(struct umr_asic *asic, struct umr_wave_status *ws, uint32_t *
 		lseek(asic->fd.gpr, addr, SEEK_SET);
 		return read(asic->fd.gpr, dst, 4 * ((ws->gpr_alloc.sgpr_size + 1) << shift));
 	} 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, 0,
 					(ws->gpr_alloc.sgpr_size + 1) << shift, dst);
 		umr_grbm_select_index(asic, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
 		return 0;
 	}
 }
+
+
+int umr_read_vgprs(struct umr_asic *asic, struct umr_wave_status *ws, uint32_t thread, uint32_t *dst)
+{
+	uint64_t addr;
+
+	if (asic->family < FAMILY_AI)
+		return -1;
+
+	if (!asic->options.no_kernel) {
+		addr =
+			(0ULL << 60)                             | // reading VGPRs
+			((uint64_t)0)                            | // starting address to read from
+			((uint64_t)ws->hw_id.se_id << 12)        |
+			((uint64_t)ws->hw_id.sh_id << 20)        |
+			((uint64_t)ws->hw_id.cu_id << 28)        |
+			((uint64_t)ws->hw_id.wave_id << 36)      |
+			((uint64_t)ws->hw_id.simd_id << 44)      |
+			((uint64_t)thread << 52);
+
+		lseek(asic->fd.gpr, addr, SEEK_SET);
+		return read(asic->fd.gpr, dst, 4 * ((ws->gpr_alloc.vgpr_size + 1) << 2));
+	} 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, thread, 0x400,
+					(ws->gpr_alloc.vgpr_size + 1) << 2, dst);
+		umr_grbm_select_index(asic, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
+		return 0;
+	}
+}
diff --git a/src/umr.h b/src/umr.h
index e49c80c..3d2252e 100644
--- a/src/umr.h
+++ b/src/umr.h
@@ -494,20 +494,21 @@ void umr_free_asic(struct umr_asic *asic);
 void umr_free_maps(struct umr_asic *asic);
 void umr_close_asic(struct umr_asic *asic); // call this to close a fully open asic
 int umr_query_drm(struct umr_asic *asic, int field, void *ret, int size);
 void umr_enumerate_devices(void);
 int umr_update(struct umr_asic *asic, char *script);
 
 /* lib helpers */
 int umr_get_wave_status(struct umr_asic *asic, unsigned se, unsigned sh, unsigned cu, unsigned simd, unsigned wave, struct umr_wave_status *ws);
 int umr_get_wave_sq_info(struct umr_asic *asic, unsigned se, unsigned sh, unsigned cu, struct umr_wave_status *ws);
 int umr_read_sgprs(struct umr_asic *asic, struct umr_wave_status *ws, uint32_t *dst);
+int umr_read_vgprs(struct umr_asic *asic, struct umr_wave_status *ws, uint32_t thread, uint32_t *dst);
 int umr_read_sensor(struct umr_asic *asic, int sensor, void *dst, int *size);
 
 /* mmio helpers */
 // init the mmio lookup table
 int umr_create_mmio_accel(struct umr_asic *asic);
 
 // find the word address of a register
 uint32_t umr_find_reg(struct umr_asic *asic, char *regname);
 
 // find the register data for a register
-- 
2.11.0

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH umr 4/4] Fix the no-kernel case of wave SGPR reading
       [not found] ` <20170909105530.10913-1-nhaehnle-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (2 preceding siblings ...)
  2017-09-09 10:55   ` [PATCH umr 3/4] Read VGPRs of halted waves on gfx9 Nicolai Hähnle
@ 2017-09-09 10:55   ` Nicolai Hähnle
  2017-09-09 12:23   ` [PATCH umr 0/4] gfx9: read VGPRs of halted waves Tom St Denis
  4 siblings, 0 replies; 8+ messages in thread
From: Nicolai Hähnle @ 2017-09-09 10:55 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Nicolai Hähnle

From: Nicolai Hähnle <nicolai.haehnle@amd.com>

Signed-off-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
---
 src/lib/read_gpr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/lib/read_gpr.c b/src/lib/read_gpr.c
index 669a49b..e6138a9 100644
--- a/src/lib/read_gpr.c
+++ b/src/lib/read_gpr.c
@@ -68,21 +68,21 @@ int umr_read_sgprs(struct umr_asic *asic, struct umr_wave_status *ws, uint32_t *
 			((uint64_t)ws->hw_id.sh_id << 20)        |
 			((uint64_t)ws->hw_id.cu_id << 28)        |
 			((uint64_t)ws->hw_id.wave_id << 36)      |
 			((uint64_t)ws->hw_id.simd_id << 44)      |
 			(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));
 	} 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, 0,
+		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);
 		umr_grbm_select_index(asic, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
 		return 0;
 	}
 }
 
 
 int umr_read_vgprs(struct umr_asic *asic, struct umr_wave_status *ws, uint32_t thread, uint32_t *dst)
 {
 	uint64_t addr;
-- 
2.11.0

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH umr 0/4] gfx9: read VGPRs of halted waves
       [not found] ` <20170909105530.10913-1-nhaehnle-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (3 preceding siblings ...)
  2017-09-09 10:55   ` [PATCH umr 4/4] Fix the no-kernel case of wave SGPR reading Nicolai Hähnle
@ 2017-09-09 12:23   ` Tom St Denis
  4 siblings, 0 replies; 8+ messages in thread
From: Tom St Denis @ 2017-09-09 12:23 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Hi Nicolai,

Patches look good I'll give them a whirl tomorrow when I have some free 
time.  I'll have to dig out your headless piglit instructions since I 
still can't bring X up on my Raven board.

Also I noticed the use of "(options.bitfields)" (etc, in print_waves) 
which is not your bug (since I did it first hehehe) but is a bug ... 
they should all be "asic->options.bitfields" which I'll fix in a 
follow-up patch after.

(provided they apply and combined with the kernel patch doesn't oops on 
me I'll R-b + push them out tomorrow or Monday morning).

Thanks,
Tom


On 09/09/17 06:55 AM, Nicolai Hähnle wrote:
> Hi all,
> 
> it seems that reading wave VGPRs actually works now with gfx9, at least
> for halted waves, and that can be pretty powerful for debugging.
> 
> Due to the volume of data it prints out, it's only enabled with -O bits.
> 
> In order for it to work properly, you'll also need the kernel patch
> I just sent out (drm/amdgpu/gfx9: implement wave VGPR reading).
> 
> Please review!
> 
> Thanks,
> Nicolai
> 
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
> 

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH umr 1/4] Fix wave SGPR reading
       [not found]     ` <20170909105530.10913-2-nhaehnle-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2017-09-11 13:31       ` Tom St Denis
       [not found]         ` <d0cd7c52-c14d-4d54-81d8-39141ff429b1-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Tom St Denis @ 2017-09-11 13:31 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Hi Nicolai,

I don't get this patch, 'x' starts at 0 and goes to sgpr_size but that 
doesn't include the offset into the SGPR space right?

I mean I get the patch in umr_read_sgprs() but in print_waves() won't 
that mean you're printing out SGPRS[0..size]?

Or are you saying having the base added to the printout is confusing for 
UMD debugging since the shader you're debugging probably doesn't have 
the offsets explicitly stated?

Cheers,
Tom

On 09/09/17 06:55 AM, Nicolai Hähnle wrote:
> From: Nicolai Hähnle <nicolai.haehnle@amd.com>
> 
> The hardware adds the alloc base already, no need to do it in the tool.
> 
> Signed-off-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
> ---
>   src/app/print_waves.c | 8 ++++----
>   src/lib/read_sgpr.c   | 5 +++--
>   2 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/src/app/print_waves.c b/src/app/print_waves.c
> index 1efd8a1..a9aaf39 100644
> --- a/src/app/print_waves.c
> +++ b/src/app/print_waves.c
> @@ -75,22 +75,22 @@ void umr_print_waves(struct umr_asic *asic)
>   "\n",
>   (unsigned)se, (unsigned)sh, (unsigned)cu, (unsigned)ws.hw_id.simd_id, (unsigned)ws.hw_id.wave_id,
>   (unsigned long)ws.wave_status.value, (unsigned long)ws.pc_hi, (unsigned long)ws.pc_lo,
>   (unsigned long)ws.wave_inst_dw0, (unsigned long)ws.wave_inst_dw1, (unsigned long)ws.exec_hi, (unsigned long)ws.exec_lo,
>   (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)
>   							for (x = 0; x < ((ws.gpr_alloc.sgpr_size + 1) << shift); x += 4)
>   								printf(">SGPRS[%u..%u] = { %08lx, %08lx, %08lx, %08lx }\n",
> -									(unsigned)((ws.gpr_alloc.sgpr_base << shift) + x),
> -									(unsigned)((ws.gpr_alloc.sgpr_base << shift) + x + 3),
> +									(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);
>   						for (x = 0; x < sizeof(opcodes)/4; x++) {
>   							printf(">pgm[%lu@%llx] = %08lx\n",
>   								(unsigned long)ws.hw_id.vm_id,
> @@ -156,22 +156,22 @@ void umr_print_waves(struct umr_asic *asic)
>   						Hv("GPR_ALLOC", ws.gpr_alloc.value);
>   						PP(gpr_alloc, vgpr_base);
>   						PP(gpr_alloc, vgpr_size);
>   						PP(gpr_alloc, sgpr_base);
>   						PP(gpr_alloc, sgpr_size);
>   
>   						if (ws.wave_status.halt) {
>   							printf("\n\nSGPRS:\n");
>   							for (x = 0; x < ((ws.gpr_alloc.sgpr_size + 1) << shift); x += 4)
>   								printf("\t[%4u..%4u] = { %08lx, %08lx, %08lx, %08lx }\n",
> -									(unsigned)((ws.gpr_alloc.sgpr_base << shift) + x),
> -									(unsigned)((ws.gpr_alloc.sgpr_base << shift) + x + 3),
> +									(unsigned)(x),
> +									(unsigned)(x + 3),
>   									(unsigned long)sgprs[x],
>   									(unsigned long)sgprs[x+1],
>   									(unsigned long)sgprs[x+2],
>   									(unsigned long)sgprs[x+3]);
>   						}
>   
>   						printf("\n\nPGM_MEM:\n");
>   						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);
>   						for (x = 0; x < sizeof(opcodes)/4; x++) {
> diff --git a/src/lib/read_sgpr.c b/src/lib/read_sgpr.c
> index cceb189..427cfc5 100644
> --- a/src/lib/read_sgpr.c
> +++ b/src/lib/read_sgpr.c
> @@ -56,27 +56,28 @@ int umr_read_sgprs(struct umr_asic *asic, struct umr_wave_status *ws, uint32_t *
>   	uint64_t addr, shift;
>   
>   	if (asic->family <= FAMILY_CIK)
>   		shift = 3;  // on SI..CIK allocations were done in 8-dword blocks
>   	else
>   		shift = 4;  // on VI allocations are in 16-dword blocks
>   
>   	if (!asic->options.no_kernel) {
>   		addr =
>   			(1ULL << 60)                             | // reading SGPRs
> -			((uint64_t)ws->gpr_alloc.sgpr_base << shift) | // starting address to read from
> +			((uint64_t)0)                            | // starting address to read from
>   			((uint64_t)ws->hw_id.se_id << 12)        |
>   			((uint64_t)ws->hw_id.sh_id << 20)        |
>   			((uint64_t)ws->hw_id.cu_id << 28)        |
>   			((uint64_t)ws->hw_id.wave_id << 36)      |
>   			((uint64_t)ws->hw_id.simd_id << 44)      |
>   			(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));
>   	} 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, ws->gpr_alloc.sgpr_base << shift, 0, (ws->gpr_alloc.sgpr_size + 1) << shift, dst);
> +		wave_read_regs_via_mmio(asic, ws->hw_id.simd_id, ws->hw_id.wave_id, 0, 0,
> +					(ws->gpr_alloc.sgpr_size + 1) << shift, dst);
>   		umr_grbm_select_index(asic, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
>   		return 0;
>   	}
>   }
> 

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH umr 1/4] Fix wave SGPR reading
       [not found]         ` <d0cd7c52-c14d-4d54-81d8-39141ff429b1-5C7GfCeVMHo@public.gmane.org>
@ 2017-09-11 15:17           ` Nicolai Hähnle
  0 siblings, 0 replies; 8+ messages in thread
From: Nicolai Hähnle @ 2017-09-11 15:17 UTC (permalink / raw)
  To: Tom St Denis, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On 11.09.2017 15:31, Tom St Denis wrote:
> Hi Nicolai,
> 
> I don't get this patch, 'x' starts at 0 and goes to sgpr_size but that 
> doesn't include the offset into the SGPR space right?
> 
> I mean I get the patch in umr_read_sgprs() but in print_waves() won't 
> that mean you're printing out SGPRS[0..size]?
> 
> Or are you saying having the base added to the printout is confusing for 
> UMD debugging since the shader you're debugging probably doesn't have 
> the offsets explicitly stated?

Precisely.

It's not a huge deal, but it's slightly easier to follow along the 
register dump and shader disassembly side-by-side when they both use the 
same indexing into the register files :)

Cheers,
Nicolai


> 
> Cheers,
> Tom
> 
> On 09/09/17 06:55 AM, Nicolai Hähnle wrote:
>> From: Nicolai Hähnle <nicolai.haehnle@amd.com>
>>
>> The hardware adds the alloc base already, no need to do it in the tool.
>>
>> Signed-off-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
>> ---
>>   src/app/print_waves.c | 8 ++++----
>>   src/lib/read_sgpr.c   | 5 +++--
>>   2 files changed, 7 insertions(+), 6 deletions(-)
>>
>> diff --git a/src/app/print_waves.c b/src/app/print_waves.c
>> index 1efd8a1..a9aaf39 100644
>> --- a/src/app/print_waves.c
>> +++ b/src/app/print_waves.c
>> @@ -75,22 +75,22 @@ void umr_print_waves(struct umr_asic *asic)
>>   "\n",
>>   (unsigned)se, (unsigned)sh, (unsigned)cu, 
>> (unsigned)ws.hw_id.simd_id, (unsigned)ws.hw_id.wave_id,
>>   (unsigned long)ws.wave_status.value, (unsigned long)ws.pc_hi, 
>> (unsigned long)ws.pc_lo,
>>   (unsigned long)ws.wave_inst_dw0, (unsigned long)ws.wave_inst_dw1, 
>> (unsigned long)ws.exec_hi, (unsigned long)ws.exec_lo,
>>   (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)
>>                               for (x = 0; x < ((ws.gpr_alloc.sgpr_size 
>> + 1) << shift); x += 4)
>>                                   printf(">SGPRS[%u..%u] = { %08lx, 
>> %08lx, %08lx, %08lx }\n",
>> -                                    
>> (unsigned)((ws.gpr_alloc.sgpr_base << shift) + x),
>> -                                    
>> (unsigned)((ws.gpr_alloc.sgpr_base << shift) + x + 3),
>> +                                    (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);
>>                           for (x = 0; x < sizeof(opcodes)/4; x++) {
>>                               printf(">pgm[%lu@%llx] = %08lx\n",
>>                                   (unsigned long)ws.hw_id.vm_id,
>> @@ -156,22 +156,22 @@ void umr_print_waves(struct umr_asic *asic)
>>                           Hv("GPR_ALLOC", ws.gpr_alloc.value);
>>                           PP(gpr_alloc, vgpr_base);
>>                           PP(gpr_alloc, vgpr_size);
>>                           PP(gpr_alloc, sgpr_base);
>>                           PP(gpr_alloc, sgpr_size);
>>                           if (ws.wave_status.halt) {
>>                               printf("\n\nSGPRS:\n");
>>                               for (x = 0; x < ((ws.gpr_alloc.sgpr_size 
>> + 1) << shift); x += 4)
>>                                   printf("\t[%4u..%4u] = { %08lx, 
>> %08lx, %08lx, %08lx }\n",
>> -                                    
>> (unsigned)((ws.gpr_alloc.sgpr_base << shift) + x),
>> -                                    
>> (unsigned)((ws.gpr_alloc.sgpr_base << shift) + x + 3),
>> +                                    (unsigned)(x),
>> +                                    (unsigned)(x + 3),
>>                                       (unsigned long)sgprs[x],
>>                                       (unsigned long)sgprs[x+1],
>>                                       (unsigned long)sgprs[x+2],
>>                                       (unsigned long)sgprs[x+3]);
>>                           }
>>                           printf("\n\nPGM_MEM:\n");
>>                           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);
>>                           for (x = 0; x < sizeof(opcodes)/4; x++) {
>> diff --git a/src/lib/read_sgpr.c b/src/lib/read_sgpr.c
>> index cceb189..427cfc5 100644
>> --- a/src/lib/read_sgpr.c
>> +++ b/src/lib/read_sgpr.c
>> @@ -56,27 +56,28 @@ int umr_read_sgprs(struct umr_asic *asic, struct 
>> umr_wave_status *ws, uint32_t *
>>       uint64_t addr, shift;
>>       if (asic->family <= FAMILY_CIK)
>>           shift = 3;  // on SI..CIK allocations were done in 8-dword 
>> blocks
>>       else
>>           shift = 4;  // on VI allocations are in 16-dword blocks
>>       if (!asic->options.no_kernel) {
>>           addr =
>>               (1ULL << 60)                             | // reading SGPRs
>> -            ((uint64_t)ws->gpr_alloc.sgpr_base << shift) | // 
>> starting address to read from
>> +            ((uint64_t)0)                            | // starting 
>> address to read from
>>               ((uint64_t)ws->hw_id.se_id << 12)        |
>>               ((uint64_t)ws->hw_id.sh_id << 20)        |
>>               ((uint64_t)ws->hw_id.cu_id << 28)        |
>>               ((uint64_t)ws->hw_id.wave_id << 36)      |
>>               ((uint64_t)ws->hw_id.simd_id << 44)      |
>>               (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));
>>       } 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, ws->gpr_alloc.sgpr_base << shift, 0, 
>> (ws->gpr_alloc.sgpr_size + 1) << shift, dst);
>> +        wave_read_regs_via_mmio(asic, ws->hw_id.simd_id, 
>> ws->hw_id.wave_id, 0, 0,
>> +                    (ws->gpr_alloc.sgpr_size + 1) << shift, dst);
>>           umr_grbm_select_index(asic, 0xFFFFFFFF, 0xFFFFFFFF, 
>> 0xFFFFFFFF);
>>           return 0;
>>       }
>>   }
>>
> 
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx


-- 
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-09-11 15:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-09 10:55 [PATCH umr 0/4] gfx9: read VGPRs of halted waves Nicolai Hähnle
     [not found] ` <20170909105530.10913-1-nhaehnle-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-09-09 10:55   ` [PATCH umr 1/4] Fix wave SGPR reading Nicolai Hähnle
     [not found]     ` <20170909105530.10913-2-nhaehnle-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-09-11 13:31       ` Tom St Denis
     [not found]         ` <d0cd7c52-c14d-4d54-81d8-39141ff429b1-5C7GfCeVMHo@public.gmane.org>
2017-09-11 15:17           ` Nicolai Hähnle
2017-09-09 10:55   ` [PATCH umr 2/4] Rename lib/read_sgpr.c to lib/read_gpr.c Nicolai Hähnle
2017-09-09 10:55   ` [PATCH umr 3/4] Read VGPRs of halted waves on gfx9 Nicolai Hähnle
2017-09-09 10:55   ` [PATCH umr 4/4] Fix the no-kernel case of wave SGPR reading Nicolai Hähnle
2017-09-09 12:23   ` [PATCH umr 0/4] gfx9: read VGPRs of halted waves Tom St Denis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox