Execlists v5
Subsystems (3)
Re: [PATCH 31/43] drm/i915/bdw: Handle context switch events
In reply to Thomas DanielQuoted 24 lines · Thomas Daniel
Handle all context status events in the context status buffer on every context switch interrupt. We only remove work from the execlist queue after a context status buffer reports that it has completed and we only attempt to schedule new contexts on interrupt when a previously submitted context completes (unless no contexts are queued, which means the GPU is free).
We canot call
intel_runtime_pm_get()in an interrupt (or with a spinlock grabbed, FWIW), because it might sleep, which is not a nice thing to do. Instead, do theruntime_pmget/put together with the create/destroy request, and handle the forcewake get/put directly.Signed-off-by Thomas Daniel <[email protected]>v2: Unreferencing the context when we are freeing the request might free the backing bo, which requires the
struct_mutexto be grabbed, so defer unreferencing and freeing to a bottom half.v3:
- Ack the interrupt inmediately, before trying to handle it (fix for missing interrupts by Bob Beckett <[email protected]>).
- Update the Context Status Buffer Read Pointer, just in case (spotted by Damien Lespiau).
Quoted 6 lines
v4: New namespace and multiple rebase changes.
v5: Squash with "drm/i915/bdw: Do not call
intel_runtime_pm_get()in an interrupt", as suggested by Daniel.Signed-off-by Oscar Mateo <[email protected]>
One more ...
Quoted 1 line
+void
intel_execlists_handle_ctx_events(struct intel_engine_cs *ring)
Please rename this to intel_execlist_ctx_events_irq_handler or similar for consistency with all the other irq handler functions in a follow-up patch. That kind of consistency helps a lot when reviewing the locking of irq-save spinlocks.
-Daniel
Quoted 112 lines
drivers/gpu/drm/i915/intel_lrc.c +62
-0+{ +struct drm_i915_private *dev_priv = ring->dev->dev_private; +u32 status_pointer; +u8 read_pointer; +u8 write_pointer; +u32 status; +u32 status_id; +u32 submit_contexts =0 ; + + status_pointer =I915_READ (RING_CONTEXT_STATUS_PTR (ring)); + + read_pointer = ring->next_context_status_buffer; + write_pointer = status_pointer &0x07 ; +if (read_pointer > write_pointer) + write_pointer +=6 ; + +spin_lock (&ring->execlist_lock); + +while (read_pointer < write_pointer) { + read_pointer++; + status =I915_READ (RING_CONTEXT_STATUS_BUF (ring) + + (read_pointer %6 ) *8 ); + status_id =I915_READ (RING_CONTEXT_STATUS_BUF (ring) + + (read_pointer %6 ) *8 +4 ); + +if (status &GEN8_CTX_STATUS_COMPLETE ) { +if (execlists_check_remove_request (ring, status_id)) + submit_contexts++; + } + } + +if (submit_contexts !=0 ) +execlists_context_unqueue (ring); + +spin_unlock (&ring->execlist_lock); + +WARN (submit_contexts >2 ,"More than two context complete events?\n" ); + ring->next_context_status_buffer = write_pointer %6 ; + +I915_WRITE (RING_CONTEXT_STATUS_PTR (ring), + ((u32 )ring->next_context_status_buffer &0x07 ) <<8 ); +} + +static void execlists_free_request_task (struct work_struct *work) +{ +struct intel_ctx_submit_request *req = + container_of(work, struct intel_ctx_submit_request, work); +struct drm_device *dev = req->ring->dev; +struct drm_i915_private *dev_priv = dev->dev_private; + +intel_runtime_pm_put (dev_priv); + +mutex_lock (&dev->struct_mutex); +i915_gem_context_unreference (req->ctx); +mutex_unlock (&dev->struct_mutex); + +kfree (req); +} +static int execlists_context_queue (struct intel_engine_cs *ring,struct intel_context *to,u32 tail)@@ -261,6 +375,8 @@ static int execlists_context_queue(struct intel_engine_cs *ring,i915_gem_context_reference (req->ctx); req->ring = ring; req->tail = tail; +INIT_WORK (&req->work, execlists_free_request_task); +intel_runtime_pm_get (dev_priv);spin_lock_irqsave (&ring->execlist_lock, flags);@@ -908,6 +1024,7 @@ static int logical_ring_init(struct drm_device *dev, struct intel_engine_cs *rinINIT_LIST_HEAD (&ring->execlist_queue);spin_lock_init (&ring->execlist_lock); + ring->next_context_status_buffer =0 ; ret =intel_lr_context_deferred_create (dctx, ring);if (ret)drivers/gpu/drm/i915/intel_lrc.h +3
-0@@ -66,6 +66,9 @@ struct intel_ctx_submit_request {u32 tail;struct list_head execlist_link; + struct work_struct work; }; +void intel_execlists_handle_ctx_events (struct intel_engine_cs *ring); +#endif /* _INTEL_LRC_H_ */ drivers/gpu/drm/i915/intel_ringbuffer.h +1
-0@@ -225,6 +225,7 @@ struct intel_engine_cs {/* Execlists */ spinlock_t execlist_lock;struct list_head execlist_queue; +u8 next_context_status_buffer;u32 irq_keep_mask;/* bitmask for interrupts that should not be masked */ int (*emit_request)(struct intel_ringbuffer *ringbuf); int (*emit_flush)(struct intel_ringbuffer *ringbuf,Signature · 6 lines
1.7.9.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 33/43] drm/i915/bdw: Help out the ctx switch interrupt handler
In reply to Thomas DanielQuoted 9 lines · Thomas Daniel
From: Oscar Mateo <[email protected]>
If we receive a storm of requests for the same context (see gem_storedw_loop_*) we might end up iterating over too many elements in interrupt time, looking for contexts to squash together. Instead, share the burden by giving more intelligence to the queue function. At most, the interrupt will iterate over three elements.
Signed-off-by Oscar Mateo <[email protected]>
I'll continue merging after this patch tomorrow.
-Daniel
Quoted 57 lines
--- drivers/gpu/drm/i915/intel_lrc.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-)drivers/gpu/drm/i915/intel_lrc.c +22
-4@@ -384,9 +384,10 @@ static int execlists_context_queue(struct intel_engine_cs *ring, struct intel_context *to, u32 tail) { -struct intel_ctx_submit_request *req =NULL ; +struct drm_i915_private *dev_priv = ring->dev->dev_private; +struct intel_ctx_submit_request *req =NULL , *cursor;unsigned long flags; -bool was_empty; +int num_elements =0 ; req =kzalloc (sizeof (*req),GFP_KERNEL );if (req ==NULL )@@ -400,9 +401,26 @@ static int execlists_context_queue(struct intel_engine_cs *ring,spin_lock_irqsave (&ring->execlist_lock, flags); - was_empty =list_empty (&ring->execlist_queue); +list_for_each_entry (cursor, &ring->execlist_queue, execlist_link) +if (++num_elements >2 ) +break ; + +if (num_elements >2 ) { +struct intel_ctx_submit_request *tail_req; + + tail_req =list_last_entry (&ring->execlist_queue, + struct intel_ctx_submit_request, + execlist_link); +if (to == tail_req->ctx) { +WARN (tail_req->elsp_submitted !=0 , +"More than 2 already-submitted reqs queued\n" ); +list_del (&tail_req->execlist_link); +queue_work (dev_priv->wq, &tail_req->work); + } + } +list_add_tail (&req->execlist_link, &ring->execlist_queue); -if (was_empty) +if (num_elements ==0 )execlists_context_unqueue (ring);spin_unlock_irqrestore (&ring->execlist_lock, flags);Signature · 6 lines
1.7.9.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 27/43] drm/i915/bdw: Render state init for Execlists
In reply to Daniel VetterQuoted 90 lines
-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Thursday, August 14, 2014 9:00 PM
To: Daniel, Thomas
Cc: Daniel Vetter; [email protected]
Subject: Re: [Intel-gfx] [PATCH 27/43] drm/i915/bdw: Render state init for ExeclistsQuoted 20 lines · Daniel Vetter
Quoted 19 lines · Thomas
Quoted 19 lines
-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, August 11, 2014 10:25 PM
To: Daniel, Thomas
Cc: [email protected]
Subject: Re: [Intel-gfx] [PATCH 27/43] drm/i915/bdw: Render state init for ExeclistsQuoted 1 line · Thomas Daniel
From: Oscar Mateo <[email protected]>
index 9085ff1..0dc6992 100644
drivers/gpu/drm/i915/i915_gem_context.c int i915_gem_context_enable(struct
Quoted 3 lines
drivers/gpu/drm/i915/i915_gem_context.c +0
-0@@ -513,8 +513,23 @@ int i915_gem_context_enable(struct
drm_i915_private*dev_priv)Quoted 3 lines
drivers/gpu/drm/i915/i915_gem_context.c +0
-0ppgtt->enable (ppgtt); }Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/i915/i915_gem_context.c int i915_gem_context_enable(struct drm_i915_private *dev_priv)
Quoted 9 lines
drivers/gpu/drm/i915/i915_gem_context.c +8
-1-if (i915.enable_execlists) +if (i915.enable_execlists) { +struct intel_context *dctx; + + ring = &dev_priv->ring[RCS ]; + dctx = ring->default_context; + +if (!dctx->rcs_initialized) { + ret = intel_lr_context_render_state_init(ring,dctx);
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/i915/i915_gem_context.c int i915_gem_context_enable(struct · line 525
Quoted 2 lines
drivers/gpu/drm/i915/i915_gem_context.c +2
-0+if (ret) { + DRM_ERROR("Init render state failed:%d\n",
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
ret);
drivers/gpu/drm/i915/i915_gem_context.c int i915_gem_context_enable(struct drm_i915_private *dev_priv) · line 532
Quoted 7 lines
drivers/gpu/drm/i915/i915_gem_context.c +6
-0+return ret; + } + dctx->rcs_initialized = true; + } +return 0 ; + }This looks very much like the wrong place. We should init the render state when we create the context, or when we switch to it for
the first time.
Quoted 33 lines
Quoted 11 lines
Quoted 4 lines
The later is what the legacy contexts currently do in
do_switch.But
ctx_enableshould do the switch to the default context and that's aboutWell, a side-effect of switching to the default context in legacy mode is that the render state gets initialized. I could move the lr render state init call into an
enable_execlistsbranch ini915_switch_context()but that doen't seem like the right place.How about in
i915_gem_init()after callingi915_gem_init_hw()?Quoted 7 lines
Quoted 5 lines
it. If there's some depency then I guess we should stall the creation of the default context a bit, maybe.
In any case someone needs to explain this better and if there's not other wey this at least needs a bit comment. So I'll punt for now.
When the default context is created the driver is not ready to execute a batch. That is why the render state init can't be done then.
That sounds like the default context is created too early. Essentially I want to avoid needless divergence between the default context and normal contexts, because sooner or later that will means someone will creep in with a _really_ subtle bug.
What about:
- We create the default lrc contexs incontext_init, but like with a normal context we don't do any of the deferred setup.
- Incontext_enable(which since yesterday properly propagates errors to callers) we force the deferred lrc ctx setup for the default contexts on all engines.
- The render state init is done as part of the deferred ctx setup for the render engine in all cases.
Quoted 5 lines
Quoted 2 lines
Totally off the track or do you see a workable solution somewhere in that direction?
I'd like to discuss this first a bit more, so will punt on this patch for now. -Daniel
I think that your proposal will work. I've been having some trouble with my RVP board so haven't had a chance to test it out yet.
Thomas.
Quoted 4 lines
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 30/43] drm/i915/bdw: Two-stage execlist submit process
In reply to Daniel VetterQuoted 70 lines
-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Thursday, August 14, 2014 9:10 PM
To: Daniel, Thomas
Cc: [email protected]
Subject: Re: [Intel-gfx] [PATCH 30/43] drm/i915/bdw: Two-stage execlist submit processQuoted 21 lines · Thomas Daniel
From: Michel Thierry <[email protected]>
Context switch (and execlist submission) should happen only when other contexts are not active, otherwise pre-emption occurs.
To assure this, we place context switch requests in a queue and those request are later consumed when the right context switch interrupt is received (still TODO).
v2: Use a spinlock, do not remove the requests on unqueue (wait for context switch completion).
Signed-off-by Thomas Daniel <[email protected]>v3: Several rebases and code changes. Use unique ID.
v4:
- Move the queue/lock init to the late ring initialization.
- Damien's kmalloc review comments: check return, usesizeof(*req), do not cast.Quoted 8 lines
v5:
- Do not reusedrm_i915_gem_request. Instead, create our own.
- New namespace.Signed-off-by Michel Thierry <[email protected]> (v1)Signed-off-by Oscar Mateo <[email protected]> (v2-v5)--- drivers/gpu/drm/i915/intel_lrc.c | 63++++++++++++++++++++++++++++++-
drivers/gpu/drm/i915/intel_lrc.c static int execlists_submit_context(struct
Quoted 10 lines
drivers/gpu/drm/i915/intel_lrc.h | 8 ++++ drivers/gpu/drm/i915/intel_ringbuffer.h | 2 + 3 files changed, 71 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/intel_lrc.c +0
-0@@ -217,6 +217,63 @@ static int execlists_submit_context(struct
intel_engine_cs*ring,drivers/gpu/drm/i915/intel_lrc.c static int execlists_submit_context(struct intel_engine_cs *ring,
Quoted 13 lines
drivers/gpu/drm/i915/intel_lrc.c +10
-0return 0 ; } +static void execlists_context_unqueue (struct intel_engine_cs *ring) { +struct intel_ctx_submit_request *req0 =NULL , *req1 =NULL ; +struct intel_ctx_submit_request *cursor =NULL , *tmp =NULL ; + +if (list_empty (&ring->execlist_queue)) +return ; + +/* Try to read in pairs */ +list_for_each_entry_safe (cursor, tmp, &ring->execlist_queue, +execlist_link) {Ok, because checkpatch I've looked at this. Imo open-coding this would be much easier to read i.e.
Quoted 8 lines
if (!list_empty) grab&remove first item; if (!list_empty) grab&remove 2nd item;Care to follow up with a patch for that?
Thanks, Daniel
This needs to be kept as a loop because if there are two consecutive requests for the same context they are squashed. Also the non-squashed requests are not removed here (unfortunately the remove is in the next patch).
Quoted 4 lines
drivers/gpu/drm/i915/intel_lrc.c static int execlists_submit_context(struct intel_engine_cs *ring, · line 232
Quoted 4 lines
drivers/gpu/drm/i915/intel_lrc.c +3
-0+if (!req0) + req0 = cursor; +else if (req0->ctx == cursor->ctx) {
This:
Quoted 114 lines
Quoted 46 lines
drivers/gpu/drm/i915/intel_lrc.c +43
-0+/* Same ctx: ignore first request, as second request +* will update tail past first request's workload */ +list_del (&req0->execlist_link); +i915_gem_context_unreference (req0->ctx); +kfree (req0); + req0 = cursor; + }else { + req1 = cursor; +break ; + } + } + +BUG_ON (execlists_submit_context (ring, req0->ctx, req0->tail, + req1? req1->ctx :NULL , req1? req1->tail :0 )); } + +static int execlists_context_queue (struct intel_engine_cs *ring, +struct intel_context *to, +u32 tail) +{ +struct intel_ctx_submit_request *req =NULL ; +unsigned long flags; +bool was_empty; + + req =kzalloc (sizeof (*req),GFP_KERNEL ); +if (req ==NULL ) +return -ENOMEM ; + req->ctx = to; +i915_gem_context_reference (req->ctx); + req->ring = ring; + req->tail = tail; + +spin_lock_irqsave (&ring->execlist_lock, flags); + + was_empty =list_empty (&ring->execlist_queue); +list_add_tail (&req->execlist_link, &ring->execlist_queue); +if (was_empty) +execlists_context_unqueue (ring); + +spin_unlock_irqrestore (&ring->execlist_lock, flags); + +return 0 ; +} +static int logical_ring_invalidate_all_caches (struct intel_ringbuffer *ringbuf) { struct intel_engine_cs *ring = ringbuf->ring; @@ -405,8 +462,7 @@Quoted 1 line
void intel_logical_ring_advance_and_submit(struct
intel_ringbuffer*ringbuf)
drivers/gpu/drm/i915/intel_lrc.c void intel_logical_ring_advance_and_submit(struct intel_ringbuffer *ringbuf)
Quoted 10 lines
drivers/gpu/drm/i915/intel_lrc.c +1
-3if (intel_ring_stopped (ring))return ; -/* FIXME: too cheeky, we don't even check if the ELSP is ready */ -execlists_submit_context (ring, ctx, ringbuf->tail,NULL ,0 ); +execlists_context_queue (ring, ctx, ringbuf->tail); } static int logical_ring_alloc_seqno(struct intel_engine_cs *ring, @@ -850,6 +906,9 @@ static int logical_ring_init(struct drm_device *dev, struct
intel_engine_cs*rindrivers/gpu/drm/i915/intel_lrc.h int intel_execlists_submission(struct drm_device
Quoted 15 lines
drivers/gpu/drm/i915/intel_lrc.c +3
-0INIT_LIST_HEAD (&ring->request_list);init_waitqueue_head (&ring->irq_queue); +INIT_LIST_HEAD (&ring->execlist_queue); +spin_lock_init (&ring->execlist_lock); + ret =intel_lr_context_deferred_create (dctx, ring);if (ret)return ret;drivers/gpu/drm/i915/intel_lrc.h +0
-0@@ -60,4 +60,12 @@ int intel_execlists_submission(struct drm_device*dev, struct
drm_file*file,Quoted 18 lines
drivers/gpu/drm/i915/intel_lrc.h +8
-0u64 exec_start, u32 flags);u32 intel_execlists_ctx_id (struct drm_i915_gem_object *ctx_obj); +struct intel_ctx_submit_request { +struct intel_context *ctx; +struct intel_engine_cs *ring; +u32 tail; + +struct list_head execlist_link; +}; +#endif /* _INTEL_LRC_H_ */ drivers/gpu/drm/i915/intel_ringbuffer.h +0
-0drivers/gpu/drm/i915/intel_ringbuffer.h struct intel_engine_cs { · line 228
Quoted 6 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +2
-0@@ -223,6 +223,8 @@ struct intel_engine_cs { } semaphore;/* Execlists */ +spinlock_t execlist_lock; +struct list_head execlist_queue;u32 irq_keep_mask;/* bitmask for interrupts that should not be masked */
Quoted 9 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +0
-1int (*emit_request)(struct intel_ringbuffer *ringbuf); int (*emit_flush)(struct intel_ringbuffer *ringbuf, --1.7.9.5
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 30/43] drm/i915/bdw: Two-stage execlist submit process
Quoted 29 lines · Thomas
Quoted 29 lines
-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Thursday, August 14, 2014 9:10 PM
To: Daniel, Thomas
Cc: [email protected]
Subject: Re: [Intel-gfx] [PATCH 30/43] drm/i915/bdw: Two-stage execlist submit processdrivers/gpu/drm/i915/intel_lrc.c static int execlists_submit_context(struct intel_engine_cs *ring,
Quoted 11 lines · Thomas Daniel
From: Michel Thierry <[email protected]>
drivers/gpu/drm/i915/intel_lrc.c +10
-0+static void execlists_context_unqueue (struct intel_engine_cs *ring) { +struct intel_ctx_submit_request *req0 =NULL , *req1 =NULL ; +struct intel_ctx_submit_request *cursor =NULL , *tmp =NULL ; + +if (list_empty (&ring->execlist_queue)) +return ; + +/* Try to read in pairs */ +list_for_each_entry_safe (cursor, tmp, &ring->execlist_queue, +execlist_link) {Ok, because checkpatch I've looked at this. Imo open-coding this would be much easier to read i.e.
if (!list_empty) grab&remove first item; if (!list_empty) grab&remove 2nd item;
Quoted 7 lines
Quoted 3 lines
Care to follow up with a patch for that?
Thanks, Daniel
This needs to be kept as a loop because if there are two consecutive requests for the same context they are squashed. Also the non-squashed requests are not removed here (unfortunately the remove is in the next patch).
Ok, this sounds like we need to overhaul it anyway for the request tracking then.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 11/43] drm/i915/bdw: Render moot context reset and switch with Execlists
In reply to Daniel VetterQuoted 35 lines
-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, August 11, 2014 3:30 PM
To: Daniel, Thomas
Cc: [email protected]
Subject: Re: [Intel-gfx] [PATCH 11/43] drm/i915/bdw: Render moot context reset and switch with Execlistsdrivers/gpu/drm/i915/i915_gem_context.c void i915_gem_context_reset(struct drm_device
Quoted 19 lines · Thomas Daniel
From: Oscar Mateo <[email protected]>
These two functions make no sense in an Logical Ring Context & Execlists world.
v2: We got rid of
lrc_enabledand centralized everything in the sanitized i915.enbale_execlists instead.Signed-off-by Oscar Mateo <[email protected]>--- drivers/gpu/drm/i915/i915_gem_context.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/gpu/drm/i915/i915_gem_context.c +0
-0@@ -380,6 +380,9 @@ void i915_gem_context_reset(struct drm_device*dev)
Quoted 3 lines
drivers/gpu/drm/i915/i915_gem_context.c +0
-0struct drm_i915_private *dev_priv = dev->dev_private;int i;
Quoted 6 lines
drivers/gpu/drm/i915/i915_gem_context.c void i915_gem_context_reset(struct drm_device *dev) · line 384
Quoted 2 lines
drivers/gpu/drm/i915/i915_gem_context.c +2
-0+if (i915.enable_execlists) +return ;This will conflict badly with Alistair's patch at a functional level. I'm pretty sure that we want _some_ form of reset for the context state, since the hw didn't just magically load the previously running context. So NACK on this hunk.
OK I'll wait to see the final version of Alistair's patch and decide what to do about this hunk.
Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_context.c void i915_gem_context_reset(struct drm_device · line 386
Quoted 3 lines
drivers/gpu/drm/i915/i915_gem_context.c +1
-0+/* Prevent the hardware from restoring the last context (which hung) on
Quoted 6 lines
drivers/gpu/drm/i915/i915_gem_context.c +0
-0* the next switch */ for (i = 0; i < I915_NUM_RINGS; i++) { @@ -514,6 +517,9 @@ int
i915_gem_context_enable(struct drm_i915_private *dev_priv)drivers/gpu/drm/i915/i915_gem_context.c +0
-0ppgtt->enable (ppgtt); }
Quoted 5 lines
drivers/gpu/drm/i915/i915_gem_context.c
Quoted 2 lines
drivers/gpu/drm/i915/i915_gem_context.c +2
-0+if (i915.enable_execlists) +return 0 ;Again this conflicts with Alistair's patch. Furthermore it looks redudant since you no-op out
i915_switch_contextseparately.
I don't think this is a conflict. Doesn't Alistair's change here just involve writing PDPs for full PPGTT? We don't want to do that in lrc mode.
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/i915/i915_gem_context.c +1
-0+/* FIXME: We should make this work, even in reset */ if (i915_reset_in_progress (&dev_priv->gpu_error))return 0 ;@@ -769,6 +775,9 @@ int i915_switch_context(struct intel_engine_cs *ring, {struct drm_i915_private *dev_priv = ring->dev->dev_private;
Quoted 8 lines
drivers/gpu/drm/i915/i915_gem_context.c int i915_switch_context(struct intel_engine_cs · line 779
Quoted 2 lines
drivers/gpu/drm/i915/i915_gem_context.c +2
-0+if (i915.enable_execlists) +return 0 ;I've hoped we don't need this with the legacy ringbuffer cmdsubmission fuly split out. If there are other paths (resume, gpu reset) where this comes into play then I guess we need to look at where the best place is to make this call. So until this comes with a bit a better justification I'll punt on this for now. -Daniel
Yes, the command submission lrc path doesn't call this but other codepaths do. If we keep the check in context_enable() the only remaining call I see is in i915_gpu_idle(). I don't mind if the check is done there but perhaps a WARN_ON should then be added into switch_context() because we don't want to be putting illegal MI_SET_CONTEXT commands into the ring.
Thomas.
Quoted 18 lines
Quoted 9 lines
drivers/gpu/drm/i915/i915_gem_context.c +1
-0+WARN_ON (!mutex_is_locked (&dev_priv->dev->struct_mutex));if (to->legacy_hw_ctx.rcs_state ==NULL ) {/* We have the fake context */
--
1.7.9.5Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 1/1 drm/i915/bdw: Don't write PDP in the legacy way when using LRCs
In reply to Thomas DanielFrom: Oscar Mateo <[email protected]>
This is mostly for correctness so that we know we are running the LR context correctly (this is, the PDPs are contained inside the context object).
v2: Move the check to inside the enable PPGTT function. The switch happens in two places: the legacy context switch (that we won't hit when Execlists are enabled) and the PPGTT enable, which unfortunately we need. This would look much nicer if the ppgtt->enable was part of the ring init, where it logically belongs.
v3: Move the check to the start of the enable PPGTT function. None of the legacy PPGTT enabling is required when using LRCs as the PPGTT is enabled in the context descriptor and the PDPs are written in the LRC.
v4: Clarify comment based on review feedback.
--- drivers/gpu/drm/i915/i915_gem_gtt.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/i915_gem_gtt.c +6 -0
@@ -843,6 +843,12 @@ static int gen8_ppgtt_enable(struct i915_hw_ppgtt *ppgtt)struct intel_engine_cs *ring;int j, ret; +/* In the case of execlists, PPGTT is enabled by the context descriptor +* and the PDPs are contained within the context itself. We don't +* need to do anything here. */ +if (i915.enable_execlists) +return 0 ; +for_each_ring (ring, dev_priv, j) {I915_WRITE (RING_MODE_GEN7 (ring),_MASKED_BIT_ENABLE (GFX_PPGTT_ENABLE ));
Signature · 1 line
1.7.9.5
Re: [PATCH 35/43] drm/i915/bdw: Make sure error capture keeps working with Execlists
In reply to Thomas DanielQuoted 9 lines · Thomas Daniel
From: Oscar Mateo <[email protected]>
Since the ringbuffer does not belong per engine anymore, we have to make sure that we are always recording the correct ringbuffer.
TODO: This is only a small fix to keep basic error capture working, but we need to add more information for it to be useful (e.g. dump the context being executed).
Quoted 5 lines
v2: Reorder how the ringbuffer is chosen to clarify the change and rename the variable, both changes suggested by Chris Wilson. Also, add the TODO comment to the code, as suggested by Daniel.
Signed-off-by Oscar Mateo <[email protected]>
There's a bit too much stuff in-flight to fix up error capture for ppgtt. I think it's better to stall this patch here until that work is completed. Please coordinate with Mika here.
-Daniel
Quoted 59 lines
--- drivers/gpu/drm/i915/i915_gpu_error.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)drivers/gpu/drm/i915/i915_gpu_error.c +18
-4@@ -874,9 +874,6 @@ static void i915_record_ring_state(struct drm_device *dev, ering->hws =I915_READ (mmio); } - ering->cpu_ring_head = ring->buffer->head; - ering->cpu_ring_tail = ring->buffer->tail; - ering->hangcheck_score = ring->hangcheck.score; ering->hangcheck_action = ring->hangcheck.action;@@ -936,6 +933,7 @@ static void i915_gem_record_rings(struct drm_device *dev,for (i =0 ; i <I915_NUM_RINGS ; i++) {struct intel_engine_cs *ring = &dev_priv->ring[i]; +struct intel_ringbuffer *rbuf; error->ring[i].pid =-1 ;@@ -979,8 +977,24 @@ static void i915_gem_record_rings(struct drm_device *dev, } } +if (i915.enable_execlists) { +/* TODO: This is only a small fix to keep basic error +* capture working, but we need to add more information +* for it to be useful (e.g. dump the context being +* executed). +*/ +if (request) + rbuf = request->ctx->engine[ring->id].ringbuf; +else + rbuf = ring->default_context->engine[ring->id].ringbuf; + }else + rbuf = ring->buffer; + + error->ring[i].cpu_ring_head = rbuf->head; + error->ring[i].cpu_ring_tail = rbuf->tail; + error->ring[i].ringbuffer = -i915_error_ggtt_object_create (dev_priv, ring->buffer->obj); +i915_error_ggtt_object_create (dev_priv, rbuf->obj);if (ring->status_page.obj) error->ring[i].hws_page =Signature · 6 lines
1.7.9.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 40/43] drm/i915/bdw: Document Logical Rings, LR contexts and Execlists
In reply to Thomas DanielQuoted 4 lines · Thomas Daniel
+/**
+ *intel_lr_context_render_state_init()- render state init for Execlists
+ * @ring: Engine Command Streamer.
+ * @ctx: Context to initialize.
Quoted 8 lines
+ *
+ * A.K.A. null-context, A.K.A. golden-context. In a word, the render engine
+ * contexts require to always have a valid 3d pipeline state. As this is
+ * achieved with the submission of a batchbuffer, we require an alternative
+ * entry point to the legacy ringbuffer submission one (i915_gem_render_state_init).
+ *
+ * Return: non-zero if the initialization failed.
+ */
I've dropped this hunk here since that part isn't merged yet. -Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 42/43] drm/i915/bdw: Pin the context backing objects to GGTT on-demand
In reply to Thomas DanielQuoted 32 lines · Thomas Daniel
From: Oscar Mateo <[email protected]>
Up until now, we have pinned every logical ring context backing object during creation, and left it pinned until destruction. This made my life easier, but it's a harmful thing to do, because we cause fragmentation of the GGTT (and, eventually, we would run out of space).
This patch makes the pinning on-demand: the backing objects of the two contexts that are written to the ELSP are pinned right before submission and unpinned once the hardware is done with them. The only context that is still pinned regardless is the global default one, so that the HWS can still be accessed in the same way (
ring->status_page).v2: In the early version of this patch, we were pinning the context as we put it into the ELSP: on the one hand, this is very efficient because only a maximum two contexts are pinned at any given time, but on the other hand, we cannot really pin in interrupt time :(
Signed-off-by Oscar Mateo <[email protected]>--- drivers/gpu/drm/i915/i915_debugfs.c | 11 +++++++-- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_gem.c | 44 ++++++++++++++++++++++++----------- drivers/gpu/drm/i915/intel_lrc.c | 42 ++++++++++++++++++++++++--------- drivers/gpu/drm/i915/intel_lrc.h | 2 ++ 5 files changed, 73 insertions(+), 27 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +0
-0
drivers/gpu/drm/i915/i915_debugfs.c static int i915_dump_lrc(struct seq_file *m, void *unused) · line 1728
Quoted 10 lines
drivers/gpu/drm/i915/i915_debugfs.c +3
-2@@ -1721,10 +1721,15 @@ static int i915_dump_lrc(struct seq_file *m, void *unused)continue ;if (ctx_obj) { -struct page *page =i915_gem_object_get_page (ctx_obj,1 ); -uint32_t *reg_state =kmap_atomic (page); +struct page *page ; +uint32_t *reg_state;int j; +i915_gem_obj_ggtt_pin (ctx_obj,GEN8_LR_CONTEXT_ALIGN ,0 );
This just needs a get/put_pages, no pinning required.
Quoted 21 lines
drivers/gpu/drm/i915/i915_debugfs.c +6
-0+ + page =i915_gem_object_get_page (ctx_obj,1 ); + reg_state =kmap_atomic (page); +seq_printf (m,"CONTEXT: %s %u\n" , ring->name,intel_execlists_ctx_id (ctx_obj));@@ -1736,6 +1741,8 @@ static int i915_dump_lrc(struct seq_file *m, void *unused) }kunmap_atomic (reg_state); +i915_gem_object_ggtt_unpin (ctx_obj); +seq_putc (m,'\n' ); } }drivers/gpu/drm/i915/i915_drv.h +0
-0
drivers/gpu/drm/i915/i915_drv.h struct intel_context { · line 631
Quoted 4 lines
drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -628,6 +628,7 @@ struct intel_context {struct {struct drm_i915_gem_object *state;struct intel_ringbuffer *ringbuf; +atomic_t unpin_count;
No need to reinvent wheels for this. We should be able to do exactly what we've done for the legacy ctx objects, namely:
- Always pin the default system context so that we can always switch to that.
- Shovel all context releated objects through the active queue and obj management. This might depend upon the reworked exec list item.
- In the shrinker have a last-ditch effort to switch to the default context in case we run out of space.
- igt testcase. For legacy rings this code here resulted in some _really_ expensive bugs and regressions.
I'll do another jira for this.
Otherwise I think I've pulled pretty much everything in except those places where I think directly reworking the patches makes more sense. And we should have JIRA tasks for all the outstanding work (plus ofc getting ppgtt ready since execlists requires that).
If there's a patch I've missed or where people think it makes more sense to merge the wip version now, please pipe up.
Thanks, Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 11/43] drm/i915/bdw: Render moot context reset and switch with Execlists
In reply to Daniel, ThomasQuoted 54 lines · Thomas
Quoted 35 lines
-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, August 11, 2014 3:30 PM
To: Daniel, Thomas
Cc: [email protected]
Subject: Re: [Intel-gfx] [PATCH 11/43] drm/i915/bdw: Render moot context reset and switch with Execlistsdrivers/gpu/drm/i915/i915_gem_context.c void i915_gem_context_reset(struct drm_device
Quoted 19 lines · Thomas Daniel
From: Oscar Mateo <[email protected]>
These two functions make no sense in an Logical Ring Context & Execlists world.
v2: We got rid of
lrc_enabledand centralized everything in the sanitized i915.enbale_execlists instead.Signed-off-by Oscar Mateo <[email protected]>--- drivers/gpu/drm/i915/i915_gem_context.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/gpu/drm/i915/i915_gem_context.c +0
-0@@ -380,6 +380,9 @@ void i915_gem_context_reset(struct drm_device*dev)
Quoted 3 lines
drivers/gpu/drm/i915/i915_gem_context.c +0
-0struct drm_i915_private *dev_priv = dev->dev_private;int i;Quoted 6 lines
drivers/gpu/drm/i915/i915_gem_context.c void i915_gem_context_reset(struct drm_device *dev) · line 384
Quoted 2 lines
drivers/gpu/drm/i915/i915_gem_context.c +2
-0+if (i915.enable_execlists) +return ;This will conflict badly with Alistair's patch at a functional level. I'm pretty sure that we want _some_ form of reset for the context state, since the hw didn't just magically load the previously running context. So NACK on this hunk.
OK I'll wait to see the final version of Alistair's patch and decide what to do about this hunk.
Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_context.c void i915_gem_context_reset(struct drm_device · line 386
Quoted 3 lines
drivers/gpu/drm/i915/i915_gem_context.c +1
-0+/* Prevent the hardware from restoring the last context (which hung) on
Quoted 6 lines
drivers/gpu/drm/i915/i915_gem_context.c +0
-0* the next switch */ for (i = 0; i < I915_NUM_RINGS; i++) { @@ -514,6 +517,9 @@ int
i915_gem_context_enable(struct drm_i915_private *dev_priv)drivers/gpu/drm/i915/i915_gem_context.c +0
-0ppgtt->enable (ppgtt); }
Quoted 7 lines
Quoted 5 lines
drivers/gpu/drm/i915/i915_gem_context.c
Quoted 2 lines
drivers/gpu/drm/i915/i915_gem_context.c +2
-0+if (i915.enable_execlists) +return 0 ;Again this conflicts with Alistair's patch. Furthermore it looks redudant since you no-op out
i915_switch_contextseparately.I don't think this is a conflict. Doesn't Alistair's change here just involve writing PDPs for full PPGTT? We don't want to do that in lrc mode.
Oh, just context conflict since Alistair's patch removes the next line ;-) Also I shuffled some of the ppgtt code right above this around.
Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/i915_gem_context.c +1
-0+/* FIXME: We should make this work, even in reset */ if (i915_reset_in_progress (&dev_priv->gpu_error))return 0 ;@@ -769,6 +775,9 @@ int i915_switch_context(struct intel_engine_cs *ring, {struct drm_i915_private *dev_priv = ring->dev->dev_private;Quoted 8 lines
drivers/gpu/drm/i915/i915_gem_context.c int i915_switch_context(struct intel_engine_cs · line 779
Quoted 2 lines
drivers/gpu/drm/i915/i915_gem_context.c +2
-0+if (i915.enable_execlists) +return 0 ;I've hoped we don't need this with the legacy ringbuffer cmdsubmission fuly split out. If there are other paths (resume, gpu reset) where this comes into play then I guess we need to look at where the best place is to make this call. So until this comes with a bit a better justification I'll punt on this for now. -Daniel
Quoted 5 lines
Yes, the command submission lrc path doesn't call this but other codepaths do. If we keep the check in
context_enable()the only remaining call I see is ini915_gpu_idle(). I don't mind if the check is done there but perhaps aWARN_ONshould then be added intoswitch_context()because we don't want to be putting illegalMI_SET_CONTEXTcommands into the ring.
Yeah, that sounds like a plan. There's still a bit of confusion around the ctx reset in Alistairs patch but unrelated to the code bits we've discussed here. So when you resend this revised patch can you please merge Alistair's patch into your baseline to avoid conflicts.
Thanks, Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Jani Nikula
maintainerRe: [PATCH 41/43] drm/i915/bdw: Enable Logical Ring Contexts (hence, Execlists)
In reply to Thomas DanielQuoted 3 lines · Thomas Daniel
From: Oscar Mateo <[email protected]>
The time has come, the Walrus said, to talk of many things.
FYI this causes https://bugs.freedesktop.org/show_bug.cgi?id=82740
Quoted 25 lines
Signed-off-by Oscar Mateo <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/i915/i915_drv.h +1
-1@@ -2061,7 +2061,7 @@ struct drm_i915_cmd_table {#define I915_NEED_GFX_HWS (dev) (INTEL_INFO(dev)->need_gfx_hws)#define HAS_HW_CONTEXTS (dev) (INTEL_INFO(dev)->gen >= 6) -#define HAS_LOGICAL_RING_CONTEXTS (dev) 0 +#define HAS_LOGICAL_RING_CONTEXTS (dev) (INTEL_INFO(dev)->gen >= 8)#define HAS_ALIASING_PPGTT (dev) (INTEL_INFO(dev)->gen >= 6)#define HAS_PPGTT (dev) (INTEL_INFO(dev)->gen >= 7 && !IS_GEN8(dev))#define USES_PPGTT (dev) intel_enable_ppgtt(dev, false)Signature · 6 lines
1.7.9.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 1 line
Jani Nikula, Intel Open Source Technology Center
Re: [PATCH 41/43] drm/i915/bdw: Enable Logical Ring Contexts (hence, Execlists)
Quoted 9 lines
-----Original Message-----
From: Jani Nikula [mailto:[email protected]]
Sent: Monday, August 18, 2014 9:33 AM
To: Daniel, Thomas; [email protected]
Subject: Re: [Intel-gfx] [PATCH 41/43] drm/i915/bdw: Enable Logical Ring Contexts (hence, Execlists)
Quoted 6 lines
Quoted 3 lines · Thomas Daniel
From: Oscar Mateo <[email protected]>
The time has come, the Walrus said, to talk of many things.
FYI this causes https://bugs.freedesktop.org/show_bug.cgi?id=82740
Hmm, this seems to be an interaction between execlists and PPGTT patches, specifically:
http://patchwork.freedesktop.org/patch/31150/
which breaks aliasing PPGTT when execlists are enabled, resulting in this oops on boot.
I will post a patch which avoids this but I don't know if the intention is to drop aliasing PPGTT support when execlists are enabled.
Thomas.
Quoted 30 lines
Quoted 10 lines
Signed-off-by Oscar Mateo <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/gpu/drm/i915/i915_drv.hindex b7cf0ec..1ce51d6 100644drivers/gpu/drm/i915/i915_drv.h struct drm_i915_cmd_table { · line 2067
Quoted 8 lines
drivers/gpu/drm/i915/i915_drv.h +1
-1@@ -2061,7 +2061,7 @@ struct drm_i915_cmd_table {#define I915_NEED_GFX_HWS (dev) (INTEL_INFO(dev)->need_gfx_hws)#define HAS_HW_CONTEXTS (dev) (INTEL_INFO(dev)->gen >= 6) -#define HAS_LOGICAL_RING_CONTEXTS (dev) 0 +#define HAS_LOGICAL_RING_CONTEXTS (dev) (INTEL_INFO(dev)- gen >= 8)#define HAS_ALIASING_PPGTT (dev) (INTEL_INFO(dev)->gen >= 6)#define HAS_PPGTT (dev) (INTEL_INFO(dev)->gen >= 7 &&!IS_GEN8(dev))
Quoted 8 lines
#define
USES_PPGTT(dev)intel_enable_ppgtt(dev, false)
--
1.7.9.5_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx--
Jani Nikula, Intel Open Source Technology Center
PATCH 1/1 drm/i915/bdw: Render moot context reset and switch with Execlists
In reply to Thomas DanielThese two functions make no sense in an Logical Ring Context & Execlists world.
v2: We got rid of lrc_enabled and centralized everything in the sanitized i915.enable_execlists instead.
v3: Rebased. Corrected a typo in comment for i915_switch_context and added a comment that it should not be called in execlist mode. Added WARN_ON if i915_switch_context is called in execlist mode. Moved check for execlist mode out of i915_switch_context and into callers. Added comment in context_reset explaining why nothing is done in execlist mode.
--- drivers/gpu/drm/i915/i915_gem.c | 8 +++++--- drivers/gpu/drm/i915/i915_gem_context.c | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +5 -3
@@ -2981,9 +2981,11 @@ int i915_gpu_idle(struct drm_device *dev)/* Flush everything onto the inactive list. */ for_each_ring (ring, dev_priv, i) { - ret =i915_switch_context (ring, ring->default_context); -if (ret) -return ret; +if (!i915.enable_execlists) { + ret =i915_switch_context (ring, ring->default_context); +if (ret) +return ret; + } ret =intel_ring_idle (ring);if (ret)
drivers/gpu/drm/i915/i915_gem_context.c +15 -1
@@ -289,6 +289,12 @@ void i915_gem_context_reset(struct drm_device *dev)struct drm_i915_private *dev_priv = dev->dev_private;int i; +/* In execlists mode we will unreference the context when the execlist +* queue is cleared and the requests destroyed. +*/ +if (i915.enable_execlists) +return ; +for (i =0 ; i <I915_NUM_RINGS ; i++) {struct intel_engine_cs *ring = &dev_priv->ring[i];struct intel_context *lctx = ring->last_context;
@@ -397,6 +403,9 @@ int i915_gem_context_enable(struct drm_i915_private *dev_priv)BUG_ON (!dev_priv->ring[RCS ].default_context); +if (i915.enable_execlists) +return 0 ; +for_each_ring (ring, dev_priv, i) { ret =i915_switch_context (ring, ring->default_context);if (ret)
@@ -637,14 +646,19 @@ unpin_out:* * The context life cycle is simple. The context refcount is incremented and * decremented by 1 and create and destroy. If the context is in use by the GPU, -* it will have a refoucnt > 1. This allows us to destroy the context abstract +* it will have a refcount > 1. This allows us to destroy the context abstract * object while letting the normal object tracking destroy the backing BO. +* +* This function should not be used in execlists mode. Instead the context is +* switched by writing to the ELSP and requests keep a reference to their +* context. */ int i915_switch_context (struct intel_engine_cs *ring,struct intel_context *to) {struct drm_i915_private *dev_priv = ring->dev->dev_private; +WARN_ON (i915.enable_execlists);WARN_ON (!mutex_is_locked (&dev_priv->dev->struct_mutex));if (to->legacy_hw_ctx.rcs_state ==NULL ) {/* We have the fake context */
Signature · 1 line
1.7.9.5
Re: [PATCH] drm/i915/bdw: Render moot context reset and switch with Execlists
Quoted 6 lines · Thomas Daniel
These two functions make no sense in an Logical Ring Context & Execlists world.
v2: We got rid of
lrc_enabledand centralized everything in the sanitized i915.enable_execlists instead.
Quoted 8 lines
Signed-off-by Oscar Mateo <[email protected]>v3: Rebased. Corrected a typo in comment for
i915_switch_contextand added a comment that it should not be called in execlist mode. AddedWARN_ONifi915_switch_contextis called in execlist mode. Moved check for execlist mode out ofi915_switch_contextand into callers. Added comment incontext_resetexplaining why nothing is done in execlist mode.
No, this is not the way. The requirement is to reduce the number of special cases not increase them. These should be evaluated to be no-ops when execlists is used.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Re: [PATCH 27/43] drm/i915/bdw: Render state init for Execlists
In reply to Daniel VetterQuoted 104 lines
-----Original Message-----
From: Daniel, Thomas
Sent: Friday, August 15, 2014 9:44 AM
To: 'Daniel Vetter'
Cc: [email protected]
Subject: RE: [Intel-gfx] [PATCH 27/43] drm/i915/bdw: Render state init for ExeclistsQuoted 92 lines
-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Thursday, August 14, 2014 9:00 PM
To: Daniel, Thomas
Cc: Daniel Vetter; [email protected]
Subject: Re: [Intel-gfx] [PATCH 27/43] drm/i915/bdw: Render state init for ExeclistsQuoted 20 lines · Daniel Vetter
Quoted 19 lines · Thomas
Quoted 19 lines
-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, August 11, 2014 10:25 PM
To: Daniel, Thomas
Cc: [email protected]
Subject: Re: [Intel-gfx] [PATCH 27/43] drm/i915/bdw: Render state init for ExeclistsQuoted 1 line · Thomas Daniel
From: Oscar Mateo <[email protected]>
index 9085ff1..0dc6992 100644
drivers/gpu/drm/i915/i915_gem_context.c int i915_gem_context_enable(struct
Quoted 3 lines
drivers/gpu/drm/i915/i915_gem_context.c +0
-0@@ -513,8 +513,23 @@ int i915_gem_context_enable(struct
drm_i915_private*dev_priv)Quoted 3 lines
drivers/gpu/drm/i915/i915_gem_context.c +0
-0ppgtt->enable (ppgtt); }Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/i915/i915_gem_context.c int i915_gem_context_enable(struct drm_i915_private *dev_priv)
Quoted 9 lines
drivers/gpu/drm/i915/i915_gem_context.c +8
-1-if (i915.enable_execlists) +if (i915.enable_execlists) { +struct intel_context *dctx; + + ring = &dev_priv->ring[RCS ]; + dctx = ring->default_context; + +if (!dctx->rcs_initialized) { + ret = intel_lr_context_render_state_init(ring,dctx);
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/i915/i915_gem_context.c int i915_gem_context_enable(struct · line 525
Quoted 2 lines
drivers/gpu/drm/i915/i915_gem_context.c +2
-0+if (ret) { + DRM_ERROR("Init render state failed:%d\n",
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
ret);
drivers/gpu/drm/i915/i915_gem_context.c int i915_gem_context_enable(struct drm_i915_private *dev_priv) · line 532
Quoted 7 lines
drivers/gpu/drm/i915/i915_gem_context.c +6
-0+return ret; + } + dctx->rcs_initialized = true; + } +return 0 ; + }This looks very much like the wrong place. We should init the render state when we create the context, or when we switch to it for
the first time.
Quoted 35 lines
Quoted 11 lines
Quoted 4 lines
The later is what the legacy contexts currently do in
do_switch.But
ctx_enableshould do the switch to the default context and that's aboutWell, a side-effect of switching to the default context in legacy mode is that the render state gets initialized. I could move the lr render state init call into an
enable_execlistsbranch ini915_switch_context()but that doen't seem like the right place.How about in
i915_gem_init()after callingi915_gem_init_hw()?Quoted 7 lines
Quoted 5 lines
it. If there's some depency then I guess we should stall the creation of the default context a bit, maybe.
In any case someone needs to explain this better and if there's not other wey this at least needs a bit comment. So I'll punt for now.
When the default context is created the driver is not ready to execute a batch. That is why the render state init can't be done then.
That sounds like the default context is created too early. Essentially I want to avoid needless divergence between the default context and normal contexts, because sooner or later that will means someone will creep in with a _really_ subtle bug.
What about:
- We create the default lrc contexs incontext_init, but like with a normal context we don't do any of the deferred setup.
- Incontext_enable(which since yesterday properly propagates errors to callers) we force the deferred lrc ctx setup for the default contexts on all engines.
- The render state init is done as part of the deferred ctx setup for the render engine in all cases.Totally off the track or do you see a workable solution somewhere in that direction?
Quoted 6 lines
Quoted 2 lines
I'd like to discuss this first a bit more, so will punt on this patch for now. -Daniel
I think that your proposal will work. I've been having some trouble with my RVP board so haven't had a chance to test it out yet.
Thomas.
I've now tried this out and I don't think it can work without introducing more problems than the original patch. Trouble is that in lrc mode the Hardware Status Page is offset 0 from the context. All contexts use the default context's HWSP for writing seqnos, this is stored in ring->status_page. We can't populate this until the deferred creation of the default context is done, so we can't execute any instructions in the deferred creation (unless we check for default context in the deferred creation which is what we wanted to avoid in the first place).
Thomas.
Quoted 4 lines
Quoted 4 lines
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 1/1 drm/i915/bdw: Render state init for Execlists
In reply to Thomas DanielFrom: Oscar Mateo <[email protected]>
The batchbuffer that sets the render context state is submitted in a different way, and from different places.
We needed to make both the render state preparation and free functions outside accesible, and namespace accordingly. This mess is so that all LR, LRC and Execlists functionality can go together in intel_lrc.c: we can fix all of this later on, once the interfaces are clear.
v2: Create a separate ctx->rcs_initialized for the Execlists case, as suggested by Chris Wilson.
v3: Setup ring status page in lr_context_deferred_create when the default context is being created. This means that the render state init for the default context is no longer a special case. Execute deferred creation of the default context at the end of logical_ring_init to allow the render state commands to be submitted. Fix style errors reported by checkpatch. Rebased.
--- drivers/gpu/drm/i915/i915_drv.h | 4 +- drivers/gpu/drm/i915/i915_gem_render_state.c | 40 ++++++++------ drivers/gpu/drm/i915/i915_gem_render_state.h | 47 +++++++++++++++++ drivers/gpu/drm/i915/intel_lrc.c | 73 ++++++++++++++++++++------ drivers/gpu/drm/i915/intel_lrc.h | 2 + drivers/gpu/drm/i915/intel_renderstate.h | 8 +-- 6 files changed, 135 insertions(+), 39 deletions(-) create mode 100644 drivers/gpu/drm/i915/i915_gem_render_state.h
drivers/gpu/drm/i915/i915_drv.h +2 -2
@@ -37,6 +37,7 @@#include "intel_ringbuffer.h" #include "intel_lrc.h" #include "i915_gem_gtt.h" +#include "i915_gem_render_state.h" #include <linux/io-mapping.h> #include <linux/i2c.h> #include <linux/i2c-algo-bit.h>
@@ -635,6 +636,7 @@ struct intel_context { } legacy_hw_ctx;/* Execlists */ +bool rcs_initialized;struct {struct drm_i915_gem_object *state;struct intel_ringbuffer *ringbuf;
@@ -2596,8 +2598,6 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,int i915_gem_context_destroy_ioctl (struct drm_device *dev,void *data,struct drm_file *file); -/* i915_gem_render_state.c */ -int i915_gem_render_state_init (struct intel_engine_cs *ring);/* i915_gem_evict.c */ int __must_check i915_gem_evict_something(struct drm_device *dev, struct i915_address_space *vm,
drivers/gpu/drm/i915/i915_gem_render_state.c +25 -15
@@ -28,13 +28,6 @@#include "i915_drv.h" #include "intel_renderstate.h" -struct render_state { -const struct intel_renderstate_rodata *rodata; -struct drm_i915_gem_object *obj; -u64 ggtt_offset; -int gen; -}; -static const struct intel_renderstate_rodata *render_state_get_rodata (struct drm_device *dev,const int gen) {
@@ -127,30 +120,47 @@ static int render_state_setup(struct render_state *so)return 0 ; } -static void render_state_fini (struct render_state *so) +void i915_gem_render_state_fini (struct render_state *so) {i915_gem_object_ggtt_unpin (so->obj);drm_gem_object_unreference (&so->obj->base); } -int i915_gem_render_state_init (struct intel_engine_cs *ring) +int i915_gem_render_state_prepare (struct intel_engine_cs *ring, +struct render_state *so) { -struct render_state so;int ret;if (WARN_ON (ring->id !=RCS ))return -ENOENT ; - ret =render_state_init (&so, ring->dev); + ret =render_state_init (so, ring->dev);if (ret)return ret; -if (so.rodata ==NULL ) +if (so->rodata ==NULL )return 0 ; - ret =render_state_setup (&so); + ret =render_state_setup (so); +if (ret) { +i915_gem_render_state_fini (so); +return ret; + } + +return 0 ; +} + +int i915_gem_render_state_init (struct intel_engine_cs *ring) +{ +struct render_state so; +int ret; + + ret =i915_gem_render_state_prepare (ring, &so);if (ret) - goto out; +return ret; + +if (so.rodata ==NULL ) +return 0 ; ret = ring->dispatch_execbuffer(ring, so.ggtt_offset,
@@ -164,6 +174,6 @@ int i915_gem_render_state_init(struct intel_engine_cs *ring) ret =__i915_add_request (ring,NULL , so.obj,NULL );/* __i915_add_request moves object to inactive if it fails */ out: -render_state_fini (&so); +i915_gem_render_state_fini (&so);return ret; }
drivers/gpu/drm/i915/i915_gem_render_state.h new file +47 -0
47 lines not on this page · raw message
drivers/gpu/drm/i915/intel_lrc.c +58 -15
103 lines not on this page · raw message
drivers/gpu/drm/i915/intel_lrc.h +2 -0
@@ -62,6 +62,8 @@ static inline void intel_logical_ring_emit(struct intel_ringbuffer *ringbuf,int intel_logical_ring_begin (struct intel_ringbuffer *ringbuf,int num_dwords);/* Logical Ring Contexts */ +int intel_lr_context_render_state_init (struct intel_engine_cs *ring, +struct intel_context *ctx);void intel_lr_context_free (struct intel_context *ctx);int intel_lr_context_deferred_create (struct intel_context *ctx,struct intel_engine_cs *ring);
drivers/gpu/drm/i915/intel_renderstate.h +1 -7
@@ -24,13 +24,7 @@#ifndef _INTEL_RENDERSTATE_H#define _INTEL_RENDERSTATE_H -#include <linux/types.h> - -struct intel_renderstate_rodata { -const u32 *reloc; -const u32 *batch; -const u32 batch_items; -}; +#include "i915_drv.h" extern const struct intel_renderstate_rodata gen6_null_state;extern const struct intel_renderstate_rodata gen7_null_state;
Signature · 6 lines
1.7.9.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 35/43] drm/i915/bdw: Make sure error capture keeps working with Execlists
In reply to Daniel VetterQuoted 25 lines
-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Friday, August 15, 2014 1:14 PM
To: Daniel, Thomas
Cc: [email protected]; Mika Kuoppala
Subject: Re: [Intel-gfx] [PATCH 35/43] drm/i915/bdw: Make sure error capture keeps working with ExeclistsQuoted 13 lines · Thomas Daniel
From: Oscar Mateo <[email protected]>
Since the ringbuffer does not belong per engine anymore, we have to make sure that we are always recording the correct ringbuffer.
TODO: This is only a small fix to keep basic error capture working, but we need to add more information for it to be useful (e.g. dump the context being executed).
v2: Reorder how the ringbuffer is chosen to clarify the change and rename the variable, both changes suggested by Chris Wilson. Also, add the TODO comment to the code, as suggested by Daniel.
Quoted 6 lines
Quoted 1 line
Signed-off-by Oscar Mateo <[email protected]>There's a bit too much stuff in-flight to fix up error capture for ppgtt. I think it's better to stall this patch here until that work is completed. Please coordinate with Mika here.
-Daniel
Mika has now closed the Jira issue. This patch still applies and looks correct. Is it OK to be merged as-is?
Thomas.
Quoted 73 lines
drivers/gpu/drm/i915/i915_gpu_error.c static void i915_record_ring_state(struct
Quoted 11 lines
--- drivers/gpu/drm/i915/i915_gpu_error.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)drivers/gpu/drm/i915/i915_gpu_error.c +0
-0@@ -874,9 +874,6 @@ static void i915_record_ring_state(struct
drm_device*dev,drivers/gpu/drm/i915/i915_gpu_error.c static void i915_gem_record_rings(struct
Quoted 19 lines
drivers/gpu/drm/i915/i915_gpu_error.c +1
-3ering->hws =I915_READ (mmio); } - ering->cpu_ring_head = ring->buffer->head; - ering->cpu_ring_tail = ring->buffer->tail; - ering->hangcheck_score = ring->hangcheck.score; ering->hangcheck_action = ring->hangcheck.action;@@ -936,6 +933,7 @@ static void i915_gem_record_rings(struct drm_device *dev, for (i = 0; i < I915_NUM_RINGS; i++) {struct intel_engine_cs *ring = &dev_priv->ring[i]; +struct intel_ringbuffer *rbuf; error->ring[i].pid =-1 ;@@ -979,8 +977,24 @@ static void i915_gem_record_rings(struct
drm_device*dev,drivers/gpu/drm/i915/i915_gpu_error.c static void i915_gem_record_rings(struct drm_device *dev,
Quoted 6 lines
drivers/gpu/drm/i915/i915_gpu_error.c +3
-0} } +if (i915.enable_execlists) { +/* TODO: This is only a small fix to keep basic error +* capture working, but we need to add more information
Quoted 25 lines
drivers/gpu/drm/i915/i915_gpu_error.c +14
-1+* for it to be useful (e.g. dump the context being +* executed). +*/ +if (request) + rbuf = request->ctx->engine[ring- id].ringbuf; +else + rbuf = ring->default_context->engine[ring- id].ringbuf; + }else + rbuf = ring->buffer; + + error->ring[i].cpu_ring_head = rbuf->head; + error->ring[i].cpu_ring_tail = rbuf->tail; + error->ring[i].ringbuffer = -i915_error_ggtt_object_create (dev_priv, ring- buffer->obj); +i915_error_ggtt_object_create (dev_priv, rbuf->obj);drivers/gpu/drm/i915/i915_gpu_error.c +0
-1if (ring->status_page.obj) error->ring[i].hws_page = --1.7.9.5
Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH] drm/i915/bdw: Render moot context reset and switch with Execlists
In reply to Chris WilsonQuoted 16 lines · Chris Wilson
Quoted 6 lines · Thomas Daniel
These two functions make no sense in an Logical Ring Context & Execlists world.
v2: We got rid of
lrc_enabledand centralized everything in the sanitized i915.enable_execlists instead.Quoted 8 lines
Signed-off-by Oscar Mateo <[email protected]>v3: Rebased. Corrected a typo in comment for
i915_switch_contextand added a comment that it should not be called in execlist mode. AddedWARN_ONifi915_switch_contextis called in execlist mode. Moved check for execlist mode out ofi915_switch_contextand into callers. Added comment incontext_resetexplaining why nothing is done in execlist mode.
Quoted 3 lines
No, this is not the way. The requirement is to reduce the number of special cases not increase them. These should be evaluated to be no-ops when execlists is used.
I think it's ok-ish for now. Maybe we need to reconsider when we wire up lrc reclaim - which is the real user of the switch_context in gpu_idle. The problem I have though is that I can't parse the subject of the patch, someone please translate that to simplified English for me. I can do the replacement while applying.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 27/43] drm/i915/bdw: Render state init for Execlists
In reply to Daniel, ThomasQuoted 110 lines · Thomas
Quoted 104 lines
-----Original Message-----
From: Daniel, Thomas
Sent: Friday, August 15, 2014 9:44 AM
To: 'Daniel Vetter'
Cc: [email protected]
Subject: RE: [Intel-gfx] [PATCH 27/43] drm/i915/bdw: Render state init for ExeclistsQuoted 92 lines
-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Thursday, August 14, 2014 9:00 PM
To: Daniel, Thomas
Cc: Daniel Vetter; [email protected]
Subject: Re: [Intel-gfx] [PATCH 27/43] drm/i915/bdw: Render state init for ExeclistsQuoted 20 lines · Daniel Vetter
Quoted 19 lines · Thomas
Quoted 19 lines
-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, August 11, 2014 10:25 PM
To: Daniel, Thomas
Cc: [email protected]
Subject: Re: [Intel-gfx] [PATCH 27/43] drm/i915/bdw: Render state init for ExeclistsQuoted 1 line · Thomas Daniel
From: Oscar Mateo <[email protected]>
index 9085ff1..0dc6992 100644
drivers/gpu/drm/i915/i915_gem_context.c int i915_gem_context_enable(struct
Quoted 3 lines
drivers/gpu/drm/i915/i915_gem_context.c +0
-0@@ -513,8 +513,23 @@ int i915_gem_context_enable(struct
drm_i915_private*dev_priv)Quoted 3 lines
drivers/gpu/drm/i915/i915_gem_context.c +0
-0ppgtt->enable (ppgtt); }Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/i915/i915_gem_context.c int i915_gem_context_enable(struct drm_i915_private *dev_priv)
Quoted 9 lines
drivers/gpu/drm/i915/i915_gem_context.c +8
-1-if (i915.enable_execlists) +if (i915.enable_execlists) { +struct intel_context *dctx; + + ring = &dev_priv->ring[RCS ]; + dctx = ring->default_context; + +if (!dctx->rcs_initialized) { + ret = intel_lr_context_render_state_init(ring,dctx);
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/i915/i915_gem_context.c int i915_gem_context_enable(struct · line 525
Quoted 2 lines
drivers/gpu/drm/i915/i915_gem_context.c +2
-0+if (ret) { + DRM_ERROR("Init render state failed:%d\n",
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
ret);
drivers/gpu/drm/i915/i915_gem_context.c int i915_gem_context_enable(struct drm_i915_private *dev_priv) · line 532
Quoted 7 lines
drivers/gpu/drm/i915/i915_gem_context.c +6
-0+return ret; + } + dctx->rcs_initialized = true; + } +return 0 ; + }This looks very much like the wrong place. We should init the render state when we create the context, or when we switch to it for
the first time.
Quoted 35 lines
Quoted 11 lines
Quoted 4 lines
The later is what the legacy contexts currently do in
do_switch.But
ctx_enableshould do the switch to the default context and that's aboutWell, a side-effect of switching to the default context in legacy mode is that the render state gets initialized. I could move the lr render state init call into an
enable_execlistsbranch ini915_switch_context()but that doen't seem like the right place.How about in
i915_gem_init()after callingi915_gem_init_hw()?Quoted 7 lines
Quoted 5 lines
it. If there's some depency then I guess we should stall the creation of the default context a bit, maybe.
In any case someone needs to explain this better and if there's not other wey this at least needs a bit comment. So I'll punt for now.
When the default context is created the driver is not ready to execute a batch. That is why the render state init can't be done then.
That sounds like the default context is created too early. Essentially I want to avoid needless divergence between the default context and normal contexts, because sooner or later that will means someone will creep in with a _really_ subtle bug.
What about:
- We create the default lrc contexs incontext_init, but like with a normal context we don't do any of the deferred setup.
- Incontext_enable(which since yesterday properly propagates errors to callers) we force the deferred lrc ctx setup for the default contexts on all engines.
- The render state init is done as part of the deferred ctx setup for the render engine in all cases.Totally off the track or do you see a workable solution somewhere in that direction?
Quoted 6 lines
Quoted 2 lines
I'd like to discuss this first a bit more, so will punt on this patch for now. -Daniel
I think that your proposal will work. I've been having some trouble with my RVP board so haven't had a chance to test it out yet.
Thomas.
Quoted 8 lines
I've now tried this out and I don't think it can work without introducing more problems than the original patch. Trouble is that in lrc mode the Hardware Status Page is offset 0 from the context. All contexts use the default context's HWSP for writing seqnos, this is stored in
ring->status_page. We can't populate this until the deferred creation of the default context is done, so we can't execute any instructions in the deferred creation (unless we check for default context in the deferred creation which is what we wanted to avoid in the first place).
That just sounds like we should either allocate the HWS at engine init time (since it's shared across all rings). Or that we should switch to per-ring/ctx hws, but that's probably only something for when the scheduler shows up.
Or is there some other blocker?
Generally I really don't like to bend over backwards in the init code if we get such initialization ordering constraints wrong - in the past that really has been a fairly awesome source of bugs. What's needed though is a pile of WARN_ON to check that the initialization ordering is done in the right way, in case someone touches the code. That still means runtime testing, but that's still a lot better than silent failures. -Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 35/43] drm/i915/bdw: Make sure error capture keeps working with Execlists
In reply to Daniel, ThomasQuoted 25 lines · Thomas
Quoted 25 lines
-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Friday, August 15, 2014 1:14 PM
To: Daniel, Thomas
Cc: [email protected]; Mika Kuoppala
Subject: Re: [Intel-gfx] [PATCH 35/43] drm/i915/bdw: Make sure error capture keeps working with ExeclistsQuoted 13 lines · Thomas Daniel
From: Oscar Mateo <[email protected]>
Since the ringbuffer does not belong per engine anymore, we have to make sure that we are always recording the correct ringbuffer.
TODO: This is only a small fix to keep basic error capture working, but we need to add more information for it to be useful (e.g. dump the context being executed).
v2: Reorder how the ringbuffer is chosen to clarify the change and rename the variable, both changes suggested by Chris Wilson. Also, add the TODO comment to the code, as suggested by Daniel.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Signed-off-by Oscar Mateo <[email protected]>There's a bit too much stuff in-flight to fix up error capture for ppgtt. I think it's better to stall this patch here until that work is completed. Please coordinate with Mika here.
-DanielMika has now closed the Jira issue. This patch still applies and looks correct. Is it OK to be merged as-is?
Apparently Mika closed the Jira before I've merged all the patches. I'd like to do that first, then come back to this patch.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Daniel Vetter
AppliedRe: [PATCH 35/43] drm/i915/bdw: Make sure error capture keeps working with Execlists
In reply to Daniel, ThomasQuoted 25 lines · Thomas
Quoted 25 lines
-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Friday, August 15, 2014 1:14 PM
To: Daniel, Thomas
Cc: [email protected]; Mika Kuoppala
Subject: Re: [Intel-gfx] [PATCH 35/43] drm/i915/bdw: Make sure error capture keeps working with ExeclistsQuoted 13 lines · Thomas Daniel
From: Oscar Mateo <[email protected]>
Since the ringbuffer does not belong per engine anymore, we have to make sure that we are always recording the correct ringbuffer.
TODO: This is only a small fix to keep basic error capture working, but we need to add more information for it to be useful (e.g. dump the context being executed).
v2: Reorder how the ringbuffer is chosen to clarify the change and rename the variable, both changes suggested by Chris Wilson. Also, add the TODO comment to the code, as suggested by Daniel.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Signed-off-by Oscar Mateo <[email protected]>There's a bit too much stuff in-flight to fix up error capture for ppgtt. I think it's better to stall this patch here until that work is completed. Please coordinate with Mika here.
-DanielMika has now closed the Jira issue. This patch still applies and looks correct. Is it OK to be merged as-is?
Queued for -next, thanks for the patch.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH] drm/i915/bdw: Render moot context reset and switch with Execlists
In reply to Daniel VetterQuoted 21 lines · Daniel Vetter
Quoted 16 lines · Chris Wilson
Quoted 6 lines · Thomas Daniel
These two functions make no sense in an Logical Ring Context & Execlists world.
v2: We got rid of
lrc_enabledand centralized everything in the sanitized i915.enable_execlists instead.Quoted 8 lines
Signed-off-by Oscar Mateo <[email protected]>v3: Rebased. Corrected a typo in comment for
i915_switch_contextand added a comment that it should not be called in execlist mode. AddedWARN_ONifi915_switch_contextis called in execlist mode. Moved check for execlist mode out ofi915_switch_contextand into callers. Added comment incontext_resetexplaining why nothing is done in execlist mode.Quoted 3 lines
No, this is not the way. The requirement is to reduce the number of special cases not increase them. These should be evaluated to be no-ops when execlists is used.
Quoted 6 lines
I think it's ok-ish for now. Maybe we need to reconsider when we wire up lrc reclaim - which is the real user of the
switch_contextingpu_idle. The problem I have though is that I can't parse the subject of the patch, someone please translate that to simplified English for me. I can do the replacement while applying.
-Daniel
"Render moot" usually means something like "make obsolete", not sure about the rest.
Re: [PATCH] drm/i915/bdw: Render moot context reset and switch with Execlists
In reply to Daniel VetterQuoted 21 lines · Daniel Vetter
Quoted 16 lines · Chris Wilson
Quoted 6 lines · Thomas Daniel
These two functions make no sense in an Logical Ring Context & Execlists world.
v2: We got rid of
lrc_enabledand centralized everything in the sanitized i915.enable_execlists instead.Quoted 8 lines
Signed-off-by Oscar Mateo <[email protected]>v3: Rebased. Corrected a typo in comment for
i915_switch_contextand added a comment that it should not be called in execlist mode. AddedWARN_ONifi915_switch_contextis called in execlist mode. Moved check for execlist mode out ofi915_switch_contextand into callers. Added comment incontext_resetexplaining why nothing is done in execlist mode.Quoted 3 lines
No, this is not the way. The requirement is to reduce the number of special cases not increase them. These should be evaluated to be no-ops when execlists is used.
Quoted 5 lines
I think it's ok-ish for now. Maybe we need to reconsider when we wire up lrc reclaim - which is the real user of the
switch_contextingpu_idle. The problem I have though is that I can't parse the subject of the patch, someone please translate that to simplified English for me. I can do the replacement while applying.
No, it is not. execlists is badly designed and this is a further symptom of that.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Re: [PATCH] drm/i915/bdw: Render moot context reset and switch with Execlists
Quoted 28 lines · Chris Wilson
Quoted 21 lines · Daniel Vetter
Quoted 16 lines · Chris Wilson
Quoted 6 lines · Thomas Daniel
These two functions make no sense in an Logical Ring Context & Execlists world.
v2: We got rid of
lrc_enabledand centralized everything in the sanitized i915.enable_execlists instead.Quoted 8 lines
Signed-off-by Oscar Mateo <[email protected]>v3: Rebased. Corrected a typo in comment for
i915_switch_contextand added a comment that it should not be called in execlist mode. AddedWARN_ONifi915_switch_contextis called in execlist mode. Moved check for execlist mode out ofi915_switch_contextand into callers. Added comment incontext_resetexplaining why nothing is done in execlist mode.Quoted 3 lines
No, this is not the way. The requirement is to reduce the number of special cases not increase them. These should be evaluated to be no-ops when execlists is used.
Quoted 5 lines
I think it's ok-ish for now. Maybe we need to reconsider when we wire up lrc reclaim - which is the real user of the
switch_contextingpu_idle. The problem I have though is that I can't parse the subject of the patch, someone please translate that to simplified English for me. I can do the replacement while applying.
Quoted 4 lines
No, it is not. execlists is badly designed and this is a further symptom of that.
-Chris
Thomas is not available and I am replying on his behalf. Is the following subject is good for this patch?
"Don't execute context reset and switch when using Execlists"
regards
Arun
Re: [PATCH] drm/i915/bdw: Render moot context reset and switch with Execlists
Quoted 29 lines · Arun
Quoted 28 lines · Chris Wilson
Quoted 26 lines · Daniel Vetter
Quoted 16 lines · Chris Wilson
Quoted 6 lines · Thomas Daniel
These two functions make no sense in an Logical Ring Context & Execlists world.
v2: We got rid of
lrc_enabledand centralized everything in the sanitized i915.enable_execlists instead.Quoted 8 lines
Signed-off-by Oscar Mateo <[email protected]>v3: Rebased. Corrected a typo in comment for
i915_switch_contextand added a comment that it should not be called in execlist mode. AddedWARN_ONifi915_switch_contextis called in execlist mode. Moved check for execlist mode out ofi915_switch_contextand into callers. Added comment incontext_resetexplaining why nothing is done in execlist mode.Quoted 3 lines
No, this is not the way. The requirement is to reduce the number of special cases not increase them. These should be evaluated to be no-ops when execlists is used.
I think it's ok-ish for now. Maybe we need to reconsider when we wire up lrc reclaim - which is the real user of the
switch_contextingpu_idle. The problem I have though is that I can't parse the subject of the patch, someone please translate that to simplified English for me. I can do the replacement while applying.
Quoted 8 lines
Quoted 4 lines
No, it is not. execlists is badly designed and this is a further symptom of that.
-ChrisThomas is not available and I am replying on his behalf. Is the following subject is good for this patch?
"Don't execute context reset and switch when using Execlists"
Yeah, I think that's more parseable by mere mortals^W^W non-native speakers. Pulled in.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Daniel Vetter
AppliedRe: [PATCH] drm/i915/bdw: Render state init for Execlists
In reply to Thomas DanielQuoted 15 lines · Thomas Daniel
From: Oscar Mateo <[email protected]>
The batchbuffer that sets the render context state is submitted in a different way, and from different places.
We needed to make both the render state preparation and free functions outside accesible, and namespace accordingly. This mess is so that all LR, LRC and Execlists functionality can go together in
intel_lrc.c: we can fix all of this later on, once the interfaces are clear.v2: Create a separate
ctx->rcs_initializedfor the Execlists case, as suggested by Chris Wilson.Signed-off-by Oscar Mateo <[email protected]>
Quoted 8 lines
v3: Setup ring status page in
lr_context_deferred_createwhen the default context is being created. This means that the render state init for the default context is no longer a special case. Execute deferred creation of the default context at the end oflogical_ring_initto allow the render state commands to be submitted. Fix style errors reported by checkpatch. Rebased.Signed-off-by Thomas Daniel <[email protected]>
Queued for -next, thanks for the patch.
-Daniel
Quoted 324 lines
--- drivers/gpu/drm/i915/i915_drv.h | 4 +- drivers/gpu/drm/i915/i915_gem_render_state.c | 40 ++++++++------ drivers/gpu/drm/i915/i915_gem_render_state.h | 47 +++++++++++++++++ drivers/gpu/drm/i915/intel_lrc.c | 73 ++++++++++++++++++++------ drivers/gpu/drm/i915/intel_lrc.h | 2 + drivers/gpu/drm/i915/intel_renderstate.h | 8 +-- 6 files changed, 135 insertions(+), 39 deletions(-) create mode 100644 drivers/gpu/drm/i915/i915_gem_render_state.hdrivers/gpu/drm/i915/i915_drv.h +2
-2@@ -37,6 +37,7 @@#include "intel_ringbuffer.h" #include "intel_lrc.h" #include "i915_gem_gtt.h" +#include "i915_gem_render_state.h" #include <linux/io-mapping.h> #include <linux/i2c.h> #include <linux/i2c-algo-bit.h> @@ -635,6 +636,7 @@ struct intel_context { } legacy_hw_ctx;/* Execlists */ +bool rcs_initialized;struct {struct drm_i915_gem_object *state;struct intel_ringbuffer *ringbuf;@@ -2596,8 +2598,6 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,int i915_gem_context_destroy_ioctl (struct drm_device *dev,void *data,struct drm_file *file); -/* i915_gem_render_state.c */ -int i915_gem_render_state_init (struct intel_engine_cs *ring);/* i915_gem_evict.c */ int __must_check i915_gem_evict_something(struct drm_device *dev, struct i915_address_space *vm,drivers/gpu/drm/i915/i915_gem_render_state.c +25
-15@@ -28,13 +28,6 @@#include "i915_drv.h" #include "intel_renderstate.h" -struct render_state { -const struct intel_renderstate_rodata *rodata; -struct drm_i915_gem_object *obj; -u64 ggtt_offset; -int gen; -}; -static const struct intel_renderstate_rodata *render_state_get_rodata (struct drm_device *dev,const int gen) {@@ -127,30 +120,47 @@ static int render_state_setup(struct render_state *so)return 0 ; } -static void render_state_fini (struct render_state *so) +void i915_gem_render_state_fini (struct render_state *so) {i915_gem_object_ggtt_unpin (so->obj);drm_gem_object_unreference (&so->obj->base); } -int i915_gem_render_state_init (struct intel_engine_cs *ring) +int i915_gem_render_state_prepare (struct intel_engine_cs *ring, +struct render_state *so) { -struct render_state so;int ret;if (WARN_ON (ring->id !=RCS ))return -ENOENT ; - ret =render_state_init (&so, ring->dev); + ret =render_state_init (so, ring->dev);if (ret)return ret; -if (so.rodata ==NULL ) +if (so->rodata ==NULL )return 0 ; - ret =render_state_setup (&so); + ret =render_state_setup (so); +if (ret) { +i915_gem_render_state_fini (so); +return ret; + } + +return 0 ; +} + +int i915_gem_render_state_init (struct intel_engine_cs *ring) +{ +struct render_state so; +int ret; + + ret =i915_gem_render_state_prepare (ring, &so);if (ret) - goto out; +return ret; + +if (so.rodata ==NULL ) +return 0 ; ret = ring->dispatch_execbuffer(ring, so.ggtt_offset,@@ -164,6 +174,6 @@ int i915_gem_render_state_init(struct intel_engine_cs *ring) ret =__i915_add_request (ring,NULL , so.obj,NULL );/* __i915_add_request moves object to inactive if it fails */ out: -render_state_fini (&so); +i915_gem_render_state_fini (&so);return ret; }drivers/gpu/drm/i915/i915_gem_render_state.h new file +47
-0@@ -0,0 +1,47 @@ +/* +* Copyright © 2014 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#ifndef _I915_GEM_RENDER_STATE_H_ +#define _I915_GEM_RENDER_STATE_H_ + +#include <linux/types.h> + +struct intel_renderstate_rodata { +const u32 *reloc; +const u32 *batch; +const u32 batch_items; +}; + +struct render_state { +const struct intel_renderstate_rodata *rodata; +struct drm_i915_gem_object *obj; +u64 ggtt_offset; +int gen; +}; + +int i915_gem_render_state_init (struct intel_engine_cs *ring); +void i915_gem_render_state_fini (struct render_state *so); +int i915_gem_render_state_prepare (struct intel_engine_cs *ring, +struct render_state *so); + +#endif /* _I915_GEM_RENDER_STATE_H_ */ drivers/gpu/drm/i915/intel_lrc.c +58
-15@@ -1217,8 +1217,6 @@ void intel_logical_ring_cleanup(struct intel_engine_cs *ring)static int logical_ring_init (struct drm_device *dev,struct intel_engine_cs *ring) {int ret; -struct intel_context *dctx = ring->default_context; -struct drm_i915_gem_object *dctx_obj;/* Intentionally left blank. */ ring->buffer =NULL ;@@ -1232,18 +1230,6 @@ static int logical_ring_init(struct drm_device *dev, struct intel_engine_cs *rinspin_lock_init (&ring->execlist_lock); ring->next_context_status_buffer =0 ; - ret =intel_lr_context_deferred_create (dctx, ring); -if (ret) -return ret; - -/* The status page is offset 0 from the context object in LRCs. */ - dctx_obj = dctx->engine[ring->id].state; - ring->status_page.gfx_addr =i915_gem_obj_ggtt_offset (dctx_obj); - ring->status_page.page_addr =kmap (sg_page (dctx_obj->pages->sgl)); -if (ring->status_page.page_addr ==NULL ) -return -ENOMEM ; - ring->status_page.obj = dctx_obj; - ret =i915_cmd_parser_init_ring (ring);if (ret)return ret;@@ -1254,7 +1240,9 @@ static int logical_ring_init(struct drm_device *dev, struct intel_engine_cs *rinreturn ret; } -return 0 ; + ret =intel_lr_context_deferred_create (ring->default_context, ring); + +return ret; }static int logical_render_ring_init (struct drm_device *dev)@@ -1448,6 +1436,38 @@ cleanup_render_ring:return ret; } +int intel_lr_context_render_state_init (struct intel_engine_cs *ring, +struct intel_context *ctx) +{ +struct intel_ringbuffer *ringbuf = ctx->engine[ring->id].ringbuf; +struct render_state so; +struct drm_i915_file_private *file_priv = ctx->file_priv; +struct drm_file *file = file_priv ? file_priv->file :NULL ; +int ret; + + ret =i915_gem_render_state_prepare (ring, &so); +if (ret) +return ret; + +if (so.rodata ==NULL ) +return 0 ; + + ret = ring->emit_bb_start (ringbuf, + so.ggtt_offset, +I915_DISPATCH_SECURE ); +if (ret) + goto out; + +i915_vma_move_to_active (i915_gem_obj_to_ggtt (so.obj), ring); + + ret =__i915_add_request (ring, file, so.obj,NULL ); +/* intel_logical_ring_add_request moves object to inactive if it +* fails */ +out: +i915_gem_render_state_fini (&so); +return ret; +} +static int populate_lr_context (struct intel_context *ctx,struct drm_i915_gem_object *ctx_obj,struct intel_engine_cs *ring,struct intel_ringbuffer *ringbuf)@@ -1687,6 +1707,29 @@ int intel_lr_context_deferred_create(struct intel_context *ctx, ctx->engine[ring->id].ringbuf = ringbuf; ctx->engine[ring->id].state = ctx_obj; +if (ctx == ring->default_context) { +/* The status page is offset 0 from the default context object +* in LRC mode. */ + ring->status_page.gfx_addr =i915_gem_obj_ggtt_offset (ctx_obj); + ring->status_page.page_addr = +kmap (sg_page (ctx_obj->pages->sgl)); +if (ring->status_page.page_addr ==NULL ) +return -ENOMEM ; + ring->status_page.obj = ctx_obj; + } + +if (ring->id ==RCS && !ctx->rcs_initialized) { + ret =intel_lr_context_render_state_init (ring, ctx); +if (ret) { +DRM_ERROR ("Init render state failed: %d\n" , ret); + ctx->engine[ring->id].ringbuf =NULL ; + ctx->engine[ring->id].state =NULL ; +intel_destroy_ringbuffer_obj (ringbuf); + goto error; + } + ctx->rcs_initialized = true; + } +return 0 ; error:drivers/gpu/drm/i915/intel_lrc.h +2
-0@@ -62,6 +62,8 @@ static inline void intel_logical_ring_emit(struct intel_ringbuffer *ringbuf,int intel_logical_ring_begin (struct intel_ringbuffer *ringbuf,int num_dwords);/* Logical Ring Contexts */ +int intel_lr_context_render_state_init (struct intel_engine_cs *ring, +struct intel_context *ctx);void intel_lr_context_free (struct intel_context *ctx);int intel_lr_context_deferred_create (struct intel_context *ctx,struct intel_engine_cs *ring);drivers/gpu/drm/i915/intel_renderstate.h +1
-7@@ -24,13 +24,7 @@#ifndef _INTEL_RENDERSTATE_H#define _INTEL_RENDERSTATE_H -#include <linux/types.h> - -struct intel_renderstate_rodata { -const u32 *reloc; -const u32 *batch; -const u32 batch_items; -}; +#include "i915_drv.h" extern const struct intel_renderstate_rodata gen6_null_state;extern const struct intel_renderstate_rodata gen7_null_state;Signature · 6 lines
1.7.9.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch