Since newer asics have IP blocks with the same register we must specify both. Signed-off-by: Tom St Denis <tom.stdenis at amd.com> --- doc/umr.1 | 2 +- src/app/main.c | 3 ++- src/app/umr_lookup.c | 33 ++++++++++++++++++++++++--------- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/doc/umr.1 b/doc/umr.1 index e865e131fa51..69a2087d1ade 100644 --- a/doc/umr.1 +++ b/doc/umr.1 @@ -31,7 +31,7 @@ List all blocks attached to the asic that has been detected. List all registers in an IP block (can use '-O bits' to list bitfields) .IP "--lookup, -lu <address_or_regname> <number>" Look up an MMIO register by address and bitfield decode the value specified (with 0x prefix) or by -register name. +register name. The register name string must include the ipname, e.g., uvd6.mmUVD_CONTEXT_ID. .IP "--write -w <string> <number>" Write a value specified in hex to a register specified with a complete register path in the form < diff --git a/src/app/main.c b/src/app/main.c index 17c99b4296a4..0a44c4399bb8 100644 --- a/src/app/main.c +++ b/src/app/main.c @@ -502,7 +502,8 @@ if (strcmp(argv[i], "--vm-write") && strcmp(argv[i], "-vw")) { "\n\t--enumerate, -e\n\t\tEnumerate all AMDGPU devices detected.\n" "\n\t--list-blocks, -lb\n\t\tList IP blocks discovered for this device.\n" "\n\t--list-regs, -lr <string>\n\t\tList registers for a given IP block (can use '-O bits' to list bitfields).\n" -"\n\t--lookup, -lu <address_or_regname> <value>\n\t\tLook up bit decoding of an MMIO register by address (with 0x prefix) or by register name.\n" +"\n\t--lookup, -lu <address_or_regname> <value>\n\t\tLook up bit decoding of an MMIO register by address (with 0x prefix) or by register name." + "\n\t\tThe register name string must include the ipname, e.g., uvd6.mmUVD_CONTEXT_ID.\n" "\n\t--write, -w <address> <number>\n\t\tWrite a value in hex to a register specified as a register path in the" "\n\t\tform <asicname.ipname.regname>. For instance \"tonga.uvd5.mmUVD_SOFT_RESET\"." "\n\t\tCan be used multiple times to set multiple registers. You can" diff --git a/src/app/umr_lookup.c b/src/app/umr_lookup.c index d07130ab0dfa..f88d0b6bce77 100644 --- a/src/app/umr_lookup.c +++ b/src/app/umr_lookup.c @@ -47,16 +47,31 @@ void umr_lookup(struct umr_asic *asic, char *address, char *value) } } } else { + char ipname[256], regname[256], *p; + + memset(ipname, 0, sizeof ipname); + memset(regname, 0, sizeof regname); + p = strstr(address, "."); + if (!p) { + fprintf(stderr, "[ERROR]: Must specify ipname.regname for umr_lookup()\n"); + return; + } + memcpy(ipname, address, p - address); + strcpy(regname, p + 1); + for (i = 0; i < asic->no_blocks; i++) - for (j = 0; j < asic->blocks[i]->no_regs; j++) - if (asic->blocks[i]->regs[j].type == REG_MMIO && - !strcmp(asic->blocks[i]->regs[j].regname, address)) { - printf("%s.%s => 0x%08lx\n", asic->blocks[i]->ipname, asic->blocks[i]->regs[j].regname, (unsigned long)num); - for (k = 0; k < asic->blocks[i]->regs[j].no_bits; k++) { - uint32_t v; - v = (1UL << (asic->blocks[i]->regs[j].bits[k].stop + 1 - asic->blocks[i]->regs[j].bits[k].start)) - 1; - v &= (num >> asic->blocks[i]->regs[j].bits[k].start); - asic->blocks[i]->regs[j].bits[k].bitfield_print(asic, asic->asicname, asic->blocks[i]->ipname, asic->blocks[i]->regs[j].regname, asic->blocks[i]->regs[j].bits[k].regname, asic->blocks[i]->regs[j].bits[k].start, asic->blocks[i]->regs[j].bits[k].stop, v); + if (!strcmp(asic->blocks[i]->ipname, ipname)) { + for (j = 0; j < asic->blocks[i]->no_regs; j++) { + if (asic->blocks[i]->regs[j].type == REG_MMIO && + !strcmp(asic->blocks[i]->regs[j].regname, regname)) { + printf("%s.%s => 0x%08lx\n", asic->blocks[i]->ipname, asic->blocks[i]->regs[j].regname, (unsigned long)num); + for (k = 0; k < asic->blocks[i]->regs[j].no_bits; k++) { + uint32_t v; + v = (1UL << (asic->blocks[i]->regs[j].bits[k].stop + 1 - asic->blocks[i]->regs[j].bits[k].start)) - 1; + v &= (num >> asic->blocks[i]->regs[j].bits[k].start); + asic->blocks[i]->regs[j].bits[k].bitfield_print(asic, asic->asicname, asic->blocks[i]->ipname, asic->blocks[i]->regs[j].regname, asic->blocks[i]->regs[j].bits[k].regname, asic->blocks[i]->regs[j].bits[k].start, asic->blocks[i]->regs[j].bits[k].stop, v); + } + } } } } -- 2.12.0