aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_ringbuffer.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2017-11-10 09:26:33 -0500
committerChris Wilson <chris@chris-wilson.co.uk>2017-11-10 12:23:10 -0500
commitd2b4b97933f5adacfba42dc3b9200d0e21fbe2c4 (patch)
treeed930479bbd2f36b2f28997fc4f2ccb2f37824e3 /drivers/gpu/drm/i915/intel_ringbuffer.c
parentf4e15af7e21861445821d5f09922ef7e695269a1 (diff)
drm/i915: Record the default hw state after reset upon load
Take a copy of the HW state after a reset upon module loading by executing a context switch from a blank context to the kernel context, thus saving the default hw state over the blank context image. We can then use the default hw state to initialise any future context, ensuring that each starts with the default view of hw state. v2: Unmap our default state from the GTT after stealing it from the context. This should stop us from accidentally overwriting it via the GTT (and frees up some precious GTT space). Testcase: igt/gem_ctx_isolation Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20171110142634.10551-7-chris@chris-wilson.co.uk
Diffstat (limited to 'drivers/gpu/drm/i915/intel_ringbuffer.c')
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.c45
1 files changed, 33 insertions, 12 deletions
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 7e2a671882fb..464dc58af27b 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -1384,11 +1384,34 @@ alloc_context_vma(struct intel_engine_cs *engine)
1384 struct drm_i915_private *i915 = engine->i915; 1384 struct drm_i915_private *i915 = engine->i915;
1385 struct drm_i915_gem_object *obj; 1385 struct drm_i915_gem_object *obj;
1386 struct i915_vma *vma; 1386 struct i915_vma *vma;
1387 int err;
1387 1388
1388 obj = i915_gem_object_create(i915, engine->context_size); 1389 obj = i915_gem_object_create(i915, engine->context_size);
1389 if (IS_ERR(obj)) 1390 if (IS_ERR(obj))
1390 return ERR_CAST(obj); 1391 return ERR_CAST(obj);
1391 1392
1393 if (engine->default_state) {
1394 void *defaults, *vaddr;
1395
1396 vaddr = i915_gem_object_pin_map(obj, I915_MAP_WB);
1397 if (IS_ERR(vaddr)) {
1398 err = PTR_ERR(vaddr);
1399 goto err_obj;
1400 }
1401
1402 defaults = i915_gem_object_pin_map(engine->default_state,
1403 I915_MAP_WB);
1404 if (IS_ERR(defaults)) {
1405 err = PTR_ERR(defaults);
1406 goto err_map;
1407 }
1408
1409 memcpy(vaddr, defaults, engine->context_size);
1410
1411 i915_gem_object_unpin_map(engine->default_state);
1412 i915_gem_object_unpin_map(obj);
1413 }
1414
1392 /* 1415 /*
1393 * Try to make the context utilize L3 as well as LLC. 1416 * Try to make the context utilize L3 as well as LLC.
1394 * 1417 *
@@ -1410,10 +1433,18 @@ alloc_context_vma(struct intel_engine_cs *engine)
1410 } 1433 }
1411 1434
1412 vma = i915_vma_instance(obj, &i915->ggtt.base, NULL); 1435 vma = i915_vma_instance(obj, &i915->ggtt.base, NULL);
1413 if (IS_ERR(vma)) 1436 if (IS_ERR(vma)) {
1414 i915_gem_object_put(obj); 1437 err = PTR_ERR(vma);
1438 goto err_obj;
1439 }
1415 1440
1416 return vma; 1441 return vma;
1442
1443err_map:
1444 i915_gem_object_unpin_map(obj);
1445err_obj:
1446 i915_gem_object_put(obj);
1447 return ERR_PTR(err);
1417} 1448}
1418 1449
1419static struct intel_ring * 1450static struct intel_ring *
@@ -1449,16 +1480,6 @@ intel_ring_context_pin(struct intel_engine_cs *engine,
1449 ce->state->obj->pin_global++; 1480 ce->state->obj->pin_global++;
1450 } 1481 }
1451 1482
1452 /* The kernel context is only used as a placeholder for flushing the
1453 * active context. It is never used for submitting user rendering and
1454 * as such never requires the golden render context, and so we can skip
1455 * emitting it when we switch to the kernel context. This is required
1456 * as during eviction we cannot allocate and pin the renderstate in
1457 * order to initialise the context.
1458 */
1459 if (i915_gem_context_is_kernel(ctx))
1460 ce->initialised = true;
1461
1462 i915_gem_context_get(ctx); 1483 i915_gem_context_get(ctx);
1463 1484
1464out: 1485out: