* [PATCH i-g-t] igt_kms: Dynamically allocate igt_display->pipes
@ 2016-12-12 20:50 Lyude
2016-12-13 5:20 ` Abdiel Janulgue
0 siblings, 1 reply; 3+ messages in thread
From: Lyude @ 2016-12-12 20:50 UTC (permalink / raw)
To: intel-gfx; +Cc: 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.
Signed-off-by: Lyude <lyude@redhat.com>
---
lib/igt_kms.c | 2 ++
lib/igt_kms.h | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 7d906c2..f3927fc 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -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;
}
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index dadbcdd..bb36424 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -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;
};
--
2.9.3
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH i-g-t] igt_kms: Dynamically allocate igt_display->pipes
2016-12-12 20:50 [PATCH i-g-t] igt_kms: Dynamically allocate igt_display->pipes Lyude
@ 2016-12-13 5:20 ` Abdiel Janulgue
2016-12-13 16:48 ` Lyude Paul
0 siblings, 1 reply; 3+ messages in thread
From: Abdiel Janulgue @ 2016-12-13 5:20 UTC (permalink / raw)
To: Lyude, intel-gfx
On 12.12.2016 22:50, Lyude wrote:
> 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.
>
> Signed-off-by: Lyude <lyude@redhat.com>
Reviewed-by: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
> ---
> lib/igt_kms.c | 2 ++
> lib/igt_kms.h | 2 +-
> 2 files changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index 7d906c2..f3927fc 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -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;
> }
>
> diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> index dadbcdd..bb36424 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -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
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH i-g-t] igt_kms: Dynamically allocate igt_display->pipes
2016-12-13 5:20 ` Abdiel Janulgue
@ 2016-12-13 16:48 ` Lyude Paul
0 siblings, 0 replies; 3+ messages in thread
From: Lyude Paul @ 2016-12-13 16:48 UTC (permalink / raw)
To: Abdiel Janulgue, intel-gfx
Pushed, thanks
On Tue, 2016-12-13 at 07:20 +0200, Abdiel Janulgue wrote:
>
> On 12.12.2016 22:50, Lyude wrote:
> > 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.
> >
> > Signed-off-by: Lyude <lyude@redhat.com>
>
> Reviewed-by: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
>
> > ---
> > lib/igt_kms.c | 2 ++
> > lib/igt_kms.h | 2 +-
> > 2 files changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> > index 7d906c2..f3927fc 100644
> > --- a/lib/igt_kms.c
> > +++ b/lib/igt_kms.c
> > @@ -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;
> > }
> >
> > diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> > index dadbcdd..bb36424 100644
> > --- a/lib/igt_kms.h
> > +++ b/lib/igt_kms.h
> > @@ -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
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-12-13 16:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-12 20:50 [PATCH i-g-t] igt_kms: Dynamically allocate igt_display->pipes Lyude
2016-12-13 5:20 ` Abdiel Janulgue
2016-12-13 16:48 ` Lyude Paul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox