Skip to content

tests/util: Call `drmGetDevices2()` instead of `drmOpen()`ing all modules

Marijn Suijten requested to merge MarijnS95/drm:test-util-nvidia-drm into main

Whenever util_open() is called to open a device for the first matching module, it will skip devices for the nvidia_drm kernel module which is not in the list. We could add this module for now, but keeping this list of DRM modules up to date is cumbersome.

At the same time walking a list of modules and calling drmOpen() for each of them is incredibly expensive (when the user doesn't explicitly specify one with -M), as each each call opens every DRM node just to see if they are associated to the requested module. And for no good reason: all we want is the first DRM_NODE_PRIMARY (which is what drmOpen() also returns) to use by default.

For example on the "msm" driver, which used to be the 9th in the modules list, all nodes are opened for the 9th time before e.g. modetest returns a useful result, which takes ages unless the user painstakingly provides the module for the currently known device on the cmdline.

This is very simply solved by calling drmGetDevices(2)(), which iterates through all DRM nodes only once and allows us to immediately find + open() the first device that has a PRIMARY node. A random search for the error shows that this was also attempted in (a fork of?) kmscube: https://git.ti.com/cgit/glsdk/kmscube/commit/?id=456cabc661caac5c60729751d45efd668faa8e97

In the future we could extrapolate this feature by letting query commands like modetest -c list connectors for every device/module, not just the first PRIMARY node that we found.

Edited by Marijn Suijten

Merge request reports