From a4f13a3268c3f641a123eb1113fcd6c15a0b3363 Mon Sep 17 00:00:00 2001 From: Mika Kahola Date: Thu, 16 Feb 2017 11:20:45 +0200 Subject: [PATCH] lib/igt_kms: Fix regression on kms_plane_lowres test kms_plane_lowres subtest pipe-C-tiling-none crashes when reading out number of crtc. This patch fixes the bug on crtc readout. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99653 Fixes: 9de635976c426b4c835083792c7d4d6e32aec615 ("lib/igt_kms: Avoid depencency on static plane count") Signed-off-by: Mika Kahola --- lib/igt_kms.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index dae8bf9..5388a83 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -1331,6 +1331,7 @@ void kmstest_get_crtc(enum pipe pipe, struct kmstest_crtc *crtc) const char *mode = "r"; int ncrtc; int line; + long int n; fid = igt_debugfs_fopen("i915_display_info", mode); @@ -1344,18 +1345,21 @@ void kmstest_get_crtc(enum pipe pipe, struct kmstest_crtc *crtc) crtc->active = true; parse_crtc(tmp, crtc); + n = ftell(fid); crtc->n_planes = parse_planes(fid, NULL); crtc->planes = calloc(crtc->n_planes, sizeof(*crtc->planes)); igt_assert_f(crtc->planes, "Failed to allocate memory for %d planes\n", crtc->n_planes); - fseek(fid, 0, SEEK_END); - fseek(fid, 0, SEEK_SET); + fseek(fid, n, SEEK_SET); parse_planes(fid, crtc->planes); - if (crtc->pipe != pipe) - crtc = NULL; - else + if (crtc->pipe != pipe) { + free(crtc->planes); + } + else { ncrtc++; + break; + } } } -- 2.7.4