Skip to contentSkip to conversation

igt_kms: Dynamically allocate igt_display->pipes

PATCH In review Lyude 2 participants 3 messages Dec 12, 2016 – Dec 13, 2016 Library code

lore
Share & tools
lore

Lyude

author
#0 lore raw

PATCH 1/1 igt_kms: Dynamically allocate igt_display->pipes

Many GPUs have more then 3 pipes available, so hard limiting this to I915_MAX_PIPES prevents us from using anything that relies on igt_display_init() on non-intel systems (since we end up writing out of bounds and seg faulting). Fix this by dynamically allocating igt_display->pipes using the number of pipes we've detected on the GPU.

---
 lib/igt_kms.c | 2 ++
 lib/igt_kms.h | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
lib/igt_kms.c +2 -0
index 7d906c2..f3927fc 100644
@@ -1349,6 +1349,7 @@ void igt_display_init(igt_display_t *display, int drm_fd)
 	 * hardware and cannot change of time (for now, at least).
 	 */
 	display->n_pipes = resources->count_crtcs;
+	display->pipes = calloc(sizeof(igt_pipe_t), display->n_pipes);
 
 	drmSetClientCap(drm_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
 	is_atomic = drmSetClientCap(drm_fd, DRM_CLIENT_CAP_ATOMIC, 1);
@@ -1561,6 +1562,7 @@ void igt_display_fini(igt_display_t *display)
 	for (i = 0; i < display->n_outputs; i++)
 		igt_output_fini(&display->outputs[i]);
 	free(display->outputs);
+	free(display->pipes);
 	display->outputs = NULL;
 }
 
lib/igt_kms.h +1 -1
index dadbcdd..bb36424 100644
@@ -310,7 +310,7 @@ struct igt_display {
 	int n_outputs;
 	unsigned long pipes_in_use;
 	igt_output_t *outputs;
-	igt_pipe_t pipes[I915_MAX_PIPES];
+	igt_pipe_t *pipes;
 	bool has_cursor_plane;
 	bool is_atomic;
 };
Signature · 6 lines
2.9.3

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

Many GPUs have more then 3 pipes available, so hard limiting this to I915_MAX_PIPES prevents us from using anything that relies on igt_display_init() on non-intel systems (since we end up writing out of bounds and seg faulting). Fix this by dynamically allocating igt_display->pipes using the number of pipes we've detected on the GPU.

Quoted 31 lines
---
 lib/igt_kms.c | 2 ++
 lib/igt_kms.h | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
lib/igt_kms.c +2 -0
index 7d906c2..f3927fc 100644
@@ -1349,6 +1349,7 @@ void igt_display_init(igt_display_t *display, int drm_fd)
 	 * hardware and cannot change of time (for now, at least).
 	 */
 	display->n_pipes = resources->count_crtcs;
+	display->pipes = calloc(sizeof(igt_pipe_t), display->n_pipes);
 
 	drmSetClientCap(drm_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
 	is_atomic = drmSetClientCap(drm_fd, DRM_CLIENT_CAP_ATOMIC, 1);
@@ -1561,6 +1562,7 @@ void igt_display_fini(igt_display_t *display)
 	for (i = 0; i < display->n_outputs; i++)
 		igt_output_fini(&display->outputs[i]);
 	free(display->outputs);
+	free(display->pipes);
 	display->outputs = NULL;
 }
 
lib/igt_kms.h +0 -0
index dadbcdd..bb36424 100644

lib/igt_kms.h struct igt_display { · line 316

Quoted 8 lines
lib/igt_kms.h +1 -1
@@ -310,7 +310,7 @@ struct igt_display {
 	int n_outputs;
 	unsigned long pipes_in_use;
 	igt_output_t *outputs;
-	igt_pipe_t pipes[I915_MAX_PIPES];
+	igt_pipe_t *pipes;
 	bool has_cursor_plane;
 	bool is_atomic;
 };

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

author
#2 lore raw

Pushed, thanks

Quoted 50 lines · Abdiel Janulgue
Quoted 10 lines · Lyude

Many GPUs have more then 3 pipes available, so hard limiting this to
I915_MAX_PIPES prevents us from using anything that relies on igt_display_init() on non-intel systems (since we end up writing out of
bounds and seg faulting). Fix this by dynamically allocating igt_display->pipes using the number of pipes we've detected on the GPU.

Quoted 35 lines

---
 lib/igt_kms.c | 2 ++
 lib/igt_kms.h | 2 +-

 2 files changed, 3 insertions(+), 1 deletion(-)
lib/igt_kms.c +1 -0
index 7d906c2..f3927fc 100644
@@ -1349,6 +1349,7 @@ void igt_display_init(igt_display_t *display,
 int drm_fd)
  	 * hardware and cannot change of time (for now, at least).
  	 */
  	display->n_pipes = resources->count_crtcs;
+	display->pipes = calloc(sizeof(igt_pipe_t), display-
 >n_pipes);


  drmSetClientCap(drm_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
  is_atomic = drmSetClientCap(drm_fd, DRM_CLIENT_CAP_ATOMIC, 1);

lib/igt_kms.c +1 -0
@@ -1561,6 +1562,7 @@ void igt_display_fini(igt_display_t *display)
  	for (i = 0; i < display->n_outputs; i++)
  		igt_output_fini(&display->outputs[i]);
  	free(display->outputs);
+	free(display->pipes);
  	display->outputs = NULL;
  }

lib/igt_kms.h +0 -0
index dadbcdd..bb36424 100644
@@ -310,7 +310,7 @@ struct igt_display {
  	int n_outputs;
Quoted 8 lines

lib/igt_kms.h struct igt_display { · line 316

Quoted 8 lines
lib/igt_kms.h +1 -1
  	unsigned long pipes_in_use;
  	igt_output_t *outputs;
-	igt_pipe_t pipes[I915_MAX_PIPES];
+	igt_pipe_t *pipes;
  	bool has_cursor_plane;
  	bool is_atomic;
  };

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