[PATCH umr 13/17] server/waves: fix ring halt logic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Whether GPRs can be read or not only depends on the state of the individual
wave, not on the state of any ring.

Use ring_is_halted only to gate the logic that tries to extract shader
references from PM4 for more convenient disassembly.

Signed-off-by: Nicolai Hähnle <nicolai.haehnle@xxxxxxx>
---
 src/app/gui/commands.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/app/gui/commands.c b/src/app/gui/commands.c
index 1e5e854..fbb11fa 100644
--- a/src/app/gui/commands.c
+++ b/src/app/gui/commands.c
@@ -1537,21 +1537,21 @@ void init_asics() {
 			}
 
 			index++;
 		} else {
 			fclose(opt.test_log_fd);
 			free(ip_discovery_dump);
 		}
 	}
 }
 
-static void wave_to_json(struct umr_asic *asic, int is_halted, int include_shaders, JSON_Object *out) {
+static void wave_to_json(struct umr_asic *asic, int ring_is_halted, int include_shaders, JSON_Object *out) {
 	// TODO: This is using the deprecated API ...
 	struct umr_pm4_stream *stream = NULL; // umr_pm4_decode_ring(asic, asic->options.ring_name, 1, -1, -1);
 
 	struct umr_wave_data *wd = umr_scan_wave_data(asic);
 
 	JSON_Value *shaders = json_value_init_object();
 
 	JSON_Value *waves = json_value_init_array();
 	while (wd) {
 		uint64_t pgm_addr = (((uint64_t)wd->ws.pc_hi << 32) | wd->ws.pc_lo);
@@ -1633,21 +1633,21 @@ static void wave_to_json(struct umr_asic *asic, int is_halted, int include_shade
 		}
 		json_object_set_value(json_object(wave), "threads", threads);
 
 		JSON_Value *gpr_alloc = json_value_init_object();
 		json_object_set_number(json_object(gpr_alloc), "vgpr_base", wd->ws.gpr_alloc.vgpr_base);
 		json_object_set_number(json_object(gpr_alloc), "vgpr_size", wd->ws.gpr_alloc.vgpr_size);
 		json_object_set_number(json_object(gpr_alloc), "sgpr_base", wd->ws.gpr_alloc.sgpr_base);
 		json_object_set_number(json_object(gpr_alloc), "sgpr_size", wd->ws.gpr_alloc.sgpr_size);
 		json_object_set_value(json_object(wave), "gpr_alloc", gpr_alloc);
 
-		if (is_halted && wd->ws.gpr_alloc.value != 0xbebebeef) {
+		if (wd->ws.gpr_alloc.value != 0xbebebeef) {
 			int sgpr_count;
 			if (asic->family <= FAMILY_AI) {
 				int shift = asic->family <= FAMILY_CIK ? 3 : 4;
 				sgpr_count = (wd->ws.gpr_alloc.sgpr_size + 1) << shift;
 			} else {
 				sgpr_count = 108; // regular SGPRs and VCC
 			}
 			JSON_Value *sgpr = json_value_init_array();
 			for (int x = 0; x < sgpr_count; x++) {
 				json_array_append_number(json_array(sgpr), wd->sgprs[x]);
@@ -1663,23 +1663,27 @@ static void wave_to_json(struct umr_asic *asic, int is_halted, int include_shade
 					for (int thread = 0; thread < num_threads; thread++) {
 						json_array_append_number(json_array(v), wd->vgprs[thread * 256 + x]);
 					}
 					json_array_append_value(json_array(vgpr), v);
 				}
 				json_object_set_value(json_object(wave), "vgpr", vgpr);
 			}
 
 			/* */
 			if (include_shaders && (wd->ws.wave_status.halt || wd->ws.wave_status.fatal_halt)) {
-				struct umr_shaders_pgm *shader = umr_find_shader_in_stream(stream, vmid, pgm_addr);
+				struct umr_shaders_pgm *shader = NULL;
 				uint32_t shader_size;
 				uint64_t shader_addr;
+
+				if (ring_is_halted)
+					shader = umr_find_shader_in_stream(stream, vmid, pgm_addr);
+
 				if (shader) {
 					shader_size = shader->size;
 					shader_addr = shader->addr;
 				} else {
 					#define NUM_OPCODE_WORDS 16
 					pgm_addr -= (NUM_OPCODE_WORDS*4)/2;
 					shader_addr = pgm_addr;
 					shader_size = NUM_OPCODE_WORDS * 4;
 					#undef NUM_OPCODE_WORDS
 				}
@@ -2013,25 +2017,25 @@ JSON_Value *umr_process_json_request(JSON_Object *request, void **raw_data, unsi
 		}
 
 		if (halt_waves) {
 			umr_sq_cmd_halt_waves(asic, UMR_SQ_CMD_HALT);
 		}
 
 		asic->options.skip_gprs = 0;
 		asic->options.halt_waves = halt_waves;
 		asic->options.verbose = 0;
 
-		int is_halted = umr_ring_is_halted(asic, asic->options.ring_name);
+		int ring_is_halted = umr_ring_is_halted(asic, asic->options.ring_name);
 
 		answer = json_value_init_object();
 
-		wave_to_json(asic, is_halted, 1, json_object(answer));
+		wave_to_json(asic, ring_is_halted, 1, json_object(answer));
 
 		if (disable_gfxoff && asic->fd.gfxoff >= 0) {
 			uint32_t value = 1;
 			write(asic->fd.gfxoff, &value, sizeof(value));
 		}
 		if (resume_waves)
 			umr_sq_cmd_halt_waves(asic, UMR_SQ_CMD_RESUME);
 	} else if (strcmp(command, "resume-waves") == 0) {
 		strcpy(asic->options.ring_name, json_object_get_string(request, "ring"));
 		umr_sq_cmd_halt_waves(asic, UMR_SQ_CMD_RESUME);
-- 
2.40.0




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux