diff mbox

[11/16] drm/i915/execlists: Request the kernel context be pinned high

Message ID 20161207135833.32740-12-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson Dec. 7, 2016, 1:58 p.m. UTC
PIN_HIGH is an expensive operation (in comparison to allocating from the
hole stack) unsuitable for frequent use (such as switching between
contexts). However, the kernel context should be pinned just once for
the lifetime of the driver, and here it is appropriate to keep it out of
the mappable range (in order to maximise mappable space for users).

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/intel_lrc.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Tvrtko Ursulin Dec. 9, 2016, 3:08 p.m. UTC | #1
On 07/12/2016 13:58, Chris Wilson wrote:
> PIN_HIGH is an expensive operation (in comparison to allocating from the
> hole stack) unsuitable for frequent use (such as switching between
> contexts). However, the kernel context should be pinned just once for
> the lifetime of the driver, and here it is appropriate to keep it out of
> the mappable range (in order to maximise mappable space for users).
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/intel_lrc.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
> index 58cea1f9ad27..22ded92d0346 100644
> --- a/drivers/gpu/drm/i915/intel_lrc.c
> +++ b/drivers/gpu/drm/i915/intel_lrc.c
> @@ -767,6 +767,7 @@ static int execlists_context_pin(struct intel_engine_cs *engine,
>  				 struct i915_gem_context *ctx)
>  {
>  	struct intel_context *ce = &ctx->engine[engine->id];
> +	unsigned int flags;
>  	void *vaddr;
>  	int ret;
>
> @@ -781,8 +782,11 @@ static int execlists_context_pin(struct intel_engine_cs *engine,
>  			goto err;
>  	}
>
> -	ret = i915_vma_pin(ce->state, 0, GEN8_LR_CONTEXT_ALIGN,
> -			   PIN_OFFSET_BIAS | GUC_WOPCM_TOP | PIN_GLOBAL);
> +	flags = PIN_OFFSET_BIAS | GUC_WOPCM_TOP | PIN_GLOBAL;
> +	if (ctx == ctx->i915->kernel_context)
> +		flags |= PIN_HIGH;
> +
> +	ret = i915_vma_pin(ce->state, 0, GEN8_LR_CONTEXT_ALIGN, flags);
>  	if (ret)
>  		goto err;
>
>

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

Tvrtko
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 58cea1f9ad27..22ded92d0346 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -767,6 +767,7 @@  static int execlists_context_pin(struct intel_engine_cs *engine,
 				 struct i915_gem_context *ctx)
 {
 	struct intel_context *ce = &ctx->engine[engine->id];
+	unsigned int flags;
 	void *vaddr;
 	int ret;
 
@@ -781,8 +782,11 @@  static int execlists_context_pin(struct intel_engine_cs *engine,
 			goto err;
 	}
 
-	ret = i915_vma_pin(ce->state, 0, GEN8_LR_CONTEXT_ALIGN,
-			   PIN_OFFSET_BIAS | GUC_WOPCM_TOP | PIN_GLOBAL);
+	flags = PIN_OFFSET_BIAS | GUC_WOPCM_TOP | PIN_GLOBAL;
+	if (ctx == ctx->i915->kernel_context)
+		flags |= PIN_HIGH;
+
+	ret = i915_vma_pin(ce->state, 0, GEN8_LR_CONTEXT_ALIGN, flags);
 	if (ret)
 		goto err;