summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorTvrtko Ursulin <tvrtko.ursulin@intel.com>2022-05-23 13:22:44 +0100
committerTvrtko Ursulin <tvrtko.ursulin@intel.com>2022-05-27 10:45:31 +0100
commit0e5b5c5050a25a9ce09f1751d1522e11e8dae16b (patch)
treef3abf639d7bab061f76b27dc341df9225d5a3fba /tools
parent7e2033da45f024a0348e6034fcb7f70a91b80ee9 (diff)
intel_gpu_top: Don't show client header if no kernel support
On kernels without support for the feature we should skip showing the clients header to avoid confusing users. Simply briefly open a render node to the selected device during init and look if the relevant fields are present in the fdinfo data. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Issue: https://gitlab.freedesktop.org/drm/igt-gpu-tools/-/issues/120 Reviewed-by: Petri Latvala <petri.latvala@intel.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/intel_gpu_top.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
index 1984c10d..26986a82 100644
--- a/tools/intel_gpu_top.c
+++ b/tools/intel_gpu_top.c
@@ -2389,6 +2389,23 @@ static void process_stdin(unsigned int timeout_us)
process_normal_stdin();
}
+static bool has_drm_fdinfo(const struct igt_device_card *card)
+{
+ struct drm_client_fdinfo info;
+ unsigned int cnt;
+ int fd;
+
+ fd = open(card->render, O_RDWR);
+ if (fd < 0)
+ return false;
+
+ cnt = igt_parse_drm_fdinfo(fd, &info);
+
+ close(fd);
+
+ return cnt > 0;
+}
+
static void show_help_screen(void)
{
printf(
@@ -2545,8 +2562,9 @@ int main(int argc, char **argv)
ret = EXIT_SUCCESS;
- clients = init_clients(card.pci_slot_name[0] ?
- card.pci_slot_name : IGPU_PCI);
+ if (has_drm_fdinfo(&card))
+ clients = init_clients(card.pci_slot_name[0] ?
+ card.pci_slot_name : IGPU_PCI);
init_engine_classes(engines);
if (clients) {
clients->num_classes = engines->num_classes;