Skip to contentSkip to conversation

lib/igt_kms: Fix regression on kms_plane_lowres test

PATCH In review Mika Kahola 2 participants 2 messages Feb 16, 2017 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")

---
 lib/igt_kms.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
lib/igt_kms.c +8 -5
index dae8bf9..5388a83 100644
@@ -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 +1342,20 @@ 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;
+				}
 			}
 		}
 
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 1/1
#1 lore raw

Applied and tested patch.

Quoted 41 lines · Mika Kahola

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")

---
 lib/igt_kms.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
lib/igt_kms.c +3 -4
index dae8bf9..5388a83 100644
@@ -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 +1342,20 @@ 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;

lib/igt_kms.c void kmstest_get_crtc(enum pipe pipe, struct kmstest_crtc *crtc) · line 1361

Quoted 10 lines
lib/igt_kms.c +5 -1
-				else
+				if (crtc->pipe != pipe) {
+					free(crtc->planes);
+				} else {
 					ncrtc++;
+					break;
+				}
 			}
 		}
 

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx