Opening the DRM file (/dev/dri/card%d) triggers all sorts of KMD
work to happen which is not useful if the KMD is hung or not working.

Since --top is the only user of the file currently we simply defer
opening it until --top is invoked.

Signed-off-by: Tom St Denis <tom.stde...@amd.com>
---
 src/app/top.c      | 7 +++++++
 src/lib/discover.c | 3 +--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/app/top.c b/src/app/top.c
index 364180eb70f6..a4d3aa8e699d 100644
--- a/src/app/top.c
+++ b/src/app/top.c
@@ -933,8 +933,15 @@ void umr_top(struct umr_asic *asic)
        time_t tt;
        uint64_t ts;
        char hostname[64] = { 0 };
+       char fname[64];
        pthread_t sensor_thread;
 
+       // open drm file if not already open
+       if (asic->fd.drm < 0) {
+               snprintf(fname, sizeof(fname)-1, "/dev/dri/card%d", 
asic->instance);
+               asic->fd.drm = open(fname, O_RDWR);
+       }
+
        if (getenv("HOSTNAME")) strcpy(hostname, getenv("HOSTNAME"));
 
        // init stats
diff --git a/src/lib/discover.c b/src/lib/discover.c
index d561efafe4d4..c9c2f74a4818 100644
--- a/src/lib/discover.c
+++ b/src/lib/discover.c
@@ -127,8 +127,7 @@ struct umr_asic *umr_discover_asic(struct umr_options 
*options)
                asic->fd.vram = open(fname, O_RDWR);
                snprintf(fname, sizeof(fname)-1, 
"/sys/kernel/debug/dri/%d/amdgpu_gpr", asic->instance);
                asic->fd.gpr = open(fname, O_RDWR);
-               snprintf(fname, sizeof(fname)-1, "/dev/dri/card%d", 
asic->instance);
-               asic->fd.drm = open(fname, O_RDWR);
+               asic->fd.drm = -1; // default to closed
                // if appending to the fd list remember to update close_asic() 
and discover_by_did()...
 
                if (options->use_pci) {
-- 
2.12.0

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reply via email to