[Mesa-dev] [PATCH v2 3/4] i965: Pass the EGL/DRI context priority through to the kernel

Emil Velikov emil.l.velikov at gmail.com
Wed Apr 12 13:47:06 UTC 2017


Hi Chris,

On 11 April 2017 at 17:11, Chris Wilson <chris at chris-wilson.co.uk> wrote:
> Decode the EGL/DRI priority enum into the [-1023, 1023] range as
> interpreted by the kernel and call DRM_I915_GEM_CONTEXT_SETPARAM to
> adjust the priority. We use 0 as the default medium priority (also the
> kernel default) and so only need adjust up or down. By only doing the
> adjustment if not setting to medium, we can faithfully report any error
> whilst setting without worrying about kernel version.
>
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/mesa/drivers/dri/i965/brw_bufmgr.c  | 22 ++++++++++++++++++++++
>  src/mesa/drivers/dri/i965/brw_bufmgr.h  |  3 +++
>  src/mesa/drivers/dri/i965/brw_context.c | 13 +++++++++++++
>  3 files changed, 38 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c b/src/mesa/drivers/dri/i965/brw_bufmgr.c
> index 1c5ad2467a..ec00ba5af3 100644
> --- a/src/mesa/drivers/dri/i965/brw_bufmgr.c
> +++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c
> @@ -1205,6 +1205,28 @@ brw_create_hw_context(struct brw_bufmgr *bufmgr)
>     return create.ctx_id;
>  }
>
> +int brw_hw_context_set_priority(struct brw_bufmgr *bufmgr,
> +                                uint32_t ctx_id,
> +                                int priority)
> +{
> +#ifdef I915_CONTEXT_PARAM_PRIORITY

Do we have the kernel parts in-tree? If not - consider this an Ack
from my end (FWIW) and let's merge those.
Once that is in, add a fall-back define here. The current ifdef code is iffy.

Think about: build server with old headers, while running the compiled
code on a capable kernel.


> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -1102,6 +1102,19 @@ brwCreateContext(gl_api api,
>           intelDestroyContext(driContextPriv);
>           return false;
>        }
> +
> +      int hw_priority = 0;
> +      switch (priority) {
> +      case __DRI_CTX_PRIORITY_LOW: hw_priority = -1023/2; break;
> +      case __DRI_CTX_PRIORITY_HIGH: hw_priority = 1023/2; break;
Nit: a define for +/-1023 and a comment where it comes from (alongside
"/2") would be great.

Thanks
Emil


More information about the mesa-dev mailing list