Signed-off-by: Tom St Denis <tom.stdenis at amd.com> --- src/app/main.c | 18 ++++++++++++++++++ src/lib/read_vram.c | 22 +++++++++++++++++----- src/umr.h | 7 +++++-- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/src/app/main.c b/src/app/main.c index 0b46643400ba..006727ba7981 100644 --- a/src/app/main.c +++ b/src/app/main.c @@ -341,6 +341,14 @@ int main(int argc, char **argv) } else if (!strcmp(argv[i], "--enumerate") || !strcmp(argv[i], "-e")) { umr_enumerate_devices(); return 0; + } else if (!strcmp(argv[i], "-mm")) { + if (i + 1 < argc) { + strcpy(options.hub_name, argv[i+1]); + ++i; + } else { + printf("-mm requires on parameter"); + return EXIT_FAILURE; + } } else if (!strcmp(argv[i], "--vm-decode") || !strcmp(argv[i], "-vm")) { if (i + 2 < argc) { uint64_t address; @@ -361,6 +369,11 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } sscanf(argv[i+2], "%"SCNx32, &size); + + // imply user hub if hub name specified + if (options.hub_name[0]) + vmid |= UMR_USER_HUB; + while (size--) { if (umr_read_vram(asic, vmid, address, 0, NULL)) break; @@ -389,6 +402,11 @@ int main(int argc, char **argv) sscanf(argv[i+1], "%"SCNx64, &address); vmid = UMR_LINEAR_HUB; } + + // imply user hub if hub name specified + if (options.hub_name[0]) + vmid |= UMR_USER_HUB; + sscanf(argv[i+2], "%"SCNx32, &size); do { n = size > sizeof(buf) ? sizeof(buf) : size; diff --git a/src/lib/read_vram.c b/src/lib/read_vram.c index b58400f1f4ca..91d4e7659704 100644 --- a/src/lib/read_vram.c +++ b/src/lib/read_vram.c @@ -309,6 +309,7 @@ static int umr_read_vram_ai(struct umr_asic *asic, uint32_t vmid, uint64_t addre char buf[64]; unsigned char *pdst = dst; char *hub; + unsigned hubid; memset(®isters, 0, sizeof registers); @@ -333,13 +334,24 @@ static int umr_read_vram_ai(struct umr_asic *asic, uint32_t vmid, uint64_t addre * 0 valid */ - if ((vmid & 0xFF00) == UMR_MM_HUB) - hub = "mmhub"; - else - hub = "gfx"; - + hubid = vmid & 0xFF00; vmid &= 0xFF; + switch (hubid) { + case UMR_MM_HUB: + hub = "mmhub"; + break; + case UMR_GFX_HUB: + hub = "gfx"; + break; + case UMR_USER_HUB: + hub = asic->options.hub_name; + break; + default: + fprintf(stderr, "[ERROR]: Invalid hub specified in umr_read_vram_ai()\n"); + return -1; + } + // read vm registers sprintf(buf, "mmVM_CONTEXT%d_PAGE_TABLE_START_ADDR_LO32", (int)vmid); registers.mmVM_CONTEXTx_PAGE_TABLE_START_ADDR_LO32 = umr_read_reg_by_name_by_ip(asic, hub, buf); diff --git a/src/umr.h b/src/umr.h index dd7f80c38f0c..3cc7994fc8ad 100644 --- a/src/umr.h +++ b/src/umr.h @@ -44,6 +44,7 @@ enum umr_hub_space { UMR_GFX_HUB = 0 << 8, // default on everything before AI UMR_MM_HUB = 1 << 8, // available on AI and later + UMR_USER_HUB = 0xFE << 8, // for user supplied HUB names (npi work...) UMR_LINEAR_HUB = 0xFF << 8, // this is for linear access to vram }; @@ -196,8 +197,10 @@ struct umr_options { se_bank, sh_bank; long forcedid; - char *scanblock; - char dev_name[32]; + char + *scanblock, + dev_name[32], + hub_name[32]; struct { int domain, bus, -- 2.12.0