diff options
author | Tvrtko Ursulin <tvrtko.ursulin@igalia.com> | 2024-04-03 15:02:36 +0100 |
---|---|---|
committer | Tvrtko Ursulin <tvrtko.ursulin@igalia.com> | 2024-04-16 16:07:53 +0100 |
commit | 3a71f659700859cab49b8e05a198ba18a5cbd24a (patch) | |
tree | 526c6dfcf0ad24a85049b83f0869d4ab99a15c18 | |
parent | 135f9d25b7c2d0d39895a65d052a761b6fed8bf9 (diff) |
tools/gputop: Fix engine columns with amdgpu
Amdgpu kernel driver skips output of fdinfo keys for unused engines. That
is completely legal but corrupts the column formatting in the current
code.
Fix it by simply treating change in detected engines used by a client
as trigger to re-emit a new header. This ensures columns are always
correctly aligned, albeit with a cost of potentially duplicating the
header for the same DRM minor.
This is considered good enough for a reference implementation. The
alternative would be to add some real per DRM minor state tracking which
sounds like an overkill, at least until gputop gains a nicer (any) UI.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Acked-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Acked-by: Christian König <christian.koenig@amd.com>
-rw-r--r-- | tools/gputop.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/tools/gputop.c b/tools/gputop.c index b13044b50..8f81e6fca 100644 --- a/tools/gputop.c +++ b/tools/gputop.c @@ -119,11 +119,36 @@ print_client_header(struct igt_drm_client *c, int lines, int con_w, int con_h, return lines; } +static bool +engines_identical(const struct igt_drm_client *c, + const struct igt_drm_client *pc) +{ + unsigned int i; + + if (c->engines->num_engines != pc->engines->num_engines || + c->engines->max_engine_id != pc->engines->max_engine_id) + return false; + + for (i = 0; i <= c->engines->max_engine_id; i++) + if (c->engines->capacity[i] != pc->engines->capacity[i] || + !!c->engines->names[i] != !!pc->engines->names[i] || + strcmp(c->engines->names[i], pc->engines->names[i])) + return false; + + return true; +} static bool newheader(const struct igt_drm_client *c, const struct igt_drm_client *pc) { - return !pc || c->drm_minor != pc->drm_minor; + return !pc || c->drm_minor != pc->drm_minor || + /* + * Below is a a hack for drivers like amdgpu which omit listing + * unused engines. Simply treat them as separate minors which + * will ensure the per-engine columns are correctly sized in all + * cases. + */ + !engines_identical(c, pc); } static int |