All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH umr] Avoid opening the DRM file by default
@ 2017-04-27 16:41 Tom St Denis
       [not found] ` <20170427164123.27787-1-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Tom St Denis @ 2017-04-27 16:41 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Tom St Denis

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.stdenis@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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH umr] Avoid opening the DRM file by default
       [not found] ` <20170427164123.27787-1-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
@ 2017-04-28 16:23   ` Alex Deucher
  0 siblings, 0 replies; 2+ messages in thread
From: Alex Deucher @ 2017-04-28 16:23 UTC (permalink / raw)
  To: Tom St Denis; +Cc: amd-gfx list

On Thu, Apr 27, 2017 at 12:41 PM, Tom St Denis <tom.stdenis@amd.com> wrote:
> 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.stdenis@amd.com>

Reviewed-by: Alex Deucher <alexander.deucher@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
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-04-28 16:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-27 16:41 [PATCH umr] Avoid opening the DRM file by default Tom St Denis
     [not found] ` <20170427164123.27787-1-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
2017-04-28 16:23   ` Alex Deucher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.