Misc cleanups and locking fixes
Subsystems (2)
v2 cover Misc cleanups and locking fixes
From: Tvrtko Ursulin <[email protected]>
Random cleanups from yesterday mutated into a bit of locking verification and fixing as suggested by Daniel Vetter.
Replacig list_for_each_entry with a dedicated i915_gem_obj_for_each_vma which asserts the struct_mutex uncovered a few holes, not all of which (atomic display are being fixed in this series).
I've also added the same assert to i915_gem_object_get_page since it sounds correct to me to require it although I have not analysed all callsites. Some might assume they know what they are doing so the approach might be too drastic, but one like execlist is fixed in this series.
Tvrtko Ursulin (13):
drm/i915/bdw+: Replace list_del+list_add_tail with list_move_tail drm/i915: Don't need a timer to wake us up
drm/i915: Avoid invariant conditionals in lrc interrupt handler drm/i915: Fail engine initialization if LRCA is incorrectly aligned drm/i915: Cache LRCA in the context
drm/i915: Only grab timestamps when needed
drm/i915: Introduce dedicated object VMA iterator drm/i915: GEM operations need to be done under the big lock drm/i915: Remove two impossible asserts
drm/i915: Introduce dedicated safe object VMA iterator drm/i915: Cache ringbuffer GTT address
drm/i915: Add BKL asserts to get page helpers
drm/i915: Cache LRC state page in the context
drivers/gpu/drm/i915/i915_debugfs.c | 23 +++--- drivers/gpu/drm/i915/i915_drv.h | 17 +++++ drivers/gpu/drm/i915/i915_gem.c | 72 ++++++++---------- drivers/gpu/drm/i915/i915_gem_gtt.c | 2 +- drivers/gpu/drm/i915/i915_gem_shrinker.c | 5 +- drivers/gpu/drm/i915/i915_gem_stolen.c | 5 ++ drivers/gpu/drm/i915/i915_gem_userptr.c | 2 +- drivers/gpu/drm/i915/i915_gpu_error.c | 4 +- drivers/gpu/drm/i915/intel_lrc.c | 122 ++++++++++++++++--------------- drivers/gpu/drm/i915/intel_lrc.h | 3 +- drivers/gpu/drm/i915/intel_ringbuffer.c | 3 + drivers/gpu/drm/i915/intel_ringbuffer.h | 3 + 12 files changed, 140 insertions(+), 121 deletions(-)
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 1/13 drm/i915/bdw+: Replace list_del+list_add_tail with list_move_tail
From: Tvrtko Ursulin <[email protected]>
Same effect for slightly less source code and resulting binary.
--- drivers/gpu/drm/i915/intel_lrc.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +6 -9
@@ -431,9 +431,8 @@ static void execlists_context_unqueue(struct intel_engine_cs *ring)/* Same ctx: ignore first request, as second request * will update tail past first request's workload */ cursor->elsp_submitted = req0->elsp_submitted; -list_del (&req0->execlist_link); -list_add_tail (&req0->execlist_link, - &ring->execlist_retired_req_list); +list_move_tail (&req0->execlist_link, + &ring->execlist_retired_req_list); req0 = cursor; }else { req1 = cursor;
@@ -485,9 +484,8 @@ static bool execlists_check_remove_request(struct intel_engine_cs *ring, "Never submitted head request\n");if (--head_req->elsp_submitted <=0 ) { -list_del (&head_req->execlist_link); -list_add_tail (&head_req->execlist_link, - &ring->execlist_retired_req_list); +list_move_tail (&head_req->execlist_link, + &ring->execlist_retired_req_list);return true; } }
@@ -608,9 +606,8 @@ static int execlists_context_queue(struct drm_i915_gem_request *request)if (request->ctx == tail_req->ctx) {WARN (tail_req->elsp_submitted !=0 ,"More than 2 already-submitted reqs queued\n" ); -list_del (&tail_req->execlist_link); -list_add_tail (&tail_req->execlist_link, - &ring->execlist_retired_req_list); +list_move_tail (&tail_req->execlist_link, + &ring->execlist_retired_req_list); } }
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 01/13] drm/i915/bdw+: Replace list_del+list_add_tail with list_move_tail
Quoted 5 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
Same effect for slightly less source code and resulting binary.
Signed-off-by Tvrtko Ursulin <[email protected]>
Quoted 21 lines
--- drivers/gpu/drm/i915/intel_lrc.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)drivers/gpu/drm/i915/intel_lrc.c +2
-3@@ -431,9 +431,8 @@ static void execlists_context_unqueue(struct intel_engine_cs *ring)/* Same ctx: ignore first request, as second request * will update tail past first request's workload */ cursor->elsp_submitted = req0->elsp_submitted; -list_del (&req0->execlist_link); -list_add_tail (&req0->execlist_link, - &ring->execlist_retired_req_list); +list_move_tail (&req0->execlist_link, + &ring->execlist_retired_req_list); req0 = cursor; }else { req1 = cursor;
drivers/gpu/drm/i915/intel_lrc.c static bool execlists_check_remove_request(struct intel_engine_cs *ring, · line 489
Quoted 9 lines
drivers/gpu/drm/i915/intel_lrc.c +2
-3@@ -485,9 +484,8 @@ static bool execlists_check_remove_request(struct intel_engine_cs *ring, "Never submitted head request\n");if (--head_req->elsp_submitted <=0 ) { -list_del (&head_req->execlist_link); -list_add_tail (&head_req->execlist_link, - &ring->execlist_retired_req_list); +list_move_tail (&head_req->execlist_link, + &ring->execlist_retired_req_list);return true;
Aside: Some of this code is over-indented ...
-Daniel
Quoted 21 lines
drivers/gpu/drm/i915/intel_lrc.c +2
-3} }@@ -608,9 +606,8 @@ static int execlists_context_queue(struct drm_i915_gem_request *request)if (request->ctx == tail_req->ctx) {WARN (tail_req->elsp_submitted !=0 ,"More than 2 already-submitted reqs queued\n" ); -list_del (&tail_req->execlist_link); -list_add_tail (&tail_req->execlist_link, - &ring->execlist_retired_req_list); +list_move_tail (&tail_req->execlist_link, + &ring->execlist_retired_req_list); } }Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 2/13 drm/i915: Don't need a timer to wake us up
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
Looks like the sleeping loop in __i915_wait_request can be simplified by using io_schedule_timeout instead of setting up and destroying a timer.
--- drivers/gpu/drm/i915/i915_gem.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +8 -20
@@ -1135,11 +1135,6 @@ i915_gem_check_wedge(struct i915_gpu_error *error,return 0 ; } -static void fake_irq (unsigned long data) -{ -wake_up_process ((struct task_struct *)data); -} -static bool missed_irq (struct drm_i915_private *dev_priv,struct intel_engine_cs *ring) {
@@ -1291,7 +1286,7 @@ int __i915_wait_request(struct drm_i915_gem_request *req, }for (;;) { -struct timer_list timer; +long sched_timeout;prepare_to_wait (&ring->irq_queue, &wait, state);
@@ -1321,21 +1316,14 @@ int __i915_wait_request(struct drm_i915_gem_request *req,break ; } - timer.function =NULL ; -if (timeout ||missed_irq (dev_priv, ring)) { -unsigned long expire; - -setup_timer_on_stack (&timer, fake_irq, (unsigned long )current); - expire =missed_irq (dev_priv, ring) ? jiffies +1 : timeout_expire; -mod_timer (&timer, expire); - } - -io_schedule (); +if (timeout) + sched_timeout = timeout_expire - jiffies; +else if (missed_irq (dev_priv, ring)) + sched_timeout =1 ; +else + sched_timeout =MAX_SCHEDULE_TIMEOUT ; -if (timer.function) { -del_singleshot_timer_sync (&timer); -destroy_timer_on_stack (&timer); - } +io_schedule_timeout (sched_timeout); }if (!irq_test_in_progress) ring->irq_put (ring);
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 02/13] drm/i915: Don't need a timer to wake us up
Quoted 8 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
Looks like the sleeping loop in
__i915_wait_requestcan be simplified by usingio_schedule_timeoutinstead of setting up and destroying a timer.Signed-off-by Tvrtko Ursulin <[email protected]>Cc Chris Wilson <[email protected]>
io_schedule_timeout was only added in
commit 9cff8adeaa34b5d2802f03f89803da57856b3b72
Author: NeilBrown <[email protected]> Date: Fri Feb 13 15:49:17 2015 +1100
sched: Prevent recursion in io_schedule()
(well the EXPORT_SYMBOL for it), that was iirc why this was open-coded. Please add this to your commit message.
Quoted 65 lines
--- drivers/gpu/drm/i915/i915_gem.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-)drivers/gpu/drm/i915/i915_gem.c +8
-20@@ -1135,11 +1135,6 @@ i915_gem_check_wedge(struct i915_gpu_error *error,return 0 ; } -static void fake_irq (unsigned long data) -{ -wake_up_process ((struct task_struct *)data); -} -static bool missed_irq (struct drm_i915_private *dev_priv,struct intel_engine_cs *ring) {@@ -1291,7 +1286,7 @@ int __i915_wait_request(struct drm_i915_gem_request *req, }for (;;) { -struct timer_list timer; +long sched_timeout;prepare_to_wait (&ring->irq_queue, &wait, state);@@ -1321,21 +1316,14 @@ int __i915_wait_request(struct drm_i915_gem_request *req,break ; } - timer.function =NULL ; -if (timeout ||missed_irq (dev_priv, ring)) { -unsigned long expire; - -setup_timer_on_stack (&timer, fake_irq, (unsigned long )current); - expire =missed_irq (dev_priv, ring) ? jiffies +1 : timeout_expire; -mod_timer (&timer, expire); - } - -io_schedule (); +if (timeout) + sched_timeout = timeout_expire - jiffies; +else if (missed_irq (dev_priv, ring)) + sched_timeout =1 ; +else + sched_timeout =MAX_SCHEDULE_TIMEOUT ; -if (timer.function) { -del_singleshot_timer_sync (&timer); -destroy_timer_on_stack (&timer); - } +io_schedule_timeout (sched_timeout); }if (!irq_test_in_progress) ring->irq_put (ring);Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 3/13 drm/i915: Avoid invariant conditionals in lrc interrupt handler
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
There is no need to check on what Gen we are running on every interrupt and every command submission. We can instead set up some of that when engines are initialized, store it in the engine structure and use it directly at runtime.
--- drivers/gpu/drm/i915/intel_lrc.c | 36 ++++++++++++++++++--------------- drivers/gpu/drm/i915/intel_ringbuffer.h | 2 ++ 2 files changed, 22 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +20 -16
@@ -298,29 +298,15 @@ uint64_t intel_lr_context_descriptor(struct intel_context *ctx, struct intel_engine_cs *ring) {struct drm_i915_gem_object *ctx_obj = ctx->engine[ring->id].state; -uint64_t desc; +uint64_t desc = ring->ctx_desc_template;uint64_t lrca =i915_gem_obj_ggtt_offset (ctx_obj) +LRC_PPHWSP_PN *PAGE_SIZE ;WARN_ON (lrca &0xFFFFFFFF00000FFFULL ); - desc =GEN8_CTX_VALID ; - desc |=GEN8_CTX_ADDRESSING_MODE (dev) <<GEN8_CTX_ADDRESSING_MODE_SHIFT ; -if (IS_GEN8 (ctx_obj->base.dev)) - desc |=GEN8_CTX_L3LLC_COHERENT ; - desc |=GEN8_CTX_PRIVILEGE ; desc |= lrca; desc |= (u64 )intel_execlists_ctx_id (ctx_obj) <<GEN8_CTX_ID_SHIFT ; -/* TODO: WaDisableLiteRestore when we start using semaphore -* signalling between Command Streamers */ -/* desc |= GEN8_CTX_FORCE_RESTORE; */ - -/* WaEnableForceRestoreInCtxtDescForVCS:skl */ -/* WaEnableForceRestoreInCtxtDescForVCS:bxt */ -if (disable_lite_restore_wa (ring)) - desc |=GEN8_CTX_FORCE_RESTORE ; -return desc; }
@@ -556,7 +542,7 @@ void intel_lrc_irq_handler(struct intel_engine_cs *ring) } } -if (disable_lite_restore_wa (ring)) { +if (ring->disable_lite_restore_wa) {/* Prevent a ctx to preempt itself */ if ((status &GEN8_CTX_STATUS_ACTIVE_IDLE ) && (submit_contexts !=0 ))
@@ -1980,6 +1966,24 @@ static int logical_ring_init(struct drm_device *dev, struct intel_engine_cs *rin goto error; } + ring->disable_lite_restore_wa =disable_lite_restore_wa (ring); + + ring->ctx_desc_template =GEN8_CTX_VALID ; + ring->ctx_desc_template |=GEN8_CTX_ADDRESSING_MODE (dev) << +GEN8_CTX_ADDRESSING_MODE_SHIFT ; +if (IS_GEN8 (dev)) + ring->ctx_desc_template |=GEN8_CTX_L3LLC_COHERENT ; + ring->ctx_desc_template |=GEN8_CTX_PRIVILEGE ; + +/* TODO: WaDisableLiteRestore when we start using semaphore +* signalling between Command Streamers */ +/* ring->ctx_desc_template |= GEN8_CTX_FORCE_RESTORE; */ + +/* WaEnableForceRestoreInCtxtDescForVCS:skl */ +/* WaEnableForceRestoreInCtxtDescForVCS:bxt */ +if (ring->disable_lite_restore_wa) + ring->ctx_desc_template |=GEN8_CTX_FORCE_RESTORE ; +return 0 ; error:
drivers/gpu/drm/i915/intel_ringbuffer.h +2 -0
@@ -268,6 +268,8 @@ struct intel_engine_cs {struct list_head execlist_queue;struct list_head execlist_retired_req_list;u8 next_context_status_buffer; +bool disable_lite_restore_wa; +u32 ctx_desc_template;u32 irq_keep_mask;/* bitmask for interrupts that should not be masked */ int (*emit_request)(struct drm_i915_gem_request *request); int (*emit_flush)(struct drm_i915_gem_request *request,
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 03/13] drm/i915: Avoid invariant conditionals in lrc interrupt handler
Quoted 37 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
There is no need to check on what Gen we are running on every interrupt and every command submission. We can instead set up some of that when engines are initialized, store it in the engine structure and use it directly at runtime.
Signed-off-by Tvrtko Ursulin <[email protected]>--- drivers/gpu/drm/i915/intel_lrc.c | 36 ++++++++++++++++++--------------- drivers/gpu/drm/i915/intel_ringbuffer.h | 2 ++ 2 files changed, 22 insertions(+), 16 deletions(-)drivers/gpu/drm/i915/intel_lrc.c +1
-7@@ -298,29 +298,15 @@ uint64_t intel_lr_context_descriptor(struct intel_context *ctx, struct intel_engine_cs *ring) {struct drm_i915_gem_object *ctx_obj = ctx->engine[ring->id].state; -uint64_t desc; +uint64_t desc = ring->ctx_desc_template;uint64_t lrca =i915_gem_obj_ggtt_offset (ctx_obj) +LRC_PPHWSP_PN *PAGE_SIZE ;WARN_ON (lrca &0xFFFFFFFF00000FFFULL ); - desc =GEN8_CTX_VALID ; - desc |=GEN8_CTX_ADDRESSING_MODE (dev) <<GEN8_CTX_ADDRESSING_MODE_SHIFT ; -if (IS_GEN8 (ctx_obj->base.dev)) - desc |=GEN8_CTX_L3LLC_COHERENT ; - desc |=GEN8_CTX_PRIVILEGE ; desc |= lrca; desc |= (u64 )intel_execlists_ctx_id (ctx_obj) <<GEN8_CTX_ID_SHIFT ; -/* TODO: WaDisableLiteRestore when we start using semaphore
drivers/gpu/drm/i915/intel_lrc.c uint64_t intel_lr_context_descriptor(struct intel_context *ctx, · line 311
Quoted 10 lines
drivers/gpu/drm/i915/intel_lrc.c +0
-8-* signalling between Command Streamers */ -/* desc |= GEN8_CTX_FORCE_RESTORE; */ - -/* WaEnableForceRestoreInCtxtDescForVCS:skl */ -/* WaEnableForceRestoreInCtxtDescForVCS:bxt */ -if (disable_lite_restore_wa (ring)) - desc |=GEN8_CTX_FORCE_RESTORE ; -return desc; }
tbh I'd go full monty and just cache the entire context descriptor. -Daniel
Quoted 55 lines
drivers/gpu/drm/i915/intel_lrc.c +19
-1@@ -556,7 +542,7 @@ void intel_lrc_irq_handler(struct intel_engine_cs *ring) } } -if (disable_lite_restore_wa (ring)) { +if (ring->disable_lite_restore_wa) {/* Prevent a ctx to preempt itself */ if ((status &GEN8_CTX_STATUS_ACTIVE_IDLE ) && (submit_contexts !=0 ))@@ -1980,6 +1966,24 @@ static int logical_ring_init(struct drm_device *dev, struct intel_engine_cs *rin goto error; } + ring->disable_lite_restore_wa =disable_lite_restore_wa (ring); + + ring->ctx_desc_template =GEN8_CTX_VALID ; + ring->ctx_desc_template |=GEN8_CTX_ADDRESSING_MODE (dev) << +GEN8_CTX_ADDRESSING_MODE_SHIFT ; +if (IS_GEN8 (dev)) + ring->ctx_desc_template |=GEN8_CTX_L3LLC_COHERENT ; + ring->ctx_desc_template |=GEN8_CTX_PRIVILEGE ; + +/* TODO: WaDisableLiteRestore when we start using semaphore +* signalling between Command Streamers */ +/* ring->ctx_desc_template |= GEN8_CTX_FORCE_RESTORE; */ + +/* WaEnableForceRestoreInCtxtDescForVCS:skl */ +/* WaEnableForceRestoreInCtxtDescForVCS:bxt */ +if (ring->disable_lite_restore_wa) + ring->ctx_desc_template |=GEN8_CTX_FORCE_RESTORE ; +return 0 ; error:drivers/gpu/drm/i915/intel_ringbuffer.h +2
-0@@ -268,6 +268,8 @@ struct intel_engine_cs {struct list_head execlist_queue;struct list_head execlist_retired_req_list;u8 next_context_status_buffer; +bool disable_lite_restore_wa; +u32 ctx_desc_template;u32 irq_keep_mask;/* bitmask for interrupts that should not be masked */ int (*emit_request)(struct drm_i915_gem_request *request); int (*emit_flush)(struct drm_i915_gem_request *request,Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 03/13] drm/i915: Avoid invariant conditionals in lrc interrupt handler
Quoted 37 lines · Daniel Vetter
Quoted 36 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
There is no need to check on what Gen we are running on every interrupt and every command submission. We can instead set up some of that when engines are initialized, store it in the engine structure and use it directly at runtime.
Signed-off-by Tvrtko Ursulin <[email protected]>--- drivers/gpu/drm/i915/intel_lrc.c | 36 ++++++++++++++++++--------------- drivers/gpu/drm/i915/intel_ringbuffer.h | 2 ++ 2 files changed, 22 insertions(+), 16 deletions(-)drivers/gpu/drm/i915/intel_lrc.c +1
-6@@ -298,29 +298,15 @@ uint64_t intel_lr_context_descriptor(struct intel_context *ctx, struct intel_engine_cs *ring) {struct drm_i915_gem_object *ctx_obj = ctx->engine[ring->id].state; -uint64_t desc; +uint64_t desc = ring->ctx_desc_template;uint64_t lrca =i915_gem_obj_ggtt_offset (ctx_obj) +LRC_PPHWSP_PN *PAGE_SIZE ;WARN_ON (lrca &0xFFFFFFFF00000FFFULL ); - desc =GEN8_CTX_VALID ; - desc |=GEN8_CTX_ADDRESSING_MODE (dev) <<GEN8_CTX_ADDRESSING_MODE_SHIFT ; -if (IS_GEN8 (ctx_obj->base.dev)) - desc |=GEN8_CTX_L3LLC_COHERENT ; - desc |=GEN8_CTX_PRIVILEGE ; desc |= lrca; desc |= (u64 )intel_execlists_ctx_id (ctx_obj) <<GEN8_CTX_ID_SHIFT ;
Quoted 13 lines
drivers/gpu/drm/i915/intel_lrc.c uint64_t intel_lr_context_descriptor(struct intel_context *ctx, · line 311
Quoted 11 lines
drivers/gpu/drm/i915/intel_lrc.c +0
-9-/* TODO: WaDisableLiteRestore when we start using semaphore -* signalling between Command Streamers */ -/* desc |= GEN8_CTX_FORCE_RESTORE; */ - -/* WaEnableForceRestoreInCtxtDescForVCS:skl */ -/* WaEnableForceRestoreInCtxtDescForVCS:bxt */ -if (disable_lite_restore_wa (ring)) - desc |=GEN8_CTX_FORCE_RESTORE ; -return desc; }tbh I'd go full monty and just cache the entire context descriptor.
Yeah you're right - this was more a consequence of me learning about this code as making small cleanups.
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 4/13 drm/i915: Fail engine initialization if LRCA is incorrectly aligned
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
LRCA can change only when it goes from unpinned to pinned so it makes sense to check its alignment at that point rather than at every batch buffer submission.
Furthermore, if we check it at pin time we can actually gracefuly fail the engine initialization rather than just spamming the logs at runtime with WARNs.
v2: Return ENODEV for bad alignment. (Chris Wilson)
--- drivers/gpu/drm/i915/intel_lrc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +7 -2
@@ -302,8 +302,6 @@ uint64_t intel_lr_context_descriptor(struct intel_context *ctx,uint64_t lrca =i915_gem_obj_ggtt_offset (ctx_obj) +LRC_PPHWSP_PN *PAGE_SIZE ; -WARN_ON (lrca &0xFFFFFFFF00000FFFULL ); - desc |= lrca; desc |= (u64 )intel_execlists_ctx_id (ctx_obj) <<GEN8_CTX_ID_SHIFT ;
@@ -1030,6 +1028,7 @@ static int intel_lr_context_do_pin(struct intel_engine_cs *ring, {struct drm_device *dev = ring->dev;struct drm_i915_private *dev_priv = dev->dev_private; +u64 lrca;int ret =0 ;WARN_ON (!mutex_is_locked (&ring->dev->struct_mutex));
@@ -1038,6 +1037,12 @@ static int intel_lr_context_do_pin(struct intel_engine_cs *ring,if (ret)return ret; + lrca =i915_gem_obj_ggtt_offset (ctx_obj) +LRC_PPHWSP_PN *PAGE_SIZE ; +if (WARN_ON (lrca &0xFFFFFFFF00000FFFULL )) { + ret = -ENODEV ; + goto unpin_ctx_obj; + } + ret =intel_pin_and_map_ringbuffer_obj (ring->dev, ringbuf);if (ret) goto unpin_ctx_obj;
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 04/13] drm/i915: Fail engine initialization if LRCA is incorrectly aligned
Quoted 39 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
LRCA can change only when it goes from unpinned to pinned so it makes sense to check its alignment at that point rather than at every batch buffer submission.
Furthermore, if we check it at pin time we can actually gracefuly fail the engine initialization rather than just spamming the logs at runtime with WARNs.
v2: Return ENODEV for bad alignment. (Chris Wilson)
Signed-off-by Tvrtko Ursulin <[email protected]>--- drivers/gpu/drm/i915/intel_lrc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/intel_lrc.c +1
-2@@ -302,8 +302,6 @@ uint64_t intel_lr_context_descriptor(struct intel_context *ctx,uint64_t lrca =i915_gem_obj_ggtt_offset (ctx_obj) +LRC_PPHWSP_PN *PAGE_SIZE ; -WARN_ON (lrca &0xFFFFFFFF00000FFFULL ); - desc |= lrca; desc |= (u64 )intel_execlists_ctx_id (ctx_obj) <<GEN8_CTX_ID_SHIFT ;@@ -1030,6 +1028,7 @@ static int intel_lr_context_do_pin(struct intel_engine_cs *ring, {struct drm_device *dev = ring->dev;struct drm_i915_private *dev_priv = dev->dev_private; +u64 lrca;int ret =0 ;WARN_ON (!mutex_is_locked (&ring->dev->struct_mutex));
drivers/gpu/drm/i915/intel_lrc.c static int intel_lr_context_do_pin(struct intel_engine_cs *ring, · line 1041
Quoted 5 lines
drivers/gpu/drm/i915/intel_lrc.c +2
-0@@ -1038,6 +1037,12 @@ static int intel_lr_context_do_pin(struct intel_engine_cs *ring,if (ret)return ret; + lrca =i915_gem_obj_ggtt_offset (ctx_obj) +LRC_PPHWSP_PN *PAGE_SIZE ; +if (WARN_ON (lrca &0xFFFFFFFF00000FFFULL )) {
Essentially this checks that it's page-aligned (which is a fundamental assumption of how we place objects we depend upon everywhere) and that it fits within the 4G hw limit of the global gtt (again we assume our code is correct that way). tbh I'd just drop entirely, it's a useless check. -Daniel
Quoted 14 lines
drivers/gpu/drm/i915/intel_lrc.c +4
-0+ ret = -ENODEV ; + goto unpin_ctx_obj; + } + ret =intel_pin_and_map_ringbuffer_obj (ring->dev, ringbuf);if (ret) goto unpin_ctx_obj;Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 04/13] drm/i915: Fail engine initialization if LRCA is incorrectly aligned
Quoted 43 lines · Daniel Vetter
Quoted 42 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
LRCA can change only when it goes from unpinned to pinned so it makes sense to check its alignment at that point rather than at every batch buffer submission.
Furthermore, if we check it at pin time we can actually gracefuly fail the engine initialization rather than just spamming the logs at runtime with WARNs.
v2: Return ENODEV for bad alignment. (Chris Wilson)
Signed-off-by Tvrtko Ursulin <[email protected]>--- drivers/gpu/drm/i915/intel_lrc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/intel_lrc.c +1
-2@@ -302,8 +302,6 @@ uint64_t intel_lr_context_descriptor(struct intel_context *ctx,uint64_t lrca =i915_gem_obj_ggtt_offset (ctx_obj) +LRC_PPHWSP_PN *PAGE_SIZE ; -WARN_ON (lrca &0xFFFFFFFF00000FFFULL ); - desc |= lrca; desc |= (u64 )intel_execlists_ctx_id (ctx_obj) <<GEN8_CTX_ID_SHIFT ;@@ -1030,6 +1028,7 @@ static int intel_lr_context_do_pin(struct intel_engine_cs *ring, {struct drm_device *dev = ring->dev;struct drm_i915_private *dev_priv = dev->dev_private; +u64 lrca;int ret =0 ;WARN_ON (!mutex_is_locked (&ring->dev->struct_mutex));@@ -1038,6 +1037,12 @@ static int intel_lr_context_do_pin(struct intel_engine_cs *ring,if (ret)return ret;
Quoted 8 lines
drivers/gpu/drm/i915/intel_lrc.c static int intel_lr_context_do_pin(struct intel_engine_cs *ring, · line 1041
Quoted 2 lines
drivers/gpu/drm/i915/intel_lrc.c +2
-0+ lrca =i915_gem_obj_ggtt_offset (ctx_obj) +LRC_PPHWSP_PN *PAGE_SIZE ; +if (WARN_ON (lrca &0xFFFFFFFF00000FFFULL )) {Essentially this checks that it's page-aligned (which is a fundamental assumption of how we place objects we depend upon everywhere) and that it fits within the 4G hw limit of the global gtt (again we assume our code is correct that way). tbh I'd just drop entirely, it's a useless check. -Daniel
IIRC the original version of this WARN (in intel_lr_context_descriptor()
above) was added with the GuC submission code, because the context descriptor as used in execlist code is a 64-bit value, but the GuC requires that all the unique stuff fits in those 20 unmasked bits of a 32-bit value, with the low 12 bits being used for flags. So we wanted to check that we never got a context ID that couldn't be pruned down to just those 20 bits without losing information. It's never been seen to happen since GuC development finished, so we can reasonably lose the check now.
Unless anyone wants to be prepared for the expansion of the GTT beyond 4Gb!
.Dave.
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 04/13] drm/i915: Fail engine initialization if LRCA is incorrectly aligned
Quoted 9 lines · Dave Gordon
IIRC the original version of this WARN (in
intel_lr_context_descriptor()above) was added with the GuC submission code, because the context descriptor as used in execlist code is a 64-bit value, but the GuC requires that all the unique stuff fits in those 20 unmasked bits of a 32-bit value, with the low 12 bits being used for flags. So we wanted to check that we never got a context ID that couldn't be pruned down to just those 20 bits without losing information. It's never been seen to happen since GuC development finished, so we can reasonably lose the check now.
I am missing something here as the GuC doesn't use the high 32bits of the context descriptor, i.e. it never touches the lrca portion? -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 5/13 drm/i915: Cache LRCA in the context
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
We are not allowed to call i915_gem_obj_ggtt_offset from irq context without the big kernel lock held.
LRCA lifetime is well defined so cache it so it can be looked up cheaply from the interrupt context and at command submission time.
v2: Added irq context reasoning to the commit message. (Daniel Vetter)
--- drivers/gpu/drm/i915/i915_debugfs.c | 15 ++++++-------- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_lrc.c | 40 ++++++++++++++++--------------------- drivers/gpu/drm/i915/intel_lrc.h | 3 ++- 4 files changed, 26 insertions(+), 33 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +6 -9
@@ -1976,12 +1976,13 @@ static int i915_context_status(struct seq_file *m, void *unused) }static void i915_dump_lrc_obj (struct seq_file *m, -struct intel_engine_cs *ring, -struct drm_i915_gem_object *ctx_obj) +struct intel_context *ctx, +struct intel_engine_cs *ring) {struct page *page;uint32_t *reg_state;int j; +struct drm_i915_gem_object *ctx_obj = ctx->engine[ring->id].state;unsigned long ggtt_offset =0 ;if (ctx_obj ==NULL ) {
@@ -1991,7 +1992,7 @@ static void i915_dump_lrc_obj(struct seq_file *m, }seq_printf (m,"CONTEXT: %s %u\n" , ring->name, -intel_execlists_ctx_id (ctx_obj)); +intel_execlists_ctx_id (ctx, ring));if (!i915_gem_obj_ggtt_bound (ctx_obj))seq_puts (m,"\tNot bound in GGTT\n" );
@@ -2040,8 +2041,7 @@ static int i915_dump_lrc(struct seq_file *m, void *unused)list_for_each_entry (ctx, &dev_priv->context_list, link) {for_each_ring (ring, dev_priv, i) {if (ring->default_context != ctx) -i915_dump_lrc_obj (m, ring, - ctx->engine[i].state); +i915_dump_lrc_obj (m, ctx, ring); } }
@@ -2115,11 +2115,8 @@ static int i915_execlists(struct seq_file *m, void *data)seq_printf (m,"\t%d requests in queue\n" , count);if (head_req) { -struct drm_i915_gem_object *ctx_obj; - - ctx_obj = head_req->ctx->engine[ring_id].state;seq_printf (m,"\tHead request id: %u\n" , -intel_execlists_ctx_id (ctx_obj)); +intel_execlists_ctx_id (head_req->ctx, ring));seq_printf (m,"\tHead request tail: %u\n" , head_req->tail); }
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -881,6 +881,7 @@ struct intel_context {struct drm_i915_gem_object *state;struct intel_ringbuffer *ringbuf;int pin_count; +u32 lrca; } engine[I915_NUM_RINGS ];struct list_head link;
drivers/gpu/drm/i915/intel_lrc.c +17 -23
@@ -265,7 +265,8 @@ int intel_sanitize_enable_execlists(struct drm_device *dev, int enable_execlists/** * intel_execlists_ctx_id() - get the Execlists Context ID -* @ctx_obj: Logical Ring Context backing object. +* @ctx: Context to get the ID for +* @ring: Engine to get the ID for * * Do not confuse with ctx->id! Unfortunately we have a name overload * here: the old context ID we pass to userspace as a handler so that
@@ -275,14 +276,12 @@ int intel_sanitize_enable_execlists(struct drm_device *dev, int enable_execlists* * Return: 20-bits globally unique context ID. */ -u32 intel_execlists_ctx_id (struct drm_i915_gem_object *ctx_obj) +u32 intel_execlists_ctx_id (struct intel_context *ctx, +struct intel_engine_cs *ring) { -u32 lrca =i915_gem_obj_ggtt_offset (ctx_obj) + -LRC_PPHWSP_PN *PAGE_SIZE ; -/* LRCA is required to be 4K aligned so the more significant 20 bits * are globally unique */ -return lrca >>12 ; +return ctx->engine[ring->id].lrca >>12 ; }static bool disable_lite_restore_wa (struct intel_engine_cs *ring)
@@ -297,13 +296,11 @@ static bool disable_lite_restore_wa(struct intel_engine_cs *ring)uint64_t intel_lr_context_descriptor (struct intel_context *ctx,struct intel_engine_cs *ring) { -struct drm_i915_gem_object *ctx_obj = ctx->engine[ring->id].state; +uint64_t lrca = ctx->engine[ring->id].lrca;uint64_t desc = ring->ctx_desc_template; -uint64_t lrca =i915_gem_obj_ggtt_offset (ctx_obj) + -LRC_PPHWSP_PN *PAGE_SIZE ; desc |= lrca; - desc |= (u64 )intel_execlists_ctx_id (ctx_obj) <<GEN8_CTX_ID_SHIFT ; + desc |= (u64 )intel_execlists_ctx_id (ctx, ring) <<GEN8_CTX_ID_SHIFT ;return desc; }
@@ -461,9 +458,7 @@ static bool execlists_check_remove_request(struct intel_engine_cs *ring, execlist_link);if (head_req !=NULL ) { -struct drm_i915_gem_object *ctx_obj = - head_req->ctx->engine[ring->id].state; -if (intel_execlists_ctx_id (ctx_obj) == request_id) { +if (intel_execlists_ctx_id (head_req->ctx, ring) == request_id) {WARN (head_req->elsp_submitted ==0 ,"Never submitted head request\n" );
@@ -1023,15 +1018,17 @@ int logical_ring_flush_all_caches(struct drm_i915_gem_request *req) }static int intel_lr_context_do_pin (struct intel_engine_cs *ring, -struct drm_i915_gem_object *ctx_obj, -struct intel_ringbuffer *ringbuf) +struct intel_context *ctx) {struct drm_device *dev = ring->dev;struct drm_i915_private *dev_priv = dev->dev_private; +struct drm_i915_gem_object *ctx_obj = ctx->engine[ring->id].state; +struct intel_ringbuffer *ringbuf = ctx->engine[ring->id].ringbuf;u64 lrca; -int ret =0 ; +int ret;WARN_ON (!mutex_is_locked (&ring->dev->struct_mutex)); + ret =i915_gem_obj_ggtt_pin (ctx_obj,GEN8_LR_CONTEXT_ALIGN ,PIN_OFFSET_BIAS |GUC_WOPCM_TOP );if (ret)
@@ -1047,6 +1044,7 @@ static int intel_lr_context_do_pin(struct intel_engine_cs *ring,if (ret) goto unpin_ctx_obj; + ctx->engine[ring->id].lrca = lrca; ctx_obj->dirty = true;/* Invalidate GuC TLB. */
@@ -1065,11 +1063,9 @@ static int intel_lr_context_pin(struct drm_i915_gem_request *rq) {int ret =0 ;struct intel_engine_cs *ring = rq->ring; -struct drm_i915_gem_object *ctx_obj = rq->ctx->engine[ring->id].state; -struct intel_ringbuffer *ringbuf = rq->ringbuf;if (rq->ctx->engine[ring->id].pin_count++ ==0 ) { - ret =intel_lr_context_do_pin (ring, ctx_obj, ringbuf); + ret =intel_lr_context_do_pin (ring, rq->ctx);if (ret) goto reset_pin_count; }
@@ -1091,6 +1087,7 @@ void intel_lr_context_unpin(struct drm_i915_gem_request *rq)if (--rq->ctx->engine[ring->id].pin_count ==0 ) {intel_unpin_ringbuffer_obj (ringbuf);i915_gem_object_ggtt_unpin (ctx_obj); + rq->ctx->engine[ring->id].lrca =0 ; } } }
@@ -1960,10 +1957,7 @@ static int logical_ring_init(struct drm_device *dev, struct intel_engine_cs *rin goto error;/* As this is the default context, always pin it */ - ret =intel_lr_context_do_pin ( - ring, - ring->default_context->engine[ring->id].state, - ring->default_context->engine[ring->id].ringbuf); + ret =intel_lr_context_do_pin (ring, ring->default_context);if (ret) { DRM_ERROR( "Failed to pin and map ringbuffer %s: %d\n",
drivers/gpu/drm/i915/intel_lrc.h +2 -1
@@ -106,6 +106,8 @@ void intel_lr_context_reset(struct drm_device *dev, struct intel_context *ctx);uint64_t intel_lr_context_descriptor (struct intel_context *ctx,struct intel_engine_cs *ring); +u32 intel_execlists_ctx_id (struct intel_context *ctx, +struct intel_engine_cs *ring);/* Execlists */ int intel_sanitize_enable_execlists (struct drm_device *dev,int enable_execlists);
@@ -113,7 +115,6 @@ struct i915_execbuffer_params;int intel_execlists_submission (struct i915_execbuffer_params *params,struct drm_i915_gem_execbuffer2 *args,struct list_head *vmas); -u32 intel_execlists_ctx_id (struct drm_i915_gem_object *ctx_obj);void intel_lrc_irq_handler (struct intel_engine_cs *ring);void intel_execlists_retire_requests (struct intel_engine_cs *ring);
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 05/13] drm/i915: Cache LRCA in the context
Quoted 5 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
We are not allowed to call
i915_gem_obj_ggtt_offsetfrom irq context without the big kernel lock held.
Quoted 7 lines
LRCA lifetime is well defined so cache it so it can be looked up cheaply from the interrupt context and at command submission time.
v2: Added irq context reasoning to the commit message. (Daniel Vetter)
Signed-off-by Tvrtko Ursulin <[email protected]>
A i915_obj_for_each_vma macro with a WARN_ON(!mutex_is_locked(dev->struct_mutex)) would be awesome to validate this. Especially since this is by far not the only time I've seen this bug. Needs to be a follow-up though to avoid stalling this fix.
Quoted 64 lines
--- drivers/gpu/drm/i915/i915_debugfs.c | 15 ++++++-------- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_lrc.c | 40 ++++++++++++++++--------------------- drivers/gpu/drm/i915/intel_lrc.h | 3 ++- 4 files changed, 26 insertions(+), 33 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +6
-9@@ -1976,12 +1976,13 @@ static int i915_context_status(struct seq_file *m, void *unused) }static void i915_dump_lrc_obj (struct seq_file *m, -struct intel_engine_cs *ring, -struct drm_i915_gem_object *ctx_obj) +struct intel_context *ctx, +struct intel_engine_cs *ring) {struct page *page;uint32_t *reg_state;int j; +struct drm_i915_gem_object *ctx_obj = ctx->engine[ring->id].state;unsigned long ggtt_offset =0 ;if (ctx_obj ==NULL ) {@@ -1991,7 +1992,7 @@ static void i915_dump_lrc_obj(struct seq_file *m, }seq_printf (m,"CONTEXT: %s %u\n" , ring->name, -intel_execlists_ctx_id (ctx_obj)); +intel_execlists_ctx_id (ctx, ring));if (!i915_gem_obj_ggtt_bound (ctx_obj))seq_puts (m,"\tNot bound in GGTT\n" );@@ -2040,8 +2041,7 @@ static int i915_dump_lrc(struct seq_file *m, void *unused)list_for_each_entry (ctx, &dev_priv->context_list, link) {for_each_ring (ring, dev_priv, i) {if (ring->default_context != ctx) -i915_dump_lrc_obj (m, ring, - ctx->engine[i].state); +i915_dump_lrc_obj (m, ctx, ring); } }@@ -2115,11 +2115,8 @@ static int i915_execlists(struct seq_file *m, void *data)seq_printf (m,"\t%d requests in queue\n" , count);if (head_req) { -struct drm_i915_gem_object *ctx_obj; - - ctx_obj = head_req->ctx->engine[ring_id].state;seq_printf (m,"\tHead request id: %u\n" , -intel_execlists_ctx_id (ctx_obj)); +intel_execlists_ctx_id (head_req->ctx, ring));seq_printf (m,"\tHead request tail: %u\n" , head_req->tail); }drivers/gpu/drm/i915/i915_drv.h +0
-0
drivers/gpu/drm/i915/i915_drv.h struct intel_context { · line 884
Quoted 4 lines
drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -881,6 +881,7 @@ struct intel_context {struct drm_i915_gem_object *state;struct intel_ringbuffer *ringbuf;int pin_count; +u32 lrca;
lrc_offset imo. Consistent with our other usage in the driver, and actually readable. Please apply liberally everywhere else (I know that bsepc calls it lrca, but we don't need to follow bad naming styles blindly).
With that Reviewed-by: Daniel Vetter <[email protected]>
Quoted 152 lines
drivers/gpu/drm/i915/i915_drv.h +0
-0} engine[I915_NUM_RINGS ];struct list_head link;drivers/gpu/drm/i915/intel_lrc.c +17
-23@@ -265,7 +265,8 @@ int intel_sanitize_enable_execlists(struct drm_device *dev, int enable_execlists/** * intel_execlists_ctx_id() - get the Execlists Context ID -* @ctx_obj: Logical Ring Context backing object. +* @ctx: Context to get the ID for +* @ring: Engine to get the ID for * * Do not confuse with ctx->id! Unfortunately we have a name overload * here: the old context ID we pass to userspace as a handler so that @@ -275,14 +276,12 @@ int intel_sanitize_enable_execlists(struct drm_device *dev, int enable_execlists* * Return: 20-bits globally unique context ID. */ -u32 intel_execlists_ctx_id (struct drm_i915_gem_object *ctx_obj) +u32 intel_execlists_ctx_id (struct intel_context *ctx, +struct intel_engine_cs *ring) { -u32 lrca =i915_gem_obj_ggtt_offset (ctx_obj) + -LRC_PPHWSP_PN *PAGE_SIZE ; -/* LRCA is required to be 4K aligned so the more significant 20 bits * are globally unique */ -return lrca >>12 ; +return ctx->engine[ring->id].lrca >>12 ; }static bool disable_lite_restore_wa (struct intel_engine_cs *ring)@@ -297,13 +296,11 @@ static bool disable_lite_restore_wa(struct intel_engine_cs *ring)uint64_t intel_lr_context_descriptor (struct intel_context *ctx,struct intel_engine_cs *ring) { -struct drm_i915_gem_object *ctx_obj = ctx->engine[ring->id].state; +uint64_t lrca = ctx->engine[ring->id].lrca;uint64_t desc = ring->ctx_desc_template; -uint64_t lrca =i915_gem_obj_ggtt_offset (ctx_obj) + -LRC_PPHWSP_PN *PAGE_SIZE ; desc |= lrca; - desc |= (u64 )intel_execlists_ctx_id (ctx_obj) <<GEN8_CTX_ID_SHIFT ; + desc |= (u64 )intel_execlists_ctx_id (ctx, ring) <<GEN8_CTX_ID_SHIFT ;return desc; }@@ -461,9 +458,7 @@ static bool execlists_check_remove_request(struct intel_engine_cs *ring, execlist_link);if (head_req !=NULL ) { -struct drm_i915_gem_object *ctx_obj = - head_req->ctx->engine[ring->id].state; -if (intel_execlists_ctx_id (ctx_obj) == request_id) { +if (intel_execlists_ctx_id (head_req->ctx, ring) == request_id) {WARN (head_req->elsp_submitted ==0 ,"Never submitted head request\n" );@@ -1023,15 +1018,17 @@ int logical_ring_flush_all_caches(struct drm_i915_gem_request *req) }static int intel_lr_context_do_pin (struct intel_engine_cs *ring, -struct drm_i915_gem_object *ctx_obj, -struct intel_ringbuffer *ringbuf) +struct intel_context *ctx) {struct drm_device *dev = ring->dev;struct drm_i915_private *dev_priv = dev->dev_private; +struct drm_i915_gem_object *ctx_obj = ctx->engine[ring->id].state; +struct intel_ringbuffer *ringbuf = ctx->engine[ring->id].ringbuf;u64 lrca; -int ret =0 ; +int ret;WARN_ON (!mutex_is_locked (&ring->dev->struct_mutex)); + ret =i915_gem_obj_ggtt_pin (ctx_obj,GEN8_LR_CONTEXT_ALIGN ,PIN_OFFSET_BIAS |GUC_WOPCM_TOP );if (ret)@@ -1047,6 +1044,7 @@ static int intel_lr_context_do_pin(struct intel_engine_cs *ring,if (ret) goto unpin_ctx_obj; + ctx->engine[ring->id].lrca = lrca; ctx_obj->dirty = true;/* Invalidate GuC TLB. */ @@ -1065,11 +1063,9 @@ static int intel_lr_context_pin(struct drm_i915_gem_request *rq) {int ret =0 ;struct intel_engine_cs *ring = rq->ring; -struct drm_i915_gem_object *ctx_obj = rq->ctx->engine[ring->id].state; -struct intel_ringbuffer *ringbuf = rq->ringbuf;if (rq->ctx->engine[ring->id].pin_count++ ==0 ) { - ret =intel_lr_context_do_pin (ring, ctx_obj, ringbuf); + ret =intel_lr_context_do_pin (ring, rq->ctx);if (ret) goto reset_pin_count; }@@ -1091,6 +1087,7 @@ void intel_lr_context_unpin(struct drm_i915_gem_request *rq)if (--rq->ctx->engine[ring->id].pin_count ==0 ) {intel_unpin_ringbuffer_obj (ringbuf);i915_gem_object_ggtt_unpin (ctx_obj); + rq->ctx->engine[ring->id].lrca =0 ; } } }@@ -1960,10 +1957,7 @@ static int logical_ring_init(struct drm_device *dev, struct intel_engine_cs *rin goto error;/* As this is the default context, always pin it */ - ret =intel_lr_context_do_pin ( - ring, - ring->default_context->engine[ring->id].state, - ring->default_context->engine[ring->id].ringbuf); + ret =intel_lr_context_do_pin (ring, ring->default_context);if (ret) { DRM_ERROR( "Failed to pin and map ringbuffer %s: %d\n",drivers/gpu/drm/i915/intel_lrc.h +2
-1@@ -106,6 +106,8 @@ void intel_lr_context_reset(struct drm_device *dev, struct intel_context *ctx);uint64_t intel_lr_context_descriptor (struct intel_context *ctx,struct intel_engine_cs *ring); +u32 intel_execlists_ctx_id (struct intel_context *ctx, +struct intel_engine_cs *ring);/* Execlists */ int intel_sanitize_enable_execlists (struct drm_device *dev,int enable_execlists);@@ -113,7 +115,6 @@ struct i915_execbuffer_params;int intel_execlists_submission (struct i915_execbuffer_params *params,struct drm_i915_gem_execbuffer2 *args,struct list_head *vmas); -u32 intel_execlists_ctx_id (struct drm_i915_gem_object *ctx_obj);void intel_lrc_irq_handler (struct intel_engine_cs *ring);void intel_execlists_retire_requests (struct intel_engine_cs *ring);Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 05/13] drm/i915: Cache LRCA in the context
Quoted 243 lines · Daniel Vetter
Quoted 5 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
We are not allowed to call
i915_gem_obj_ggtt_offsetfrom irq context without the big kernel lock held.Quoted 7 lines
LRCA lifetime is well defined so cache it so it can be looked up cheaply from the interrupt context and at command submission time.
v2: Added irq context reasoning to the commit message. (Daniel Vetter)
Signed-off-by Tvrtko Ursulin <[email protected]>A
i915_obj_for_each_vmamacro with a WARN_ON(!mutex_is_locked(dev->struct_mutex)) would be awesome to validate this. Especially since this is by far not the only time I've seen this bug. Needs to be a follow-up though to avoid stalling this fix.Quoted 64 lines
--- drivers/gpu/drm/i915/i915_debugfs.c | 15 ++++++-------- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_lrc.c | 40 ++++++++++++++++--------------------- drivers/gpu/drm/i915/intel_lrc.h | 3 ++- 4 files changed, 26 insertions(+), 33 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +6
-9@@ -1976,12 +1976,13 @@ static int i915_context_status(struct seq_file *m, void *unused) }static void i915_dump_lrc_obj (struct seq_file *m, -struct intel_engine_cs *ring, -struct drm_i915_gem_object *ctx_obj) +struct intel_context *ctx, +struct intel_engine_cs *ring) {struct page *page;uint32_t *reg_state;int j; +struct drm_i915_gem_object *ctx_obj = ctx->engine[ring->id].state;unsigned long ggtt_offset =0 ;if (ctx_obj ==NULL ) {@@ -1991,7 +1992,7 @@ static void i915_dump_lrc_obj(struct seq_file *m, }seq_printf (m,"CONTEXT: %s %u\n" , ring->name, -intel_execlists_ctx_id (ctx_obj)); +intel_execlists_ctx_id (ctx, ring));if (!i915_gem_obj_ggtt_bound (ctx_obj))seq_puts (m,"\tNot bound in GGTT\n" );@@ -2040,8 +2041,7 @@ static int i915_dump_lrc(struct seq_file *m, void *unused)list_for_each_entry (ctx, &dev_priv->context_list, link) {for_each_ring (ring, dev_priv, i) {if (ring->default_context != ctx) -i915_dump_lrc_obj (m, ring, - ctx->engine[i].state); +i915_dump_lrc_obj (m, ctx, ring); } }@@ -2115,11 +2115,8 @@ static int i915_execlists(struct seq_file *m, void *data)seq_printf (m,"\t%d requests in queue\n" , count);if (head_req) { -struct drm_i915_gem_object *ctx_obj; - - ctx_obj = head_req->ctx->engine[ring_id].state;seq_printf (m,"\tHead request id: %u\n" , -intel_execlists_ctx_id (ctx_obj)); +intel_execlists_ctx_id (head_req->ctx, ring));seq_printf (m,"\tHead request tail: %u\n" , head_req->tail); }drivers/gpu/drm/i915/i915_drv.h +0
-0drivers/gpu/drm/i915/i915_drv.h struct intel_context { · line 884
Quoted 4 lines
drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -881,6 +881,7 @@ struct intel_context {struct drm_i915_gem_object *state;struct intel_ringbuffer *ringbuf;int pin_count; +u32 lrca;
lrc_offsetimo. Consistent with our other usage in the driver, and actually readable. Please apply liberally everywhere else (I know that bsepc calls it lrca, but we don't need to follow bad naming styles blindly).With that Reviewed-by: Daniel Vetter <[email protected]>
Quoted 148 lines
drivers/gpu/drm/i915/i915_drv.h +0
-0} engine[I915_NUM_RINGS ];struct list_head link;drivers/gpu/drm/i915/intel_lrc.c +17
-23@@ -265,7 +265,8 @@ int intel_sanitize_enable_execlists(struct drm_device *dev, int enable_execlists/** * intel_execlists_ctx_id() - get the Execlists Context ID -* @ctx_obj: Logical Ring Context backing object. +* @ctx: Context to get the ID for +* @ring: Engine to get the ID for * * Do not confuse with ctx->id! Unfortunately we have a name overload * here: the old context ID we pass to userspace as a handler so that @@ -275,14 +276,12 @@ int intel_sanitize_enable_execlists(struct drm_device *dev, int enable_execlists* * Return: 20-bits globally unique context ID. */ -u32 intel_execlists_ctx_id (struct drm_i915_gem_object *ctx_obj) +u32 intel_execlists_ctx_id (struct intel_context *ctx, +struct intel_engine_cs *ring) { -u32 lrca =i915_gem_obj_ggtt_offset (ctx_obj) + -LRC_PPHWSP_PN *PAGE_SIZE ; -/* LRCA is required to be 4K aligned so the more significant 20 bits * are globally unique */ -return lrca >>12 ; +return ctx->engine[ring->id].lrca >>12 ; }static bool disable_lite_restore_wa (struct intel_engine_cs *ring)@@ -297,13 +296,11 @@ static bool disable_lite_restore_wa(struct intel_engine_cs *ring)uint64_t intel_lr_context_descriptor (struct intel_context *ctx,struct intel_engine_cs *ring) { -struct drm_i915_gem_object *ctx_obj = ctx->engine[ring->id].state; +uint64_t lrca = ctx->engine[ring->id].lrca;uint64_t desc = ring->ctx_desc_template; -uint64_t lrca =i915_gem_obj_ggtt_offset (ctx_obj) + -LRC_PPHWSP_PN *PAGE_SIZE ; desc |= lrca; - desc |= (u64 )intel_execlists_ctx_id (ctx_obj) <<GEN8_CTX_ID_SHIFT ; + desc |= (u64 )intel_execlists_ctx_id (ctx, ring) <<GEN8_CTX_ID_SHIFT ;return desc; }@@ -461,9 +458,7 @@ static bool execlists_check_remove_request(struct intel_engine_cs *ring, execlist_link);if (head_req !=NULL ) { -struct drm_i915_gem_object *ctx_obj = - head_req->ctx->engine[ring->id].state; -if (intel_execlists_ctx_id (ctx_obj) == request_id) { +if (intel_execlists_ctx_id (head_req->ctx, ring) == request_id) {WARN (head_req->elsp_submitted ==0 ,"Never submitted head request\n" );@@ -1023,15 +1018,17 @@ int logical_ring_flush_all_caches(struct drm_i915_gem_request *req) }static int intel_lr_context_do_pin (struct intel_engine_cs *ring, -struct drm_i915_gem_object *ctx_obj, -struct intel_ringbuffer *ringbuf) +struct intel_context *ctx) {struct drm_device *dev = ring->dev;struct drm_i915_private *dev_priv = dev->dev_private; +struct drm_i915_gem_object *ctx_obj = ctx->engine[ring->id].state; +struct intel_ringbuffer *ringbuf = ctx->engine[ring->id].ringbuf;u64 lrca; -int ret =0 ; +int ret;WARN_ON (!mutex_is_locked (&ring->dev->struct_mutex)); + ret =i915_gem_obj_ggtt_pin (ctx_obj,GEN8_LR_CONTEXT_ALIGN ,PIN_OFFSET_BIAS |GUC_WOPCM_TOP );if (ret)@@ -1047,6 +1044,7 @@ static int intel_lr_context_do_pin(struct intel_engine_cs *ring,if (ret) goto unpin_ctx_obj; + ctx->engine[ring->id].lrca = lrca; ctx_obj->dirty = true;/* Invalidate GuC TLB. */ @@ -1065,11 +1063,9 @@ static int intel_lr_context_pin(struct drm_i915_gem_request *rq) {int ret =0 ;struct intel_engine_cs *ring = rq->ring; -struct drm_i915_gem_object *ctx_obj = rq->ctx->engine[ring->id].state; -struct intel_ringbuffer *ringbuf = rq->ringbuf;if (rq->ctx->engine[ring->id].pin_count++ ==0 ) { - ret =intel_lr_context_do_pin (ring, ctx_obj, ringbuf); + ret =intel_lr_context_do_pin (ring, rq->ctx);if (ret) goto reset_pin_count; }@@ -1091,6 +1087,7 @@ void intel_lr_context_unpin(struct drm_i915_gem_request *rq)if (--rq->ctx->engine[ring->id].pin_count ==0 ) {intel_unpin_ringbuffer_obj (ringbuf);i915_gem_object_ggtt_unpin (ctx_obj); + rq->ctx->engine[ring->id].lrca =0 ; } } }@@ -1960,10 +1957,7 @@ static int logical_ring_init(struct drm_device *dev, struct intel_engine_cs *rin goto error;/* As this is the default context, always pin it */ - ret =intel_lr_context_do_pin ( - ring, - ring->default_context->engine[ring->id].state, - ring->default_context->engine[ring->id].ringbuf); + ret =intel_lr_context_do_pin (ring, ring->default_context);if (ret) { DRM_ERROR( "Failed to pin and map ringbuffer %s: %d\n",drivers/gpu/drm/i915/intel_lrc.h +2
-2@@ -106,6 +106,8 @@ void intel_lr_context_reset(struct drm_device *dev, struct intel_context *ctx);uint64_t intel_lr_context_descriptor (struct intel_context *ctx,struct intel_engine_cs *ring); +u32 intel_execlists_ctx_id (struct intel_context *ctx, +struct intel_engine_cs *ring);/* Execlists */ int intel_sanitize_enable_execlists (struct drm_device *dev,int enable_execlists);@@ -113,7 +115,6 @@ struct i915_execbuffer_params;int intel_execlists_submission (struct i915_execbuffer_params *params,struct drm_i915_gem_execbuffer2 *args,struct list_head *vmas); -u32 intel_execlists_ctx_id (struct drm_i915_gem_object *ctx_obj);void intel_lrc_irq_handler (struct intel_engine_cs *ring);void intel_execlists_retire_requests (struct intel_engine_cs *ring); --1.9.1
Quoted 4 lines
Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
How about caching the WHOLE descriptor so that retrieval becomes trivial, retrieving the context ID becomes almost as trivial, as
does retrieving the LRCA (all these could be inlined) and the single calculate-and-cache function can be nicely documented as to how a descriptor encodes LRCA etc. Something like this ...
/**
* intel_lr_context_descriptor_update() - calculate & cache the
* descriptor for a pinned
* context
* @ctx: Context to work on
* @ring: Engine the descriptor will be used with
*
* The context descriptor encodes various attributes of a context,
* including its GTT address and some flags. Because it's fairly
* expensive to calculate, we'll just do it once and cache the result,
* which remains valid until the context is unpinned.
*
* This is what a descriptor looks like, from LSB to MSB:
* bits 0-11: flags, GEN8_CTX_* (cached in ctx_desc_template)
* bits 12-31: LRCA, GTT address of (the HWSP of) this context
* bits 32-51: ctx ID, a globally unique tag (the LRCA again!)
* bits 52-63: reserved, may encode the engine ID (for GuC)
*/
static void
intel_lr_context_descriptor_update(struct intel_context *ctx,
struct intel_engine_cs *ring)
{
struct drm_i915_gem_object *ctx_obj;
uint64_t lrca, desc;
ctx_obj = ctx->engine[ring->id].state;
lrca = i915_gem_obj_ggtt_offset(ctx_obj) + LRC_PPHWSP_PN * PAGE_SIZE;
desc = ring->ctx_desc_template; /* bits 0-11 */
desc |= lrca; /* bits 12-31 */
desc |= (lrca >> PAGE_SHIFT) << 32; /* bits 32-51 */
ctx->engine[ring->id].ctx_desc = desc;
}/**
* intel_lr_context_descriptor() - get the descriptor for the specified
* context/engine combination
* @ctx: Context to get the ID for
* @ring: Engine to get the ID for
*
* Now just a trivial accessor, since the value was computed and cached
* above at the point when the context was pinned.
*
* Return: 64-bit context descriptor (encodes LRCA and various flags) */uint64_t inline
intel_lr_context_descriptor(struct intel_context *ctx,
struct intel_engine_cs *ring)
{
return ctx->engine[ring->id].ctx_desc;
}/**
* intel_lr_context_address() - get the GTT address of (the HWSP of) the
* specified context/engine combination
* @ctx: Context to get the ID for
* @ring: Engine to get the ID for
*
* The address (LRCA) is a portion of the context descriptor, so we can
* just extract the required part from the cached descriptor. *
* Return: 32-bit GTT address
*/uint32_t inline
intel_lr_context_address(struct intel_context *ctx,
struct intel_engine_cs *ring)
{
return (u32)intel_lr_context_descriptor(ctx, ring) & PAGE_MASK;
}/**
* intel_execlists_ctx_id() - get the Execlists Context ID
* @ctx: Context to get the ID for
* @ring: Engine to get the ID for
*
* Do not confuse with ctx->id! Unfortunately we have a name overload
* here: the old context ID we pass to userspace as a handler so that
* they can refer to a context, and the new context ID we pass to the
* ELSP so that the GPU can inform us of the context status via
* interrupts.
*
* The context ID is a portion of the context descriptor, so we can
* just extract the required part from the cached descriptor. *
* Return: 20-bit globally unique ctx ID (actually, a GTT page number) */uint32_t inline
intel_execlists_ctx_id(struct intel_context *ctx,
struct intel_engine_cs *ring)
{
return (u32)(intel_lr_context_descriptor(ctx, ring) >> 32);
}... and insert a call to intel_lr_context_descriptor_update() into the appropriate spot in intel_lr_context_do_pin().
.Dave.
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 05/13] drm/i915: Cache LRCA in the context
Quoted 266 lines · Dave Gordon
Quoted 265 lines · Daniel Vetter
Quoted 5 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
We are not allowed to call
i915_gem_obj_ggtt_offsetfrom irq context without the big kernel lock held.Quoted 7 lines
LRCA lifetime is well defined so cache it so it can be looked up cheaply from the interrupt context and at command submission time.
v2: Added irq context reasoning to the commit message. (Daniel Vetter)
Signed-off-by Tvrtko Ursulin <[email protected]>A
i915_obj_for_each_vmamacro with a WARN_ON(!mutex_is_locked(dev->struct_mutex)) would be awesome to validate this. Especially since this is by far not the only time I've seen this bug. Needs to be a follow-up though to avoid stalling this fix.Quoted 70 lines
--- drivers/gpu/drm/i915/i915_debugfs.c | 15 ++++++-------- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_lrc.c | 40 ++++++++++++++++--------------------- drivers/gpu/drm/i915/intel_lrc.h | 3 ++- 4 files changed, 26 insertions(+), 33 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +3
-2@@ -1976,12 +1976,13 @@ static int i915_context_status(struct seq_file *m, void *unused) }static void i915_dump_lrc_obj (struct seq_file *m, -struct intel_engine_cs *ring, -struct drm_i915_gem_object *ctx_obj) +struct intel_context *ctx, +struct intel_engine_cs *ring) {struct page *page;uint32_t *reg_state;int j; +struct drm_i915_gem_object *ctx_obj = ctx->engine[ring->id].state;unsigned long ggtt_offset =0 ;if (ctx_obj == NULL) {drivers/gpu/drm/i915/i915_debugfs.c +3
-7@@ -1991,7 +1992,7 @@ static void i915_dump_lrc_obj(struct seq_file *m, }seq_printf (m,"CONTEXT: %s %u\n" , ring->name, -intel_execlists_ctx_id (ctx_obj)); +intel_execlists_ctx_id (ctx, ring));if (!i915_gem_obj_ggtt_bound (ctx_obj))seq_puts (m,"\tNot bound in GGTT\n" );@@ -2040,8 +2041,7 @@ static int i915_dump_lrc(struct seq_file *m, void *unused)list_for_each_entry (ctx, &dev_priv->context_list, link) {for_each_ring (ring, dev_priv, i) {if (ring->default_context != ctx) -i915_dump_lrc_obj (m, ring, - ctx->engine[i].state); +i915_dump_lrc_obj (m, ctx, ring); } }@@ -2115,11 +2115,8 @@ static int i915_execlists(struct seq_file *m, void *data) seq_printf(m, "\t%d requests in queue\n", count);if (head_req) { -struct drm_i915_gem_object *ctx_obj; - - ctx_obj = head_req->ctx->engine[ring_id].state;seq_printf (m,"\tHead request id: %u\n" , -intel_execlists_ctx_id (ctx_obj)); +intel_execlists_ctx_id (head_req->ctx, ring));seq_printf (m,"\tHead request tail: %u\n" , head_req->tail);}drivers/gpu/drm/i915/i915_drv.h +0
-0drivers/gpu/drm/i915/i915_drv.h struct intel_context { · line 884
Quoted 4 lines
drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -881,6 +881,7 @@ struct intel_context {struct drm_i915_gem_object *state;struct intel_ringbuffer *ringbuf;int pin_count; +u32 lrca;
lrc_offsetimo. Consistent with our other usage in the driver, and actually readable. Please apply liberally everywhere else (I know that bsepc calls it lrca, but we don't need to follow bad naming styles blindly).With that Reviewed-by: Daniel Vetter <[email protected]>
Quoted 164 lines
drivers/gpu/drm/i915/i915_drv.h +0
-0} engine[I915_NUM_RINGS ];struct list_head link;drivers/gpu/drm/i915/intel_lrc.c +0
-0@@ -265,7 +265,8 @@ int intel_sanitize_enable_execlists(struct
drm_device*dev, intenable_execlists/**
*intel_execlists_ctx_id()- get the Execlists Context ID
- * @ctx_obj: Logical Ring Context backing object.
+ * @ctx: Context to get the ID for
+ * @ring: Engine to get the ID for
*
* Do not confuse withctx->id! Unfortunately we have a name overload
* here: the old context ID we pass to userspace as a handler so thatdrivers/gpu/drm/i915/intel_lrc.c +0
-0@@ -275,14 +276,12 @@ int intel_sanitize_enable_execlists(struct
drm_device*dev, intenable_execlists
*
* Return: 20-bits globally unique context ID.
*/drivers/gpu/drm/i915/intel_lrc.c +2
-4-u32 intel_execlists_ctx_id (struct drm_i915_gem_object *ctx_obj) +u32 intel_execlists_ctx_id (struct intel_context *ctx, +struct intel_engine_cs *ring) { -u32 lrca =i915_gem_obj_ggtt_offset (ctx_obj) + -LRC_PPHWSP_PN *PAGE_SIZE ; -/* LRCA is required to be 4K aligned so the more significant 20 bits
* are globally unique */drivers/gpu/drm/i915/intel_lrc.c +3
-5-return lrca >>12 ; +return ctx->engine[ring->id].lrca >>12 ; }static bool disable_lite_restore_wa (struct intel_engine_cs *ring)@@ -297,13 +296,11 @@ static bool disable_lite_restore_wa(struct intel_engine_cs *ring)uint64_t intel_lr_context_descriptor (struct intel_context *ctx,struct intel_engine_cs *ring) { -struct drm_i915_gem_object *ctx_obj = ctx->engine[ring->id].state; +uint64_t lrca = ctx->engine[ring->id].lrca;uint64_t desc = ring->ctx_desc_template; -uint64_t lrca =i915_gem_obj_ggtt_offset (ctx_obj) + -LRC_PPHWSP_PN *PAGE_SIZE ; desc |= lrca; - desc |= (u64 )intel_execlists_ctx_id (ctx_obj) <<GEN8_CTX_ID_SHIFT ; + desc |= (u64 )intel_execlists_ctx_id (ctx, ring) <<GEN8_CTX_ID_SHIFT ;return desc;}
drivers/gpu/drm/i915/intel_lrc.c +1
-3@@ -461,9 +458,7 @@ static bool execlists_check_remove_request(structintel_engine_cs *ring, execlist_link);if (head_req !=NULL ) { -struct drm_i915_gem_object *ctx_obj = - head_req->ctx->engine[ring->id].state; -if (intel_execlists_ctx_id (ctx_obj) == request_id) { +if (intel_execlists_ctx_id (head_req->ctx, ring) == request_id) { WARN(head_req->elsp_submitted == 0,"Never submitted head request\n");drivers/gpu/drm/i915/intel_lrc.c +5
-3@@ -1023,15 +1018,17 @@ int logical_ring_flush_all_caches(struct drm_i915_gem_request *req) }static int intel_lr_context_do_pin (struct intel_engine_cs *ring, -struct drm_i915_gem_object *ctx_obj, -struct intel_ringbuffer *ringbuf) +struct intel_context *ctx) {struct drm_device *dev = ring->dev;struct drm_i915_private *dev_priv = dev->dev_private; +struct drm_i915_gem_object *ctx_obj = ctx->engine[ring->id].state; +struct intel_ringbuffer *ringbuf = ctx->engine[ring->id].ringbuf;u64 lrca; -int ret =0 ; +int ret;WARN_ON (!mutex_is_locked (&ring->dev->struct_mutex)); + ret =i915_gem_obj_ggtt_pin (ctx_obj,GEN8_LR_CONTEXT_ALIGN ,PIN_OFFSET_BIAS |GUC_WOPCM_TOP );if (ret)
drivers/gpu/drm/i915/intel_lrc.c +1
-0@@ -1047,6 +1044,7 @@ static int intel_lr_context_do_pin(struct intel_engine_cs *ring, if (ret) goto unpin_ctx_obj; + ctx->engine[ring->id].lrca = lrca; ctx_obj->dirty = true;/* Invalidate GuC TLB. */drivers/gpu/drm/i915/intel_lrc.c +1
-3@@ -1065,11 +1063,9 @@ static int intel_lr_context_pin(struct drm_i915_gem_request *rq) {int ret =0 ;struct intel_engine_cs *ring = rq->ring; -struct drm_i915_gem_object *ctx_obj = rq->ctx->engine[ring->id].state; -struct intel_ringbuffer *ringbuf = rq->ringbuf;if (rq->ctx->engine[ring->id].pin_count++ ==0 ) { - ret =intel_lr_context_do_pin (ring, ctx_obj, ringbuf); + ret =intel_lr_context_do_pin (ring, rq->ctx);if (ret)goto reset_pin_count; }drivers/gpu/drm/i915/intel_lrc.c +1
-0@@ -1091,6 +1087,7 @@ void intel_lr_context_unpin(struct drm_i915_gem_request *rq)if (--rq->ctx->engine[ring->id].pin_count ==0 ) {intel_unpin_ringbuffer_obj (ringbuf);i915_gem_object_ggtt_unpin (ctx_obj); + rq->ctx->engine[ring->id].lrca =0 ; } }}drivers/gpu/drm/i915/intel_lrc.c +1
-4@@ -1960,10 +1957,7 @@ static int logical_ring_init(struct drm_device *dev, struct intel_engine_cs *rin goto error;/* As this is the default context, always pin it */ - ret =intel_lr_context_do_pin ( - ring, - ring->default_context->engine[ring->id].state, - ring->default_context->engine[ring->id].ringbuf); + ret =intel_lr_context_do_pin (ring, ring->default_context);if (ret) { DRM_ERROR("Failed to pin and map ringbuffer %s: %d\n",
drivers/gpu/drm/i915/intel_lrc.h +2
-0@@ -106,6 +106,8 @@ void intel_lr_context_reset(struct drm_device *dev, struct intel_context *ctx);uint64_t intel_lr_context_descriptor (struct intel_context *ctx,struct intel_engine_cs *ring); +u32 intel_execlists_ctx_id (struct intel_context *ctx, +struct intel_engine_cs *ring);/* Execlists */ int intel_sanitize_enable_execlists(struct drm_device *dev, int
enable_execlists);drivers/gpu/drm/i915/intel_lrc.h +0
-2@@ -113,7 +115,6 @@ struct i915_execbuffer_params;int intel_execlists_submission (struct i915_execbuffer_params *params,struct drm_i915_gem_execbuffer2 *args,struct list_head *vmas); -u32 intel_execlists_ctx_id (struct drm_i915_gem_object *ctx_obj);void intel_lrc_irq_handler (struct intel_engine_cs *ring);void intel_execlists_retire_requests (struct intel_engine_cs *ring); --1.9.1
Quoted 10 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfxHow about caching the WHOLE descriptor so that retrieval becomes trivial, retrieving the context ID becomes almost as trivial, as does retrieving the LRCA (all these could be inlined) and the single calculate-and-cache function can be nicely documented as to how a descriptor encodes LRCA etc. Something like this ...
Similar to v3 of my series from yesterday as Daniel already suggested caching it all. :)
But I think moving towards storing the VMA will be the approach unless we can agree on that I915_GTT_BAD_ADDRESS idea.
Quoted 90 lines
/**
*intel_lr_context_descriptor_update()- calculate & cache the
* descriptor for a pinned
* context
* @ctx: Context to work on
* @ring: Engine the descriptor will be used with
*
* The context descriptor encodes various attributes of a context,
* including its GTT address and some flags. Because it's fairly
* expensive to calculate, we'll just do it once and cache the result,
* which remains valid until the context is unpinned.
*
* This is what a descriptor looks like, from LSB to MSB:* bits 0-11: flags, GEN8_CTX_* (cached in ctx_desc_template) * bits 12-31: LRCA, GTT address of (the HWSP of) this context * bits 32-51: ctx ID, a globally unique tag (the LRCA again!) * bits 52-63: reserved, may encode the engine ID (for GuC)*/
static void intel_lr_context_descriptor_update(structintel_context*ctx,
structintel_engine_cs*ring){ struct drm_i915_gem_object *ctx_obj; uint64_t lrca, desc; ctx_obj = ctx->engine[ring->id].state; lrca = i915_gem_obj_ggtt_offset(ctx_obj) + LRC_PPHWSP_PN * PAGE_SIZE; desc = ring->ctx_desc_template; /* bits 0-11 */ desc |= lrca; /* bits 12-31 */ desc |= (lrca >> PAGE_SHIFT) << 32; /* bits 32-51 */ ctx->engine[ring->id].ctx_desc = desc; }/**
*intel_lr_context_descriptor()- get the descriptor for the specified
* context/engine combination
* @ctx: Context to get the ID for
* @ring: Engine to get the ID for
*
* Now just a trivial accessor, since the value was computed and cached
* above at the point when the context was pinned.
*
* Return: 64-bit context descriptor (encodes LRCA and various flags) */uint64_tinline
intel_lr_context_descriptor(structintel_context*ctx,
structintel_engine_cs*ring){ return ctx->engine[ring->id].ctx_desc; }/**
*intel_lr_context_address()- get the GTT address of (the HWSP of) the
* specified context/engine combination
* @ctx: Context to get the ID for
* @ring: Engine to get the ID for
*
* The address (LRCA) is a portion of the context descriptor, so we can
* just extract the required part from the cached descriptor. *
* Return: 32-bit GTT address
*/uint32_tinline
intel_lr_context_address(structintel_context*ctx,
structintel_engine_cs*ring){ return (u32)intel_lr_context_descriptor(ctx, ring) & PAGE_MASK; }/**
*intel_execlists_ctx_id()- get the Execlists Context ID
* @ctx: Context to get the ID for
* @ring: Engine to get the ID for
*
* Do not confuse withctx->id! Unfortunately we have a name overload
* here: the old context ID we pass to userspace as a handler so that
* they can refer to a context, and the new context ID we pass to the
* ELSP so that the GPU can inform us of the context status via
* interrupts.
*
* The context ID is a portion of the context descriptor, so we can
* just extract the required part from the cached descriptor. *
* Return: 20-bit globally unique ctx ID (actually, a GTT page number) */uint32_tinline
intel_execlists_ctx_id(structintel_context*ctx,
structintel_engine_cs*ring)
Quoted 6 lines
{ return (u32)(intel_lr_context_descriptor(ctx, ring) >> 32); }... and insert a call to
intel_lr_context_descriptor_update()into the appropriate spot inintel_lr_context_do_pin().
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 6/13 drm/i915: Only grab timestamps when needed
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
No need to call ktime_get_raw_ns twice per unlimited wait and can also elimate a local variable.
--- drivers/gpu/drm/i915/i915_gem.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +7 -5
@@ -1246,7 +1246,7 @@ int __i915_wait_request(struct drm_i915_gem_request *req,int state = interruptible ?TASK_INTERRUPTIBLE :TASK_UNINTERRUPTIBLE ;DEFINE_WAIT (wait);unsigned long timeout_expire; -s64 before, now; +s64 before =0 ;int ret;WARN (!intel_irqs_enabled (dev_priv),"IRQs disabled" );
@@ -1266,14 +1266,17 @@ int __i915_wait_request(struct drm_i915_gem_request *req,return -ETIME ; timeout_expire = jiffies +nsecs_to_jiffies_timeout (*timeout); + +/* +* Record current time in case interrupted by signal, or wedged. +*/ + before =ktime_get_raw_ns (); }if (INTEL_INFO (dev_priv)->gen >=6 )gen6_rps_boost (dev_priv, rps, req->emitted_jiffies); -/* Record current time in case interrupted by signal, or wedged */ trace_i915_gem_request_wait_begin (req); - before =ktime_get_raw_ns ();/* Optimistic spin for the next jiffie before touching IRQs */ ret =__i915_spin_request (req, state);
@@ -1331,11 +1334,10 @@ int __i915_wait_request(struct drm_i915_gem_request *req,finish_wait (&ring->irq_queue, &wait); out: - now =ktime_get_raw_ns ();trace_i915_gem_request_wait_end (req);if (timeout) { -s64 tres = *timeout - (now - before); +s64 tres = *timeout - (ktime_get_raw_ns () - before); *timeout = tres <0 ?0 : tres;
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 06/13] drm/i915: Only grab timestamps when needed
Quoted 15 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
No need to call
ktime_get_raw_nstwice per unlimited wait and can also elimate a local variable.Signed-off-by Tvrtko Ursulin <[email protected]>--- drivers/gpu/drm/i915/i915_gem.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)drivers/gpu/drm/i915/i915_gem.c +0
-0
drivers/gpu/drm/i915/i915_gem.c int __i915_wait_request(struct drm_i915_gem_request *req, · line 1249
Quoted 5 lines
drivers/gpu/drm/i915/i915_gem.c +1
-1@@ -1246,7 +1246,7 @@ int __i915_wait_request(struct drm_i915_gem_request *req,int state = interruptible ?TASK_INTERRUPTIBLE :TASK_UNINTERRUPTIBLE ;DEFINE_WAIT (wait);unsigned long timeout_expire; -s64 before, now; +s64 before =0 ;
Is gcc really this dense? Should be easy for it to spot that both branches depend upon the same condition. Please remove that assignment. With that changed:
Quoted 43 lines
drivers/gpu/drm/i915/i915_gem.c +6
-4int ret;WARN (!intel_irqs_enabled (dev_priv),"IRQs disabled" );@@ -1266,14 +1266,17 @@ int __i915_wait_request(struct drm_i915_gem_request *req,return -ETIME ; timeout_expire = jiffies +nsecs_to_jiffies_timeout (*timeout); + +/* +* Record current time in case interrupted by signal, or wedged. +*/ + before =ktime_get_raw_ns (); }if (INTEL_INFO (dev_priv)->gen >=6 )gen6_rps_boost (dev_priv, rps, req->emitted_jiffies); -/* Record current time in case interrupted by signal, or wedged */ trace_i915_gem_request_wait_begin (req); - before =ktime_get_raw_ns ();/* Optimistic spin for the next jiffie before touching IRQs */ ret =__i915_spin_request (req, state);@@ -1331,11 +1334,10 @@ int __i915_wait_request(struct drm_i915_gem_request *req,finish_wait (&ring->irq_queue, &wait); out: - now =ktime_get_raw_ns ();trace_i915_gem_request_wait_end (req);if (timeout) { -s64 tres = *timeout - (now - before); +s64 tres = *timeout - (ktime_get_raw_ns () - before); *timeout = tres <0 ?0 : tres;Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 06/13] drm/i915: Only grab timestamps when needed
Quoted 26 lines · Daniel Vetter
Quoted 15 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
No need to call
ktime_get_raw_nstwice per unlimited wait and can also elimate a local variable.Signed-off-by Tvrtko Ursulin <[email protected]>--- drivers/gpu/drm/i915/i915_gem.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)drivers/gpu/drm/i915/i915_gem.c +0
-0drivers/gpu/drm/i915/i915_gem.c int __i915_wait_request(struct drm_i915_gem_request *req, · line 1249
Quoted 5 lines
drivers/gpu/drm/i915/i915_gem.c +1
-1@@ -1246,7 +1246,7 @@ int __i915_wait_request(struct drm_i915_gem_request *req,int state = interruptible ?TASK_INTERRUPTIBLE :TASK_UNINTERRUPTIBLE ;DEFINE_WAIT (wait);unsigned long timeout_expire; -s64 before, now; +s64 before =0 ;Is gcc really this dense? Should be easy for it to spot that both branches depend upon the same condition. Please remove that assignment. With that changed:
Quoted 1 line
Reviewed-by Daniel Vetter <[email protected]>
It is this dense, at least gcc 4.8.4 on my machine. :(
Do you want to remove it regardless of the warning?
Rrgards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 7/13 drm/i915: Introduce dedicated object VMA iterator
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
Purpose is to catch places which iterate the object VMA list without holding the big lock.
Implemented by open coding list_for_each_entry to make the macro compatible with existing call sites.
--- drivers/gpu/drm/i915/i915_debugfs.c | 8 ++++---- drivers/gpu/drm/i915/i915_drv.h | 6 ++++++ drivers/gpu/drm/i915/i915_gem.c | 24 ++++++++++++------------ drivers/gpu/drm/i915/i915_gem_gtt.c | 2 +- drivers/gpu/drm/i915/i915_gem_shrinker.c | 2 +- drivers/gpu/drm/i915/i915_gpu_error.c | 4 ++-- 6 files changed, 26 insertions(+), 20 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +4 -4
@@ -117,7 +117,7 @@ static u64 i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj)u64 size =0 ;struct i915_vma *vma; -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {if (i915_is_ggtt (vma->vm) &&drm_mm_node_allocated (&vma->node)) size += vma->node.size;
@@ -155,7 +155,7 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) obj->madv == I915_MADV_DONTNEED ? " purgeable" : "");if (obj->base.name)seq_printf (m," (name: %d)" , obj->base.name); -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {if (vma->pin_count >0 ) pin_count++; }
@@ -164,7 +164,7 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)seq_printf (m," (display)" );if (obj->fence_reg !=I915_FENCE_REG_NONE )seq_printf (m," (fence: %d)" , obj->fence_reg); -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {seq_printf (m," (%sgtt offset: %08llx, size: %08llx" ,i915_is_ggtt (vma->vm) ?"g" :"pp" , vma->node.start, vma->node.size);
@@ -342,7 +342,7 @@ static int per_file_stats(int id, void *ptr, void *data) stats->shared += obj->base.size;if (USES_FULL_PPGTT (obj->base.dev)) { -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {struct i915_hw_ppgtt *ppgtt;if (!drm_mm_node_allocated (&vma->node))
drivers/gpu/drm/i915/i915_drv.h +6 -0
@@ -2852,6 +2852,12 @@ struct drm_i915_gem_object *i915_gem_object_create_from_data(void i915_gem_free_object (struct drm_gem_object *obj);void i915_gem_vma_destroy (struct i915_vma *vma); +#define i915_gem_obj_for_each_vma (vma, obj) \ + for (WARN_ON_ONCE(!mutex_is_locked(&(obj)->base.dev->struct_mutex)), \ + vma = list_first_entry(&(obj)->vma_list, typeof(*vma), vma_link);\ + &vma->vma_link != (&(obj)->vma_list); \ + vma = list_next_entry(vma, vma_link)) +/* Flags used by pin/bind&friends. */ #define PIN_MAPPABLE (1<<0)#define PIN_NONBLOCK (1<<1)
drivers/gpu/drm/i915/i915_gem.c +12 -12
@@ -2442,7 +2442,7 @@ i915_gem_object_retire__read(struct drm_i915_gem_object *obj, int ring)list_move_tail (&obj->global_list, &to_i915 (obj->base.dev)->mm.bound_list); -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {if (!list_empty (&vma->mm_list))list_move_tail (&vma->mm_list, &vma->vm->inactive_list); }
@@ -3834,7 +3834,7 @@ int i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj,*/ } -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {if (!drm_mm_node_allocated (&vma->node))continue ;
@@ -3844,7 +3844,7 @@ int i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj, } } -list_for_each_entry (vma, &obj->vma_list, vma_link) +i915_gem_obj_for_each_vma (vma, obj) vma->node.color = cache_level; obj->cache_level = cache_level;
@@ -4564,7 +4564,7 @@ struct i915_vma *i915_gem_obj_to_vma(struct drm_i915_gem_object *obj, struct i915_address_space *vm) {struct i915_vma *vma; -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {if (vma->ggtt_view.type ==I915_GGTT_VIEW_NORMAL && vma->vm == vm)return vma;
@@ -4581,7 +4581,7 @@ struct i915_vma *i915_gem_obj_to_ggtt_view(struct drm_i915_gem_object *obj,if (WARN_ONCE (!view,"no view specified" ))return ERR_PTR (-EINVAL ); -list_for_each_entry (vma, &obj->vma_list, vma_link) +i915_gem_obj_for_each_vma (vma, obj)if (vma->vm == ggtt &&i915_ggtt_view_equal (&vma->ggtt_view, view))return vma;
@@ -5144,7 +5144,7 @@ u64 i915_gem_obj_offset(struct drm_i915_gem_object *o,WARN_ON (vm == &dev_priv->mm.aliasing_ppgtt->base); -list_for_each_entry (vma, &o->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, o) {if (i915_is_ggtt (vma->vm) && vma->ggtt_view.type !=I915_GGTT_VIEW_NORMAL )continue ;
@@ -5163,7 +5163,7 @@ u64 i915_gem_obj_ggtt_offset_view(struct drm_i915_gem_object *o,struct i915_address_space *ggtt =i915_obj_to_ggtt (o);struct i915_vma *vma; -list_for_each_entry (vma, &o->vma_list, vma_link) +i915_gem_obj_for_each_vma (vma, o)if (vma->vm == ggtt &&i915_ggtt_view_equal (&vma->ggtt_view, view))return vma->node.start;
@@ -5177,7 +5177,7 @@ bool i915_gem_obj_bound(struct drm_i915_gem_object *o, {struct i915_vma *vma; -list_for_each_entry (vma, &o->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, o) {if (i915_is_ggtt (vma->vm) && vma->ggtt_view.type !=I915_GGTT_VIEW_NORMAL )continue ;
@@ -5194,7 +5194,7 @@ bool i915_gem_obj_ggtt_bound_view(struct drm_i915_gem_object *o,struct i915_address_space *ggtt =i915_obj_to_ggtt (o);struct i915_vma *vma; -list_for_each_entry (vma, &o->vma_list, vma_link) +i915_gem_obj_for_each_vma (vma, o)if (vma->vm == ggtt &&i915_ggtt_view_equal (&vma->ggtt_view, view) &&drm_mm_node_allocated (&vma->node))
@@ -5207,7 +5207,7 @@ bool i915_gem_obj_bound_any(struct drm_i915_gem_object *o) {struct i915_vma *vma; -list_for_each_entry (vma, &o->vma_list, vma_link) +i915_gem_obj_for_each_vma (vma, o)if (drm_mm_node_allocated (&vma->node))return true;
@@ -5224,7 +5224,7 @@ unsigned long i915_gem_obj_size(struct drm_i915_gem_object *o,BUG_ON (list_empty (&o->vma_list)); -list_for_each_entry (vma, &o->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, o) {if (i915_is_ggtt (vma->vm) && vma->ggtt_view.type !=I915_GGTT_VIEW_NORMAL )continue ;
@@ -5237,7 +5237,7 @@ unsigned long i915_gem_obj_size(struct drm_i915_gem_object *o,bool i915_gem_obj_is_pinned (struct drm_i915_gem_object *obj) {struct i915_vma *vma; -list_for_each_entry (vma, &obj->vma_list, vma_link) +i915_gem_obj_for_each_vma (vma, obj)if (vma->pin_count >0 )return true;
drivers/gpu/drm/i915/i915_gem_gtt.c +1 -1
@@ -3220,7 +3220,7 @@ void i915_gem_restore_gtt_mappings(struct drm_device *dev) vm = &dev_priv->gtt.base;list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list) { flush = false; -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {if (vma->vm != vm)continue ;
drivers/gpu/drm/i915/i915_gem_shrinker.c +1 -1
@@ -52,7 +52,7 @@ static int num_vma_bound(struct drm_i915_gem_object *obj)struct i915_vma *vma;int count =0 ; -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {if (drm_mm_node_allocated (&vma->node)) count++;if (vma->pin_count)
drivers/gpu/drm/i915/i915_gpu_error.c +2 -2
@@ -755,7 +755,7 @@ static u32 capture_pinned_bo(struct drm_i915_error_buffer *err,if (err == last)break ; -list_for_each_entry (vma, &obj->vma_list, vma_link) +i915_gem_obj_for_each_vma (vma, obj)if (vma->vm == vm && vma->pin_count >0 )capture_bo (err++, vma); }
@@ -1128,7 +1128,7 @@ static void i915_gem_capture_vm(struct drm_i915_private *dev_priv, error->active_bo_count[ndx] = i;list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list) { -list_for_each_entry (vma, &obj->vma_list, vma_link) +i915_gem_obj_for_each_vma (vma, obj)if (vma->vm == vm && vma->pin_count >0 ) i++; }
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 07/13] drm/i915: Introduce dedicated object VMA iterator
drivers/gpu/drm/i915/i915_drv.h struct drm_i915_gem_object *i915_gem_object_create_from_data( · line 2856
Quoted 12 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
Purpose is to catch places which iterate the object VMA list without holding the big lock.
Implemented by open coding
list_for_each_entryto make the macro compatible with existing call sites.Signed-off-by Tvrtko Ursulin <[email protected]>Cc Daniel Vetter <[email protected]>drivers/gpu/drm/i915/i915_drv.h +2
-0+#define i915_gem_obj_for_each_vma (vma, obj) \ + for (WARN_ON_ONCE(!mutex_is_locked(&(obj)->base.dev->struct_mutex)), \
Let's not go around adding WARN(!mutex_locked) to GEM code when lockdep_assert_held doesn't add overhead outside of testing. -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 07/13] drm/i915: Introduce dedicated object VMA iterator
Quoted 9 lines · Chris Wilson
Quoted 8 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
Purpose is to catch places which iterate the object VMA list without holding the big lock.
Implemented by open coding
list_for_each_entryto make the macro compatible with existing call sites.
Quoted 7 lines
drivers/gpu/drm/i915/i915_drv.h struct drm_i915_gem_object *i915_gem_object_create_from_data( · line 2856
Quoted 4 lines
Signed-off-by Tvrtko Ursulin <[email protected]>Cc Daniel Vetter <[email protected]>drivers/gpu/drm/i915/i915_drv.h +2
-0+#define i915_gem_obj_for_each_vma (vma, obj) \ + for (WARN_ON_ONCE(!mutex_is_locked(&(obj)->base.dev->struct_mutex)), \Let's not go around adding
WARN(!mutex_locked)to GEM code whenlockdep_assert_helddoesn't add overhead outside of testing.
Hm yeah I still prefere WARN_ON for modeset code (where it doesn't matter) because of increased test coverage. But for gem it indeed makes more sense to only do this for lockdep-enabled builds. CI runs with lockdep, so we're good.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 07/13] drm/i915: Introduce dedicated object VMA iterator
In reply to Tvrtko UrsulinQuoted 64 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
Purpose is to catch places which iterate the object VMA list without holding the big lock.
Implemented by open coding
list_for_each_entryto make the macro compatible with existing call sites.Signed-off-by Tvrtko Ursulin <[email protected]>Cc Daniel Vetter <[email protected]>--- drivers/gpu/drm/i915/i915_debugfs.c | 8 ++++---- drivers/gpu/drm/i915/i915_drv.h | 6 ++++++ drivers/gpu/drm/i915/i915_gem.c | 24 ++++++++++++------------ drivers/gpu/drm/i915/i915_gem_gtt.c | 2 +- drivers/gpu/drm/i915/i915_gem_shrinker.c | 2 +- drivers/gpu/drm/i915/i915_gpu_error.c | 4 ++-- 6 files changed, 26 insertions(+), 20 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +4
-4@@ -117,7 +117,7 @@ static u64 i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj)u64 size =0 ;struct i915_vma *vma; -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {if (i915_is_ggtt (vma->vm) &&drm_mm_node_allocated (&vma->node)) size += vma->node.size;@@ -155,7 +155,7 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) obj->madv == I915_MADV_DONTNEED ? " purgeable" : "");if (obj->base.name)seq_printf (m," (name: %d)" , obj->base.name); -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {if (vma->pin_count >0 ) pin_count++; }@@ -164,7 +164,7 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)seq_printf (m," (display)" );if (obj->fence_reg !=I915_FENCE_REG_NONE )seq_printf (m," (fence: %d)" , obj->fence_reg); -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {seq_printf (m," (%sgtt offset: %08llx, size: %08llx" ,i915_is_ggtt (vma->vm) ?"g" :"pp" , vma->node.start, vma->node.size);@@ -342,7 +342,7 @@ static int per_file_stats(int id, void *ptr, void *data) stats->shared += obj->base.size;if (USES_FULL_PPGTT (obj->base.dev)) { -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {struct i915_hw_ppgtt *ppgtt;if (!drm_mm_node_allocated (&vma->node))drivers/gpu/drm/i915/i915_drv.h +0
-0
drivers/gpu/drm/i915/i915_drv.h struct drm_i915_gem_object *i915_gem_object_create_from_data( · line 2860
Quoted 9 lines
drivers/gpu/drm/i915/i915_drv.h +6
-0@@ -2852,6 +2852,12 @@ struct drm_i915_gem_object *i915_gem_object_create_from_data(void i915_gem_free_object (struct drm_gem_object *obj);void i915_gem_vma_destroy (struct i915_vma *vma); +#define i915_gem_obj_for_each_vma (vma, obj) \ + for (WARN_ON_ONCE(!mutex_is_locked(&(obj)->base.dev->struct_mutex)), \ + vma = list_first_entry(&(obj)->vma_list, typeof(*vma), vma_link);\ + &vma->vma_link != (&(obj)->vma_list); \ + vma = list_next_entry(vma, vma_link)) +
Unfortunately error capture is not happy with this approach. Can't even see that error capture attempts to grab the mutex anywhere.
So what? Drop the idea or add a "doing error capture" flag somewhere?
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 07/13] drm/i915: Introduce dedicated object VMA iterator
Quoted 80 lines · Tvrtko Ursulin
Quoted 64 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
Purpose is to catch places which iterate the object VMA list without holding the big lock.
Implemented by open coding
list_for_each_entryto make the macro compatible with existing call sites.Signed-off-by Tvrtko Ursulin <[email protected]>Cc Daniel Vetter <[email protected]>--- drivers/gpu/drm/i915/i915_debugfs.c | 8 ++++---- drivers/gpu/drm/i915/i915_drv.h | 6 ++++++ drivers/gpu/drm/i915/i915_gem.c | 24 ++++++++++++------------ drivers/gpu/drm/i915/i915_gem_gtt.c | 2 +- drivers/gpu/drm/i915/i915_gem_shrinker.c | 2 +- drivers/gpu/drm/i915/i915_gpu_error.c | 4 ++-- 6 files changed, 26 insertions(+), 20 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +4
-4@@ -117,7 +117,7 @@ static u64 i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj)u64 size =0 ;struct i915_vma *vma; -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {if (i915_is_ggtt (vma->vm) &&drm_mm_node_allocated (&vma->node)) size += vma->node.size;@@ -155,7 +155,7 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) obj->madv == I915_MADV_DONTNEED ? " purgeable" : "");if (obj->base.name)seq_printf (m," (name: %d)" , obj->base.name); -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {if (vma->pin_count >0 ) pin_count++; }@@ -164,7 +164,7 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)seq_printf (m," (display)" );if (obj->fence_reg !=I915_FENCE_REG_NONE )seq_printf (m," (fence: %d)" , obj->fence_reg); -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {seq_printf (m," (%sgtt offset: %08llx, size: %08llx" ,i915_is_ggtt (vma->vm) ?"g" :"pp" , vma->node.start, vma->node.size);@@ -342,7 +342,7 @@ static int per_file_stats(int id, void *ptr, void *data) stats->shared += obj->base.size;if (USES_FULL_PPGTT (obj->base.dev)) { -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {struct i915_hw_ppgtt *ppgtt;if (!drm_mm_node_allocated (&vma->node))drivers/gpu/drm/i915/i915_drv.h +0
-0drivers/gpu/drm/i915/i915_drv.h struct drm_i915_gem_object *i915_gem_object_create_from_data( · line 2860
Quoted 9 lines
drivers/gpu/drm/i915/i915_drv.h +6
-0@@ -2852,6 +2852,12 @@ struct drm_i915_gem_object *i915_gem_object_create_from_data(void i915_gem_free_object (struct drm_gem_object *obj);void i915_gem_vma_destroy (struct i915_vma *vma); +#define i915_gem_obj_for_each_vma (vma, obj) \ + for (WARN_ON_ONCE(!mutex_is_locked(&(obj)->base.dev->struct_mutex)), \ + vma = list_first_entry(&(obj)->vma_list, typeof(*vma), vma_link);\ + &vma->vma_link != (&(obj)->vma_list); \ + vma = list_next_entry(vma, vma_link)) +Unfortunately error capture is not happy with this approach. Can't even see that error capture attempts to grab the mutex anywhere.
Quoted 1 line
So what? Drop the idea or add a "doing error capture" flag somewhere?
Fix the bugs. Not surprise at all that we've screwed this up all over the place ;-) Afaics modeset code isn't much better either ... -Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 07/13] drm/i915: Introduce dedicated object VMA iterator
Quoted 81 lines · Daniel Vetter
Quoted 80 lines · Tvrtko Ursulin
Quoted 64 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
Purpose is to catch places which iterate the object VMA list without holding the big lock.
Implemented by open coding
list_for_each_entryto make the macro compatible with existing call sites.Signed-off-by Tvrtko Ursulin <[email protected]>Cc Daniel Vetter <[email protected]>--- drivers/gpu/drm/i915/i915_debugfs.c | 8 ++++---- drivers/gpu/drm/i915/i915_drv.h | 6 ++++++ drivers/gpu/drm/i915/i915_gem.c | 24 ++++++++++++------------ drivers/gpu/drm/i915/i915_gem_gtt.c | 2 +- drivers/gpu/drm/i915/i915_gem_shrinker.c | 2 +- drivers/gpu/drm/i915/i915_gpu_error.c | 4 ++-- 6 files changed, 26 insertions(+), 20 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +4
-4@@ -117,7 +117,7 @@ static u64 i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj)u64 size =0 ;struct i915_vma *vma; -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {if (i915_is_ggtt (vma->vm) &&drm_mm_node_allocated (&vma->node)) size += vma->node.size;@@ -155,7 +155,7 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) obj->madv == I915_MADV_DONTNEED ? " purgeable" : "");if (obj->base.name)seq_printf (m," (name: %d)" , obj->base.name); -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {if (vma->pin_count >0 ) pin_count++; }@@ -164,7 +164,7 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)seq_printf (m," (display)" );if (obj->fence_reg !=I915_FENCE_REG_NONE )seq_printf (m," (fence: %d)" , obj->fence_reg); -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {seq_printf (m," (%sgtt offset: %08llx, size: %08llx" ,i915_is_ggtt (vma->vm) ?"g" :"pp" , vma->node.start, vma->node.size);@@ -342,7 +342,7 @@ static int per_file_stats(int id, void *ptr, void *data) stats->shared += obj->base.size;if (USES_FULL_PPGTT (obj->base.dev)) { -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {struct i915_hw_ppgtt *ppgtt;if (!drm_mm_node_allocated (&vma->node))drivers/gpu/drm/i915/i915_drv.h +0
-0drivers/gpu/drm/i915/i915_drv.h struct drm_i915_gem_object *i915_gem_object_create_from_data( · line 2860
Quoted 9 lines
drivers/gpu/drm/i915/i915_drv.h +6
-0@@ -2852,6 +2852,12 @@ struct drm_i915_gem_object *i915_gem_object_create_from_data(void i915_gem_free_object (struct drm_gem_object *obj);void i915_gem_vma_destroy (struct i915_vma *vma); +#define i915_gem_obj_for_each_vma (vma, obj) \ + for (WARN_ON_ONCE(!mutex_is_locked(&(obj)->base.dev->struct_mutex)), \ + vma = list_first_entry(&(obj)->vma_list, typeof(*vma), vma_link);\ + &vma->vma_link != (&(obj)->vma_list); \ + vma = list_next_entry(vma, vma_link)) +Unfortunately error capture is not happy with this approach. Can't even see that error capture attempts to grab the mutex anywhere.
Quoted 4 lines
Quoted 1 line
So what? Drop the idea or add a "doing error capture" flag somewhere?
Fix the bugs. Not surprise at all that we've screwed this up all over the place ;-) Afaics modeset code isn't much better either ...
Ok I'll drop this patch then since the series contains fixes to all but one related issues. The remaining one is then:
[ 17.370366] ------------[ cut here ]------------ [ 17.375633] WARNING: CPU: 0 PID: 1128 at drivers/gpu/drm/i915/i915_gem.c:5166 i915_gem_obj_ggtt_offset_view+0x10f/0x120 [i915]() [ 17.388879] WARN_ON_ONCE(!mutex_is_locked(&(o)->base.dev->struct_mutex)) [ 17.396364] Modules linked in: hid_generic usbhid coretemp asix usbnet libphy mii i915 gpio_lynxpoint i2c_hid hid video i2c_algo_bit drm_kms_helper acpi_pad drm lpc_ich mfd_core nls_iso8859_1 e1000e ptp ahci libahci pps_core [ 17.419484] CPU: 0 PID: 1128 Comm: Xorg Tainted: G U 4.4.0-rc8-160107+ #105 [ 17.428771] Hardware name: Intel Corporation Broadwell Client platform/WhiteTip Mountain 1, BIOS BDW-E1R1.86C.0080.R01.1406120446 06/12/2014 [ 17.443161] ffffffffa0227790 ffff8800a98439b8 ffffffff81280d82 ffff8800a9843a00 [ 17.451677] ffff8800a98439f0 ffffffff81049c8c ffff8801495d0000 ffff8800aa934900 [ 17.460166] ffff8801495d8668 ffffffffa0242520 ffff8800aacea000 ffff8800a9843a50 [ 17.468674] Call Trace: [ 17.471470] [<ffffffff81280d82>] dump_stack+0x4b/0x79 [ 17.477355] [<ffffffff81049c8c>] warn_slowpath_common+0x7c/0xc0 [ 17.484255] [<ffffffff81049d17>] warn_slowpath_fmt+0x47/0x50 [ 17.490869] [<ffffffffa018f7ef>] i915_gem_obj_ggtt_offset_view+0x10f/0x120 [i915] [ 17.499572] [<ffffffffa01a7290>] ? gen9_write8+0x2d0/0x2d0 [i915] [ 17.506663] [<ffffffffa01bdbfe>] ironlake_update_primary_plane+0x1ee/0x3a0 [i915] [ 17.515358] [<ffffffffa01ace1f>] intel_plane_atomic_update+0x5f/0x70 [i915] [ 17.523391] [<ffffffffa00ef122>] drm_atomic_helper_commit_planes_on_crtc+0x142/0x230 [drm_kms_helper] [ 17.534063] [<ffffffffa01c1744>] intel_atomic_commit+0x424/0x2270 [i915] [ 17.541763] [<ffffffff814ee04a>] ? __ww_mutex_lock+0x4a/0x82 [ 17.548355] [<ffffffffa0097edb>] ? drm_atomic_check_only+0x12b/0x5e0 [drm] [ 17.556352] [<ffffffffa0097a07>] ? drm_atomic_set_crtc_for_connector+0x77/0xf0 [drm] [ 17.565346] [<ffffffffa00983c2>] drm_atomic_commit+0x32/0x50 [drm] [ 17.572553] [<ffffffffa00ef782>] drm_atomic_helper_set_config+0x72/0xb0 [drm_kms_helper] [ 17.581954] [<ffffffffa0088e8f>] drm_mode_set_config_internal+0x5f/0x100 [drm] [ 17.590313] [<ffffffffa008cdc8>] drm_mode_setcrtc+0xd8/0x500 [drm] [ 17.597491] [<ffffffffa007f5d8>] drm_ioctl+0x258/0x4f0 [drm] [ 17.604065] [<ffffffff810c34ac>] ? unlock_page+0x4c/0x50 [ 17.610245] [<ffffffffa008ccf0>] ? drm_mode_setplane+0x1c0/0x1c0 [drm] [ 17.617844] [<ffffffff8111597d>] do_vfs_ioctl+0x2cd/0x4a0 [ 17.624137] [<ffffffff81052572>] ? recalc_sigpending+0x12/0x40 [ 17.630943] [<ffffffff8111eb32>] ? __fget+0x72/0xb0 [ 17.636645] [<ffffffff81115b8c>] SyS_ioctl+0x3c/0x70 [ 17.642448] [<ffffffff81055301>] ? SyS_rt_sigprocmask+0x81/0xa0 [ 17.649334] [<ffffffff814f0017>] entry_SYSCALL_64_fastpath+0x12/0x6a [ 17.656740] ---[ end trace 3f29190006c97826 ]---
Would you like a BZ for this or maybe it is known already?
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 07/13] drm/i915: Introduce dedicated object VMA iterator
Quoted 128 lines · Tvrtko Ursulin
Quoted 81 lines · Daniel Vetter
Quoted 80 lines · Tvrtko Ursulin
Quoted 64 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
Purpose is to catch places which iterate the object VMA list without holding the big lock.
Implemented by open coding
list_for_each_entryto make the macro compatible with existing call sites.Signed-off-by Tvrtko Ursulin <[email protected]>Cc Daniel Vetter <[email protected]>--- drivers/gpu/drm/i915/i915_debugfs.c | 8 ++++---- drivers/gpu/drm/i915/i915_drv.h | 6 ++++++ drivers/gpu/drm/i915/i915_gem.c | 24 ++++++++++++------------ drivers/gpu/drm/i915/i915_gem_gtt.c | 2 +- drivers/gpu/drm/i915/i915_gem_shrinker.c | 2 +- drivers/gpu/drm/i915/i915_gpu_error.c | 4 ++-- 6 files changed, 26 insertions(+), 20 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +4
-4@@ -117,7 +117,7 @@ static u64 i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj)u64 size =0 ;struct i915_vma *vma; -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {if (i915_is_ggtt (vma->vm) &&drm_mm_node_allocated (&vma->node)) size += vma->node.size;@@ -155,7 +155,7 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) obj->madv == I915_MADV_DONTNEED ? " purgeable" : "");if (obj->base.name)seq_printf (m," (name: %d)" , obj->base.name); -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {if (vma->pin_count >0 ) pin_count++; }@@ -164,7 +164,7 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)seq_printf (m," (display)" );if (obj->fence_reg !=I915_FENCE_REG_NONE )seq_printf (m," (fence: %d)" , obj->fence_reg); -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {seq_printf (m," (%sgtt offset: %08llx, size: %08llx" ,i915_is_ggtt (vma->vm) ?"g" :"pp" , vma->node.start, vma->node.size);@@ -342,7 +342,7 @@ static int per_file_stats(int id, void *ptr, void *data) stats->shared += obj->base.size;if (USES_FULL_PPGTT (obj->base.dev)) { -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {struct i915_hw_ppgtt *ppgtt;if (!drm_mm_node_allocated (&vma->node))drivers/gpu/drm/i915/i915_drv.h +0
-0drivers/gpu/drm/i915/i915_drv.h struct drm_i915_gem_object *i915_gem_object_create_from_data( · line 2860
Quoted 9 lines
drivers/gpu/drm/i915/i915_drv.h +6
-0@@ -2852,6 +2852,12 @@ struct drm_i915_gem_object *i915_gem_object_create_from_data(void i915_gem_free_object (struct drm_gem_object *obj);void i915_gem_vma_destroy (struct i915_vma *vma); +#define i915_gem_obj_for_each_vma (vma, obj) \ + for (WARN_ON_ONCE(!mutex_is_locked(&(obj)->base.dev->struct_mutex)), \ + vma = list_first_entry(&(obj)->vma_list, typeof(*vma), vma_link);\ + &vma->vma_link != (&(obj)->vma_list); \ + vma = list_next_entry(vma, vma_link)) +Unfortunately error capture is not happy with this approach. Can't even see that error capture attempts to grab the mutex anywhere.
Quoted 4 lines
Quoted 1 line
So what? Drop the idea or add a "doing error capture" flag somewhere?
Fix the bugs. Not surprise at all that we've screwed this up all over the place ;-) Afaics modeset code isn't much better either ...
Ok I'll drop this patch then since the series contains fixes to all but one related issues. The remaining one is then:
[ 17.370366] ------------[ cut here ]------------ [ 17.375633] WARNING: CPU: 0 PID: 1128 at drivers/gpu/drm/i915/i915_gem.c:5166 i915_gem_obj_ggtt_offset_view+0x10f/0x120 [i915]() [ 17.388879] WARN_ON_ONCE(!mutex_is_locked(&(o)->base.dev->struct_mutex)) [ 17.396364] Modules linked in: hid_generic usbhid coretemp asix usbnet libphy mii i915 gpio_lynxpoint i2c_hid hid video i2c_algo_bit drm_kms_helper acpi_pad drm lpc_ich mfd_core nls_iso8859_1 e1000e ptp ahci libahci pps_core [ 17.419484] CPU: 0 PID: 1128 Comm: Xorg Tainted: G U 4.4.0-rc8-160107+ #105 [ 17.428771] Hardware name: Intel Corporation Broadwell Client platform/WhiteTip Mountain 1, BIOS BDW-E1R1.86C.0080.R01.1406120446 06/12/2014 [ 17.443161] ffffffffa0227790 ffff8800a98439b8 ffffffff81280d82 ffff8800a9843a00 [ 17.451677] ffff8800a98439f0 ffffffff81049c8c ffff8801495d0000 ffff8800aa934900 [ 17.460166] ffff8801495d8668 ffffffffa0242520 ffff8800aacea000 ffff8800a9843a50 [ 17.468674] Call Trace: [ 17.471470] [<ffffffff81280d82>] dump_stack+0x4b/0x79 [ 17.477355] [<ffffffff81049c8c>] warn_slowpath_common+0x7c/0xc0 [ 17.484255] [<ffffffff81049d17>] warn_slowpath_fmt+0x47/0x50 [ 17.490869] [<ffffffffa018f7ef>] i915_gem_obj_ggtt_offset_view+0x10f/0x120 [i915] [ 17.499572] [<ffffffffa01a7290>] ? gen9_write8+0x2d0/0x2d0 [i915] [ 17.506663] [<ffffffffa01bdbfe>] ironlake_update_primary_plane+0x1ee/0x3a0 [i915] [ 17.515358] [<ffffffffa01ace1f>] intel_plane_atomic_update+0x5f/0x70 [i915] [ 17.523391] [<ffffffffa00ef122>] drm_atomic_helper_commit_planes_on_crtc+0x142/0x230 [drm_kms_helper] [ 17.534063] [<ffffffffa01c1744>] intel_atomic_commit+0x424/0x2270 [i915] [ 17.541763] [<ffffffff814ee04a>] ? __ww_mutex_lock+0x4a/0x82 [ 17.548355] [<ffffffffa0097edb>] ? drm_atomic_check_only+0x12b/0x5e0 [drm] [ 17.556352] [<ffffffffa0097a07>] ? drm_atomic_set_crtc_for_connector+0x77/0xf0 [drm] [ 17.565346] [<ffffffffa00983c2>] drm_atomic_commit+0x32/0x50 [drm] [ 17.572553] [<ffffffffa00ef782>] drm_atomic_helper_set_config+0x72/0xb0 [drm_kms_helper] [ 17.581954] [<ffffffffa0088e8f>] drm_mode_set_config_internal+0x5f/0x100 [drm] [ 17.590313] [<ffffffffa008cdc8>] drm_mode_setcrtc+0xd8/0x500 [drm] [ 17.597491] [<ffffffffa007f5d8>] drm_ioctl+0x258/0x4f0 [drm] [ 17.604065] [<ffffffff810c34ac>] ? unlock_page+0x4c/0x50 [ 17.610245] [<ffffffffa008ccf0>] ? drm_mode_setplane+0x1c0/0x1c0 [drm] [ 17.617844] [<ffffffff8111597d>] do_vfs_ioctl+0x2cd/0x4a0 [ 17.624137] [<ffffffff81052572>] ? recalc_sigpending+0x12/0x40 [ 17.630943] [<ffffffff8111eb32>] ? __fget+0x72/0xb0 [ 17.636645] [<ffffffff81115b8c>] SyS_ioctl+0x3c/0x70 [ 17.642448] [<ffffffff81055301>] ? SyS_rt_sigprocmask+0x81/0xa0 [ 17.649334] [<ffffffff814f0017>] entry_SYSCALL_64_fastpath+0x12/0x6a [ 17.656740] ---[ end trace 3f29190006c97826 ]---
Quoted 1 line
Would you like a BZ for this or maybe it is known already?
Maarten is working on this, or at least we're tracking it already in VIZ-7000.
Can you pls coordinate with Maarten to make sure the final "enable the warning" patch lands only once all the bits are in?
Thanks, Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 07/13] drm/i915: Introduce dedicated object VMA iterator
Op 12-01-16 om 17:19 schreef Daniel Vetter:
Quoted 124 lines · Tvrtko Ursulin
Quoted 123 lines · Daniel Vetter
Quoted 79 lines · Tvrtko Ursulin
Quoted 78 lines · Tvrtko Ursulin
Quoted 64 lines
From: Tvrtko Ursulin <[email protected]>
Purpose is to catch places which iterate the object VMA list without holding the big lock.
Implemented by open coding
list_for_each_entryto make the macro compatible with existing call sites.Signed-off-by Tvrtko Ursulin <[email protected]>Cc Daniel Vetter <[email protected]>--- drivers/gpu/drm/i915/i915_debugfs.c | 8 ++++---- drivers/gpu/drm/i915/i915_drv.h | 6 ++++++ drivers/gpu/drm/i915/i915_gem.c | 24 ++++++++++++------------ drivers/gpu/drm/i915/i915_gem_gtt.c | 2 +- drivers/gpu/drm/i915/i915_gem_shrinker.c | 2 +- drivers/gpu/drm/i915/i915_gpu_error.c | 4 ++-- 6 files changed, 26 insertions(+), 20 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +4
-4@@ -117,7 +117,7 @@ static u64 i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj)u64 size =0 ;struct i915_vma *vma; -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {if (i915_is_ggtt (vma->vm) &&drm_mm_node_allocated (&vma->node)) size += vma->node.size;@@ -155,7 +155,7 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) obj->madv == I915_MADV_DONTNEED ? " purgeable" : "");if (obj->base.name)seq_printf (m," (name: %d)" , obj->base.name); -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {if (vma->pin_count >0 ) pin_count++; }@@ -164,7 +164,7 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)seq_printf (m," (display)" );if (obj->fence_reg !=I915_FENCE_REG_NONE )seq_printf (m," (fence: %d)" , obj->fence_reg); -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {seq_printf (m," (%sgtt offset: %08llx, size: %08llx" ,i915_is_ggtt (vma->vm) ?"g" :"pp" , vma->node.start, vma->node.size);@@ -342,7 +342,7 @@ static int per_file_stats(int id, void *ptr, void *data) stats->shared += obj->base.size;if (USES_FULL_PPGTT (obj->base.dev)) { -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {struct i915_hw_ppgtt *ppgtt;if (!drm_mm_node_allocated (&vma->node))drivers/gpu/drm/i915/i915_drv.h +0
-0drivers/gpu/drm/i915/i915_drv.h struct drm_i915_gem_object *i915_gem_object_create_from_data( · line 2860
Quoted 9 lines
drivers/gpu/drm/i915/i915_drv.h +6
-0@@ -2852,6 +2852,12 @@ struct drm_i915_gem_object *i915_gem_object_create_from_data(void i915_gem_free_object (struct drm_gem_object *obj);void i915_gem_vma_destroy (struct i915_vma *vma); +#define i915_gem_obj_for_each_vma (vma, obj) \ + for (WARN_ON_ONCE(!mutex_is_locked(&(obj)->base.dev->struct_mutex)), \ + vma = list_first_entry(&(obj)->vma_list, typeof(*vma), vma_link);\ + &vma->vma_link != (&(obj)->vma_list); \ + vma = list_next_entry(vma, vma_link)) +Unfortunately error capture is not happy with this approach. Can't even see that error capture attempts to grab the mutex anywhere.
Quoted 3 lines
Quoted 1 line
So what? Drop the idea or add a "doing error capture" flag somewhere?
Fix the bugs. Not surprise at all that we've screwed this up all over the place ;-) Afaics modeset code isn't much better either ...
Ok I'll drop this patch then since the series contains fixes to all but one related issues. The remaining one is then:
[ 17.370366] ------------[ cut here ]------------ [ 17.375633] WARNING: CPU: 0 PID: 1128 at drivers/gpu/drm/i915/i915_gem.c:5166 i915_gem_obj_ggtt_offset_view+0x10f/0x120 [i915]() [ 17.388879] WARN_ON_ONCE(!mutex_is_locked(&(o)->base.dev->struct_mutex)) [ 17.396364] Modules linked in: hid_generic usbhid coretemp asix usbnet libphy mii i915 gpio_lynxpoint i2c_hid hid video i2c_algo_bit drm_kms_helper acpi_pad drm lpc_ich mfd_core nls_iso8859_1 e1000e ptp ahci libahci pps_core [ 17.419484] CPU: 0 PID: 1128 Comm: Xorg Tainted: G U 4.4.0-rc8-160107+ #105 [ 17.428771] Hardware name: Intel Corporation Broadwell Client platform/WhiteTip Mountain 1, BIOS BDW-E1R1.86C.0080.R01.1406120446 06/12/2014 [ 17.443161] ffffffffa0227790 ffff8800a98439b8 ffffffff81280d82 ffff8800a9843a00 [ 17.451677] ffff8800a98439f0 ffffffff81049c8c ffff8801495d0000 ffff8800aa934900 [ 17.460166] ffff8801495d8668 ffffffffa0242520 ffff8800aacea000 ffff8800a9843a50 [ 17.468674] Call Trace: [ 17.471470] [<ffffffff81280d82>] dump_stack+0x4b/0x79 [ 17.477355] [<ffffffff81049c8c>] warn_slowpath_common+0x7c/0xc0 [ 17.484255] [<ffffffff81049d17>] warn_slowpath_fmt+0x47/0x50 [ 17.490869] [<ffffffffa018f7ef>] i915_gem_obj_ggtt_offset_view+0x10f/0x120 [i915] [ 17.499572] [<ffffffffa01a7290>] ? gen9_write8+0x2d0/0x2d0 [i915] [ 17.506663] [<ffffffffa01bdbfe>] ironlake_update_primary_plane+0x1ee/0x3a0 [i915] [ 17.515358] [<ffffffffa01ace1f>] intel_plane_atomic_update+0x5f/0x70 [i915] [ 17.523391] [<ffffffffa00ef122>] drm_atomic_helper_commit_planes_on_crtc+0x142/0x230 [drm_kms_helper] [ 17.534063] [<ffffffffa01c1744>] intel_atomic_commit+0x424/0x2270 [i915] [ 17.541763] [<ffffffff814ee04a>] ? __ww_mutex_lock+0x4a/0x82 [ 17.548355] [<ffffffffa0097edb>] ? drm_atomic_check_only+0x12b/0x5e0 [drm] [ 17.556352] [<ffffffffa0097a07>] ? drm_atomic_set_crtc_for_connector+0x77/0xf0 [drm] [ 17.565346] [<ffffffffa00983c2>] drm_atomic_commit+0x32/0x50 [drm] [ 17.572553] [<ffffffffa00ef782>] drm_atomic_helper_set_config+0x72/0xb0 [drm_kms_helper] [ 17.581954] [<ffffffffa0088e8f>] drm_mode_set_config_internal+0x5f/0x100 [drm] [ 17.590313] [<ffffffffa008cdc8>] drm_mode_setcrtc+0xd8/0x500 [drm] [ 17.597491] [<ffffffffa007f5d8>] drm_ioctl+0x258/0x4f0 [drm] [ 17.604065] [<ffffffff810c34ac>] ? unlock_page+0x4c/0x50 [ 17.610245] [<ffffffffa008ccf0>] ? drm_mode_setplane+0x1c0/0x1c0 [drm] [ 17.617844] [<ffffffff8111597d>] do_vfs_ioctl+0x2cd/0x4a0 [ 17.624137] [<ffffffff81052572>] ? recalc_sigpending+0x12/0x40 [ 17.630943] [<ffffffff8111eb32>] ? __fget+0x72/0xb0 [ 17.636645] [<ffffffff81115b8c>] SyS_ioctl+0x3c/0x70 [ 17.642448] [<ffffffff81055301>] ? SyS_rt_sigprocmask+0x81/0xa0 [ 17.649334] [<ffffffff814f0017>] entry_SYSCALL_64_fastpath+0x12/0x6a [ 17.656740] ---[ end trace 3f29190006c97826 ]---
Quoted 7 lines
Quoted 1 line
Would you like a BZ for this or maybe it is known already?
Maarten is working on this, or at least we're tracking it already in VIZ-7000.
Can you pls coordinate with Maarten to make sure the final "enable the warning" patch lands only once all the bits are in?
Chris Wilson's patch bomb makes it possible to use the vma instead of grabbing the view over and over, and that should fix this specific error.
~Maarten
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 07/13] drm/i915: Introduce dedicated object VMA iterator
In reply to Daniel VetterQuoted 129 lines · Daniel Vetter
Quoted 128 lines · Tvrtko Ursulin
Quoted 81 lines · Daniel Vetter
Quoted 80 lines · Tvrtko Ursulin
Quoted 64 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
Purpose is to catch places which iterate the object VMA list without holding the big lock.
Implemented by open coding
list_for_each_entryto make the macro compatible with existing call sites.Signed-off-by Tvrtko Ursulin <[email protected]>Cc Daniel Vetter <[email protected]>--- drivers/gpu/drm/i915/i915_debugfs.c | 8 ++++---- drivers/gpu/drm/i915/i915_drv.h | 6 ++++++ drivers/gpu/drm/i915/i915_gem.c | 24 ++++++++++++------------ drivers/gpu/drm/i915/i915_gem_gtt.c | 2 +- drivers/gpu/drm/i915/i915_gem_shrinker.c | 2 +- drivers/gpu/drm/i915/i915_gpu_error.c | 4 ++-- 6 files changed, 26 insertions(+), 20 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +4
-4@@ -117,7 +117,7 @@ static u64 i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj)u64 size =0 ;struct i915_vma *vma; -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {if (i915_is_ggtt (vma->vm) &&drm_mm_node_allocated (&vma->node)) size += vma->node.size;@@ -155,7 +155,7 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) obj->madv == I915_MADV_DONTNEED ? " purgeable" : "");if (obj->base.name)seq_printf (m," (name: %d)" , obj->base.name); -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {if (vma->pin_count >0 ) pin_count++; }@@ -164,7 +164,7 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)seq_printf (m," (display)" );if (obj->fence_reg !=I915_FENCE_REG_NONE )seq_printf (m," (fence: %d)" , obj->fence_reg); -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {seq_printf (m," (%sgtt offset: %08llx, size: %08llx" ,i915_is_ggtt (vma->vm) ?"g" :"pp" , vma->node.start, vma->node.size);@@ -342,7 +342,7 @@ static int per_file_stats(int id, void *ptr, void *data) stats->shared += obj->base.size;if (USES_FULL_PPGTT (obj->base.dev)) { -list_for_each_entry (vma, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma (vma, obj) {struct i915_hw_ppgtt *ppgtt;if (!drm_mm_node_allocated (&vma->node))drivers/gpu/drm/i915/i915_drv.h +0
-0drivers/gpu/drm/i915/i915_drv.h struct drm_i915_gem_object *i915_gem_object_create_from_data( · line 2860
Quoted 9 lines
drivers/gpu/drm/i915/i915_drv.h +6
-0@@ -2852,6 +2852,12 @@ struct drm_i915_gem_object *i915_gem_object_create_from_data(void i915_gem_free_object (struct drm_gem_object *obj);void i915_gem_vma_destroy (struct i915_vma *vma); +#define i915_gem_obj_for_each_vma (vma, obj) \ + for (WARN_ON_ONCE(!mutex_is_locked(&(obj)->base.dev->struct_mutex)), \ + vma = list_first_entry(&(obj)->vma_list, typeof(*vma), vma_link);\ + &vma->vma_link != (&(obj)->vma_list); \ + vma = list_next_entry(vma, vma_link)) +Unfortunately error capture is not happy with this approach. Can't even see that error capture attempts to grab the mutex anywhere.
Quoted 4 lines
Quoted 1 line
So what? Drop the idea or add a "doing error capture" flag somewhere?
Fix the bugs. Not surprise at all that we've screwed this up all over the place ;-) Afaics modeset code isn't much better either ...
Ok I'll drop this patch then since the series contains fixes to all but one related issues. The remaining one is then:
[ 17.370366] ------------[ cut here ]------------ [ 17.375633] WARNING: CPU: 0 PID: 1128 at drivers/gpu/drm/i915/i915_gem.c:5166 i915_gem_obj_ggtt_offset_view+0x10f/0x120 [i915]() [ 17.388879] WARN_ON_ONCE(!mutex_is_locked(&(o)->base.dev->struct_mutex)) [ 17.396364] Modules linked in: hid_generic usbhid coretemp asix usbnet libphy mii i915 gpio_lynxpoint i2c_hid hid video i2c_algo_bit drm_kms_helper acpi_pad drm lpc_ich mfd_core nls_iso8859_1 e1000e ptp ahci libahci pps_core [ 17.419484] CPU: 0 PID: 1128 Comm: Xorg Tainted: G U 4.4.0-rc8-160107+ #105 [ 17.428771] Hardware name: Intel Corporation Broadwell Client platform/WhiteTip Mountain 1, BIOS BDW-E1R1.86C.0080.R01.1406120446 06/12/2014 [ 17.443161] ffffffffa0227790 ffff8800a98439b8 ffffffff81280d82 ffff8800a9843a00 [ 17.451677] ffff8800a98439f0 ffffffff81049c8c ffff8801495d0000 ffff8800aa934900 [ 17.460166] ffff8801495d8668 ffffffffa0242520 ffff8800aacea000 ffff8800a9843a50 [ 17.468674] Call Trace: [ 17.471470] [<ffffffff81280d82>] dump_stack+0x4b/0x79 [ 17.477355] [<ffffffff81049c8c>] warn_slowpath_common+0x7c/0xc0 [ 17.484255] [<ffffffff81049d17>] warn_slowpath_fmt+0x47/0x50 [ 17.490869] [<ffffffffa018f7ef>] i915_gem_obj_ggtt_offset_view+0x10f/0x120 [i915] [ 17.499572] [<ffffffffa01a7290>] ? gen9_write8+0x2d0/0x2d0 [i915] [ 17.506663] [<ffffffffa01bdbfe>] ironlake_update_primary_plane+0x1ee/0x3a0 [i915] [ 17.515358] [<ffffffffa01ace1f>] intel_plane_atomic_update+0x5f/0x70 [i915] [ 17.523391] [<ffffffffa00ef122>] drm_atomic_helper_commit_planes_on_crtc+0x142/0x230 [drm_kms_helper] [ 17.534063] [<ffffffffa01c1744>] intel_atomic_commit+0x424/0x2270 [i915] [ 17.541763] [<ffffffff814ee04a>] ? __ww_mutex_lock+0x4a/0x82 [ 17.548355] [<ffffffffa0097edb>] ? drm_atomic_check_only+0x12b/0x5e0 [drm] [ 17.556352] [<ffffffffa0097a07>] ? drm_atomic_set_crtc_for_connector+0x77/0xf0 [drm] [ 17.565346] [<ffffffffa00983c2>] drm_atomic_commit+0x32/0x50 [drm] [ 17.572553] [<ffffffffa00ef782>] drm_atomic_helper_set_config+0x72/0xb0 [drm_kms_helper] [ 17.581954] [<ffffffffa0088e8f>] drm_mode_set_config_internal+0x5f/0x100 [drm] [ 17.590313] [<ffffffffa008cdc8>] drm_mode_setcrtc+0xd8/0x500 [drm] [ 17.597491] [<ffffffffa007f5d8>] drm_ioctl+0x258/0x4f0 [drm] [ 17.604065] [<ffffffff810c34ac>] ? unlock_page+0x4c/0x50 [ 17.610245] [<ffffffffa008ccf0>] ? drm_mode_setplane+0x1c0/0x1c0 [drm] [ 17.617844] [<ffffffff8111597d>] do_vfs_ioctl+0x2cd/0x4a0 [ 17.624137] [<ffffffff81052572>] ? recalc_sigpending+0x12/0x40 [ 17.630943] [<ffffffff8111eb32>] ? __fget+0x72/0xb0 [ 17.636645] [<ffffffff81115b8c>] SyS_ioctl+0x3c/0x70 [ 17.642448] [<ffffffff81055301>] ? SyS_rt_sigprocmask+0x81/0xa0 [ 17.649334] [<ffffffff814f0017>] entry_SYSCALL_64_fastpath+0x12/0x6a [ 17.656740] ---[ end trace 3f29190006c97826 ]---
Quoted 7 lines
Quoted 1 line
Would you like a BZ for this or maybe it is known already?
Maarten is working on this, or at least we're tracking it already in VIZ-7000.
Can you pls coordinate with Maarten to make sure the final "enable the warning" patch lands only once all the bits are in?
Oh I dropped that patch due the error capture problem - do you have a suggestion how to handle that?
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 8/13 drm/i915: GEM operations need to be done under the big lock
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
VMA creation and GEM list management need the big lock.
--- drivers/gpu/drm/i915/i915_gem_stolen.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/i915/i915_gem_stolen.c +5 -0
@@ -670,9 +670,12 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,if (gtt_offset ==I915_GTT_OFFSET_NONE )return obj; +mutex_lock (&dev->struct_mutex); + vma =i915_gem_obj_lookup_or_create_vma (obj, ggtt);if (IS_ERR (vma)) { ret =PTR_ERR (vma); +mutex_unlock (&dev->struct_mutex); goto err; }
@@ -698,6 +701,8 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,list_add_tail (&obj->global_list, &dev_priv->mm.bound_list);i915_gem_object_pin_pages (obj); +mutex_unlock (&dev->struct_mutex); +return obj; err:
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 08/13] drm/i915: GEM operations need to be done under the big lock
Quoted 3 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
VMA creation and GEM list management need the big lock.
No, this operation doesn't require locking.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 08/13] drm/i915: GEM operations need to be done under the big lock
Quoted 6 lines · Chris Wilson
Quoted 3 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
VMA creation and GEM list management need the big lock.
No, this operation doesn't require locking.
My bad, there's a vm->list tracking. I was thinking of the obj->vma_list.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 08/13] drm/i915: GEM operations need to be done under the big lock
In reply to Chris WilsonQuoted 6 lines · Chris Wilson
Quoted 3 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
VMA creation and GEM list management need the big lock.
No, this operation doesn't require locking.
You can argue about positioning and such, but it is adding it to the bound and inactive list...
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 08/13] drm/i915: GEM operations need to be done under the big lock
Quoted 11 lines · Tvrtko Ursulin
Quoted 6 lines · Chris Wilson
Quoted 3 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
VMA creation and GEM list management need the big lock.
No, this operation doesn't require locking.
You can argue about positioning and such, but it is adding it to the bound and inactive list...
Actually you raise a good point about the other stolen series, namely we need to push this lock up to the caller since we have the samme issue wit i915_gem_object_create_stolen() which I don't remember that we fixed in valleyview_setup_pctx().
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 8/13 drm/i915: GEM operations need to be done under the big lock
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
VMA creation and GEM list management need the big lock.
v2:
Mutex unlock ended on the wrong path somehow. (0-day, Julia Lawall)
Not to mention drm_gem_object_unreference was there in existing code with no mutex held.
--- drivers/gpu/drm/i915/i915_gem_stolen.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/i915/i915_gem_stolen.c +5 -0
@@ -670,6 +670,8 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,if (gtt_offset ==I915_GTT_OFFSET_NONE )return obj; +mutex_lock (&dev->struct_mutex); + vma =i915_gem_obj_lookup_or_create_vma (obj, ggtt);if (IS_ERR (vma)) { ret =PTR_ERR (vma);
@@ -698,9 +700,12 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,list_add_tail (&obj->global_list, &dev_priv->mm.bound_list);i915_gem_object_pin_pages (obj); +mutex_unlock (&dev->struct_mutex); +return obj; err:drm_gem_object_unreference (&obj->base); +mutex_unlock (&dev->struct_mutex);return NULL ; }
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v3 8/13 drm/i915: GEM operations need to be done under the big lock
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
VMA creation and GEM list management need the big lock.
v2:
Mutex unlock ended on the wrong path somehow. (0-day, Julia Lawall)
Not to mention drm_gem_object_unreference was there in existing code with no mutex held.
v3:
Some callers of i915_gem_object_create_stolen_for_preallocated already hold the lock so move the mutex into the other caller as well.
--- drivers/gpu/drm/i915/i915_gem_stolen.c | 3 +++ drivers/gpu/drm/i915/intel_display.c | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_gem_stolen.c +3 -0
@@ -635,6 +635,9 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,if (!drm_mm_initialized (&dev_priv->mm.stolen))return NULL ; +if (WARN_ON_ONCE (!mutex_is_locked (&dev->struct_mutex))) +return NULL ; +DRM_DEBUG_KMS ("creating preallocated stolen object: stolen_offset=%x, gtt_offset=%x, size=%x\n" , stolen_offset, gtt_offset, size);
drivers/gpu/drm/i915/intel_display.c +6 -2
@@ -2534,12 +2534,16 @@ intel_alloc_initial_plane_obj(struct intel_crtc *crtc,if (size_aligned *2 > dev_priv->gtt.stolen_usable_size)return false; +mutex_lock (&dev->struct_mutex); + obj =i915_gem_object_create_stolen_for_preallocated (dev, base_aligned, base_aligned, size_aligned); -if (!obj) +if (!obj) { +mutex_unlock (&dev->struct_mutex);return false; + } obj->tiling_mode = plane_config->tiling;if (obj->tiling_mode ==I915_TILING_X )
@@ -2552,12 +2556,12 @@ intel_alloc_initial_plane_obj(struct intel_crtc *crtc, mode_cmd.modifier[0 ] = fb->modifier[0 ]; mode_cmd.flags =DRM_MODE_FB_MODIFIERS ; -mutex_lock (&dev->struct_mutex);if (intel_framebuffer_init (dev,to_intel_framebuffer (fb), &mode_cmd, obj)) {DRM_DEBUG_KMS ("intel fb init failed\n" ); goto out_unref_obj; } +mutex_unlock (&dev->struct_mutex);DRM_DEBUG_KMS ("initial plane fb obj %p\n" , obj);
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 9/13 drm/i915: Remove two impossible asserts
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
Engine initialization would have failed if those two weren't pinned and calling i915_gem_obj_is_pinned is illegal from irq context without the big lock held.
--- drivers/gpu/drm/i915/intel_lrc.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +0 -2
@@ -350,8 +350,6 @@ static int execlists_update_context(struct drm_i915_gem_request *rq)uint32_t *reg_state;BUG_ON (!ctx_obj); -WARN_ON (!i915_gem_obj_is_pinned (ctx_obj)); -WARN_ON (!i915_gem_obj_is_pinned (rb_obj)); page =i915_gem_object_get_dirty_page (ctx_obj,LRC_STATE_PN ); reg_state =kmap_atomic (page);
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 09/13] drm/i915: Remove two impossible asserts
Quoted 7 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
Engine initialization would have failed if those two weren't pinned and calling
i915_gem_obj_is_pinnedis illegal from irq context without the big lock held.Signed-off-by Tvrtko Ursulin <[email protected]>
Quoted 24 lines
--- drivers/gpu/drm/i915/intel_lrc.c | 2 -- 1 file changed, 2 deletions(-)drivers/gpu/drm/i915/intel_lrc.c +0
-2@@ -350,8 +350,6 @@ static int execlists_update_context(struct drm_i915_gem_request *rq)uint32_t *reg_state;BUG_ON (!ctx_obj); -WARN_ON (!i915_gem_obj_is_pinned (ctx_obj)); -WARN_ON (!i915_gem_obj_is_pinned (rb_obj)); page =i915_gem_object_get_dirty_page (ctx_obj,LRC_STATE_PN ); reg_state =kmap_atomic (page);Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 10/13 drm/i915: Introduce dedicated safe object VMA iterator
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
Purpose is to catch places which iterate the object VMA list without holding the big lock.
Implemented by open coding list_for_each_entry_safe to make the macro compatible with existing call sites.
--- drivers/gpu/drm/i915/i915_drv.h | 7 +++++++ drivers/gpu/drm/i915/i915_gem.c | 6 +++--- drivers/gpu/drm/i915/i915_gem_shrinker.c | 3 +-- drivers/gpu/drm/i915/i915_gem_userptr.c | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +7 -0
@@ -2858,6 +2858,13 @@ void i915_gem_vma_destroy(struct i915_vma *vma); &vma->vma_link != (&(obj)->vma_list); \ vma = list_next_entry(vma, vma_link)) +#define i915_gem_obj_for_each_vma_safe (vma, next, obj) \ + for (WARN_ON_ONCE(!mutex_is_locked(&(obj)->base.dev->struct_mutex)), \ + vma = list_first_entry(&(obj)->vma_list, typeof(*vma), vma_link), \ + next = list_next_entry(vma, vma_link); \ + &vma->vma_link != (&(obj)->vma_list); \ + vma = next, next = list_next_entry(next, vma_link)) +/* Flags used by pin/bind&friends. */ #define PIN_MAPPABLE (1<<0)#define PIN_NONBLOCK (1<<1)
drivers/gpu/drm/i915/i915_gem.c +3 -3
@@ -272,7 +272,7 @@ drop_pages(struct drm_i915_gem_object *obj)int ret;drm_gem_object_reference (&obj->base); -list_for_each_entry_safe (vma, next, &obj->vma_list, vma_link) +i915_gem_obj_for_each_vma_safe (vma, next, obj)if (i915_vma_unbind (vma))break ;
@@ -3771,7 +3771,7 @@ int i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj,* catch the issue of the CS prefetch crossing page boundaries and * reading an invalid PTE on older architectures. */ -list_for_each_entry_safe (vma, next, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma_safe (vma, next, obj) {if (!drm_mm_node_allocated (&vma->node))continue ;
@@ -4507,7 +4507,7 @@ void i915_gem_free_object(struct drm_gem_object *gem_obj)trace_i915_gem_object_destroy (obj); -list_for_each_entry_safe (vma, next, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma_safe (vma, next, obj) {int ret; vma->pin_count =0 ;
drivers/gpu/drm/i915/i915_gem_shrinker.c +1 -2
@@ -175,8 +175,7 @@ i915_gem_shrink(struct drm_i915_private *dev_priv,drm_gem_object_reference (&obj->base);/* For the unbound phase, this should be a no-op! */ -list_for_each_entry_safe (vma, v, - &obj->vma_list, vma_link) +i915_gem_obj_for_each_vma_safe (vma, v, obj)if (i915_vma_unbind (vma))break ;
drivers/gpu/drm/i915/i915_gem_userptr.c +1 -1
@@ -81,7 +81,7 @@ static void __cancel_userptr__worker(struct work_struct *work) was_interruptible = dev_priv->mm.interruptible; dev_priv->mm.interruptible = false; -list_for_each_entry_safe (vma, tmp, &obj->vma_list, vma_link) { +i915_gem_obj_for_each_vma_safe (vma, tmp, obj) {int ret =i915_vma_unbind (vma);WARN_ON (ret && ret != -EIO ); }
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 11/13 drm/i915: Cache ringbuffer GTT address
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
Purpose is to avoid calling i915_gem_obj_ggtt_offset from the interrupt context without the big lock held.
--- drivers/gpu/drm/i915/intel_lrc.c | 3 +-- drivers/gpu/drm/i915/intel_ringbuffer.c | 3 +++ drivers/gpu/drm/i915/intel_ringbuffer.h | 1 + 3 files changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +1 -2
@@ -345,7 +345,6 @@ static int execlists_update_context(struct drm_i915_gem_request *rq)struct intel_engine_cs *ring = rq->ring;struct i915_hw_ppgtt *ppgtt = rq->ctx->ppgtt;struct drm_i915_gem_object *ctx_obj = rq->ctx->engine[ring->id].state; -struct drm_i915_gem_object *rb_obj = rq->ringbuf->obj;struct page *page;uint32_t *reg_state;
@@ -355,7 +354,7 @@ static int execlists_update_context(struct drm_i915_gem_request *rq) reg_state =kmap_atomic (page); reg_state[CTX_RING_TAIL +1 ] = rq->tail; - reg_state[CTX_RING_BUFFER_START +1 ] =i915_gem_obj_ggtt_offset (rb_obj); + reg_state[CTX_RING_BUFFER_START +1 ] = rq->ringbuf->gtt_start;if (ppgtt && !USES_FULL_48BIT_PPGTT (ppgtt->base.dev)) {/* True 32b PPGTT with dynamic page allocation: update PDP
drivers/gpu/drm/i915/intel_ringbuffer.c +3 -0
@@ -1988,6 +1988,7 @@ void intel_unpin_ringbuffer_obj(struct intel_ringbuffer *ringbuf)else iounmap (ringbuf->virtual_start); ringbuf->virtual_start =NULL ; + ringbuf->gtt_start =0 ;i915_gem_object_ggtt_unpin (ringbuf->obj); }
@@ -2054,6 +2055,8 @@ int intel_pin_and_map_ringbuffer_obj(struct drm_device *dev, } } + ringbuf->gtt_start =i915_gem_obj_ggtt_offset (obj); +return 0 ; }
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -0
@@ -98,6 +98,7 @@ struct intel_ring_hangcheck {struct intel_ringbuffer {struct drm_i915_gem_object *obj;void __iomem *virtual_start; +u64 gtt_start;struct intel_engine_cs *ring;struct list_head link;
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 11/13] drm/i915: Cache ringbuffer GTT address
Quoted 4 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
Purpose is to avoid calling
i915_gem_obj_ggtt_offsetfrom the interrupt context without the big lock held.
No. Move to tracking VMA.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 11/13] drm/i915: Cache ringbuffer GTT address
In reply to Tvrtko UrsulinQuoted 59 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
Purpose is to avoid calling
i915_gem_obj_ggtt_offsetfrom the interrupt context without the big lock held.Signed-off-by Tvrtko Ursulin <[email protected]>--- drivers/gpu/drm/i915/intel_lrc.c | 3 +-- drivers/gpu/drm/i915/intel_ringbuffer.c | 3 +++ drivers/gpu/drm/i915/intel_ringbuffer.h | 1 + 3 files changed, 5 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/intel_lrc.c +1
-2@@ -345,7 +345,6 @@ static int execlists_update_context(struct drm_i915_gem_request *rq)struct intel_engine_cs *ring = rq->ring;struct i915_hw_ppgtt *ppgtt = rq->ctx->ppgtt;struct drm_i915_gem_object *ctx_obj = rq->ctx->engine[ring->id].state; -struct drm_i915_gem_object *rb_obj = rq->ringbuf->obj;struct page *page;uint32_t *reg_state;@@ -355,7 +354,7 @@ static int execlists_update_context(struct drm_i915_gem_request *rq) reg_state =kmap_atomic (page); reg_state[CTX_RING_TAIL +1 ] = rq->tail; - reg_state[CTX_RING_BUFFER_START +1 ] =i915_gem_obj_ggtt_offset (rb_obj); + reg_state[CTX_RING_BUFFER_START +1 ] = rq->ringbuf->gtt_start;if (ppgtt && !USES_FULL_48BIT_PPGTT (ppgtt->base.dev)) {/* True 32b PPGTT with dynamic page allocation: update PDP drivers/gpu/drm/i915/intel_ringbuffer.c +3
-0@@ -1988,6 +1988,7 @@ void intel_unpin_ringbuffer_obj(struct intel_ringbuffer *ringbuf)else iounmap (ringbuf->virtual_start); ringbuf->virtual_start =NULL ; + ringbuf->gtt_start =0 ;i915_gem_object_ggtt_unpin (ringbuf->obj); }@@ -2054,6 +2055,8 @@ int intel_pin_and_map_ringbuffer_obj(struct drm_device *dev, } } + ringbuf->gtt_start =i915_gem_obj_ggtt_offset (obj); +return 0 ; }drivers/gpu/drm/i915/intel_ringbuffer.h +0
-0
drivers/gpu/drm/i915/intel_ringbuffer.h struct intel_ring_hangcheck { · line 101
Quoted 4 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +1
-0@@ -98,6 +98,7 @@ struct intel_ring_hangcheck {struct intel_ringbuffer {struct drm_i915_gem_object *obj;void __iomem *virtual_start; +u64 gtt_start;
gtt_offset, because consistency. Or vma, as Chris suggested. -Daniel
Quoted 10 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +0
-0struct intel_engine_cs *ring;struct list_head link;Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v3 3/7 drm/i915: Cache ringbuffer GTT VMA
From: Tvrtko Ursulin <[email protected]>
Purpose is to avoid calling i915_gem_obj_ggtt_offset from the interrupt context without the big lock held.
v2: Renamed gtt_start to gtt_offset. (Daniel Vetter)
v3: Cache the VMA instead of address. (Chris Wilson)
--- drivers/gpu/drm/i915/intel_lrc.c | 3 +-- drivers/gpu/drm/i915/intel_ringbuffer.c | 3 +++ drivers/gpu/drm/i915/intel_ringbuffer.h | 1 + 3 files changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +1 -2
@@ -340,7 +340,6 @@ static int execlists_update_context(struct drm_i915_gem_request *rq)struct intel_engine_cs *ring = rq->ring;struct i915_hw_ppgtt *ppgtt = rq->ctx->ppgtt;struct drm_i915_gem_object *ctx_obj = rq->ctx->engine[ring->id].state; -struct drm_i915_gem_object *rb_obj = rq->ringbuf->obj;struct page *page;uint32_t *reg_state;
@@ -350,7 +349,7 @@ static int execlists_update_context(struct drm_i915_gem_request *rq) reg_state =kmap_atomic (page); reg_state[CTX_RING_TAIL +1 ] = rq->tail; - reg_state[CTX_RING_BUFFER_START +1 ] =i915_gem_obj_ggtt_offset (rb_obj); + reg_state[CTX_RING_BUFFER_START +1 ] = rq->ringbuf->vma->node.start;if (ppgtt && !USES_FULL_48BIT_PPGTT (ppgtt->base.dev)) {/* True 32b PPGTT with dynamic page allocation: update PDP
drivers/gpu/drm/i915/intel_ringbuffer.c +3 -0
@@ -1988,6 +1988,7 @@ void intel_unpin_ringbuffer_obj(struct intel_ringbuffer *ringbuf)else iounmap (ringbuf->virtual_start); ringbuf->virtual_start =NULL ; + ringbuf->vma =NULL ;i915_gem_object_ggtt_unpin (ringbuf->obj); }
@@ -2054,6 +2055,8 @@ int intel_pin_and_map_ringbuffer_obj(struct drm_device *dev, } } + ringbuf->vma =i915_gem_obj_to_ggtt (obj); +return 0 ; }
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -0
@@ -99,6 +99,7 @@ struct intel_ring_hangcheck {struct intel_ringbuffer {struct drm_i915_gem_object *obj;void __iomem *virtual_start; +struct i915_vma *vma;struct intel_engine_cs *ring;struct list_head link;
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v3 3/7] drm/i915: Cache ringbuffer GTT VMA
Quoted 11 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
Purpose is to avoid calling
i915_gem_obj_ggtt_offsetfrom the interrupt context without the big lock held.v2: Renamed
gtt_starttogtt_offset. (Daniel Vetter)
v3: Cache the VMA instead of address. (Chris Wilson)Signed-off-by Tvrtko Ursulin <[email protected]>Cc Daniel Vetter <[email protected]>Cc Chris Wilson <[email protected]>
I feel like I have done this before...
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 11/13] drm/i915: Cache ringbuffer GTT address
In reply to Tvrtko UrsulinQuoted 38 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
Purpose is to avoid calling
i915_gem_obj_ggtt_offsetfrom the interrupt context without the big lock held.Signed-off-by Tvrtko Ursulin <[email protected]>--- drivers/gpu/drm/i915/intel_lrc.c | 3 +-- drivers/gpu/drm/i915/intel_ringbuffer.c | 3 +++ drivers/gpu/drm/i915/intel_ringbuffer.h | 1 + 3 files changed, 5 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/intel_lrc.c +1
-2@@ -345,7 +345,6 @@ static int execlists_update_context(struct drm_i915_gem_request *rq)struct intel_engine_cs *ring = rq->ring;struct i915_hw_ppgtt *ppgtt = rq->ctx->ppgtt;struct drm_i915_gem_object *ctx_obj = rq->ctx->engine[ring->id].state; -struct drm_i915_gem_object *rb_obj = rq->ringbuf->obj;struct page *page;uint32_t *reg_state;@@ -355,7 +354,7 @@ static int execlists_update_context(struct drm_i915_gem_request *rq) reg_state =kmap_atomic (page); reg_state[CTX_RING_TAIL +1 ] = rq->tail; - reg_state[CTX_RING_BUFFER_START +1 ] =i915_gem_obj_ggtt_offset (rb_obj); + reg_state[CTX_RING_BUFFER_START +1 ] = rq->ringbuf->gtt_start;if (ppgtt && !USES_FULL_48BIT_PPGTT (ppgtt->base.dev)) {/* True 32b PPGTT with dynamic page allocation: update PDP drivers/gpu/drm/i915/intel_ringbuffer.c +0
-0
drivers/gpu/drm/i915/intel_ringbuffer.c void intel_unpin_ringbuffer_obj(struct intel_ringbuffer *ringbuf) · line 1991
Quoted 4 lines
drivers/gpu/drm/i915/intel_ringbuffer.c +1
-0@@ -1988,6 +1988,7 @@ void intel_unpin_ringbuffer_obj(struct intel_ringbuffer *ringbuf)else iounmap (ringbuf->virtual_start); ringbuf->virtual_start =NULL ; + ringbuf->gtt_start =0 ;
Zero isn't an invalid GTT address (although it does cause confusion). Maybe we should define a suitable value to indicate not-an-address? Anything with low bits set, or above 4Gb, is not valid, so perhaps:
#define I915_GTT_BAD_ADDRESS (~(u64)0)
.Dave.
Quoted 18 lines
drivers/gpu/drm/i915/intel_ringbuffer.c +2
-0i915_gem_object_ggtt_unpin (ringbuf->obj); }@@ -2054,6 +2055,8 @@ int intel_pin_and_map_ringbuffer_obj(struct drm_device *dev, } } + ringbuf->gtt_start =i915_gem_obj_ggtt_offset (obj); +return 0 ; }drivers/gpu/drm/i915/intel_ringbuffer.h +0
-0
drivers/gpu/drm/i915/intel_ringbuffer.h struct intel_ring_hangcheck { · line 104
Quoted 7 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +1
-0@@ -98,6 +98,7 @@ struct intel_ring_hangcheck {struct intel_ringbuffer {struct drm_i915_gem_object *obj;void __iomem *virtual_start; +u64 gtt_start;struct intel_engine_cs *ring;struct list_head link;
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 11/13] drm/i915: Cache ringbuffer GTT address
Quoted 46 lines · Dave Gordon
Quoted 45 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
Purpose is to avoid calling
i915_gem_obj_ggtt_offsetfrom the interrupt context without the big lock held.Signed-off-by Tvrtko Ursulin <[email protected]>--- drivers/gpu/drm/i915/intel_lrc.c | 3 +-- drivers/gpu/drm/i915/intel_ringbuffer.c | 3 +++ drivers/gpu/drm/i915/intel_ringbuffer.h | 1 + 3 files changed, 5 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/intel_lrc.c +0
-1@@ -345,7 +345,6 @@ static int execlists_update_context(struct drm_i915_gem_request *rq)struct intel_engine_cs *ring = rq->ring;struct i915_hw_ppgtt *ppgtt = rq->ctx->ppgtt;struct drm_i915_gem_object *ctx_obj = rq->ctx->engine[ring->id].state; -struct drm_i915_gem_object *rb_obj = rq->ringbuf->obj;struct page *page;uint32_t *reg_state;drivers/gpu/drm/i915/intel_lrc.c +1
-1@@ -355,7 +354,7 @@ static int execlists_update_context(struct drm_i915_gem_request *rq) reg_state =kmap_atomic (page); reg_state[CTX_RING_TAIL +1 ] = rq->tail; - reg_state[CTX_RING_BUFFER_START +1 ] =i915_gem_obj_ggtt_offset (rb_obj); + reg_state[CTX_RING_BUFFER_START +1 ] = rq->ringbuf->gtt_start;if (ppgtt && !USES_FULL_48BIT_PPGTT(ppgtt->base.dev)) { /* True 32b PPGTT with dynamic page allocation: update PDPdrivers/gpu/drm/i915/intel_ringbuffer.c +0
-0@@ -1988,6 +1988,7 @@ void intel_unpin_ringbuffer_obj(struct intel_ringbuffer *ringbuf)
Quoted 8 lines
drivers/gpu/drm/i915/intel_ringbuffer.c void intel_unpin_ringbuffer_obj(struct intel_ringbuffer *ringbuf) · line 1991
Quoted 4 lines
drivers/gpu/drm/i915/intel_ringbuffer.c +1
-0else iounmap (ringbuf->virtual_start); ringbuf->virtual_start =NULL ; + ringbuf->gtt_start =0 ;Zero isn't an invalid GTT address (although it does cause confusion). Maybe we should define a suitable value to indicate not-an-address? Anything with low bits set, or above 4Gb, is not valid, so perhaps:
Oh yes, it crossed my mind and then I forgot about it, so thanks!
Quoted 1 line
#define
I915_GTT_BAD_ADDRESS(~(u64)0)
It would match current behaviour of i915_gem_obj_offset(_view) of returning -1 when VMA is not found so I think it is good enough to go with this approach.
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 12/13 drm/i915: Add BKL asserts to get page helpers
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
Purpose is catching illegal callers.
--- drivers/gpu/drm/i915/i915_drv.h | 2 ++ drivers/gpu/drm/i915/i915_gem.c | 2 ++ 2 files changed, 4 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +2 -0
@@ -2916,6 +2916,8 @@ i915_gem_object_get_dirty_page(struct drm_i915_gem_object *obj, int n);static inline struct page *i915_gem_object_get_page (struct drm_i915_gem_object *obj,int n) { +WARN_ON_ONCE (!mutex_is_locked (&obj->base.dev->struct_mutex)); +if (WARN_ON (n >= obj->base.size >>PAGE_SHIFT ))return NULL ;
drivers/gpu/drm/i915/i915_gem.c +2 -0
@@ -5250,6 +5250,8 @@ i915_gem_object_get_dirty_page(struct drm_i915_gem_object *obj, int n) {struct page *page; +WARN_ON_ONCE (!mutex_is_locked (&obj->base.dev->struct_mutex)); +/* Only default objects have per-page dirty tracking */ if (WARN_ON (obj->ops != &i915_gem_object_ops))return NULL ;
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 12/13] drm/i915: Add BKL asserts to get page helpers
Quoted 3 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
Purpose is catching illegal callers.
I know you didn't try benchmarking this.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 13/13 drm/i915: Cache LRC state page in the context
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
LRC lifetime is well defined so we can cache the page pointing to the object backing store in the context in order to avoid walking over the object SG page list from the interrupt context without the big lock held.
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_lrc.c | 17 +++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -882,6 +882,7 @@ struct intel_context {struct intel_ringbuffer *ringbuf;int pin_count;u32 lrca; +struct page *lrc_state_page; } engine[I915_NUM_RINGS ];struct list_head link;
drivers/gpu/drm/i915/intel_lrc.c +11 -6
@@ -344,14 +344,10 @@ static int execlists_update_context(struct drm_i915_gem_request *rq) {struct intel_engine_cs *ring = rq->ring;struct i915_hw_ppgtt *ppgtt = rq->ctx->ppgtt; -struct drm_i915_gem_object *ctx_obj = rq->ctx->engine[ring->id].state; -struct page *page;uint32_t *reg_state; -BUG_ON (!ctx_obj); - - page =i915_gem_object_get_dirty_page (ctx_obj,LRC_STATE_PN ); - reg_state =kmap_atomic (page); +BUG_ON (!rq->ctx->engine[ring->id].lrc_state_page); + reg_state =kmap_atomic (rq->ctx->engine[ring->id].lrc_state_page); reg_state[CTX_RING_TAIL +1 ] = rq->tail; reg_state[CTX_RING_BUFFER_START +1 ] = rq->ringbuf->gtt_start;
@@ -1021,6 +1017,7 @@ static int intel_lr_context_do_pin(struct intel_engine_cs *ring,struct drm_i915_private *dev_priv = dev->dev_private;struct drm_i915_gem_object *ctx_obj = ctx->engine[ring->id].state;struct intel_ringbuffer *ringbuf = ctx->engine[ring->id].ringbuf; +struct page *lrc_state_page;u64 lrca;int ret;
@@ -1037,11 +1034,18 @@ static int intel_lr_context_do_pin(struct intel_engine_cs *ring, goto unpin_ctx_obj; } + lrc_state_page =i915_gem_object_get_dirty_page (ctx_obj,LRC_STATE_PN ); +if (WARN_ON (!lrc_state_page)) { + ret = -ENODEV ; + goto unpin_ctx_obj; + } + ret =intel_pin_and_map_ringbuffer_obj (ring->dev, ringbuf);if (ret) goto unpin_ctx_obj; ctx->engine[ring->id].lrca = lrca; + ctx->engine[ring->id].lrc_state_page = lrc_state_page; ctx_obj->dirty = true;/* Invalidate GuC TLB. */
@@ -1085,6 +1089,7 @@ void intel_lr_context_unpin(struct drm_i915_gem_request *rq)intel_unpin_ringbuffer_obj (ringbuf);i915_gem_object_ggtt_unpin (ctx_obj); rq->ctx->engine[ring->id].lrca =0 ; + rq->ctx->engine[ring->id].lrc_state_page =NULL ; } } }
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 4 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
Random cleanups from yesterday mutated into a bit of locking verification and fixing as suggested by Daniel Vetter.
Rather than duplicating my work, please do help fix the bugs that are impeding moving forwards.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ failure: Fi.CI.BAT
In reply to Tvrtko Ursulin== Summary ==
== Summary ==
Built on ff88655b3a5467bbc3be8c67d3e05ebf182557d3 drm-intel-nightly: 2016y-01m-11d-07h-30m-16s UTC integration manifest
Test gem_basic:
Subgroup create-close:
pass -> DMESG-WARN (skl-i7k-2)
Test gem_cpu_reloc:
Subgroup basic:
pass -> DMESG-FAIL (skl-i7k-2)
Test gem_ctx_param_basic:
Subgroup basic:
pass -> DMESG-WARN (skl-i7k-2)
Subgroup invalid-param-set:
pass -> DMESG-WARN (skl-i7k-2)
Subgroup non-root-set-no-zeromap:
pass -> DMESG-WARN (skl-i7k-2)
Subgroup root-set-no-zeromap-disabled:
pass -> DMESG-WARN (skl-i7k-2)
Test gem_mmap:
Subgroup basic:
pass -> DMESG-WARN (skl-i7k-2)
Test gem_mmap_gtt:
Subgroup basic-read:
pass -> DMESG-WARN (skl-i7k-2)
Subgroup basic-write:
pass -> DMESG-WARN (skl-i7k-2)
Test gem_storedw_loop:
Subgroup basic-render:
dmesg-warn -> PASS (skl-i7k-2) UNSTABLE
Test kms_addfb_basic:
Subgroup addfb25-modifier-no-flag:
pass -> DMESG-WARN (skl-i7k-2)
Subgroup addfb25-x-tiled-mismatch:
pass -> DMESG-WARN (skl-i7k-2)
Subgroup addfb25-yf-tiled:
pass -> DMESG-WARN (skl-i7k-2)
Subgroup bad-pitch-1024:
pass -> DMESG-WARN (skl-i7k-2)
Subgroup bad-pitch-63:
pass -> DMESG-WARN (skl-i7k-2)
Subgroup bad-pitch-999:
pass -> DMESG-WARN (skl-i7k-2)
Subgroup clobberred-modifier:
pass -> DMESG-WARN (skl-i7k-2)
Subgroup too-high:
pass -> DMESG-WARN (skl-i7k-2)
Subgroup too-wide:
pass -> DMESG-WARN (skl-i7k-2)
Subgroup unused-offsets:
pass -> DMESG-WARN (skl-i7k-2)
Test kms_flip:
Subgroup basic-flip-vs-dpms:
dmesg-warn -> PASS (ilk-hp8440p)
Subgroup basic-plain-flip:
pass -> DMESG-FAIL (skl-i7k-2)
Test kms_pipe_crc_basic:
Subgroup hang-read-crc-pipe-a:
pass -> DMESG-WARN (skl-i5k-2)
pass -> DMESG-WARN (bdw-ultra)
pass -> DMESG-WARN (skl-i7k-2)
pass -> DMESG-WARN (byt-nuc)
pass -> DMESG-WARN (snb-x220t)
pass -> DMESG-WARN (snb-dellxps)
pass -> DMESG-WARN (hsw-brixbox)
pass -> DMESG-WARN (ilk-hp8440p)
Subgroup nonblocking-crc-pipe-a-frame-sequence:
pass -> DMESG-FAIL (skl-i7k-2)
Subgroup read-crc-pipe-b:
dmesg-warn -> PASS (byt-nuc)
Subgroup read-crc-pipe-b-frame-sequence:
pass -> DMESG-FAIL (skl-i7k-2)
Test prime_self_import:
Subgroup basic-with_two_bos:
pass -> DMESG-WARN (skl-i7k-2)bdw-ultra total:138 pass:129 dwarn:3 dfail:0 fail:0 skip:6 bsw-nuc-2 total:141 pass:113 dwarn:4 dfail:0 fail:0 skip:24 byt-nuc total:141 pass:117 dwarn:9 dfail:0 fail:0 skip:15 hsw-brixbox total:141 pass:132 dwarn:2 dfail:0 fail:0 skip:7 ilk-hp8440p total:141 pass:100 dwarn:4 dfail:0 fail:0 skip:37 skl-i5k-2 total:141 pass:130 dwarn:3 dfail:0 fail:0 skip:8 skl-i7k-2 total:141 pass:106 dwarn:22 dfail:4 fail:0 skip:8 snb-dellxps total:141 pass:121 dwarn:6 dfail:0 fail:0 skip:14 snb-x220t total:141 pass:121 dwarn:6 dfail:0 fail:1 skip:13
HANGED hsw-gt2 in igt@kms_pipe_crc_basic@suspend-read-crc-pipe-c
Results at /archive/results/CI_IGT_test/Patchwork_1115/
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx