Signed-off-by: Tom St Denis <tom.stdenis at amd.com> --- src/app/print_config.c | 2 +- src/lib/discover.c | 21 ++++++++++++--------- src/lib/scan_config.c | 9 +++++++-- src/umr.h | 2 +- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/app/print_config.c b/src/app/print_config.c index 3ad95c0cd12f..051666d52e02 100644 --- a/src/app/print_config.c +++ b/src/app/print_config.c @@ -100,6 +100,7 @@ void umr_print_config(struct umr_asic *asic) { int r, x; + printf("\tasic.instance == %d\n\n", asic->instance); printf("\tumr.version == %s\n\n", UMR_BUILD_REV); for (r = 0; asic->config.fw[r].name[0]; r++) { @@ -110,7 +111,6 @@ void umr_print_config(struct umr_asic *asic) } printf("\n"); - printf("\tasic.instance == %d\n\n", asic->instance); if (asic->pci.pdevice) { ppx(vendor_id); ppx(device_id); diff --git a/src/lib/discover.c b/src/lib/discover.c index 2faed79334ee..3e0c1f93fccd 100644 --- a/src/lib/discover.c +++ b/src/lib/discover.c @@ -128,17 +128,20 @@ struct umr_asic *umr_discover_asic(struct umr_options *options) return NULL; } } + // try to scan via debugfs - asic = calloc(1, sizeof *asic); - if (asic) { - asic->instance = options->instance; - asic->options = *options; - umr_scan_config(asic); - if (asic->config.pci.device) - trydid = asic->config.pci.device; - umr_free_asic(asic); - asic = NULL; + if (!options->no_kernel) { + asic = calloc(1, sizeof *asic); + if (asic) { + asic->instance = options->instance; + asic->options = *options; + if (!umr_scan_config(asic) && asic->config.pci.device) + trydid = asic->config.pci.device; + umr_free_asic(asic); + asic = NULL; + } } + if (trydid < 0) { snprintf(name, sizeof(name)-1, "/sys/kernel/debug/dri/%d/name", options->instance); f = fopen(name, "r"); diff --git a/src/lib/scan_config.c b/src/lib/scan_config.c index 2d9f0f419557..5d2975f33e34 100644 --- a/src/lib/scan_config.c +++ b/src/lib/scan_config.c @@ -77,13 +77,16 @@ static void parse_rev3(struct umr_asic *asic, uint32_t *data, int *r) asic->config.pci.subsystem_vendor = data[(*r)++]; } -void umr_scan_config(struct umr_asic *asic) +int umr_scan_config(struct umr_asic *asic) { uint32_t data[512]; FILE *f; char fname[256]; int r; + if (asic->options.no_kernel) + return -1; + /* process FW block */ snprintf(fname, sizeof(fname)-1, "/sys/kernel/debug/dri/%d/amdgpu_firmware_info", asic->instance); f = fopen(fname, "r"); @@ -104,7 +107,7 @@ gca_config: snprintf(fname, sizeof(fname)-1, "/sys/kernel/debug/dri/%d/amdgpu_gca_config", asic->instance); f = fopen(fname, "rb"); if (!f) - return; + return -1; fread(data, 1, sizeof(data), f); fclose(f); @@ -119,5 +122,7 @@ gca_config: break; default: printf("Invalid gca config data header\n"); + return -1; } + return 0; } diff --git a/src/umr.h b/src/umr.h index 4d63708e1c15..f3d359172d03 100644 --- a/src/umr.h +++ b/src/umr.h @@ -508,4 +508,4 @@ int umr_read_vram(struct umr_asic *asic, uint32_t vmid, uint64_t address, uint32 #define RST (options.use_colour ? "\x1b[0m" : "") void umr_bitfield_default(struct umr_asic *asic, char *asicname, char *ipname, char *regname, char *bitname, int start, int stop, uint32_t value); -void umr_scan_config(struct umr_asic *asic); +int umr_scan_config(struct umr_asic *asic); -- 2.12.0