For UMDs that don't use the 0xBF9F0000 shader terminator marker this option allows the disassembler to stop once it hits the first s_endpgm opcode. Signed-off-by: Tom St Denis <tom.stdenis at amd.com> --- doc/sphinx/source/basic.rst | 69 +++++++++++++++++++++++---------------------- doc/umr.1 | 5 ++++ src/app/main.c | 4 ++- src/lib/umr_llvm_disasm.c | 4 ++- src/umr.h | 3 +- 5 files changed, 49 insertions(+), 36 deletions(-) diff --git a/doc/sphinx/source/basic.rst b/doc/sphinx/source/basic.rst index 8d6db65aa88a..84bf35f38b39 100644 --- a/doc/sphinx/source/basic.rst +++ b/doc/sphinx/source/basic.rst @@ -104,39 +104,42 @@ comma separator. The options available are: -+--------------+------------------------------------------------------------------------------+ -| **Option** | **Description** | -+--------------+------------------------------------------------------------------------------+ -| quiet | Disable various informative outputs that are not required for functionality. | -+--------------+------------------------------------------------------------------------------+ -| read_smc | Enable scanning of SMC registers when issuing a --scan command | -+--------------+------------------------------------------------------------------------------+ -| bits | Enables the display of bitfields when registers are presented | -+--------------+------------------------------------------------------------------------------+ -| bitsfull | When printing bits use the full path to the bitfield | -+--------------+------------------------------------------------------------------------------+ -| empty_log | Empty MMIO tracer after reading it | -+--------------+------------------------------------------------------------------------------+ -| follow | Tells --logscan to continually read the MMIO tracer | -+--------------+------------------------------------------------------------------------------+ -| no_follow_ib | Instructs the --ring command to not follow IBs pointed to by the ring | -+--------------+------------------------------------------------------------------------------+ -| named | Tells --read to print out the register name along with the value | -+--------------+------------------------------------------------------------------------------+ -| many | Allows matching of register names openly. Used with --read and implies the | -| | *named* option. For instance: '\*.dce100.CRTC' will match any register that | -| | contains the fragment 'CRTC' in it. | -+--------------+------------------------------------------------------------------------------+ -| use_pci | Enables direct PCI access bypassing the kernels debugfs entries. | -+--------------+------------------------------------------------------------------------------+ -| use_colour | Enables colourful output in various commands. Also accepts use_color | -+--------------+------------------------------------------------------------------------------+ -| no_kernel | Attempts to avoid kernel access methods. Implies *use_pci*. | -+--------------+------------------------------------------------------------------------------+ -| verbose | Enables verbose output, for instance in VM decoding | -+--------------+------------------------------------------------------------------------------+ -| halt_waves | Halt active waves while reading wave status data | -+--------------+------------------------------------------------------------------------------+ ++-------------------+-------------------------------------------------------------------------+ +| **Option** | **Description** | ++-------------------+-------------------------------------------------------------------------+ +| quiet | Disable various informative outputs that are not required for | +| | functionality. | ++-------------------+-------------------------------------------------------------------------+ +| read_smc | Enable scanning of SMC registers when issuing a --scan command | ++-------------------+-------------------------------------------------------------------------+ +| bits | Enables the display of bitfields when registers are presented | ++-------------------+-------------------------------------------------------------------------+ +| bitsfull | When printing bits use the full path to the bitfield | ++-------------------+-------------------------------------------------------------------------+ +| empty_log | Empty MMIO tracer after reading it | ++-------------------+-------------------------------------------------------------------------+ +| follow | Tells --logscan to continually read the MMIO tracer | ++-------------------+-------------------------------------------------------------------------+ +| no_follow_ib | Instructs the --ring command to not follow IBs pointed to by the ring | ++-------------------+-------------------------------------------------------------------------+ +| named | Tells --read to print out the register name along with the value | ++-------------------+-------------------------------------------------------------------------+ +| many | Allows matching of register names openly. Used with --read and implies | +| | the *named* option. For instance: '\*.dce100.CRTC' will match any | +| | register that contains the fragment 'CRTC' in it. | ++-------------------+-------------------------------------------------------------------------+ +| use_pci | Enables direct PCI access bypassing the kernels debugfs entries. | ++-------------------+-------------------------------------------------------------------------+ +| use_colour | Enables colourful output in various commands. Also accepts use_color | ++-------------------+-------------------------------------------------------------------------+ +| no_kernel | Attempts to avoid kernel access methods. Implies *use_pci*. | ++-------------------+-------------------------------------------------------------------------+ +| verbose | Enables verbose output, for instance in VM decoding | ++-------------------+-------------------------------------------------------------------------+ +| halt_waves | Halt active waves while reading wave status data | ++-------------------+-------------------------------------------------------------------------+ +| disasm_early_term | Terminate disassembly early for UMDs that don't use 0xBF9F0000 marker | ++-------------------+-------------------------------------------------------------------------+ ------------------ Device Information diff --git a/doc/umr.1 b/doc/umr.1 index 991ac62a4d82..83706b887894 100644 --- a/doc/umr.1 +++ b/doc/umr.1 @@ -179,6 +179,11 @@ separated strings. Options should be specified before --update or --force comma .B halt_waves Halt/resume all waves while reading wave status. +.B disasm_early_term + Terminate shader disassembly when first s_endpgm is hit. This is required for + older UMDs (or non-mesa UMDs) that don't use the quintuple 0xBF9F0000 to signal the true + end of a shader. + .SH "Notes" - The "Waves" field in the DRM section of --top only works if GFX PG has been disabled. Otherwise, diff --git a/src/app/main.c b/src/app/main.c index 4f5d4d093670..81ebc4c5bf42 100644 --- a/src/app/main.c +++ b/src/app/main.c @@ -111,6 +111,8 @@ static void parse_options(char *str) options.verbose = 1; } else if (!strcmp(option, "halt_waves")) { options.halt_waves = 1; + } else if (!strcmp(option, "disasm_early_term")) { + options.disasm_early_term = 1; } else if (!strcmp(option, "no_kernel")) { options.no_kernel = 1; options.use_pci = 1; @@ -573,7 +575,7 @@ int main(int argc, char **argv) "\n\t--vm-disasm, -vdis [<vmid>@]<address> <size>" "\n\t\tDisassemble 'size' bytes (in hex) from a given address (in hex).\n" "\n\t--option -O <string>[,<string>,...]\n\t\tEnable various flags: bits, bitsfull, empty_log, follow, no_follow_ib, named, many," - "\n\t\tuse_pci, use_colour, read_smc, quiet, no_kernel, verbose, halt_waves.\n" + "\n\t\tuse_pci, use_colour, read_smc, quiet, no_kernel, verbose, halt_waves, disasm_early_term.\n" "\n\n", UMR_BUILD_VER, UMR_BUILD_REV); exit(EXIT_SUCCESS); } else { diff --git a/src/lib/umr_llvm_disasm.c b/src/lib/umr_llvm_disasm.c index 66d1093db58d..a4594a04db56 100644 --- a/src/lib/umr_llvm_disasm.c +++ b/src/lib/umr_llvm_disasm.c @@ -153,14 +153,16 @@ uint32_t umr_compute_shader_size(struct umr_asic *asic, } y += 4; if (buf[x] == S_ENDPGM || buf[x] == S_ENDINV) { - ++x; lastendpgm = y - 4; ++endpgm_cnt; if (endpgm_cnt == 5) break; + if (asic->options.disasm_early_term) + break; } else { endpgm_cnt = 0; } + ++x; } if (endpgm_cnt == 5) return y - 16; // remove last 4 endpgm's diff --git a/src/umr.h b/src/umr.h index 684fcd777ac3..7154db7bb2c3 100644 --- a/src/umr.h +++ b/src/umr.h @@ -191,7 +191,8 @@ struct umr_options { follow_ib, verbose, halt_waves, - no_kernel; + no_kernel, + disasm_early_term; union { struct { -- 2.14.3