aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_lrc.c
diff options
context:
space:
mode:
authorOscar Mateo <oscar.mateo@intel.com>2014-07-24 12:04:14 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-08-11 10:08:18 -0400
commit8c8579176a144b1dca1d99ebb92510924168d508 (patch)
tree7c3cfe6343d3d977b1e0c302b0176bedb5c77eed /drivers/gpu/drm/i915/intel_lrc.c
parentc9e003af2d44d9f6eafe855448c41c9ac08ae895 (diff)
drm/i915/bdw: A bit more advanced LR context alloc/free
Now that we have the ability to allocate our own context backing objects and we have multiplexed one of them per engine inside the context structs, we can finally allocate and free them correctly. Regarding the context size, reading the register to calculate the sizes can work, I think, however the docs are very clear about the actual context sizes on GEN8, so just hardcode that and use it. v2: Rebased on top of the Full PPGTT series. It is important to notice that at this point we have one global default context per engine, all of them using the aliasing PPGTT (as opposed to the single global default context we have with legacy HW contexts). v3: - Go back to one single global default context, this time with multiple backing objects inside. - Use different context sizes for non-render engines, as suggested by Damien (still hardcoded, since the information about the context size registers in the BSpec is, well, *lacking*). - Render ctx size is 20 (or 19) pages, but not 21 (caught by Damien). - Move default context backing object creation to intel_init_ring (so that we don't waste memory in rings that might not get initialized). v4: - Reuse the HW legacy context init/fini. - Create a separate free function. - Rename the functions with an intel_ preffix. v5: Several rebases to account for the changes in the previous patches. Signed-off-by: Ben Widawsky <ben@bwidawsk.net> (v1) Signed-off-by: Oscar Mateo <oscar.mateo@intel.com> Reviewed-by: Damien Lespiau <damien.lespiau@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_lrc.c')
-rw-r--r--drivers/gpu/drm/i915/intel_lrc.c59
1 files changed, 57 insertions, 2 deletions
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 2d82d52d18bb..9f30ee80e487 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -41,6 +41,11 @@
41#include <drm/i915_drm.h> 41#include <drm/i915_drm.h>
42#include "i915_drv.h" 42#include "i915_drv.h"
43 43
44#define GEN8_LR_CONTEXT_RENDER_SIZE (20 * PAGE_SIZE)
45#define GEN8_LR_CONTEXT_OTHER_SIZE (2 * PAGE_SIZE)
46
47#define GEN8_LR_CONTEXT_ALIGN 4096
48
44int intel_sanitize_enable_execlists(struct drm_device *dev, int enable_execlists) 49int intel_sanitize_enable_execlists(struct drm_device *dev, int enable_execlists)
45{ 50{
46 WARN_ON(i915.enable_ppgtt == -1); 51 WARN_ON(i915.enable_ppgtt == -1);
@@ -56,15 +61,65 @@ int intel_sanitize_enable_execlists(struct drm_device *dev, int enable_execlists
56 61
57void intel_lr_context_free(struct intel_context *ctx) 62void intel_lr_context_free(struct intel_context *ctx)
58{ 63{
59 /* TODO */ 64 int i;
65
66 for (i = 0; i < I915_NUM_RINGS; i++) {
67 struct drm_i915_gem_object *ctx_obj = ctx->engine[i].state;
68 if (ctx_obj) {
69 i915_gem_object_ggtt_unpin(ctx_obj);
70 drm_gem_object_unreference(&ctx_obj->base);
71 }
72 }
73}
74
75static uint32_t get_lr_context_size(struct intel_engine_cs *ring)
76{
77 int ret = 0;
78
79 WARN_ON(INTEL_INFO(ring->dev)->gen != 8);
80
81 switch (ring->id) {
82 case RCS:
83 ret = GEN8_LR_CONTEXT_RENDER_SIZE;
84 break;
85 case VCS:
86 case BCS:
87 case VECS:
88 case VCS2:
89 ret = GEN8_LR_CONTEXT_OTHER_SIZE;
90 break;
91 }
92
93 return ret;
60} 94}
61 95
62int intel_lr_context_deferred_create(struct intel_context *ctx, 96int intel_lr_context_deferred_create(struct intel_context *ctx,
63 struct intel_engine_cs *ring) 97 struct intel_engine_cs *ring)
64{ 98{
99 struct drm_device *dev = ring->dev;
100 struct drm_i915_gem_object *ctx_obj;
101 uint32_t context_size;
102 int ret;
103
65 WARN_ON(ctx->legacy_hw_ctx.rcs_state != NULL); 104 WARN_ON(ctx->legacy_hw_ctx.rcs_state != NULL);
66 105
67 /* TODO */ 106 context_size = round_up(get_lr_context_size(ring), 4096);
107
108 ctx_obj = i915_gem_alloc_context_obj(dev, context_size);
109 if (IS_ERR(ctx_obj)) {
110 ret = PTR_ERR(ctx_obj);
111 DRM_DEBUG_DRIVER("Alloc LRC backing obj failed: %d\n", ret);
112 return ret;
113 }
114
115 ret = i915_gem_obj_ggtt_pin(ctx_obj, GEN8_LR_CONTEXT_ALIGN, 0);
116 if (ret) {
117 DRM_DEBUG_DRIVER("Pin LRC backing obj failed: %d\n", ret);
118 drm_gem_object_unreference(&ctx_obj->base);
119 return ret;
120 }
121
122 ctx->engine[ring->id].state = ctx_obj;
68 123
69 return 0; 124 return 0;
70} 125}