Commit 519003ca authored by Chris Wilson's avatar Chris Wilson Committed by Arkadiusz Hiler

igt: Check drmModeGetResources()

If KMS is not supported on the device, drmModeGetResources() will return
NULL, often this is an indication that we should not attempt to run the
test. Although it would be preferred to use something like
igt_require_display() as the canonical check and assert that
drmModeGetResources() did not hit an error, it is not always practical
as the tests do not utilize the common igt_display abstraction.
Signed-off-by: Chris Wilson's avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Arkadiusz Hiler's avatarArkadiusz Hiler <arkadiusz.hiler@intel.com>
parent 596f48dc
......@@ -280,7 +280,7 @@ static void headless(int fd, uint32_t handle)
double n_display, n_headless;
res = drmModeGetResources(fd);
igt_assert(res);
igt_require(res);
/* require at least one connected connector for the test */
for (int i = 0; i < res->count_connectors; i++) {
......
......@@ -36,7 +36,9 @@ igt_simple_main
int mode_count, connector_id;
drm_fd = drm_open_driver_master(DRIVER_INTEL);
res = drmModeGetResources(drm_fd);
igt_require(res);
igt_assert(drmSetClientCap(drm_fd, DRM_CLIENT_CAP_STEREO_3D, 1) >= 0);
......
......@@ -420,7 +420,7 @@ prepare_output(data_t *data,
enum pipe pipe;
bool found = false;
igt_assert(res = drmModeGetResources(data->drm_fd));
igt_require(res = drmModeGetResources(data->drm_fd));
/* The chamelium's default EDID has a lot of resolutions, way more then
* we need to test
......
......@@ -254,6 +254,7 @@ static void setup_environment(void)
igt_require(drm_fd >= 0);
drm_res = drmModeGetResources(drm_fd);
igt_require(drm_res);
igt_assert(drm_res->count_connectors <= MAX_CONNECTORS);
for (i = 0; i < drm_res->count_connectors; i++)
......
......@@ -63,6 +63,7 @@ static void setup_drm(struct drm_info *drm)
drm->debugfs_fd = igt_debugfs_dir(drm->fd);
drm->res = drmModeGetResources(drm->fd);
igt_require(drm->res);
igt_assert(drm->res->count_connectors <= MAX_CONNECTORS);
for (i = 0; i < drm->res->count_connectors; i++)
......
......@@ -1355,7 +1355,7 @@ static int run_test(int duration, int flags)
igt_require(igt_setup_runtime_pm());
resources = drmModeGetResources(drm_fd);
igt_assert(resources);
igt_require(resources);
/* Count output configurations to scale test runtime. */
for (i = 0; i < resources->count_connectors; i++) {
......@@ -1412,7 +1412,7 @@ static int run_pair(int duration, int flags)
igt_require((flags & TEST_HANG) == 0 || !is_wedged(drm_fd));
resources = drmModeGetResources(drm_fd);
igt_assert(resources);
igt_require(resources);
/* Find a pair of connected displays */
for (i = 0; i < resources->count_connectors; i++) {
......
......@@ -89,8 +89,9 @@ int main(int argc, char **argv)
unsigned vga_connector_id = 0;
drm_fd = drm_open_driver_master(DRIVER_INTEL);
res = drmModeGetResources(drm_fd);
igt_assert(res);
igt_require(res);
/* find the vga connector */
for (int i = 0; i < res->count_connectors; i++) {
......
......@@ -254,7 +254,9 @@ igt_main
igt_fixture {
drm_fd = drm_open_driver_master(DRIVER_INTEL);
res = drmModeGetResources(drm_fd);
igt_require(res);
connector = get_connector(drm_fd, res);
igt_require(connector);
......
......@@ -133,8 +133,11 @@ igt_simple_main
igt_enable_connectors(data.drm_fd);
kmstest_set_vt_graphics_mode();
igt_display_require(&data.display, data.drm_fd);
data.res = drmModeGetResources(data.drm_fd);
igt_assert(data.res);
kmstest_unset_all_crtcs(data.drm_fd, data.res);
data.max_dotclock = i915_max_dotclock(&data);
......
......@@ -858,7 +858,7 @@ int main(int argc, char **argv)
kmstest_set_vt_graphics_mode();
drm_resources = drmModeGetResources(drm_fd);
igt_assert(drm_resources);
igt_require(drm_resources);
}
for (i = 0; i < ARRAY_SIZE(tests); i++) {
......
......@@ -37,8 +37,9 @@ int main(int argc, char **argv)
igt_fixture {
drm_fd = drm_open_driver_master(DRIVER_INTEL);
res = drmModeGetResources(drm_fd);
igt_assert(res);
igt_require(res);
/* find the TV connector */
for (int i = 0; i < res->count_connectors; i++) {
......
......@@ -333,6 +333,7 @@ sanity_test_init(sanity_test_t *test, igt_output_t *output, enum pipe pipe)
&test->undersized_fb);
test->moderes = drmModeGetResources(data->drm_fd);
igt_assert(test->moderes);
}
static void
......
......@@ -1398,7 +1398,7 @@ test_rc6(int gem_fd, unsigned int flags)
drmModeRes *res;
res = drmModeGetResources(gem_fd);
igt_assert(res);
igt_require(res);
/* force all connectors off */
kmstest_set_vt_graphics_mode();
......
......@@ -199,6 +199,7 @@ igt_main
devid = intel_get_drm_devid(drm_fd);
drm_res = drmModeGetResources(drm_fd);
igt_require(drm_res);
igt_assert(drm_res->count_connectors <= MAX_CONNECTORS);
for (i = 0; i < drm_res->count_connectors; i++)
......
......@@ -156,12 +156,15 @@ static void dump_connectors_fd(int drmfd)
static void dump_crtcs_fd(int drmfd)
{
int i;
drmModeRes *mode_resources = drmModeGetResources(drmfd);
drmModeRes *mode_resources;
mode_resources = drmModeGetResources(drmfd);
if (!mode_resources)
return;
igt_info("CRTCs:\n");
igt_info("id\tfb\tpos\tsize\n");
for (i = 0; i < mode_resources->count_crtcs; i++) {
for (int i = 0; i < mode_resources->count_crtcs; i++) {
drmModeCrtc *crtc;
crtc = drmModeGetCrtc(drmfd, mode_resources->crtcs[i]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment