From aa7b410592700bf6253e8695ea208d0448c1610e Mon Sep 17 00:00:00 2001 From: Sirisha Gandikota Date: Tue, 13 Sep 2016 16:19:31 -0700 Subject: [PATCH] aubinator: Remove bogus "end" parameter in gen_disasm_disassemble() Earlier, the loop pretends to loop over instructions from "start" to "end", but the callers always pass 8192 for end, which is some huge bogus value. The real loop termination condition is send-with-EOT or 0. (Ken) Signed-off-by: Sirisha Gandikota Reviewed-by: Kenneth Graunke --- src/intel/tools/aubinator.c | 12 ++++++------ src/intel/tools/disasm.c | 8 +++++--- src/intel/tools/gen_disasm.h | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/intel/tools/aubinator.c b/src/intel/tools/aubinator.c index 89d29f288fa..fad8aaa27bc 100644 --- a/src/intel/tools/aubinator.c +++ b/src/intel/tools/aubinator.c @@ -303,7 +303,7 @@ handle_media_interface_descriptor_load(struct gen_spec *spec, uint32_t *p) } insns = (struct brw_instruction *) (gtt + start); - gen_disasm_disassemble(disasm, insns, 0, 8192, stdout); + gen_disasm_disassemble(disasm, insns, 0, stdout); dump_samplers(spec, descriptors[3] & ~0x1f); dump_binding_table(spec, descriptors[4] & ~0x1f); @@ -401,7 +401,7 @@ handle_3dstate_vs(struct gen_spec *spec, uint32_t *p) instruction_base, start); insns = (struct brw_instruction *) (gtt + instruction_base + start); - gen_disasm_disassemble(disasm, insns, 0, 8192, stdout); + gen_disasm_disassemble(disasm, insns, 0, stdout); } } @@ -425,7 +425,7 @@ handle_3dstate_hs(struct gen_spec *spec, uint32_t *p) instruction_base, start); insns = (struct brw_instruction *) (gtt + instruction_base + start); - gen_disasm_disassemble(disasm, insns, 0, 8192, stdout); + gen_disasm_disassemble(disasm, insns, 0, stdout); } } @@ -519,21 +519,21 @@ handle_3dstate_ps(struct gen_spec *spec, uint32_t *p) printf(" Kernel[0] %s\n", k0); if (k0 != unused) { insns = (struct brw_instruction *) (gtt + start); - gen_disasm_disassemble(disasm, insns, 0, 8192, stdout); + gen_disasm_disassemble(disasm, insns, 0, stdout); } start = instruction_base + (p[k1_offset] & mask); printf(" Kernel[1] %s\n", k1); if (k1 != unused) { insns = (struct brw_instruction *) (gtt + start); - gen_disasm_disassemble(disasm, insns, 0, 8192, stdout); + gen_disasm_disassemble(disasm, insns, 0, stdout); } start = instruction_base + (p[k2_offset] & mask); printf(" Kernel[2] %s\n", k2); if (k2 != unused) { insns = (struct brw_instruction *) (gtt + start); - gen_disasm_disassemble(disasm, insns, 0, 8192, stdout); + gen_disasm_disassemble(disasm, insns, 0, stdout); } } diff --git a/src/intel/tools/disasm.c b/src/intel/tools/disasm.c index 89c711b1d3f..2b51424742d 100644 --- a/src/intel/tools/disasm.c +++ b/src/intel/tools/disasm.c @@ -45,13 +45,15 @@ is_send(uint32_t opcode) } void -gen_disasm_disassemble(struct gen_disasm *disasm, void *assembly, int start, - int end, FILE *out) +gen_disasm_disassemble(struct gen_disasm *disasm, void *assembly, + int start, FILE *out) { struct gen_device_info *devinfo = &disasm->devinfo; bool dump_hex = false; + int offset = start; - for (int offset = start; offset < end;) { + /* This loop exits when send-with-EOT or when opcode is 0 */ + while (true) { brw_inst *insn = assembly + offset; brw_inst uncompacted; bool compacted = brw_inst_cmpt_control(devinfo, insn); diff --git a/src/intel/tools/gen_disasm.h b/src/intel/tools/gen_disasm.h index af6654f3c33..24b56c9a8e1 100644 --- a/src/intel/tools/gen_disasm.h +++ b/src/intel/tools/gen_disasm.h @@ -28,7 +28,7 @@ struct gen_disasm; struct gen_disasm *gen_disasm_create(int pciid); void gen_disasm_disassemble(struct gen_disasm *disasm, - void *assembly, int start, int end, FILE *out); + void *assembly, int start, FILE *out); void gen_disasm_destroy(struct gen_disasm *disasm); -- 2.30.2