diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2014-08-06 09:04:53 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2014-08-13 08:23:33 -0400 |
commit | ae6c4806927b8b0781ecc187aa16b10c820fc430 (patch) | |
tree | 259b85793ed699d01048377180a1a596c0f30d26 | |
parent | fa76da3499f1789f0e37d3bbcdc320bdf47c89ca (diff) |
drm/i915: Only track real ppgtt for a context
There's a bit a confusion since we track the global gtt,
the aliasing and real ppgtt in the ctx->vm pointer. And not
all callers really bother to check for the different cases and just
presume that it points to a real ppgtt.
Now looking closely we don't actually need ->vm to always point at an
address space - the only place that cares actually has fixup code
already to decide whether to look at the per-proces or the global
address space.
So switch to just tracking the ppgtt directly and ditch all the
extraneous code.
v2: Fixup the ppgtt debugfs file to not oops on a NULL ctx->ppgtt.
Also drop the early exit - without aliasing ppgtt we want to dump all
the ppgtts of the contexts if we have full ppgtt.
v3: Actually git add the compile fix.
Reviewed-by: Michel Thierry <michel.thierry@intel.com>
Cc: "Thierry, Michel" <michel.thierry@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
OTC-Jira: VIZ-3724
[danvet: Resolve conflicts with execlist patches while applying.]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r-- | drivers/gpu/drm/i915/i915_debugfs.c | 11 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_drv.h | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem_context.c | 33 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem_execbuffer.c | 5 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_gpu_error.c | 10 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_lrc.c | 2 |
6 files changed, 30 insertions, 34 deletions
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index 1c3a9943a742..d42db6bc34e0 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c | |||
@@ -1821,7 +1821,13 @@ static int per_file_ctx(int id, void *ptr, void *data) | |||
1821 | { | 1821 | { |
1822 | struct intel_context *ctx = ptr; | 1822 | struct intel_context *ctx = ptr; |
1823 | struct seq_file *m = data; | 1823 | struct seq_file *m = data; |
1824 | struct i915_hw_ppgtt *ppgtt = ctx_to_ppgtt(ctx); | 1824 | struct i915_hw_ppgtt *ppgtt = ctx->ppgtt; |
1825 | |||
1826 | if (!ppgtt) { | ||
1827 | seq_printf(m, " no ppgtt for context %d\n", | ||
1828 | ctx->user_handle); | ||
1829 | return 0; | ||
1830 | } | ||
1825 | 1831 | ||
1826 | if (i915_gem_context_is_default(ctx)) | 1832 | if (i915_gem_context_is_default(ctx)) |
1827 | seq_puts(m, " default context:\n"); | 1833 | seq_puts(m, " default context:\n"); |
@@ -1881,8 +1887,7 @@ static void gen6_ppgtt_info(struct seq_file *m, struct drm_device *dev) | |||
1881 | seq_printf(m, "pd gtt offset: 0x%08x\n", ppgtt->pd_offset); | 1887 | seq_printf(m, "pd gtt offset: 0x%08x\n", ppgtt->pd_offset); |
1882 | 1888 | ||
1883 | ppgtt->debug_dump(ppgtt, m); | 1889 | ppgtt->debug_dump(ppgtt, m); |
1884 | } else | 1890 | } |
1885 | return; | ||
1886 | 1891 | ||
1887 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { | 1892 | list_for_each_entry_reverse(file, &dev->filelist, lhead) { |
1888 | struct drm_i915_file_private *file_priv = file->driver_priv; | 1893 | struct drm_i915_file_private *file_priv = file->driver_priv; |
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 2db22732c7ae..eb99a109c0bc 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h | |||
@@ -624,7 +624,7 @@ struct intel_context { | |||
624 | uint8_t remap_slice; | 624 | uint8_t remap_slice; |
625 | struct drm_i915_file_private *file_priv; | 625 | struct drm_i915_file_private *file_priv; |
626 | struct i915_ctx_hang_stats hang_stats; | 626 | struct i915_ctx_hang_stats hang_stats; |
627 | struct i915_address_space *vm; | 627 | struct i915_hw_ppgtt *ppgtt; |
628 | 628 | ||
629 | /* Legacy ring buffer submission */ | 629 | /* Legacy ring buffer submission */ |
630 | struct { | 630 | struct { |
@@ -2556,7 +2556,6 @@ i915_gem_object_ggtt_unbind(struct drm_i915_gem_object *obj) | |||
2556 | void i915_gem_object_ggtt_unpin(struct drm_i915_gem_object *obj); | 2556 | void i915_gem_object_ggtt_unpin(struct drm_i915_gem_object *obj); |
2557 | 2557 | ||
2558 | /* i915_gem_context.c */ | 2558 | /* i915_gem_context.c */ |
2559 | #define ctx_to_ppgtt(ctx) container_of((ctx)->vm, struct i915_hw_ppgtt, base) | ||
2560 | int __must_check i915_gem_context_init(struct drm_device *dev); | 2559 | int __must_check i915_gem_context_init(struct drm_device *dev); |
2561 | void i915_gem_context_fini(struct drm_device *dev); | 2560 | void i915_gem_context_fini(struct drm_device *dev); |
2562 | void i915_gem_context_reset(struct drm_device *dev); | 2561 | void i915_gem_context_reset(struct drm_device *dev); |
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index 7093f5df9ee7..206bf2d6c554 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c | |||
@@ -135,19 +135,13 @@ static int get_context_size(struct drm_device *dev) | |||
135 | void i915_gem_context_free(struct kref *ctx_ref) | 135 | void i915_gem_context_free(struct kref *ctx_ref) |
136 | { | 136 | { |
137 | struct intel_context *ctx = container_of(ctx_ref, | 137 | struct intel_context *ctx = container_of(ctx_ref, |
138 | typeof(*ctx), ref); | 138 | typeof(*ctx), ref); |
139 | struct i915_hw_ppgtt *ppgtt = NULL; | ||
140 | 139 | ||
141 | if (i915.enable_execlists) { | 140 | if (i915.enable_execlists) |
142 | ppgtt = ctx_to_ppgtt(ctx); | ||
143 | intel_lr_context_free(ctx); | 141 | intel_lr_context_free(ctx); |
144 | } else if (ctx->legacy_hw_ctx.rcs_state) { | ||
145 | /* We refcount even the aliasing PPGTT to keep the code symmetric */ | ||
146 | if (USES_PPGTT(ctx->legacy_hw_ctx.rcs_state->base.dev)) | ||
147 | ppgtt = ctx_to_ppgtt(ctx); | ||
148 | } | ||
149 | 142 | ||
150 | i915_ppgtt_put(ppgtt); | 143 | i915_ppgtt_put(ctx->ppgtt); |
144 | |||
151 | if (ctx->legacy_hw_ctx.rcs_state) | 145 | if (ctx->legacy_hw_ctx.rcs_state) |
152 | drm_gem_object_unreference(&ctx->legacy_hw_ctx.rcs_state->base); | 146 | drm_gem_object_unreference(&ctx->legacy_hw_ctx.rcs_state->base); |
153 | list_del(&ctx->link); | 147 | list_del(&ctx->link); |
@@ -243,7 +237,6 @@ i915_gem_create_context(struct drm_device *dev, | |||
243 | bool create_vm) | 237 | bool create_vm) |
244 | { | 238 | { |
245 | const bool is_global_default_ctx = file_priv == NULL; | 239 | const bool is_global_default_ctx = file_priv == NULL; |
246 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
247 | struct intel_context *ctx; | 240 | struct intel_context *ctx; |
248 | int ret = 0; | 241 | int ret = 0; |
249 | 242 | ||
@@ -277,15 +270,10 @@ i915_gem_create_context(struct drm_device *dev, | |||
277 | PTR_ERR(ppgtt)); | 270 | PTR_ERR(ppgtt)); |
278 | ret = PTR_ERR(ppgtt); | 271 | ret = PTR_ERR(ppgtt); |
279 | goto err_unpin; | 272 | goto err_unpin; |
280 | } else | 273 | } |
281 | ctx->vm = &ppgtt->base; | 274 | |
282 | } else if (USES_PPGTT(dev)) { | 275 | ctx->ppgtt = ppgtt; |
283 | /* For platforms which only have aliasing PPGTT, we fake the | 276 | } |
284 | * address space and refcounting. */ | ||
285 | ctx->vm = &dev_priv->mm.aliasing_ppgtt->base; | ||
286 | i915_ppgtt_get(dev_priv->mm.aliasing_ppgtt); | ||
287 | } else | ||
288 | ctx->vm = &dev_priv->gtt.base; | ||
289 | 277 | ||
290 | return ctx; | 278 | return ctx; |
291 | 279 | ||
@@ -543,7 +531,6 @@ static int do_switch(struct intel_engine_cs *ring, | |||
543 | { | 531 | { |
544 | struct drm_i915_private *dev_priv = ring->dev->dev_private; | 532 | struct drm_i915_private *dev_priv = ring->dev->dev_private; |
545 | struct intel_context *from = ring->last_context; | 533 | struct intel_context *from = ring->last_context; |
546 | struct i915_hw_ppgtt *ppgtt = ctx_to_ppgtt(to); | ||
547 | u32 hw_flags = 0; | 534 | u32 hw_flags = 0; |
548 | bool uninitialized = false; | 535 | bool uninitialized = false; |
549 | int ret, i; | 536 | int ret, i; |
@@ -571,8 +558,8 @@ static int do_switch(struct intel_engine_cs *ring, | |||
571 | */ | 558 | */ |
572 | from = ring->last_context; | 559 | from = ring->last_context; |
573 | 560 | ||
574 | if (USES_FULL_PPGTT(ring->dev)) { | 561 | if (to->ppgtt) { |
575 | ret = ppgtt->switch_mm(ppgtt, ring, false); | 562 | ret = to->ppgtt->switch_mm(to->ppgtt, ring, false); |
576 | if (ret) | 563 | if (ret) |
577 | goto unpin_out; | 564 | goto unpin_out; |
578 | } | 565 | } |
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c index 7e04a4825ed0..1a0611bb576b 100644 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c | |||
@@ -1315,8 +1315,9 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, | |||
1315 | 1315 | ||
1316 | i915_gem_context_reference(ctx); | 1316 | i915_gem_context_reference(ctx); |
1317 | 1317 | ||
1318 | vm = ctx->vm; | 1318 | if (ctx->ppgtt) |
1319 | if (!USES_FULL_PPGTT(dev)) | 1319 | vm = &ctx->ppgtt->base; |
1320 | else | ||
1320 | vm = &dev_priv->gtt.base; | 1321 | vm = &dev_priv->gtt.base; |
1321 | 1322 | ||
1322 | eb = eb_create(args); | 1323 | eb = eb_create(args); |
diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c index eab41f9390f8..fc11ac6b0373 100644 --- a/drivers/gpu/drm/i915/i915_gpu_error.c +++ b/drivers/gpu/drm/i915/i915_gpu_error.c | |||
@@ -967,6 +967,12 @@ static void i915_gem_record_rings(struct drm_device *dev, | |||
967 | 967 | ||
968 | request = i915_gem_find_active_request(ring); | 968 | request = i915_gem_find_active_request(ring); |
969 | if (request) { | 969 | if (request) { |
970 | struct i915_address_space *vm; | ||
971 | |||
972 | vm = request->ctx && request->ctx->ppgtt ? | ||
973 | &request->ctx->ppgtt->base : | ||
974 | &dev_priv->gtt.base; | ||
975 | |||
970 | /* We need to copy these to an anonymous buffer | 976 | /* We need to copy these to an anonymous buffer |
971 | * as the simplest method to avoid being overwritten | 977 | * as the simplest method to avoid being overwritten |
972 | * by userspace. | 978 | * by userspace. |
@@ -974,9 +980,7 @@ static void i915_gem_record_rings(struct drm_device *dev, | |||
974 | error->ring[i].batchbuffer = | 980 | error->ring[i].batchbuffer = |
975 | i915_error_object_create(dev_priv, | 981 | i915_error_object_create(dev_priv, |
976 | request->batch_obj, | 982 | request->batch_obj, |
977 | request->ctx ? | 983 | vm); |
978 | request->ctx->vm : | ||
979 | &dev_priv->gtt.base); | ||
980 | 984 | ||
981 | if (HAS_BROKEN_CS_TLB(dev_priv->dev) && | 985 | if (HAS_BROKEN_CS_TLB(dev_priv->dev) && |
982 | ring->scratch.obj) | 986 | ring->scratch.obj) |
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c index 6f1b64e01a05..6b5f416b5c0d 100644 --- a/drivers/gpu/drm/i915/intel_lrc.c +++ b/drivers/gpu/drm/i915/intel_lrc.c | |||
@@ -904,7 +904,7 @@ populate_lr_context(struct intel_context *ctx, struct drm_i915_gem_object *ctx_o | |||
904 | struct intel_engine_cs *ring, struct intel_ringbuffer *ringbuf) | 904 | struct intel_engine_cs *ring, struct intel_ringbuffer *ringbuf) |
905 | { | 905 | { |
906 | struct drm_i915_gem_object *ring_obj = ringbuf->obj; | 906 | struct drm_i915_gem_object *ring_obj = ringbuf->obj; |
907 | struct i915_hw_ppgtt *ppgtt = ctx_to_ppgtt(ctx); | 907 | struct i915_hw_ppgtt *ppgtt = ctx->ppgtt; |
908 | struct page *page; | 908 | struct page *page; |
909 | uint32_t *reg_state; | 909 | uint32_t *reg_state; |
910 | int ret; | 910 | int ret; |