Remove the outstanding_lazy_request
Subsystems (2)
Re: [PATCH 48/53] drm/i915: Update intel_ring_begin() to take a request structure
In reply to [email protected]Quoted 442 lines · On 19/02/2015 17:18, [email protected] wrote:
From: John Harrison <[email protected]>
Now that everything above has been converted to use requests,
intel_ring_begin()can be updated to take a request instead of a ring. This also means that it no longer needs to lazily allocate a request if no-one happens to have done it earlier.For: VIZ-5115
Signed-off-by John Harrison <[email protected]>--- drivers/gpu/drm/i915/i915_gem.c | 2 +- drivers/gpu/drm/i915/i915_gem_context.c | 2 +- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 8 ++-- drivers/gpu/drm/i915/i915_gem_gtt.c | 6 +-- drivers/gpu/drm/i915/intel_display.c | 10 ++-- drivers/gpu/drm/i915/intel_overlay.c | 8 ++-- drivers/gpu/drm/i915/intel_pm.c | 2 +- drivers/gpu/drm/i915/intel_ringbuffer.c | 72 +++++++++++++--------------- drivers/gpu/drm/i915/intel_ringbuffer.h | 2 +- 9 files changed, 54 insertions(+), 58 deletions(-)drivers/gpu/drm/i915/i915_gem.c +1
-1@@ -4656,7 +4656,7 @@ int i915_gem_l3_remap(struct drm_i915_gem_request *req, int slice)if (!HAS_L3_DPF (dev) || !remap_info)return 0 ; - ret =intel_ring_begin (ring,GEN7_L3LOG_SIZE /4 *3 ); + ret =intel_ring_begin (req,GEN7_L3LOG_SIZE /4 *3 );if (ret)return ret;drivers/gpu/drm/i915/i915_gem_context.c +1
-1@@ -503,7 +503,7 @@ mi_set_context(struct drm_i915_gem_request *req, u32 hw_flags)if (INTEL_INFO (ring->dev)->gen >=7 ) len +=2 + (num_rings ?4 *num_rings +2 :0 ); - ret =intel_ring_begin (ring, len); + ret =intel_ring_begin (req, len);if (ret)return ret;drivers/gpu/drm/i915/i915_gem_execbuffer.c +4
-4@@ -1013,7 +1013,7 @@ i915_reset_gen7_sol_offsets(struct drm_device *dev,return -EINVAL ; } - ret =intel_ring_begin (ring,4 *3 ); + ret =intel_ring_begin (req,4 *3 );if (ret)return ret;@@ -1044,7 +1044,7 @@ i915_emit_box(struct drm_i915_gem_request *req, }if (INTEL_INFO (ring->dev)->gen >=4 ) { - ret =intel_ring_begin (ring,4 ); + ret =intel_ring_begin (req,4 );if (ret)return ret;@@ -1053,7 +1053,7 @@ i915_emit_box(struct drm_i915_gem_request *req,intel_ring_emit (ring, ((box->x2 -1 ) &0xffff ) | (box->y2 -1 ) <<16 );intel_ring_emit (ring,DR4 ); }else { - ret =intel_ring_begin (ring,6 ); + ret =intel_ring_begin (req,6 );if (ret)return ret;@@ -1235,7 +1235,7 @@ i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,if (ring == &dev_priv->ring[RCS ] && instp_mode != dev_priv->relative_constants_mode) { - ret =intel_ring_begin (ring,4 ); + ret =intel_ring_begin (params->request,4 );if (ret) goto error;drivers/gpu/drm/i915/i915_gem_gtt.c +3
-3@@ -288,7 +288,7 @@ static int gen8_write_pdp(struct drm_i915_gem_request *req, unsigned entry,BUG_ON (entry >=4 ); - ret =intel_ring_begin (ring,6 ); + ret =intel_ring_begin (req,6 );if (ret)return ret;@@ -788,7 +788,7 @@ static int hsw_mm_switch(struct i915_hw_ppgtt *ppgtt,if (ret)return ret; - ret =intel_ring_begin (ring,6 ); + ret =intel_ring_begin (req,6 );if (ret)return ret;@@ -825,7 +825,7 @@ static int gen7_mm_switch(struct i915_hw_ppgtt *ppgtt,if (ret)return ret; - ret =intel_ring_begin (ring,6 ); + ret =intel_ring_begin (req,6 );if (ret)return ret;drivers/gpu/drm/i915/intel_display.c +5
-5@@ -9259,7 +9259,7 @@ static int intel_gen2_queue_flip(struct drm_device *dev,u32 flip_mask;int ret; - ret =intel_ring_begin (ring,6 ); + ret =intel_ring_begin (req,6 );if (ret)return ret;@@ -9294,7 +9294,7 @@ static int intel_gen3_queue_flip(struct drm_device *dev,u32 flip_mask;int ret; - ret =intel_ring_begin (ring,6 ); + ret =intel_ring_begin (req,6 );if (ret)return ret;@@ -9327,7 +9327,7 @@ static int intel_gen4_queue_flip(struct drm_device *dev,uint32_t pf, pipesrc;int ret; - ret =intel_ring_begin (ring,4 ); + ret =intel_ring_begin (req,4 );if (ret)return ret;@@ -9366,7 +9366,7 @@ static int intel_gen6_queue_flip(struct drm_device *dev,uint32_t pf, pipesrc;int ret; - ret =intel_ring_begin (ring,4 ); + ret =intel_ring_begin (req,4 );if (ret)return ret;@@ -9442,7 +9442,7 @@ static int intel_gen7_queue_flip(struct drm_device *dev,if (ret)return ret; - ret =intel_ring_begin (ring, len); + ret =intel_ring_begin (req, len);if (ret)return ret;drivers/gpu/drm/i915/intel_overlay.c +4
-4@@ -251,7 +251,7 @@ static int intel_overlay_on(struct intel_overlay *overlay)if (ret)return ret; - ret =intel_ring_begin (ring,4 ); + ret =intel_ring_begin (req,4 );if (ret) {i915_gem_request_unreference (req);return ret;@@ -292,7 +292,7 @@ static int intel_overlay_continue(struct intel_overlay *overlay,if (ret)return ret; - ret =intel_ring_begin (ring,2 ); + ret =intel_ring_begin (req,2 );if (ret) {i915_gem_request_unreference (req);return ret;@@ -359,7 +359,7 @@ static int intel_overlay_off(struct intel_overlay *overlay)if (ret)return ret; - ret =intel_ring_begin (ring,6 ); + ret =intel_ring_begin (req,6 );if (ret) {i915_gem_request_unreference (req);return ret;@@ -434,7 +434,7 @@ static int intel_overlay_release_old_vid(struct intel_overlay *overlay)if (ret)return ret; - ret =intel_ring_begin (ring,2 ); + ret =intel_ring_begin (req,2 );if (ret) {i915_gem_request_unreference (req);return ret;drivers/gpu/drm/i915/intel_pm.c +1
-1@@ -5012,7 +5012,7 @@ static void ironlake_enable_rc6(struct drm_device *dev)* GPU can automatically power down the render unit if given a page * to save state. */ - ret =intel_ring_begin (ring,6 ); + ret =intel_ring_begin (req,6 );if (ret) goto err;drivers/gpu/drm/i915/intel_ringbuffer.c +24
-25@@ -106,7 +106,7 @@ gen2_render_ring_flush(struct drm_i915_gem_request *req,if (invalidate_domains &I915_GEM_DOMAIN_SAMPLER ) cmd |=MI_READ_FLUSH ; - ret =intel_ring_begin (ring,2 ); + ret =intel_ring_begin (req,2 );if (ret)return ret;@@ -165,7 +165,7 @@ gen4_render_ring_flush(struct drm_i915_gem_request *req, (IS_G4X(dev) || IS_GEN5(dev))) cmd |=MI_INVALIDATE_ISP ; - ret =intel_ring_begin (ring,2 ); + ret =intel_ring_begin (req,2 );if (ret)return ret;@@ -220,8 +220,7 @@ intel_emit_post_sync_nonzero_flush(struct drm_i915_gem_request *req)u32 scratch_addr = ring->scratch.gtt_offset +2 *CACHELINE_BYTES ;int ret; - - ret =intel_ring_begin (ring,6 ); + ret =intel_ring_begin (req,6 );if (ret)return ret;@@ -234,7 +233,7 @@ intel_emit_post_sync_nonzero_flush(struct drm_i915_gem_request *req)intel_ring_emit (ring,MI_NOOP );intel_ring_advance (ring); - ret =intel_ring_begin (ring,6 ); + ret =intel_ring_begin (req,6 );if (ret)return ret;@@ -289,7 +288,7 @@ gen6_render_ring_flush(struct drm_i915_gem_request *req, flags |=PIPE_CONTROL_QW_WRITE |PIPE_CONTROL_CS_STALL ; } - ret =intel_ring_begin (ring,4 ); + ret =intel_ring_begin (req,4 );if (ret)return ret;@@ -308,7 +307,7 @@ gen7_render_ring_cs_stall_wa(struct drm_i915_gem_request *req)struct intel_engine_cs *ring = req->ring;int ret; - ret =intel_ring_begin (ring,4 ); + ret =intel_ring_begin (req,4 );if (ret)return ret;@@ -330,7 +329,7 @@ static int gen7_ring_fbc_flush(struct drm_i915_gem_request *req, u32 value)if (!ring->fbc_dirty)return 0 ; - ret =intel_ring_begin (ring,6 ); + ret =intel_ring_begin (req,6 );if (ret)return ret;/* WaFbcNukeOn3DBlt:ivb/hsw */ @@ -395,7 +394,7 @@ gen7_render_ring_flush(struct drm_i915_gem_request *req,gen7_render_ring_cs_stall_wa (req); } - ret =intel_ring_begin (ring,4 ); + ret =intel_ring_begin (req,4 );if (ret)return ret;@@ -418,7 +417,7 @@ gen8_emit_pipe_control(struct drm_i915_gem_request *req,struct intel_engine_cs *ring = req->ring;int ret; - ret =intel_ring_begin (ring,6 ); + ret =intel_ring_begin (req,6 );if (ret)return ret;@@ -760,7 +759,7 @@ static int intel_ring_workarounds_emit(struct drm_i915_gem_request *req)if (ret)return ret; - ret =intel_ring_begin (ring, (w->count *2 +2 )); + ret =intel_ring_begin (req, (w->count *2 +2 ));if (ret)return ret;@@ -1119,7 +1118,7 @@ static int gen8_rcs_signal(struct drm_i915_gem_request *signaller_req, num_dwords += (num_rings-1 ) *MBOX_UPDATE_DWORDS ;#undef MBOX_UPDATE_DWORDS - ret =intel_ring_begin (signaller, num_dwords); + ret =intel_ring_begin (signaller_req, num_dwords);if (ret)return ret;@@ -1160,7 +1159,7 @@ static int gen8_xcs_signal(struct drm_i915_gem_request *signaller_req, num_dwords += (num_rings-1 ) *MBOX_UPDATE_DWORDS ;#undef MBOX_UPDATE_DWORDS - ret =intel_ring_begin (signaller, num_dwords); + ret =intel_ring_begin (signaller_req, num_dwords);if (ret)return ret;@@ -1199,7 +1198,7 @@ static int gen6_signal(struct drm_i915_gem_request *signaller_req, num_dwords +=round_up ((num_rings-1 ) *MBOX_UPDATE_DWORDS ,2 );#undef MBOX_UPDATE_DWORDS - ret =intel_ring_begin (signaller, num_dwords); + ret =intel_ring_begin (signaller_req, num_dwords);if (ret)return ret;@@ -1237,7 +1236,7 @@ gen6_add_request(struct drm_i915_gem_request *req)if (ring->semaphore.signal) ret = ring->semaphore.signal (req,4 );else - ret =intel_ring_begin (ring,4 ); + ret =intel_ring_begin (req,4 );if (ret)return ret;@@ -1275,7 +1274,7 @@ gen8_ring_sync(struct drm_i915_gem_request *waiter_req,struct drm_i915_private *dev_priv = waiter->dev->dev_private;int ret; - ret =intel_ring_begin (waiter,4 ); + ret =intel_ring_begin (waiter_req,4 );if (ret)return ret;@@ -1312,7 +1311,7 @@ gen6_ring_sync(struct drm_i915_gem_request *waiter_req,WARN_ON (wait_mbox ==MI_SEMAPHORE_SYNC_INVALID ); - ret =intel_ring_begin (waiter,4 ); + ret =intel_ring_begin (waiter_req,4 );if (ret)return ret;@@ -1357,7 +1356,7 @@ pc_render_add_request(struct drm_i915_gem_request *req)* incoherence by flushing the 6 PIPE_NOTIFY buffers out to * memory before requesting an interrupt. */ - ret =intel_ring_begin (ring,32 ); + ret =intel_ring_begin (req,32 );if (ret)return ret;@@ -1542,7 +1541,7 @@ bsd_ring_flush(struct drm_i915_gem_request *req,struct intel_engine_cs *ring = req->ring;int ret; - ret =intel_ring_begin (ring,2 ); + ret =intel_ring_begin (req,2 );if (ret)return ret;@@ -1558,7 +1557,7 @@ i9xx_add_request(struct drm_i915_gem_request *req)struct intel_engine_cs *ring = req->ring;int ret; - ret =intel_ring_begin (ring,4 ); + ret =intel_ring_begin (req,4 );if (ret)return ret;@@ -1703,7 +1702,7 @@ i965_dispatch_execbuffer(struct drm_i915_gem_request *req,struct intel_engine_cs *ring = req->ring;int ret; - ret =intel_ring_begin (ring,2 ); + ret =intel_ring_begin (req,2 );if (ret)return ret;@@ -1731,7 +1730,7 @@ i830_dispatch_execbuffer(struct drm_i915_gem_request *req,u32 cs_offset = ring->scratch.gtt_offset;int ret; - ret =intel_ring_begin (ring,6 ); + ret =intel_ring_begin (req,6 );if (ret)return ret;@@ -1748,7 +1747,7 @@ i830_dispatch_execbuffer(struct drm_i915_gem_request *req,if (len >I830_BATCH_LIMIT )return -ENOSPC ; - ret =intel_ring_begin (ring,6 +2 ); + ret =intel_ring_begin (req,6 +2 );if (ret)return ret;@@ -1771,7 +1770,7 @@ i830_dispatch_execbuffer(struct drm_i915_gem_request *req, offset = cs_offset; } - ret =intel_ring_begin (ring,4 ); + ret =intel_ring_begin (req,4 );if (ret)return ret;@@ -1793,7 +1792,7 @@ i915_dispatch_execbuffer(struct drm_i915_gem_request *req,struct intel_engine_cs *ring = req->ring;int ret; - ret =intel_ring_begin (ring,2 ); + ret =intel_ring_begin (req,2 );if (ret)return ret;
drivers/gpu/drm/i915/intel_ringbuffer.c static int __intel_ring_prepare(struct intel_engine_cs *ring, · line 2237
Quoted 9 lines
drivers/gpu/drm/i915/intel_ringbuffer.c +2
-2@@ -2232,13 +2231,15 @@ static int __intel_ring_prepare(struct intel_engine_cs *ring,return 0 ; } -int intel_ring_begin (struct intel_engine_cs *ring, +int intel_ring_begin (struct drm_i915_gem_request *req,int num_dwords) { -struct drm_i915_gem_request *req; +struct intel_engine_cs *ring = req->ring;
The WARN_ON below will only fire _after_ we've already gotten a null pointer exception here at the req->ring dereference. You might want to rearrange this a bit so that the WARN_ON appears before the dereference.
Thanks,
Tomas
Quoted 80 lines
drivers/gpu/drm/i915/intel_ringbuffer.c +8
-11struct drm_i915_private *dev_priv = ring->dev->dev_private;int ret; +WARN_ON (req ==NULL ); + ret =i915_gem_check_wedge (&dev_priv->gpu_error, dev_priv->mm.interruptible);if (ret)@@ -2248,11 +2249,6 @@ int intel_ring_begin(struct intel_engine_cs *ring,if (ret)return ret; -/* Preallocate the olr before touching the ring */ - ret =intel_ring_alloc_request (ring,NULL , &req); -if (ret) -return ret; - ring->buffer->space -= num_dwords *sizeof (uint32_t );return 0 ; }@@ -2268,7 +2264,7 @@ int intel_ring_cacheline_align(struct drm_i915_gem_request *req)return 0 ; num_dwords =CACHELINE_BYTES /sizeof (uint32_t ) - num_dwords; - ret =intel_ring_begin (ring, num_dwords); + ret =intel_ring_begin (req, num_dwords);if (ret)return ret;@@ -2338,7 +2334,7 @@ static int gen6_bsd_ring_flush(struct drm_i915_gem_request *req,uint32_t cmd;int ret; - ret =intel_ring_begin (ring,4 ); + ret =intel_ring_begin (req,4 );if (ret)return ret;@@ -2385,7 +2381,7 @@ gen8_ring_dispatch_execbuffer(struct drm_i915_gem_request *req, !(dispatch_flags &I915_DISPATCH_SECURE );int ret; - ret =intel_ring_begin (ring,4 ); + ret =intel_ring_begin (req,4 );if (ret)return ret;@@ -2407,7 +2403,7 @@ hsw_ring_dispatch_execbuffer(struct drm_i915_gem_request *req,struct intel_engine_cs *ring = req->ring;int ret; - ret =intel_ring_begin (ring,2 ); + ret =intel_ring_begin (req,2 );if (ret)return ret;@@ -2430,7 +2426,7 @@ gen6_ring_dispatch_execbuffer(struct drm_i915_gem_request *req,struct intel_engine_cs *ring = req->ring;int ret; - ret =intel_ring_begin (ring,2 ); + ret =intel_ring_begin (req,2 );if (ret)return ret;@@ -2456,7 +2452,7 @@ static int gen6_ring_flush(struct drm_i915_gem_request *req,uint32_t cmd;int ret; - ret =intel_ring_begin (ring,4 ); + ret =intel_ring_begin (req,4 );if (ret)return ret;drivers/gpu/drm/i915/intel_ringbuffer.h +0
-0
drivers/gpu/drm/i915/intel_ringbuffer.h int intel_alloc_ringbuffer_obj(struct drm_device *dev, · line 392
Quoted 8 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +1
-1@@ -386,7 +386,7 @@ int intel_alloc_ringbuffer_obj(struct drm_device *dev,void intel_stop_ring_buffer (struct intel_engine_cs *ring);void intel_cleanup_ring_buffer (struct intel_engine_cs *ring); -int __must_check intel_ring_begin (struct intel_engine_cs *ring,int n); +int __must_check intel_ring_begin (struct drm_i915_gem_request *req,int n);int __must_check intel_ring_cacheline_align (struct drm_i915_gem_request *req); int __must_check intel_ring_alloc_request(struct intel_engine_cs *ring, struct intel_context *ctx,
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 49/53 drm/i915: Make intel_logical_ring_begin() static
In reply to [email protected]From: John Harrison <[email protected]>
The only usage of intel_logical_ring_begin() is within intel_lrc.c so it can be made static. To avoid a forward declaration at the top of the file, it and bunch of other functions have been shuffled upwards.
For: VIZ-5115
--- drivers/gpu/drm/i915/intel_lrc.c | 394 +++++++++++++++++++------------------- drivers/gpu/drm/i915/intel_lrc.h | 3 - 2 files changed, 197 insertions(+), 200 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +197 -197
@@ -606,6 +606,203 @@ static int execlists_move_to_gpu(struct drm_i915_gem_request *req,return logical_ring_invalidate_all_caches (req); } +static int logical_ring_wait_request (struct intel_ringbuffer *ringbuf, +int bytes) +{ +struct intel_engine_cs *ring = ringbuf->ring; +struct drm_i915_gem_request *request; +int ret; + +if (intel_ring_space (ringbuf) >= bytes) +return 0 ; + +list_for_each_entry (request, &ring->request_list, list) { +/* +* The request queue is per-engine, so can contain requests +* from multiple ringbuffers. Here, we must ignore any that +* aren't from the ringbuffer we're considering. +*/ +struct intel_context *ctx = request->ctx; +if (ctx->engine[ring->id].ringbuf != ringbuf) +continue ; + +/* Would completion of this request free enough space? */ +if (__intel_ring_space (request->tail, ringbuf->tail, + ringbuf->size) >= bytes) { +break ; + } + } + +if (&request->list == &ring->request_list) +return -ENOSPC ; + + ret =i915_wait_request (request); +if (ret) +return ret; + +i915_gem_retire_requests_ring (ring); + +return intel_ring_space (ringbuf) >= bytes ?0 : -ENOSPC ; +} + +/* +* intel_logical_ring_advance_and_submit() - advance the tail and submit the workload +* @ringbuf: Logical Ringbuffer to advance. +* +* The tail is updated in our logical ringbuffer struct, not in the actual context. What +* really happens during submission is that the context and current tail will be placed +* on a queue waiting for the ELSP to be ready to accept a new context submission. At that +* point, the tail *inside* the context is updated and the ELSP written to. +*/ +static void +intel_logical_ring_advance_and_submit (struct intel_ringbuffer *ringbuf, +struct intel_context *ctx, +struct drm_i915_gem_request *request) +{ +struct intel_engine_cs *ring = ringbuf->ring; + +intel_logical_ring_advance (ringbuf); + +if (intel_ring_stopped (ring)) +return ; + +execlists_context_queue (ring, ctx, ringbuf->tail, request); +} + +static int logical_ring_wait_for_space (struct intel_ringbuffer *ringbuf, +struct intel_context *ctx, +int bytes) +{ +struct intel_engine_cs *ring = ringbuf->ring; +struct drm_device *dev = ring->dev; +struct drm_i915_private *dev_priv = dev->dev_private; +unsigned long end; +int ret; + + ret =logical_ring_wait_request (ringbuf, bytes); +if (ret != -ENOSPC ) +return ret; + +/* Force the context submission in case we have been skipping it */ +intel_logical_ring_advance_and_submit (ringbuf, ctx,NULL ); + +/* With GEM the hangcheck timer should kick us out of the loop, +* leaving it early runs the risk of corrupting GEM state (due +* to running on almost untested codepaths). But on resume +* timers don't work yet, so prevent a complete hang in that +* case by choosing an insanely large timeout. */ + end = jiffies +60 *HZ ; + + ret =0 ; +do { +if (intel_ring_space (ringbuf) >= bytes) +break ; + +msleep (1 ); + +if (dev_priv->mm.interruptible &&signal_pending (current)) { + ret = -ERESTARTSYS ; +break ; + } + + ret =i915_gem_check_wedge (&dev_priv->gpu_error, + dev_priv->mm.interruptible); +if (ret) +break ; + +if (time_after (jiffies, end)) { + ret = -EBUSY ; +break ; + } + }while (1 ); + +return ret; +} + +static int logical_ring_wrap_buffer (struct intel_ringbuffer *ringbuf, +struct intel_context *ctx) +{ +uint32_t __iomem *virt; +int rem = ringbuf->size - ringbuf->tail; + +if (ringbuf->space < rem) { +int ret =logical_ring_wait_for_space (ringbuf, ctx, rem); + +if (ret) +return ret; + } + + virt = ringbuf->virtual_start + ringbuf->tail; + rem /=4 ; +while (rem--) +iowrite32 (MI_NOOP , virt++); + + ringbuf->tail =0 ; +intel_ring_update_space (ringbuf); + +return 0 ; +} + +static int logical_ring_prepare (struct intel_ringbuffer *ringbuf, +struct intel_context *ctx,int bytes) +{ +int ret; + +if (unlikely (ringbuf->tail + bytes > ringbuf->effective_size)) { + ret =logical_ring_wrap_buffer (ringbuf, ctx); +if (unlikely (ret)) +return ret; + } + +if (unlikely (ringbuf->space < bytes)) { + ret =logical_ring_wait_for_space (ringbuf, ctx, bytes); +if (unlikely (ret)) +return ret; + } + +return 0 ; +} + +/** +* intel_logical_ring_begin() - prepare the logical ringbuffer to accept some commands +* +* @ringbuf: Logical ringbuffer. +* @num_dwords: number of DWORDs that we plan to write to the ringbuffer. +* +* The ringbuffer might not be ready to accept the commands right away (maybe it needs to +* be wrapped, or wait a bit for the tail to be updated). This function takes care of that +* and also preallocates a request (every workload submission is still mediated through +* requests, same as it did with legacy ringbuffer submission). +* +* Return: non-zero if the ringbuffer is not ready to be written to. +*/ +static int intel_logical_ring_begin (struct intel_ringbuffer *ringbuf, +struct intel_context *ctx,int num_dwords) +{ +struct drm_i915_gem_request *req; +struct intel_engine_cs *ring = ringbuf->ring; +struct drm_device *dev = ring->dev; +struct drm_i915_private *dev_priv = dev->dev_private; +int ret; + + ret =i915_gem_check_wedge (&dev_priv->gpu_error, + dev_priv->mm.interruptible); +if (ret) +return ret; + + ret =logical_ring_prepare (ringbuf, ctx, num_dwords *sizeof (uint32_t )); +if (ret) +return ret; + +/* Preallocate the olr before touching the ring */ + ret =intel_logical_ring_alloc_request (ring, ctx, &req); +if (ret) +return ret; + + ringbuf->space -= num_dwords *sizeof (uint32_t ); +return 0 ; +} +/** * execlists_submission() - submit a batchbuffer for execution, Execlists style * @dev: DRM device.
@@ -783,30 +980,6 @@ int logical_ring_flush_all_caches(struct drm_i915_gem_request *req)return 0 ; } -/* -* intel_logical_ring_advance_and_submit() - advance the tail and submit the workload -* @ringbuf: Logical Ringbuffer to advance. -* -* The tail is updated in our logical ringbuffer struct, not in the actual context. What -* really happens during submission is that the context and current tail will be placed -* on a queue waiting for the ELSP to be ready to accept a new context submission. At that -* point, the tail *inside* the context is updated and the ELSP written to. -*/ -static void -intel_logical_ring_advance_and_submit (struct intel_ringbuffer *ringbuf, -struct intel_context *ctx, -struct drm_i915_gem_request *request) -{ -struct intel_engine_cs *ring = ringbuf->ring; - -intel_logical_ring_advance (ringbuf); - -if (intel_ring_stopped (ring)) -return ; - -execlists_context_queue (ring, ctx, ringbuf->tail, request); -} -static int intel_lr_context_pin (struct intel_engine_cs *ring,struct intel_context *ctx) {
@@ -901,179 +1074,6 @@ int intel_logical_ring_alloc_request(struct intel_engine_cs *ring,return 0 ; } -static int logical_ring_wait_request (struct intel_ringbuffer *ringbuf, -int bytes) -{ -struct intel_engine_cs *ring = ringbuf->ring; -struct drm_i915_gem_request *request; -int ret; - -if (intel_ring_space (ringbuf) >= bytes) -return 0 ; - -list_for_each_entry (request, &ring->request_list, list) { -/* -* The request queue is per-engine, so can contain requests -* from multiple ringbuffers. Here, we must ignore any that -* aren't from the ringbuffer we're considering. -*/ -struct intel_context *ctx = request->ctx; -if (ctx->engine[ring->id].ringbuf != ringbuf) -continue ; - -/* Would completion of this request free enough space? */ -if (__intel_ring_space (request->tail, ringbuf->tail, - ringbuf->size) >= bytes) { -break ; - } - } - -if (&request->list == &ring->request_list) -return -ENOSPC ; - - ret =i915_wait_request (request); -if (ret) -return ret; - -i915_gem_retire_requests_ring (ring); - -return intel_ring_space (ringbuf) >= bytes ?0 : -ENOSPC ; -} - -static int logical_ring_wait_for_space (struct intel_ringbuffer *ringbuf, -struct intel_context *ctx, -int bytes) -{ -struct intel_engine_cs *ring = ringbuf->ring; -struct drm_device *dev = ring->dev; -struct drm_i915_private *dev_priv = dev->dev_private; -unsigned long end; -int ret; - - ret =logical_ring_wait_request (ringbuf, bytes); -if (ret != -ENOSPC ) -return ret; - -/* Force the context submission in case we have been skipping it */ -intel_logical_ring_advance_and_submit (ringbuf, ctx,NULL ); - -/* With GEM the hangcheck timer should kick us out of the loop, -* leaving it early runs the risk of corrupting GEM state (due -* to running on almost untested codepaths). But on resume -* timers don't work yet, so prevent a complete hang in that -* case by choosing an insanely large timeout. */ - end = jiffies +60 *HZ ; - - ret =0 ; -do { -if (intel_ring_space (ringbuf) >= bytes) -break ; - -msleep (1 ); - -if (dev_priv->mm.interruptible &&signal_pending (current)) { - ret = -ERESTARTSYS ; -break ; - } - - ret =i915_gem_check_wedge (&dev_priv->gpu_error, - dev_priv->mm.interruptible); -if (ret) -break ; - -if (time_after (jiffies, end)) { - ret = -EBUSY ; -break ; - } - }while (1 ); - -return ret; -} - -static int logical_ring_wrap_buffer (struct intel_ringbuffer *ringbuf, -struct intel_context *ctx) -{ -uint32_t __iomem *virt; -int rem = ringbuf->size - ringbuf->tail; - -if (ringbuf->space < rem) { -int ret =logical_ring_wait_for_space (ringbuf, ctx, rem); - -if (ret) -return ret; - } - - virt = ringbuf->virtual_start + ringbuf->tail; - rem /=4 ; -while (rem--) -iowrite32 (MI_NOOP , virt++); - - ringbuf->tail =0 ; -intel_ring_update_space (ringbuf); - -return 0 ; -} - -static int logical_ring_prepare (struct intel_ringbuffer *ringbuf, -struct intel_context *ctx,int bytes) -{ -int ret; - -if (unlikely (ringbuf->tail + bytes > ringbuf->effective_size)) { - ret =logical_ring_wrap_buffer (ringbuf, ctx); -if (unlikely (ret)) -return ret; - } - -if (unlikely (ringbuf->space < bytes)) { - ret =logical_ring_wait_for_space (ringbuf, ctx, bytes); -if (unlikely (ret)) -return ret; - } - -return 0 ; -} - -/** -* intel_logical_ring_begin() - prepare the logical ringbuffer to accept some commands -* -* @ringbuf: Logical ringbuffer. -* @num_dwords: number of DWORDs that we plan to write to the ringbuffer. -* -* The ringbuffer might not be ready to accept the commands right away (maybe it needs to -* be wrapped, or wait a bit for the tail to be updated). This function takes care of that -* and also preallocates a request (every workload submission is still mediated through -* requests, same as it did with legacy ringbuffer submission). -* -* Return: non-zero if the ringbuffer is not ready to be written to. -*/ -int intel_logical_ring_begin (struct intel_ringbuffer *ringbuf, -struct intel_context *ctx,int num_dwords) -{ -struct drm_i915_gem_request *req; -struct intel_engine_cs *ring = ringbuf->ring; -struct drm_device *dev = ring->dev; -struct drm_i915_private *dev_priv = dev->dev_private; -int ret; - - ret =i915_gem_check_wedge (&dev_priv->gpu_error, - dev_priv->mm.interruptible); -if (ret) -return ret; - - ret =logical_ring_prepare (ringbuf, ctx, num_dwords *sizeof (uint32_t )); -if (ret) -return ret; - -/* Preallocate the olr before touching the ring */ - ret =intel_logical_ring_alloc_request (ring, ctx, &req); -if (ret) -return ret; - - ringbuf->space -= num_dwords *sizeof (uint32_t ); -return 0 ; -} -static int intel_logical_ring_workarounds_emit (struct drm_i915_gem_request *req) {int ret, i;
drivers/gpu/drm/i915/intel_lrc.h +0 -3
@@ -65,9 +65,6 @@ static inline void intel_logical_ring_emit(struct intel_ringbuffer *ringbuf,iowrite32 (data, ringbuf->virtual_start + ringbuf->tail); ringbuf->tail +=4 ; } -int intel_logical_ring_begin (struct intel_ringbuffer *ringbuf, -struct intel_context *ctx, -int num_dwords);/* Logical Ring Contexts */ void intel_lr_context_free (struct intel_context *ctx);
Signature · 6 lines
1.7.9.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 49/53] drm/i915: Make intel_logical_ring_begin() static
Quoted 438 lines · On 19/02/2015 17:18, [email protected] wrote:
From: John Harrison <[email protected]>
The only usage of
intel_logical_ring_begin()is withinintel_lrc.cso it can be made static. To avoid a forward declaration at the top of the file, it and bunch of other functions have been shuffled upwards.For: VIZ-5115
Signed-off-by John Harrison <[email protected]>--- drivers/gpu/drm/i915/intel_lrc.c | 394 +++++++++++++++++++------------------- drivers/gpu/drm/i915/intel_lrc.h | 3 - 2 files changed, 197 insertions(+), 200 deletions(-)drivers/gpu/drm/i915/intel_lrc.c +197
-197@@ -606,6 +606,203 @@ static int execlists_move_to_gpu(struct drm_i915_gem_request *req,return logical_ring_invalidate_all_caches (req); } +static int logical_ring_wait_request (struct intel_ringbuffer *ringbuf, +int bytes) +{ +struct intel_engine_cs *ring = ringbuf->ring; +struct drm_i915_gem_request *request; +int ret; + +if (intel_ring_space (ringbuf) >= bytes) +return 0 ; + +list_for_each_entry (request, &ring->request_list, list) { +/* +* The request queue is per-engine, so can contain requests +* from multiple ringbuffers. Here, we must ignore any that +* aren't from the ringbuffer we're considering. +*/ +struct intel_context *ctx = request->ctx; +if (ctx->engine[ring->id].ringbuf != ringbuf) +continue ; + +/* Would completion of this request free enough space? */ +if (__intel_ring_space (request->tail, ringbuf->tail, + ringbuf->size) >= bytes) { +break ; + } + } + +if (&request->list == &ring->request_list) +return -ENOSPC ; + + ret =i915_wait_request (request); +if (ret) +return ret; + +i915_gem_retire_requests_ring (ring); + +return intel_ring_space (ringbuf) >= bytes ?0 : -ENOSPC ; +} + +/* +* intel_logical_ring_advance_and_submit() - advance the tail and submit the workload +* @ringbuf: Logical Ringbuffer to advance. +* +* The tail is updated in our logical ringbuffer struct, not in the actual context. What +* really happens during submission is that the context and current tail will be placed +* on a queue waiting for the ELSP to be ready to accept a new context submission. At that +* point, the tail *inside* the context is updated and the ELSP written to. +*/ +static void +intel_logical_ring_advance_and_submit (struct intel_ringbuffer *ringbuf, +struct intel_context *ctx, +struct drm_i915_gem_request *request) +{ +struct intel_engine_cs *ring = ringbuf->ring; + +intel_logical_ring_advance (ringbuf); + +if (intel_ring_stopped (ring)) +return ; + +execlists_context_queue (ring, ctx, ringbuf->tail, request); +} + +static int logical_ring_wait_for_space (struct intel_ringbuffer *ringbuf, +struct intel_context *ctx, +int bytes) +{ +struct intel_engine_cs *ring = ringbuf->ring; +struct drm_device *dev = ring->dev; +struct drm_i915_private *dev_priv = dev->dev_private; +unsigned long end; +int ret; + + ret =logical_ring_wait_request (ringbuf, bytes); +if (ret != -ENOSPC ) +return ret; + +/* Force the context submission in case we have been skipping it */ +intel_logical_ring_advance_and_submit (ringbuf, ctx,NULL ); + +/* With GEM the hangcheck timer should kick us out of the loop, +* leaving it early runs the risk of corrupting GEM state (due +* to running on almost untested codepaths). But on resume +* timers don't work yet, so prevent a complete hang in that +* case by choosing an insanely large timeout. */ + end = jiffies +60 *HZ ; + + ret =0 ; +do { +if (intel_ring_space (ringbuf) >= bytes) +break ; + +msleep (1 ); + +if (dev_priv->mm.interruptible &&signal_pending (current)) { + ret = -ERESTARTSYS ; +break ; + } + + ret =i915_gem_check_wedge (&dev_priv->gpu_error, + dev_priv->mm.interruptible); +if (ret) +break ; + +if (time_after (jiffies, end)) { + ret = -EBUSY ; +break ; + } + }while (1 ); + +return ret; +} + +static int logical_ring_wrap_buffer (struct intel_ringbuffer *ringbuf, +struct intel_context *ctx) +{ +uint32_t __iomem *virt; +int rem = ringbuf->size - ringbuf->tail; + +if (ringbuf->space < rem) { +int ret =logical_ring_wait_for_space (ringbuf, ctx, rem); + +if (ret) +return ret; + } + + virt = ringbuf->virtual_start + ringbuf->tail; + rem /=4 ; +while (rem--) +iowrite32 (MI_NOOP , virt++); + + ringbuf->tail =0 ; +intel_ring_update_space (ringbuf); + +return 0 ; +} + +static int logical_ring_prepare (struct intel_ringbuffer *ringbuf, +struct intel_context *ctx,int bytes) +{ +int ret; + +if (unlikely (ringbuf->tail + bytes > ringbuf->effective_size)) { + ret =logical_ring_wrap_buffer (ringbuf, ctx); +if (unlikely (ret)) +return ret; + } + +if (unlikely (ringbuf->space < bytes)) { + ret =logical_ring_wait_for_space (ringbuf, ctx, bytes); +if (unlikely (ret)) +return ret; + } + +return 0 ; +} + +/** +* intel_logical_ring_begin() - prepare the logical ringbuffer to accept some commands +* +* @ringbuf: Logical ringbuffer. +* @num_dwords: number of DWORDs that we plan to write to the ringbuffer. +* +* The ringbuffer might not be ready to accept the commands right away (maybe it needs to +* be wrapped, or wait a bit for the tail to be updated). This function takes care of that +* and also preallocates a request (every workload submission is still mediated through +* requests, same as it did with legacy ringbuffer submission). +* +* Return: non-zero if the ringbuffer is not ready to be written to. +*/ +static int intel_logical_ring_begin (struct intel_ringbuffer *ringbuf, +struct intel_context *ctx,int num_dwords) +{ +struct drm_i915_gem_request *req; +struct intel_engine_cs *ring = ringbuf->ring; +struct drm_device *dev = ring->dev; +struct drm_i915_private *dev_priv = dev->dev_private; +int ret; + + ret =i915_gem_check_wedge (&dev_priv->gpu_error, + dev_priv->mm.interruptible); +if (ret) +return ret; + + ret =logical_ring_prepare (ringbuf, ctx, num_dwords *sizeof (uint32_t )); +if (ret) +return ret; + +/* Preallocate the olr before touching the ring */ + ret =intel_logical_ring_alloc_request (ring, ctx, &req); +if (ret) +return ret; + + ringbuf->space -= num_dwords *sizeof (uint32_t ); +return 0 ; +} +/** * execlists_submission() - submit a batchbuffer for execution, Execlists style * @dev: DRM device. @@ -783,30 +980,6 @@ int logical_ring_flush_all_caches(struct drm_i915_gem_request *req)return 0 ; } -/* -* intel_logical_ring_advance_and_submit() - advance the tail and submit the workload -* @ringbuf: Logical Ringbuffer to advance. -* -* The tail is updated in our logical ringbuffer struct, not in the actual context. What -* really happens during submission is that the context and current tail will be placed -* on a queue waiting for the ELSP to be ready to accept a new context submission. At that -* point, the tail *inside* the context is updated and the ELSP written to. -*/ -static void -intel_logical_ring_advance_and_submit (struct intel_ringbuffer *ringbuf, -struct intel_context *ctx, -struct drm_i915_gem_request *request) -{ -struct intel_engine_cs *ring = ringbuf->ring; - -intel_logical_ring_advance (ringbuf); - -if (intel_ring_stopped (ring)) -return ; - -execlists_context_queue (ring, ctx, ringbuf->tail, request); -} -static int intel_lr_context_pin (struct intel_engine_cs *ring,struct intel_context *ctx) {@@ -901,179 +1074,6 @@ int intel_logical_ring_alloc_request(struct intel_engine_cs *ring,return 0 ; } -static int logical_ring_wait_request (struct intel_ringbuffer *ringbuf, -int bytes) -{ -struct intel_engine_cs *ring = ringbuf->ring; -struct drm_i915_gem_request *request; -int ret; - -if (intel_ring_space (ringbuf) >= bytes) -return 0 ; - -list_for_each_entry (request, &ring->request_list, list) { -/* -* The request queue is per-engine, so can contain requests -* from multiple ringbuffers. Here, we must ignore any that -* aren't from the ringbuffer we're considering. -*/ -struct intel_context *ctx = request->ctx; -if (ctx->engine[ring->id].ringbuf != ringbuf) -continue ; - -/* Would completion of this request free enough space? */ -if (__intel_ring_space (request->tail, ringbuf->tail, - ringbuf->size) >= bytes) { -break ; - } - } - -if (&request->list == &ring->request_list) -return -ENOSPC ; - - ret =i915_wait_request (request); -if (ret) -return ret; - -i915_gem_retire_requests_ring (ring); - -return intel_ring_space (ringbuf) >= bytes ?0 : -ENOSPC ; -} - -static int logical_ring_wait_for_space (struct intel_ringbuffer *ringbuf, -struct intel_context *ctx, -int bytes) -{ -struct intel_engine_cs *ring = ringbuf->ring; -struct drm_device *dev = ring->dev; -struct drm_i915_private *dev_priv = dev->dev_private; -unsigned long end; -int ret; - - ret =logical_ring_wait_request (ringbuf, bytes); -if (ret != -ENOSPC ) -return ret; - -/* Force the context submission in case we have been skipping it */ -intel_logical_ring_advance_and_submit (ringbuf, ctx,NULL ); - -/* With GEM the hangcheck timer should kick us out of the loop, -* leaving it early runs the risk of corrupting GEM state (due -* to running on almost untested codepaths). But on resume -* timers don't work yet, so prevent a complete hang in that -* case by choosing an insanely large timeout. */ - end = jiffies +60 *HZ ; - - ret =0 ; -do { -if (intel_ring_space (ringbuf) >= bytes) -break ; - -msleep (1 ); - -if (dev_priv->mm.interruptible &&signal_pending (current)) { - ret = -ERESTARTSYS ; -break ; - } - - ret =i915_gem_check_wedge (&dev_priv->gpu_error, - dev_priv->mm.interruptible); -if (ret) -break ; - -if (time_after (jiffies, end)) { - ret = -EBUSY ; -break ; - } - }while (1 ); - -return ret; -} - -static int logical_ring_wrap_buffer (struct intel_ringbuffer *ringbuf, -struct intel_context *ctx) -{ -uint32_t __iomem *virt; -int rem = ringbuf->size - ringbuf->tail; - -if (ringbuf->space < rem) { -int ret =logical_ring_wait_for_space (ringbuf, ctx, rem); - -if (ret) -return ret; - } - - virt = ringbuf->virtual_start + ringbuf->tail; - rem /=4 ; -while (rem--) -iowrite32 (MI_NOOP , virt++); - - ringbuf->tail =0 ; -intel_ring_update_space (ringbuf); - -return 0 ; -} - -static int logical_ring_prepare (struct intel_ringbuffer *ringbuf, -struct intel_context *ctx,int bytes) -{ -int ret; - -if (unlikely (ringbuf->tail + bytes > ringbuf->effective_size)) { - ret =logical_ring_wrap_buffer (ringbuf, ctx); -if (unlikely (ret)) -return ret; - } - -if (unlikely (ringbuf->space < bytes)) { - ret =logical_ring_wait_for_space (ringbuf, ctx, bytes); -if (unlikely (ret)) -return ret; - } - -return 0 ; -} - -/** -* intel_logical_ring_begin() - prepare the logical ringbuffer to accept some commands -* -* @ringbuf: Logical ringbuffer. -* @num_dwords: number of DWORDs that we plan to write to the ringbuffer. -* -* The ringbuffer might not be ready to accept the commands right away (maybe it needs to -* be wrapped, or wait a bit for the tail to be updated). This function takes care of that -* and also preallocates a request (every workload submission is still mediated through -* requests, same as it did with legacy ringbuffer submission). -* -* Return: non-zero if the ringbuffer is not ready to be written to. -*/ -int intel_logical_ring_begin (struct intel_ringbuffer *ringbuf, -struct intel_context *ctx,int num_dwords) -{ -struct drm_i915_gem_request *req; -struct intel_engine_cs *ring = ringbuf->ring; -struct drm_device *dev = ring->dev; -struct drm_i915_private *dev_priv = dev->dev_private; -int ret; - - ret =i915_gem_check_wedge (&dev_priv->gpu_error, - dev_priv->mm.interruptible); -if (ret) -return ret; - - ret =logical_ring_prepare (ringbuf, ctx, num_dwords *sizeof (uint32_t )); -if (ret) -return ret; - -/* Preallocate the olr before touching the ring */ - ret =intel_logical_ring_alloc_request (ring, ctx, &req); -if (ret) -return ret; - - ringbuf->space -= num_dwords *sizeof (uint32_t ); -return 0 ; -} -static int intel_logical_ring_workarounds_emit (struct drm_i915_gem_request *req) {int ret, i;drivers/gpu/drm/i915/intel_lrc.h +0
-0
drivers/gpu/drm/i915/intel_lrc.h static inline void intel_logical_ring_emit(struct intel_ringbuffer *ringbuf, · line 70
Quoted 9 lines
drivers/gpu/drm/i915/intel_lrc.h +0
-3@@ -65,9 +65,6 @@ static inline void intel_logical_ring_emit(struct intel_ringbuffer *ringbuf,iowrite32 (data, ringbuf->virtual_start + ringbuf->tail); ringbuf->tail +=4 ; } -int intel_logical_ring_begin (struct intel_ringbuffer *ringbuf, -struct intel_context *ctx, -int num_dwords);/* Logical Ring Contexts */ void intel_lr_context_free (struct intel_context *ctx);
Thanks,
Tomas
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 50/53 drm/i915: Update intel_logical_ring_begin() to take a request structure
In reply to [email protected]From: John Harrison <[email protected]>
Now that everything above has been converted to use requests, intel_logical_ring_begin() can be updated to take a request instead of a ringbuf/context pair. This also means that it no longer needs to lazily allocate a request if no-one happens to have done it earlier.
Note that this change makes the execlist signature the same as the legacy version. Thus the two functions could be merged into a ring->begin() wrapper if required.
For: VIZ-5115
--- drivers/gpu/drm/i915/intel_lrc.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +15 -18
@@ -766,7 +766,7 @@ static int logical_ring_prepare(struct intel_ringbuffer *ringbuf,/** * intel_logical_ring_begin() - prepare the logical ringbuffer to accept some commands * -* @ringbuf: Logical ringbuffer. +* @request: The request to start some new work for * @num_dwords: number of DWORDs that we plan to write to the ringbuffer. * * The ringbuffer might not be ready to accept the commands right away (maybe it needs to
@@ -776,30 +776,27 @@ static int logical_ring_prepare(struct intel_ringbuffer *ringbuf,* * Return: non-zero if the ringbuffer is not ready to be written to. */ -static int intel_logical_ring_begin (struct intel_ringbuffer *ringbuf, -struct intel_context *ctx,int num_dwords) +static int intel_logical_ring_begin (struct drm_i915_gem_request *req, +int num_dwords) { -struct drm_i915_gem_request *req; -struct intel_engine_cs *ring = ringbuf->ring; +struct intel_engine_cs *ring = req->ring;struct drm_device *dev = ring->dev;struct drm_i915_private *dev_priv = dev->dev_private;int ret; +WARN_ON (req ==NULL ); + ret =i915_gem_check_wedge (&dev_priv->gpu_error, dev_priv->mm.interruptible);if (ret)return ret; - ret =logical_ring_prepare (ringbuf, ctx, num_dwords *sizeof (uint32_t )); -if (ret) -return ret; - -/* Preallocate the olr before touching the ring */ - ret =intel_logical_ring_alloc_request (ring, ctx, &req); + ret =logical_ring_prepare (req->ringbuf, req->ctx, + num_dwords *sizeof (uint32_t ));if (ret)return ret; - ringbuf->space -= num_dwords *sizeof (uint32_t ); + req->ringbuf->space -= num_dwords *sizeof (uint32_t );return 0 ; }
@@ -885,7 +882,7 @@ int intel_execlists_submission(struct i915_execbuffer_params *params,if (ring == &dev_priv->ring[RCS ] && instp_mode != dev_priv->relative_constants_mode) { - ret =intel_logical_ring_begin (ringbuf, params->ctx,4 ); + ret =intel_logical_ring_begin (params->request,4 );if (ret)return ret;
@@ -1091,7 +1088,7 @@ static int intel_logical_ring_workarounds_emit(struct drm_i915_gem_request *req)if (ret)return ret; - ret =intel_logical_ring_begin (ringbuf, req->ctx, w->count *2 +2 ); + ret =intel_logical_ring_begin (req, w->count *2 +2 );if (ret)return ret;
@@ -1173,7 +1170,7 @@ static int gen8_emit_bb_start(struct drm_i915_gem_request *req,bool ppgtt = !(dispatch_flags &I915_DISPATCH_SECURE );int ret; - ret =intel_logical_ring_begin (ringbuf, req->ctx,4 ); + ret =intel_logical_ring_begin (req,4 );if (ret)return ret;
@@ -1231,7 +1228,7 @@ static int gen8_emit_flush(struct drm_i915_gem_request *request,uint32_t cmd;int ret; - ret =intel_logical_ring_begin (ringbuf, request->ctx,4 ); + ret =intel_logical_ring_begin (request,4 );if (ret)return ret;
@@ -1289,7 +1286,7 @@ static int gen8_emit_flush_render(struct drm_i915_gem_request *request, flags |=PIPE_CONTROL_GLOBAL_GTT_IVB ; } - ret =intel_logical_ring_begin (ringbuf, request->ctx,6 ); + ret =intel_logical_ring_begin (request,6 );if (ret)return ret;
@@ -1321,7 +1318,7 @@ static int gen8_emit_request(struct drm_i915_gem_request *request)u32 cmd;int ret; - ret =intel_logical_ring_begin (ringbuf, request->ctx,6 ); + ret =intel_logical_ring_begin (request,6 );if (ret)return ret;
Signature · 6 lines
1.7.9.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 50/53] drm/i915: Update intel_logical_ring_begin() to take a request structure
Quoted 37 lines · On 19/02/2015 17:18, [email protected] wrote:
From: John Harrison <[email protected]>
Now that everything above has been converted to use requests,
intel_logical_ring_begin()can be updated to take a request instead of a ringbuf/context pair. This also means that it no longer needs to lazily allocate a request if no-one happens to have done it earlier.Note that this change makes the execlist signature the same as the legacy version. Thus the two functions could be merged into a
ring->begin()wrapper if required.For: VIZ-5115
Signed-off-by John Harrison <[email protected]>--- drivers/gpu/drm/i915/intel_lrc.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-)drivers/gpu/drm/i915/intel_lrc.c +2
-3@@ -766,7 +766,7 @@ static int logical_ring_prepare(struct intel_ringbuffer *ringbuf,/** * intel_logical_ring_begin() - prepare the logical ringbuffer to accept some commands * -* @ringbuf: Logical ringbuffer. +* @request: The request to start some new work for * @num_dwords: number of DWORDs that we plan to write to the ringbuffer. * * The ringbuffer might not be ready to accept the commands right away (maybe it needs to @@ -776,30 +776,27 @@ static int logical_ring_prepare(struct intel_ringbuffer *ringbuf,* * Return: non-zero if the ringbuffer is not ready to be written to. */ -static int intel_logical_ring_begin (struct intel_ringbuffer *ringbuf, -struct intel_context *ctx,int num_dwords) +static int intel_logical_ring_begin(struct drm_i915_gem_request *req,
drivers/gpu/drm/i915/intel_lrc.c static int logical_ring_prepare(struct intel_ringbuffer *ringbuf, · line 787
Quoted 10 lines
drivers/gpu/drm/i915/intel_lrc.c +3
-2+ int num_dwords) { -struct drm_i915_gem_request *req; -struct intel_engine_cs *ring = ringbuf->ring; +struct intel_engine_cs *ring = req->ring;struct drm_device *dev = ring->dev;struct drm_i915_private *dev_priv = dev->dev_private;int ret; +WARN_ON (req ==NULL );
This WARN_ON will only fire after there's been a null pointer exception in the req->ring dereference above. Please rearrange these so that it warns before the null pointer exception.
Thanks,
Tomas
Quoted 69 lines
drivers/gpu/drm/i915/intel_lrc.c +9
-12+ ret =i915_gem_check_wedge (&dev_priv->gpu_error, dev_priv->mm.interruptible);if (ret)return ret; - ret =logical_ring_prepare (ringbuf, ctx, num_dwords *sizeof (uint32_t )); -if (ret) -return ret; - -/* Preallocate the olr before touching the ring */ - ret =intel_logical_ring_alloc_request (ring, ctx, &req); + ret =logical_ring_prepare (req->ringbuf, req->ctx, + num_dwords *sizeof (uint32_t ));if (ret)return ret; - ringbuf->space -= num_dwords *sizeof (uint32_t ); + req->ringbuf->space -= num_dwords *sizeof (uint32_t );return 0 ; }@@ -885,7 +882,7 @@ int intel_execlists_submission(struct i915_execbuffer_params *params,if (ring == &dev_priv->ring[RCS ] && instp_mode != dev_priv->relative_constants_mode) { - ret =intel_logical_ring_begin (ringbuf, params->ctx,4 ); + ret =intel_logical_ring_begin (params->request,4 );if (ret)return ret;@@ -1091,7 +1088,7 @@ static int intel_logical_ring_workarounds_emit(struct drm_i915_gem_request *req)if (ret)return ret; - ret =intel_logical_ring_begin (ringbuf, req->ctx, w->count *2 +2 ); + ret =intel_logical_ring_begin (req, w->count *2 +2 );if (ret)return ret;@@ -1173,7 +1170,7 @@ static int gen8_emit_bb_start(struct drm_i915_gem_request *req,bool ppgtt = !(dispatch_flags &I915_DISPATCH_SECURE );int ret; - ret =intel_logical_ring_begin (ringbuf, req->ctx,4 ); + ret =intel_logical_ring_begin (req,4 );if (ret)return ret;@@ -1231,7 +1228,7 @@ static int gen8_emit_flush(struct drm_i915_gem_request *request,uint32_t cmd;int ret; - ret =intel_logical_ring_begin (ringbuf, request->ctx,4 ); + ret =intel_logical_ring_begin (request,4 );if (ret)return ret;@@ -1289,7 +1286,7 @@ static int gen8_emit_flush_render(struct drm_i915_gem_request *request, flags |=PIPE_CONTROL_GLOBAL_GTT_IVB ; } - ret =intel_logical_ring_begin (ringbuf, request->ctx,6 ); + ret =intel_logical_ring_begin (request,6 );if (ret)return ret;
drivers/gpu/drm/i915/intel_lrc.c static int gen8_emit_request(struct drm_i915_gem_request *request) · line 1324
Quoted 8 lines
drivers/gpu/drm/i915/intel_lrc.c +1
-1@@ -1321,7 +1318,7 @@ static int gen8_emit_request(struct drm_i915_gem_request *request)u32 cmd;int ret; - ret =intel_logical_ring_begin (ringbuf, request->ctx,6 ); + ret =intel_logical_ring_begin (request,6 );if (ret)return ret;
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 51/53 drm/i915: Remove the now obsolete intel_ring_get_request()
In reply to [email protected]From: John Harrison <[email protected]>
Much of the driver has now been converted to passing requests around instead of rings/ringbufs/contexts. Thus the function for retreiving the request from a ring (i.e. the OLR) is no longer used and can be removed.
For: VIZ-5115
--- drivers/gpu/drm/i915/intel_ringbuffer.h | 7 ------- 1 file changed, 7 deletions(-)
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -7
@@ -431,11 +431,4 @@ static inline u32 intel_ring_get_tail(struct intel_ringbuffer *ringbuf) return ringbuf->tail; } -static inline struct drm_i915_gem_request * -intel_ring_get_request (struct intel_engine_cs *ring) -{ -BUG_ON (ring->outstanding_lazy_request ==NULL ); -return ring->outstanding_lazy_request; -} -#endif /* _INTEL_RINGBUFFER_H_ */
Signature · 6 lines
1.7.9.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 51/53] drm/i915: Remove the now obsolete intel_ring_get_request()
Quoted 19 lines · On 19/02/2015 17:18, [email protected] wrote:
From: John Harrison <[email protected]>
Much of the driver has now been converted to passing requests around instead of rings/ringbufs/contexts. Thus the function for retreiving the request from a ring (i.e. the OLR) is no longer used and can be removed.
For: VIZ-5115
Signed-off-by John Harrison <[email protected]>--- drivers/gpu/drm/i915/intel_ringbuffer.h | 7 ------- 1 file changed, 7 deletions(-)drivers/gpu/drm/i915/intel_ringbuffer.h +0
-0@@ -431,11 +431,4 @@ static inline u32 intel_ring_get_tail(struct intel_ringbuffer *ringbuf)return ringbuf->tail;
drivers/gpu/drm/i915/intel_ringbuffer.h static inline u32 intel_ring_get_tail(struct intel_ringbuffer *ringbuf) · line 434
Quoted 10 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +0
-7} -static inline struct drm_i915_gem_request * -intel_ring_get_request (struct intel_engine_cs *ring) -{ -BUG_ON (ring->outstanding_lazy_request ==NULL ); -return ring->outstanding_lazy_request; -} -#endif /* _INTEL_RINGBUFFER_H_ */
Thanks,
Tomas
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 52/53 drm/i915: Remove the now obsolete 'outstanding_lazy_request'
In reply to [email protected]From: John Harrison <[email protected]>
The outstanding_lazy_request is no longer used anywhere in the driver. Everything that was looking at it now has a request explicitly passed in from on high. Everything that was relying upon behind the scenes is now explicitly creating/passing/submitting it's own private request. Thus the OLR can be removed.
For: VIZ-5115
--- drivers/gpu/drm/i915/i915_gem.c | 16 +--------------- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 4 +--- drivers/gpu/drm/i915/intel_lrc.c | 6 ++---- drivers/gpu/drm/i915/intel_ringbuffer.c | 17 ++--------------- drivers/gpu/drm/i915/intel_ringbuffer.h | 4 ---- 5 files changed, 6 insertions(+), 41 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +1 -15
@@ -1156,15 +1156,9 @@ i915_gem_check_wedge(struct i915_gpu_error *error,int i915_gem_check_olr (struct drm_i915_gem_request *req) { -int ret; -WARN_ON (!mutex_is_locked (&req->ring->dev->struct_mutex)); - ret =0 ; -if (req == req->ring->outstanding_lazy_request) - ret =i915_add_request (req); - -return ret; +return 0 ; }static void fake_irq (unsigned long data)
@@ -2424,8 +2418,6 @@ int __i915_add_request(struct drm_i915_gem_request *request, dev_priv = ring->dev->dev_private; ringbuf = request->ringbuf; -WARN_ON (request != ring->outstanding_lazy_request); - request_start =intel_ring_get_tail (ringbuf);/* * Emit any outstanding flushes - execbuf can fail to emit the flush
@@ -2486,7 +2478,6 @@ int __i915_add_request(struct drm_i915_gem_request *request, }trace_i915_gem_request_add (request); - ring->outstanding_lazy_request =NULL ;i915_queue_hangcheck (ring->dev);
@@ -2672,9 +2663,6 @@ static void i915_gem_reset_ring_cleanup(struct drm_i915_private *dev_priv,i915_gem_free_request (request); } - -/* This may not have been flushed before the reset, so clean it now */ -i915_gem_request_assign (&ring->outstanding_lazy_request,NULL ); }void i915_gem_restore_fences (struct drm_device *dev)
@@ -3124,8 +3112,6 @@ int i915_gpu_idle(struct drm_device *dev) } } -WARN_ON (ring->outstanding_lazy_request); - ret =intel_ring_idle (ring);if (ret)return ret;
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -3
@@ -1571,10 +1571,8 @@ err:* must be freed again. If it was submitted then it is being tracked * on the active request list and no clean up is required here. */ -if (ret && params->request) { +if (ret && params->request)i915_gem_request_unreference (params->request); - ring->outstanding_lazy_request =NULL ; - }mutex_unlock (&dev->struct_mutex);
drivers/gpu/drm/i915/intel_lrc.c +2 -4
@@ -1032,8 +1032,7 @@ int intel_logical_ring_alloc_request(struct intel_engine_cs *ring,if (!req_out)return -EINVAL ; -if ((*req_out = ring->outstanding_lazy_request) !=NULL ) -return 0 ; + *req_out =NULL ; request =kzalloc (sizeof (*request),GFP_KERNEL );if (request ==NULL )
@@ -1067,7 +1066,7 @@ int intel_logical_ring_alloc_request(struct intel_engine_cs *ring,i915_gem_context_reference (request->ctx); request->ringbuf = ctx->engine[ring->id].ringbuf; - *req_out = ring->outstanding_lazy_request = request; + *req_out = request;return 0 ; }
@@ -1393,7 +1392,6 @@ void intel_logical_ring_cleanup(struct intel_engine_cs *ring)intel_logical_ring_stop (ring);WARN_ON ((I915_READ_MODE (ring) &MODE_IDLE ) ==0 ); -i915_gem_request_assign (&ring->outstanding_lazy_request,NULL );if (ring->cleanup) ring->cleanup (ring);
drivers/gpu/drm/i915/intel_ringbuffer.c +2 -15
@@ -2034,7 +2034,6 @@ void intel_cleanup_ring_buffer(struct intel_engine_cs *ring)intel_unpin_ringbuffer_obj (ringbuf);intel_destroy_ringbuffer_obj (ringbuf); -i915_gem_request_assign (&ring->outstanding_lazy_request,NULL );if (ring->cleanup) ring->cleanup (ring);
@@ -2153,15 +2152,6 @@ static int intel_wrap_ring_buffer(struct intel_engine_cs *ring)int intel_ring_idle (struct intel_engine_cs *ring) {struct drm_i915_gem_request *req; -int ret; - -/* We need to add any requests required to flush the objects and ring */ -WARN_ON (ring->outstanding_lazy_request); -if (ring->outstanding_lazy_request) { - ret =i915_add_request (ring->outstanding_lazy_request); -if (ret) -return ret; - }/* Wait upon the last request to be completed */ if (list_empty (&ring->request_list))
@@ -2186,8 +2176,7 @@ intel_ring_alloc_request(struct intel_engine_cs *ring,if (!req_out)return -EINVAL ; -if ((*req_out = ring->outstanding_lazy_request) !=NULL ) -return 0 ; + *req_out =NULL ; request =kzalloc (sizeof (*request),GFP_KERNEL );if (request ==NULL )
@@ -2206,7 +2195,7 @@ intel_ring_alloc_request(struct intel_engine_cs *ring,return ret; } - *req_out = ring->outstanding_lazy_request = request; + *req_out = request;return 0 ; }
@@ -2281,8 +2270,6 @@ void intel_ring_init_seqno(struct intel_engine_cs *ring, u32 seqno)struct drm_device *dev = ring->dev;struct drm_i915_private *dev_priv = dev->dev_private; -BUG_ON (ring->outstanding_lazy_request); -if (INTEL_INFO (dev)->gen ==6 ||INTEL_INFO (dev)->gen ==7 ) {I915_WRITE (RING_SYNC_0 (ring->mmio_base),0 );I915_WRITE (RING_SYNC_1 (ring->mmio_base),0 );
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -4
@@ -258,10 +258,6 @@ struct intel_engine_cs {*/ struct list_head request_list; -/** -* Do we have some not yet emitted requests outstanding? -*/ -struct drm_i915_gem_request *outstanding_lazy_request;bool gpu_caches_dirty;bool fbc_dirty;
Signature · 6 lines
1.7.9.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 52/53] drm/i915: Remove the now obsolete 'outstanding_lazy_request'
Quoted 8 lines · On 19/02/2015 17:18, [email protected] wrote:
From: John Harrison <[email protected]>
The
outstanding_lazy_requestis no longer used anywhere in the driver. Everything that was looking at it now has a request explicitly passed in from on high. Everything that was relying upon behind the scenes is now explicitly creating/passing/submitting it's own private request. Thus the OLR can be removed.
"Everything that was relying upon behind the scenes is now explicitly creating/passing/submitting it's ..." --->
"Everything that was relying on it behind the scenes is now explicitly creating/passing/submitting its ..." ?
Quoted 176 lines
For: VIZ-5115
Signed-off-by John Harrison <[email protected]>--- drivers/gpu/drm/i915/i915_gem.c | 16 +--------------- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 4 +--- drivers/gpu/drm/i915/intel_lrc.c | 6 ++---- drivers/gpu/drm/i915/intel_ringbuffer.c | 17 ++--------------- drivers/gpu/drm/i915/intel_ringbuffer.h | 4 ---- 5 files changed, 6 insertions(+), 41 deletions(-)drivers/gpu/drm/i915/i915_gem.c +1
-15@@ -1156,15 +1156,9 @@ i915_gem_check_wedge(struct i915_gpu_error *error,int i915_gem_check_olr (struct drm_i915_gem_request *req) { -int ret; -WARN_ON (!mutex_is_locked (&req->ring->dev->struct_mutex)); - ret =0 ; -if (req == req->ring->outstanding_lazy_request) - ret =i915_add_request (req); - -return ret; +return 0 ; }static void fake_irq (unsigned long data)@@ -2424,8 +2418,6 @@ int __i915_add_request(struct drm_i915_gem_request *request, dev_priv = ring->dev->dev_private; ringbuf = request->ringbuf; -WARN_ON (request != ring->outstanding_lazy_request); - request_start =intel_ring_get_tail (ringbuf);/* * Emit any outstanding flushes - execbuf can fail to emit the flush @@ -2486,7 +2478,6 @@ int __i915_add_request(struct drm_i915_gem_request *request, }trace_i915_gem_request_add (request); - ring->outstanding_lazy_request =NULL ;i915_queue_hangcheck (ring->dev);@@ -2672,9 +2663,6 @@ static void i915_gem_reset_ring_cleanup(struct drm_i915_private *dev_priv,i915_gem_free_request (request); } - -/* This may not have been flushed before the reset, so clean it now */ -i915_gem_request_assign (&ring->outstanding_lazy_request,NULL ); }void i915_gem_restore_fences (struct drm_device *dev)@@ -3124,8 +3112,6 @@ int i915_gpu_idle(struct drm_device *dev) } } -WARN_ON (ring->outstanding_lazy_request); - ret =intel_ring_idle (ring);if (ret)return ret;drivers/gpu/drm/i915/i915_gem_execbuffer.c +1
-3@@ -1571,10 +1571,8 @@ err:* must be freed again. If it was submitted then it is being tracked * on the active request list and no clean up is required here. */ -if (ret && params->request) { +if (ret && params->request)i915_gem_request_unreference (params->request); - ring->outstanding_lazy_request =NULL ; - }mutex_unlock (&dev->struct_mutex);drivers/gpu/drm/i915/intel_lrc.c +2
-4@@ -1032,8 +1032,7 @@ int intel_logical_ring_alloc_request(struct intel_engine_cs *ring,if (!req_out)return -EINVAL ; -if ((*req_out = ring->outstanding_lazy_request) !=NULL ) -return 0 ; + *req_out =NULL ; request =kzalloc (sizeof (*request),GFP_KERNEL );if (request ==NULL )@@ -1067,7 +1066,7 @@ int intel_logical_ring_alloc_request(struct intel_engine_cs *ring,i915_gem_context_reference (request->ctx); request->ringbuf = ctx->engine[ring->id].ringbuf; - *req_out = ring->outstanding_lazy_request = request; + *req_out = request;return 0 ; }@@ -1393,7 +1392,6 @@ void intel_logical_ring_cleanup(struct intel_engine_cs *ring)intel_logical_ring_stop (ring);WARN_ON ((I915_READ_MODE (ring) &MODE_IDLE ) ==0 ); -i915_gem_request_assign (&ring->outstanding_lazy_request,NULL );if (ring->cleanup) ring->cleanup (ring);drivers/gpu/drm/i915/intel_ringbuffer.c +2
-15@@ -2034,7 +2034,6 @@ void intel_cleanup_ring_buffer(struct intel_engine_cs *ring)intel_unpin_ringbuffer_obj (ringbuf);intel_destroy_ringbuffer_obj (ringbuf); -i915_gem_request_assign (&ring->outstanding_lazy_request,NULL );if (ring->cleanup) ring->cleanup (ring);@@ -2153,15 +2152,6 @@ static int intel_wrap_ring_buffer(struct intel_engine_cs *ring)int intel_ring_idle (struct intel_engine_cs *ring) {struct drm_i915_gem_request *req; -int ret; - -/* We need to add any requests required to flush the objects and ring */ -WARN_ON (ring->outstanding_lazy_request); -if (ring->outstanding_lazy_request) { - ret =i915_add_request (ring->outstanding_lazy_request); -if (ret) -return ret; - }/* Wait upon the last request to be completed */ if (list_empty (&ring->request_list))@@ -2186,8 +2176,7 @@ intel_ring_alloc_request(struct intel_engine_cs *ring,if (!req_out)return -EINVAL ; -if ((*req_out = ring->outstanding_lazy_request) !=NULL ) -return 0 ; + *req_out =NULL ; request =kzalloc (sizeof (*request),GFP_KERNEL );if (request ==NULL )@@ -2206,7 +2195,7 @@ intel_ring_alloc_request(struct intel_engine_cs *ring,return ret; } - *req_out = ring->outstanding_lazy_request = request; + *req_out = request;return 0 ; }@@ -2281,8 +2270,6 @@ void intel_ring_init_seqno(struct intel_engine_cs *ring, u32 seqno)struct drm_device *dev = ring->dev;struct drm_i915_private *dev_priv = dev->dev_private; -BUG_ON (ring->outstanding_lazy_request); -if (INTEL_INFO (dev)->gen ==6 ||INTEL_INFO (dev)->gen ==7 ) {I915_WRITE (RING_SYNC_0 (ring->mmio_base),0 );I915_WRITE (RING_SYNC_1 (ring->mmio_base),0 );drivers/gpu/drm/i915/intel_ringbuffer.h +0
-0
drivers/gpu/drm/i915/intel_ringbuffer.h struct intel_engine_cs { · line 263
Quoted 10 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +0
-4@@ -258,10 +258,6 @@ struct intel_engine_cs {*/ struct list_head request_list; -/** -* Do we have some not yet emitted requests outstanding? -*/ -struct drm_i915_gem_request *outstanding_lazy_request;bool gpu_caches_dirty;bool fbc_dirty;
Since we're removing the i915_add_request from i915_check_olr and thereby removing the OLR emission the following comment at i915_gem_object_flush_active is no longer valid:
/**
* Ensures that an object will eventually get non-busy by
flushing any required
* write domains, emitting any outstanding lazy request and
retiring and
* completed requests.
*/
static int
i915_gem_object_flush_active(struct drm_i915_gem_object *obj)
{
struct intel_engine_cs *ring;
int ret;
if (obj->active) {
ring =
i915_gem_request_get_ring(obj->last_read_req);
ret = i915_gem_check_olr(obj->last_read_req);Thanks,
Tomas
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 52/53] drm/i915: Remove the now obsolete 'outstanding_lazy_request'
Quoted 213 lines · Tomas Elf
Quoted 8 lines · On 19/02/2015 17:18, [email protected] wrote:
From: John Harrison <[email protected]>
The
outstanding_lazy_requestis no longer used anywhere in the driver. Everything that was looking at it now has a request explicitly passed in from on high. Everything that was relying upon behind the scenes is now explicitly creating/passing/submitting it's own private request. Thus the OLR can be removed."Everything that was relying upon behind the scenes is now explicitly creating/passing/submitting it's ..."
--->
"Everything that was relying on it behind the scenes is now explicitly creating/passing/submitting its ..." ?Quoted 176 lines
For: VIZ-5115
Signed-off-by John Harrison <[email protected]>--- drivers/gpu/drm/i915/i915_gem.c | 16 +--------------- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 4 +--- drivers/gpu/drm/i915/intel_lrc.c | 6 ++---- drivers/gpu/drm/i915/intel_ringbuffer.c | 17 ++--------------- drivers/gpu/drm/i915/intel_ringbuffer.h | 4 ---- 5 files changed, 6 insertions(+), 41 deletions(-)drivers/gpu/drm/i915/i915_gem.c +1
-15@@ -1156,15 +1156,9 @@ i915_gem_check_wedge(struct i915_gpu_error *error,int i915_gem_check_olr (struct drm_i915_gem_request *req) { -int ret; -WARN_ON (!mutex_is_locked (&req->ring->dev->struct_mutex)); - ret =0 ; -if (req == req->ring->outstanding_lazy_request) - ret =i915_add_request (req); - -return ret; +return 0 ; }static void fake_irq (unsigned long data)@@ -2424,8 +2418,6 @@ int __i915_add_request(struct drm_i915_gem_request *request, dev_priv = ring->dev->dev_private; ringbuf = request->ringbuf; -WARN_ON (request != ring->outstanding_lazy_request); - request_start =intel_ring_get_tail (ringbuf);/* * Emit any outstanding flushes - execbuf can fail to emit the flush @@ -2486,7 +2478,6 @@ int __i915_add_request(struct drm_i915_gem_request *request, }trace_i915_gem_request_add (request); - ring->outstanding_lazy_request =NULL ;i915_queue_hangcheck (ring->dev);@@ -2672,9 +2663,6 @@ static void i915_gem_reset_ring_cleanup(struct drm_i915_private *dev_priv,i915_gem_free_request (request); } - -/* This may not have been flushed before the reset, so clean it now */ -i915_gem_request_assign (&ring->outstanding_lazy_request,NULL ); }void i915_gem_restore_fences (struct drm_device *dev)@@ -3124,8 +3112,6 @@ int i915_gpu_idle(struct drm_device *dev) } } -WARN_ON (ring->outstanding_lazy_request); - ret =intel_ring_idle (ring);if (ret)return ret;drivers/gpu/drm/i915/i915_gem_execbuffer.c +1
-3@@ -1571,10 +1571,8 @@ err:* must be freed again. If it was submitted then it is being tracked * on the active request list and no clean up is required here. */ -if (ret && params->request) { +if (ret && params->request)i915_gem_request_unreference (params->request); - ring->outstanding_lazy_request =NULL ; - }mutex_unlock (&dev->struct_mutex);drivers/gpu/drm/i915/intel_lrc.c +2
-4@@ -1032,8 +1032,7 @@ int intel_logical_ring_alloc_request(struct intel_engine_cs *ring,if (!req_out)return -EINVAL ; -if ((*req_out = ring->outstanding_lazy_request) !=NULL ) -return 0 ; + *req_out =NULL ; request =kzalloc (sizeof (*request),GFP_KERNEL );if (request ==NULL )@@ -1067,7 +1066,7 @@ int intel_logical_ring_alloc_request(struct intel_engine_cs *ring,i915_gem_context_reference (request->ctx); request->ringbuf = ctx->engine[ring->id].ringbuf; - *req_out = ring->outstanding_lazy_request = request; + *req_out = request;return 0 ; }@@ -1393,7 +1392,6 @@ void intel_logical_ring_cleanup(struct intel_engine_cs *ring)intel_logical_ring_stop (ring);WARN_ON ((I915_READ_MODE (ring) &MODE_IDLE ) ==0 ); -i915_gem_request_assign (&ring->outstanding_lazy_request,NULL );if (ring->cleanup) ring->cleanup (ring);drivers/gpu/drm/i915/intel_ringbuffer.c +2
-15@@ -2034,7 +2034,6 @@ void intel_cleanup_ring_buffer(struct intel_engine_cs *ring)intel_unpin_ringbuffer_obj (ringbuf);intel_destroy_ringbuffer_obj (ringbuf); -i915_gem_request_assign (&ring->outstanding_lazy_request,NULL );if (ring->cleanup) ring->cleanup (ring);@@ -2153,15 +2152,6 @@ static int intel_wrap_ring_buffer(struct intel_engine_cs *ring)int intel_ring_idle (struct intel_engine_cs *ring) {struct drm_i915_gem_request *req; -int ret; - -/* We need to add any requests required to flush the objects and ring */ -WARN_ON (ring->outstanding_lazy_request); -if (ring->outstanding_lazy_request) { - ret =i915_add_request (ring->outstanding_lazy_request); -if (ret) -return ret; - }/* Wait upon the last request to be completed */ if (list_empty (&ring->request_list))@@ -2186,8 +2176,7 @@ intel_ring_alloc_request(struct intel_engine_cs *ring,if (!req_out)return -EINVAL ; -if ((*req_out = ring->outstanding_lazy_request) !=NULL ) -return 0 ; + *req_out =NULL ; request =kzalloc (sizeof (*request),GFP_KERNEL );if (request ==NULL )@@ -2206,7 +2195,7 @@ intel_ring_alloc_request(struct intel_engine_cs *ring,return ret; } - *req_out = ring->outstanding_lazy_request = request; + *req_out = request;return 0 ; }@@ -2281,8 +2270,6 @@ void intel_ring_init_seqno(struct intel_engine_cs *ring, u32 seqno)struct drm_device *dev = ring->dev;struct drm_i915_private *dev_priv = dev->dev_private; -BUG_ON (ring->outstanding_lazy_request); -if (INTEL_INFO (dev)->gen ==6 ||INTEL_INFO (dev)->gen ==7 ) {I915_WRITE (RING_SYNC_0 (ring->mmio_base),0 );I915_WRITE (RING_SYNC_1 (ring->mmio_base),0 );drivers/gpu/drm/i915/intel_ringbuffer.h +0
-0drivers/gpu/drm/i915/intel_ringbuffer.h struct intel_engine_cs { · line 263
Quoted 10 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +0
-4@@ -258,10 +258,6 @@ struct intel_engine_cs {*/ struct list_head request_list; -/** -* Do we have some not yet emitted requests outstanding? -*/ -struct drm_i915_gem_request *outstanding_lazy_request;bool gpu_caches_dirty;bool fbc_dirty;Since we're removing the
i915_add_requestfromi915_check_olrand thereby removing the OLR emission the following comment ati915_gem_object_flush_activeis no longer valid:/**
* Ensures that an object will eventually get non-busy by flushing
any required
* write domains, emitting any outstanding lazy request and retiring
and
Quoted 12 lines
* completed requests.
*/
static int
i915_gem_object_flush_active(struct drm_i915_gem_object *obj)
{
struct intel_engine_cs *ring;
int ret;
if (obj->active) {
ring =
i915_gem_request_get_ring(obj->last_read_req);
ret = i915_gem_check_olr(obj->last_read_req);Nice catch! On top of that the int return value is no longer needed, so a follow-up patch should simplify it to void.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 52/53] drm/i915: Remove the now obsolete 'outstanding_lazy_request'
Quoted 220 lines · Daniel Vetter
Quoted 219 lines · Tomas Elf
Quoted 8 lines · On 19/02/2015 17:18, [email protected] wrote:
From: John Harrison <[email protected]>
The
outstanding_lazy_requestis no longer used anywhere in the driver. Everything that was looking at it now has a request explicitly passed in from on high. Everything that was relying upon behind the scenes is now explicitly creating/passing/submitting it's own private request. Thus the OLR can be removed."Everything that was relying upon behind the scenes is now explicitly creating/passing/submitting it's ..."
--->
"Everything that was relying on it behind the scenes is now explicitly creating/passing/submitting its ..." ?Quoted 176 lines
For: VIZ-5115
Signed-off-by John Harrison <[email protected]>--- drivers/gpu/drm/i915/i915_gem.c | 16 +--------------- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 4 +--- drivers/gpu/drm/i915/intel_lrc.c | 6 ++---- drivers/gpu/drm/i915/intel_ringbuffer.c | 17 ++--------------- drivers/gpu/drm/i915/intel_ringbuffer.h | 4 ---- 5 files changed, 6 insertions(+), 41 deletions(-)drivers/gpu/drm/i915/i915_gem.c +1
-15@@ -1156,15 +1156,9 @@ i915_gem_check_wedge(struct i915_gpu_error *error,int i915_gem_check_olr (struct drm_i915_gem_request *req) { -int ret; -WARN_ON (!mutex_is_locked (&req->ring->dev->struct_mutex)); - ret =0 ; -if (req == req->ring->outstanding_lazy_request) - ret =i915_add_request (req); - -return ret; +return 0 ; }static void fake_irq (unsigned long data)@@ -2424,8 +2418,6 @@ int __i915_add_request(struct drm_i915_gem_request *request, dev_priv = ring->dev->dev_private; ringbuf = request->ringbuf; -WARN_ON (request != ring->outstanding_lazy_request); - request_start =intel_ring_get_tail (ringbuf);/* * Emit any outstanding flushes - execbuf can fail to emit the flush @@ -2486,7 +2478,6 @@ int __i915_add_request(struct drm_i915_gem_request *request, }trace_i915_gem_request_add (request); - ring->outstanding_lazy_request =NULL ;i915_queue_hangcheck (ring->dev);@@ -2672,9 +2663,6 @@ static void i915_gem_reset_ring_cleanup(struct drm_i915_private *dev_priv,i915_gem_free_request (request); } - -/* This may not have been flushed before the reset, so clean it now */ -i915_gem_request_assign (&ring->outstanding_lazy_request,NULL ); }void i915_gem_restore_fences (struct drm_device *dev)@@ -3124,8 +3112,6 @@ int i915_gpu_idle(struct drm_device *dev) } } -WARN_ON (ring->outstanding_lazy_request); - ret =intel_ring_idle (ring);if (ret)return ret;drivers/gpu/drm/i915/i915_gem_execbuffer.c +1
-3@@ -1571,10 +1571,8 @@ err:* must be freed again. If it was submitted then it is being tracked * on the active request list and no clean up is required here. */ -if (ret && params->request) { +if (ret && params->request)i915_gem_request_unreference (params->request); - ring->outstanding_lazy_request =NULL ; - }mutex_unlock (&dev->struct_mutex);drivers/gpu/drm/i915/intel_lrc.c +2
-4@@ -1032,8 +1032,7 @@ int intel_logical_ring_alloc_request(struct intel_engine_cs *ring,if (!req_out)return -EINVAL ; -if ((*req_out = ring->outstanding_lazy_request) !=NULL ) -return 0 ; + *req_out =NULL ; request =kzalloc (sizeof (*request),GFP_KERNEL );if (request ==NULL )@@ -1067,7 +1066,7 @@ int intel_logical_ring_alloc_request(struct intel_engine_cs *ring,i915_gem_context_reference (request->ctx); request->ringbuf = ctx->engine[ring->id].ringbuf; - *req_out = ring->outstanding_lazy_request = request; + *req_out = request;return 0 ; }@@ -1393,7 +1392,6 @@ void intel_logical_ring_cleanup(struct intel_engine_cs *ring)intel_logical_ring_stop (ring);WARN_ON ((I915_READ_MODE (ring) &MODE_IDLE ) ==0 ); -i915_gem_request_assign (&ring->outstanding_lazy_request,NULL );if (ring->cleanup) ring->cleanup (ring);drivers/gpu/drm/i915/intel_ringbuffer.c +2
-15@@ -2034,7 +2034,6 @@ void intel_cleanup_ring_buffer(struct intel_engine_cs *ring)intel_unpin_ringbuffer_obj (ringbuf);intel_destroy_ringbuffer_obj (ringbuf); -i915_gem_request_assign (&ring->outstanding_lazy_request,NULL );if (ring->cleanup) ring->cleanup (ring);@@ -2153,15 +2152,6 @@ static int intel_wrap_ring_buffer(struct intel_engine_cs *ring)int intel_ring_idle (struct intel_engine_cs *ring) {struct drm_i915_gem_request *req; -int ret; - -/* We need to add any requests required to flush the objects and ring */ -WARN_ON (ring->outstanding_lazy_request); -if (ring->outstanding_lazy_request) { - ret =i915_add_request (ring->outstanding_lazy_request); -if (ret) -return ret; - }/* Wait upon the last request to be completed */ if (list_empty (&ring->request_list))@@ -2186,8 +2176,7 @@ intel_ring_alloc_request(struct intel_engine_cs *ring,if (!req_out)return -EINVAL ; -if ((*req_out = ring->outstanding_lazy_request) !=NULL ) -return 0 ; + *req_out =NULL ; request =kzalloc (sizeof (*request),GFP_KERNEL );if (request ==NULL )@@ -2206,7 +2195,7 @@ intel_ring_alloc_request(struct intel_engine_cs *ring,return ret; } - *req_out = ring->outstanding_lazy_request = request; + *req_out = request;return 0 ; }@@ -2281,8 +2270,6 @@ void intel_ring_init_seqno(struct intel_engine_cs *ring, u32 seqno)struct drm_device *dev = ring->dev;struct drm_i915_private *dev_priv = dev->dev_private; -BUG_ON (ring->outstanding_lazy_request); -if (INTEL_INFO (dev)->gen ==6 ||INTEL_INFO (dev)->gen ==7 ) {I915_WRITE (RING_SYNC_0 (ring->mmio_base),0 );I915_WRITE (RING_SYNC_1 (ring->mmio_base),0 );drivers/gpu/drm/i915/intel_ringbuffer.h +0
-0drivers/gpu/drm/i915/intel_ringbuffer.h struct intel_engine_cs { · line 263
Quoted 10 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +0
-4@@ -258,10 +258,6 @@ struct intel_engine_cs {*/ struct list_head request_list; -/** -* Do we have some not yet emitted requests outstanding? -*/ -struct drm_i915_gem_request *outstanding_lazy_request;bool gpu_caches_dirty;bool fbc_dirty;Since we're removing the
i915_add_requestfromi915_check_olrand thereby removing the OLR emission the following comment ati915_gem_object_flush_activeis no longer valid:/**
* Ensures that an object will eventually get non-busy by flushing
any required
* write domains, emitting any outstanding lazy request and retiring
and* completed requests. */ static int i915_gem_object_flush_active(struct drm_i915_gem_object *obj) { struct intel_engine_cs *ring; int ret;
Quoted 7 lines
Quoted 4 lines
if (obj->active) { ring = i915_gem_request_get_ring(obj->last_read_req); ret = i915_gem_check_olr(obj->last_read_req);Nice catch! On top of that the int return value is no longer needed, so a follow-up patch should simplify it to void.
-Daniel
The comment also talks about flushing write domains but there is no obvious flush call. All it does is the check_olr (which is now a no-op) and the retire (which won't do anything unless the request has already completed). So is there any need for this function at all anymore? Or should it just be removed and replaced with a call to retire instead?
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 52/53] drm/i915: Remove the now obsolete 'outstanding_lazy_request'
Quoted 44 lines · John Harrison
Quoted 35 lines · Daniel Vetter
Quoted 34 lines · Tomas Elf
Quoted 6 lines · On 19/02/2015 17:18, [email protected] wrote:
drivers/gpu/drm/i915/intel_ringbuffer.h +0
-0drivers/gpu/drm/i915/intel_ringbuffer.h struct intel_engine_cs { · line 263
Quoted 10 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +0
-4@@ -258,10 +258,6 @@ struct intel_engine_cs {*/ struct list_head request_list; -/** -* Do we have some not yet emitted requests outstanding? -*/ -struct drm_i915_gem_request *outstanding_lazy_request;bool gpu_caches_dirty;bool fbc_dirty;Since we're removing the
i915_add_requestfromi915_check_olrand thereby removing the OLR emission the following comment ati915_gem_object_flush_activeis no longer valid:/**
* Ensures that an object will eventually get non-busy by flushing
any required
* write domains, emitting any outstanding lazy request and retiring
and* completed requests. */ static int i915_gem_object_flush_active(struct drm_i915_gem_object *obj) { struct intel_engine_cs *ring; int ret;Quoted 7 lines
Quoted 4 lines
if (obj->active) { ring = i915_gem_request_get_ring(obj->last_read_req); ret = i915_gem_check_olr(obj->last_read_req);Nice catch! On top of that the int return value is no longer needed, so a follow-up patch should simplify it to void.
-Daniel
Quoted 5 lines
The comment also talks about flushing write domains but there is no obvious flush call. All it does is the
check_olr(which is now a no-op) and the retire (which won't do anything unless the request has already completed). So is there any need for this function at all anymore? Or should it just be removed and replaced with a call to retire instead?
That's historical baggage - way back we've done lazy cache-flushing, which mean on readback you might have needed to flush caches first. Massive case of premature optimization, the comment is just plainly outdated. See
commit 65ce3027415d4dc9ee18ef0a135214b4fb76730b
Author: Chris Wilson <[email protected]> Date: Fri Jul 20 12:41:02 2012 +0100
drm/i915: Remove the defunct flushing list
and
commit cc889e0f6ce6a63c62db17d702ecfed86d58083f
Author: Daniel Vetter <[email protected]> Date: Wed Jun 13 20:45:19 2012 +0200
drm/i915: disable flushing_list/gpu_write_list
You can savely remove the comment (maybe with the above commits referenced in the commit message).
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 54/56 drm/i915: Rename 'do_execbuf' to 'execbuf_submit'
In reply to [email protected]From: John Harrison <[email protected]>
The submission portion of the execbuffer code path was abstracted into a function pointer indirection as part of the legacy vs execlist work. The two implementation functions are called 'i915_gem_ringbuffer_submission' and 'intel_execlists_submission' but the pointer was called 'do_execbuf'. There is already a 'i915_gem_do_execbuffer' function (which is what calls the pointer indirection). The name of the pointer is therefore considered to be backwards and should be changed.
This patch renames it to 'execbuf_submit' which is hopefully a bit clearer.
--- drivers/gpu/drm/i915/i915_drv.h | 6 +++--- drivers/gpu/drm/i915/i915_gem.c | 4 ++-- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +3 -3
@@ -1793,9 +1793,9 @@ struct drm_i915_private {int (*alloc_request)(struct intel_engine_cs *ring,struct intel_context *ctx,struct drm_i915_gem_request **req_out); -int (*do_execbuf)(struct i915_execbuffer_params *params, -struct drm_i915_gem_execbuffer2 *args, -struct list_head *vmas); +int (*execbuf_submit)(struct i915_execbuffer_params *params, +struct drm_i915_gem_execbuffer2 *args, +struct list_head *vmas);int (*init_rings)(struct drm_device *dev);void (*cleanup_ring)(struct intel_engine_cs *ring);void (*stop_ring)(struct intel_engine_cs *ring);
drivers/gpu/drm/i915/i915_gem.c +2 -2
@@ -4928,13 +4928,13 @@ int i915_gem_init(struct drm_device *dev)if (!i915.enable_execlists) { dev_priv->gt.alloc_request = intel_ring_alloc_request; - dev_priv->gt.do_execbuf = i915_gem_ringbuffer_submission; + dev_priv->gt.execbuf_submit = i915_gem_ringbuffer_submission; dev_priv->gt.init_rings = i915_gem_init_rings; dev_priv->gt.cleanup_ring = intel_cleanup_ring_buffer; dev_priv->gt.stop_ring = intel_stop_ring_buffer; }else { dev_priv->gt.alloc_request = intel_logical_ring_alloc_request; - dev_priv->gt.do_execbuf = intel_execlists_submission; + dev_priv->gt.execbuf_submit = intel_execlists_submission; dev_priv->gt.init_rings = intel_logical_rings_init; dev_priv->gt.cleanup_ring = intel_logical_ring_cleanup; dev_priv->gt.stop_ring = intel_logical_ring_stop;
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -1
@@ -1558,7 +1558,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, params->batch_obj = batch_obj; params->ctx = ctx; - ret = dev_priv->gt.do_execbuf (params, args, &eb->vmas); + ret = dev_priv->gt.execbuf_submit (params, args, &eb->vmas); err:/*
Signature · 6 lines
1.7.9.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 55/56 drm/i915: Remove 'faked' request from LRC submission
From: John Harrison <[email protected]>
The LRC submission code requires a request for tracking purposes. It does not actually require that request to 'complete' it simply uses it for keeping hold of reference counts on contexts and such like.
In the case where the ring buffer is completely full, the LRC code looks for a pending request that would free up sufficient space upon completion and waits for it. If no such request can be found it resorts to simply polling the free space count until it is big enough. This situation should only occur when the entire buffer is filled with the request currently being generated. I.e., the user is trying to submit a single piece of work that is large than the ring buffer itself (which should be impossible because very large batch buffers don't consume any more ring buffer space). Before starting to poll, a submit call is made to make sure that the currently queued up work in the buffer will actually be submtted and thus the poll will eventually succeed.
The problem here is that the 'official' request cannot be used as that could lead to multiple LRC submissions being tagged to a single request structure. Instead, the code fakes up a private request structure and uses that.
This patch moves the faked request allocation higher up in the call stack to the wait code itself (rather than being at the very lowest submission level). Thus it is now obvious where the faked request is coming from and why it is necessary. The patch also replaces it with a call to the official request allocation code rather than attempting to duplicate that code. This becomes especially important in the future when the request allocation changes to accommodate a conversion to struct fence.
For: VIZ-5115
--- drivers/gpu/drm/i915/intel_lrc.c | 45 ++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 19 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +26 -19
@@ -507,23 +507,11 @@ static int execlists_context_queue(struct intel_engine_cs *ring,if (to != ring->default_context)intel_lr_context_pin (ring, to); -if (!request) { -/* -* If there isn't a request associated with this submission, -* create one as a temporary holder. -*/ - request =kzalloc (sizeof (*request),GFP_KERNEL ); -if (request ==NULL ) -return -ENOMEM ; - request->ring = ring; - request->ctx = to; -kref_init (&request->ref); - request->uniq = dev_priv->request_uniq++; -i915_gem_context_reference (request->ctx); - }else { -i915_gem_request_reference (request); -WARN_ON (to != request->ctx); - } +WARN_ON (!request); +WARN_ON (to != request->ctx); + +i915_gem_request_reference (request); + request->tail = tail;intel_runtime_pm_get (dev_priv);
@@ -677,6 +665,7 @@ static int logical_ring_wait_for_space(struct intel_ringbuffer *ringbuf,struct intel_engine_cs *ring = ringbuf->ring;struct drm_device *dev = ring->dev;struct drm_i915_private *dev_priv = dev->dev_private; +struct drm_i915_gem_request *local_req;unsigned long end;int ret;
@@ -684,8 +673,23 @@ static int logical_ring_wait_for_space(struct intel_ringbuffer *ringbuf,if (ret != -ENOSPC )return ret; -/* Force the context submission in case we have been skipping it */ -intel_logical_ring_advance_and_submit (ringbuf, ctx,NULL ); +/* +* Force the context submission in case we have been skipping it. +* This requires creating a place holder request so that the LRC +* submission can be tracked. Note that if this point has been +* reached then it is the current submission that is blocking the +* driver and the only course of action is to do a partial send and +* wait for it to complete. +* Note also that because there is no space left in the ring, it is +* not possible to write the request submission prologue (which does +* things like update seqno values and trigger completion interrupts). +* Thus the request cannot be submitted via i915_add_request() and +* can not be waiting on by i915_gem_wait_request(). +*/ + ret = dev_priv->gt.alloc_request (ring, ctx, &local_req); +if (ret) +return ret; +intel_logical_ring_advance_and_submit (ringbuf, ctx, local_req);/* With GEM the hangcheck timer should kick us out of the loop, * leaving it early runs the risk of corrupting GEM state (due
@@ -717,6 +721,9 @@ static int logical_ring_wait_for_space(struct intel_ringbuffer *ringbuf, } }while (1 ); +/* This request is now done with and can be disposed of. */ +i915_gem_request_unreference (local_req); +return ret; }
Signature · 6 lines
1.7.9.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 55/56] drm/i915: Remove 'faked' request from LRC submission
Quoted 29 lines · On Thu, Mar 05, 2015 at 01:57:31PM +0000, [email protected] wrote:
From: John Harrison <[email protected]>
The LRC submission code requires a request for tracking purposes. It does not actually require that request to 'complete' it simply uses it for keeping hold of reference counts on contexts and such like.
In the case where the ring buffer is completely full, the LRC code looks for a pending request that would free up sufficient space upon completion and waits for it. If no such request can be found it resorts to simply polling the free space count until it is big enough. This situation should only occur when the entire buffer is filled with the request currently being generated. I.e., the user is trying to submit a single piece of work that is large than the ring buffer itself (which should be impossible because very large batch buffers don't consume any more ring buffer space). Before starting to poll, a submit call is made to make sure that the currently queued up work in the buffer will actually be submtted and thus the poll will eventually succeed.
The problem here is that the 'official' request cannot be used as that could lead to multiple LRC submissions being tagged to a single request structure. Instead, the code fakes up a private request structure and uses that.
This patch moves the faked request allocation higher up in the call stack to the wait code itself (rather than being at the very lowest submission level). Thus it is now obvious where the faked request is coming from and why it is necessary. The patch also replaces it with a call to the official request allocation code rather than attempting to duplicate that code. This becomes especially important in the future when the request allocation changes to accommodate a conversion to struct fence.
Quoted 2 lines
For: VIZ-5115
Signed-off-by John Harrison <[email protected]>
This is only possible if you pile up tons of olr. Since your patch series fixes this design issue by removing olr I think we can just put a WARN_ON in here if this ever happens and bail out with -ELOSTMYMARBLES or something. And then rip out all this complexity.
Or do I miss something important?
-Daniel
Quoted 88 lines
--- drivers/gpu/drm/i915/intel_lrc.c | 45 ++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 19 deletions(-)drivers/gpu/drm/i915/intel_lrc.c +26
-19@@ -507,23 +507,11 @@ static int execlists_context_queue(struct intel_engine_cs *ring,if (to != ring->default_context)intel_lr_context_pin (ring, to); -if (!request) { -/* -* If there isn't a request associated with this submission, -* create one as a temporary holder. -*/ - request =kzalloc (sizeof (*request),GFP_KERNEL ); -if (request ==NULL ) -return -ENOMEM ; - request->ring = ring; - request->ctx = to; -kref_init (&request->ref); - request->uniq = dev_priv->request_uniq++; -i915_gem_context_reference (request->ctx); - }else { -i915_gem_request_reference (request); -WARN_ON (to != request->ctx); - } +WARN_ON (!request); +WARN_ON (to != request->ctx); + +i915_gem_request_reference (request); + request->tail = tail;intel_runtime_pm_get (dev_priv);@@ -677,6 +665,7 @@ static int logical_ring_wait_for_space(struct intel_ringbuffer *ringbuf,struct intel_engine_cs *ring = ringbuf->ring;struct drm_device *dev = ring->dev;struct drm_i915_private *dev_priv = dev->dev_private; +struct drm_i915_gem_request *local_req;unsigned long end;int ret;@@ -684,8 +673,23 @@ static int logical_ring_wait_for_space(struct intel_ringbuffer *ringbuf,if (ret != -ENOSPC )return ret; -/* Force the context submission in case we have been skipping it */ -intel_logical_ring_advance_and_submit (ringbuf, ctx,NULL ); +/* +* Force the context submission in case we have been skipping it. +* This requires creating a place holder request so that the LRC +* submission can be tracked. Note that if this point has been +* reached then it is the current submission that is blocking the +* driver and the only course of action is to do a partial send and +* wait for it to complete. +* Note also that because there is no space left in the ring, it is +* not possible to write the request submission prologue (which does +* things like update seqno values and trigger completion interrupts). +* Thus the request cannot be submitted via i915_add_request() and +* can not be waiting on by i915_gem_wait_request(). +*/ + ret = dev_priv->gt.alloc_request (ring, ctx, &local_req); +if (ret) +return ret; +intel_logical_ring_advance_and_submit (ringbuf, ctx, local_req);/* With GEM the hangcheck timer should kick us out of the loop, * leaving it early runs the risk of corrupting GEM state (due @@ -717,6 +721,9 @@ static int logical_ring_wait_for_space(struct intel_ringbuffer *ringbuf, } }while (1 ); +/* This request is now done with and can be disposed of. */ +i915_gem_request_unreference (local_req); +return ret; }Signature · 6 lines
1.7.9.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 55/56] drm/i915: Remove 'faked' request from LRC submission
Quoted 32 lines · Daniel Vetter
Quoted 29 lines · On Thu, Mar 05, 2015 at 01:57:31PM +0000, [email protected] wrote:
From: John Harrison <[email protected]>
The LRC submission code requires a request for tracking purposes. It does not actually require that request to 'complete' it simply uses it for keeping hold of reference counts on contexts and such like.
In the case where the ring buffer is completely full, the LRC code looks for a pending request that would free up sufficient space upon completion and waits for it. If no such request can be found it resorts to simply polling the free space count until it is big enough. This situation should only occur when the entire buffer is filled with the request currently being generated. I.e., the user is trying to submit a single piece of work that is large than the ring buffer itself (which should be impossible because very large batch buffers don't consume any more ring buffer space). Before starting to poll, a submit call is made to make sure that the currently queued up work in the buffer will actually be submtted and thus the poll will eventually succeed.
The problem here is that the 'official' request cannot be used as that could lead to multiple LRC submissions being tagged to a single request structure. Instead, the code fakes up a private request structure and uses that.
This patch moves the faked request allocation higher up in the call stack to the wait code itself (rather than being at the very lowest submission level). Thus it is now obvious where the faked request is coming from and why it is necessary. The patch also replaces it with a call to the official request allocation code rather than attempting to duplicate that code. This becomes especially important in the future when the request allocation changes to accommodate a conversion to struct fence.
Quoted 2 lines
For: VIZ-5115
Signed-off-by John Harrison <[email protected]>
Quoted 7 lines
This is only possible if you pile up tons of olr. Since your patch series fixes this design issue by removing olr I think we can just put a
WARN_ONin here if this ever happens and bail out with-ELOSTMYMARBLESor something. And then rip out all this complexity.Or do I miss something important?
-Daniel
Yeah, you missed the extremely important bug in the free space calculation that meant this impossible code path was being hit on a regular basis. The LRC wait_request code differed from the legacy wait_request code in the the latter was updated with request->postfix changes and the former was not. Thus the LRC one would happily find a request that frees up enough space, wait on it, retire it and then find there was still not enough space!
New patches to fix the space calculation bug and to completely remove the polling path will be forth coming...
Quoted 81 lines
Quoted 81 lines
--- drivers/gpu/drm/i915/intel_lrc.c | 45 ++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 19 deletions(-)drivers/gpu/drm/i915/intel_lrc.c +26
-19@@ -507,23 +507,11 @@ static int execlists_context_queue(struct intel_engine_cs *ring,if (to != ring->default_context)intel_lr_context_pin (ring, to); -if (!request) { -/* -* If there isn't a request associated with this submission, -* create one as a temporary holder. -*/ - request =kzalloc (sizeof (*request),GFP_KERNEL ); -if (request ==NULL ) -return -ENOMEM ; - request->ring = ring; - request->ctx = to; -kref_init (&request->ref); - request->uniq = dev_priv->request_uniq++; -i915_gem_context_reference (request->ctx); - }else { -i915_gem_request_reference (request); -WARN_ON (to != request->ctx); - } +WARN_ON (!request); +WARN_ON (to != request->ctx); + +i915_gem_request_reference (request); + request->tail = tail;intel_runtime_pm_get (dev_priv);@@ -677,6 +665,7 @@ static int logical_ring_wait_for_space(struct intel_ringbuffer *ringbuf,struct intel_engine_cs *ring = ringbuf->ring;struct drm_device *dev = ring->dev;struct drm_i915_private *dev_priv = dev->dev_private; +struct drm_i915_gem_request *local_req;unsigned long end;int ret;@@ -684,8 +673,23 @@ static int logical_ring_wait_for_space(struct intel_ringbuffer *ringbuf,if (ret != -ENOSPC )return ret; -/* Force the context submission in case we have been skipping it */ -intel_logical_ring_advance_and_submit (ringbuf, ctx,NULL ); +/* +* Force the context submission in case we have been skipping it. +* This requires creating a place holder request so that the LRC +* submission can be tracked. Note that if this point has been +* reached then it is the current submission that is blocking the +* driver and the only course of action is to do a partial send and +* wait for it to complete. +* Note also that because there is no space left in the ring, it is +* not possible to write the request submission prologue (which does +* things like update seqno values and trigger completion interrupts). +* Thus the request cannot be submitted via i915_add_request() and +* can not be waiting on by i915_gem_wait_request(). +*/ + ret = dev_priv->gt.alloc_request (ring, ctx, &local_req); +if (ret) +return ret; +intel_logical_ring_advance_and_submit (ringbuf, ctx, local_req);/* With GEM the hangcheck timer should kick us out of the loop, * leaving it early runs the risk of corrupting GEM state (due @@ -717,6 +721,9 @@ static int logical_ring_wait_for_space(struct intel_ringbuffer *ringbuf, } }while (1 ); +/* This request is now done with and can be disposed of. */ +i915_gem_request_unreference (local_req); +return ret; }
Quoted 7 lines
Quoted 7 lines
Signature · 6 lines
1.7.9.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 55/56] drm/i915: Remove 'faked' request from LRC submission
Quoted 48 lines · John Harrison
Quoted 32 lines · Daniel Vetter
Quoted 29 lines · On Thu, Mar 05, 2015 at 01:57:31PM +0000, [email protected] wrote:
From: John Harrison <[email protected]>
The LRC submission code requires a request for tracking purposes. It does not actually require that request to 'complete' it simply uses it for keeping hold of reference counts on contexts and such like.
In the case where the ring buffer is completely full, the LRC code looks for a pending request that would free up sufficient space upon completion and waits for it. If no such request can be found it resorts to simply polling the free space count until it is big enough. This situation should only occur when the entire buffer is filled with the request currently being generated. I.e., the user is trying to submit a single piece of work that is large than the ring buffer itself (which should be impossible because very large batch buffers don't consume any more ring buffer space). Before starting to poll, a submit call is made to make sure that the currently queued up work in the buffer will actually be submtted and thus the poll will eventually succeed.
The problem here is that the 'official' request cannot be used as that could lead to multiple LRC submissions being tagged to a single request structure. Instead, the code fakes up a private request structure and uses that.
This patch moves the faked request allocation higher up in the call stack to the wait code itself (rather than being at the very lowest submission level). Thus it is now obvious where the faked request is coming from and why it is necessary. The patch also replaces it with a call to the official request allocation code rather than attempting to duplicate that code. This becomes especially important in the future when the request allocation changes to accommodate a conversion to struct fence.
Quoted 2 lines
For: VIZ-5115
Signed-off-by John Harrison <[email protected]>Quoted 7 lines
This is only possible if you pile up tons of olr. Since your patch series fixes this design issue by removing olr I think we can just put a
WARN_ONin here if this ever happens and bail out with-ELOSTMYMARBLESor something. And then rip out all this complexity.Or do I miss something important?
-DanielYeah, you missed the extremely important bug in the free space calculation that meant this impossible code path was being hit on a regular basis. The LRC
wait_requestcode differed from the legacywait_requestcode in the the latter was updated withrequest->postfixchanges and the former was not. Thus the LRC one would happily find a request that frees up enough space, wait on it, retire it and then find there was still not enough space!
Quoted 2 lines
New patches to fix the space calculation bug and to completely remove the polling path will be forth coming...
Hm, Jesse did dig out a regression where gem_ringfill blows up on execlist. That igt is specifically to exercise this cornercases. I'm not sure whith bugzilla Jesse meant, there's two:
https://bugs.freedesktop.org/show_bug.cgi?id=89001
https://bugs.freedesktop.org/show_bug.cgi?id=88865
Can you please check whether your fixes help for those issues two?
Also adding Jesse since he's chasing these atm.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 55/56] drm/i915: Remove 'faked' request from LRC submission
Quoted 56 lines · Daniel Vetter
Quoted 48 lines · John Harrison
Quoted 32 lines · Daniel Vetter
Quoted 29 lines · On Thu, Mar 05, 2015 at 01:57:31PM +0000, [email protected] wrote:
From: John Harrison <[email protected]>
The LRC submission code requires a request for tracking purposes. It does not actually require that request to 'complete' it simply uses it for keeping hold of reference counts on contexts and such like.
In the case where the ring buffer is completely full, the LRC code looks for a pending request that would free up sufficient space upon completion and waits for it. If no such request can be found it resorts to simply polling the free space count until it is big enough. This situation should only occur when the entire buffer is filled with the request currently being generated. I.e., the user is trying to submit a single piece of work that is large than the ring buffer itself (which should be impossible because very large batch buffers don't consume any more ring buffer space). Before starting to poll, a submit call is made to make sure that the currently queued up work in the buffer will actually be submtted and thus the poll will eventually succeed.
The problem here is that the 'official' request cannot be used as that could lead to multiple LRC submissions being tagged to a single request structure. Instead, the code fakes up a private request structure and uses that.
This patch moves the faked request allocation higher up in the call stack to the wait code itself (rather than being at the very lowest submission level). Thus it is now obvious where the faked request is coming from and why it is necessary. The patch also replaces it with a call to the official request allocation code rather than attempting to duplicate that code. This becomes especially important in the future when the request allocation changes to accommodate a conversion to struct fence.
Quoted 2 lines
For: VIZ-5115
Signed-off-by John Harrison <[email protected]>Quoted 7 lines
This is only possible if you pile up tons of olr. Since your patch series fixes this design issue by removing olr I think we can just put a
WARN_ONin here if this ever happens and bail out with-ELOSTMYMARBLESor something. And then rip out all this complexity.Or do I miss something important?
-DanielYeah, you missed the extremely important bug in the free space calculation that meant this impossible code path was being hit on a regular basis. The LRC
wait_requestcode differed from the legacywait_requestcode in the the latter was updated withrequest->postfixchanges and the former was not. Thus the LRC one would happily find a request that frees up enough space, wait on it, retire it and then find there was still not enough space!Quoted 2 lines
New patches to fix the space calculation bug and to completely remove the polling path will be forth coming...
Hm, Jesse did dig out a regression where
gem_ringfillblows up on execlist. That igt is specifically to exercise this cornercases. I'm not sure whith bugzilla Jesse meant, there's two:
Quoted 6 lines
https://bugs.freedesktop.org/show_bug.cgi?id=89001
https://bugs.freedesktop.org/show_bug.cgi?id=88865Can you please check whether your fixes help for those issues two?
Also adding Jesse since he's chasing these atm.
Ah cool, sounds related at least. 89001 was the one I looked at yesterday. The worrying thing was that this bug caused a hard system hang. Not even the reset button worked... I guess we should have an HSD for that too so we can root cause the system part of it.
Jesse
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 55/56] drm/i915: Remove 'faked' request from LRC submission
Quoted 49 lines · Jesse Barnes
Quoted 48 lines · Daniel Vetter
Quoted 47 lines · John Harrison
Quoted 32 lines · Daniel Vetter
Quoted 29 lines · On Thu, Mar 05, 2015 at 01:57:31PM +0000, [email protected] wrote:
From: John Harrison <[email protected]>
The LRC submission code requires a request for tracking purposes. It does not actually require that request to 'complete' it simply uses it for keeping hold of reference counts on contexts and such like.
In the case where the ring buffer is completely full, the LRC code looks for a pending request that would free up sufficient space upon completion and waits for it. If no such request can be found it resorts to simply polling the free space count until it is big enough. This situation should only occur when the entire buffer is filled with the request currently being generated. I.e., the user is trying to submit a single piece of work that is large than the ring buffer itself (which should be impossible because very large batch buffers don't consume any more ring buffer space). Before starting to poll, a submit call is made to make sure that the currently queued up work in the buffer will actually be submtted and thus the poll will eventually succeed.
The problem here is that the 'official' request cannot be used as that could lead to multiple LRC submissions being tagged to a single request structure. Instead, the code fakes up a private request structure and uses that.
This patch moves the faked request allocation higher up in the call stack to the wait code itself (rather than being at the very lowest submission level). Thus it is now obvious where the faked request is coming from and why it is necessary. The patch also replaces it with a call to the official request allocation code rather than attempting to duplicate that code. This becomes especially important in the future when the request allocation changes to accommodate a conversion to struct fence.
Quoted 2 lines
For: VIZ-5115
Signed-off-by John Harrison <[email protected]>Quoted 7 lines
This is only possible if you pile up tons of olr. Since your patch series fixes this design issue by removing olr I think we can just put a
WARN_ONin here if this ever happens and bail out with-ELOSTMYMARBLESor something. And then rip out all this complexity.Or do I miss something important?
-DanielYeah, you missed the extremely important bug in the free space calculation that meant this impossible code path was being hit on a regular basis. The LRC
wait_requestcode differed from the legacywait_requestcode in the the latter was updated withrequest->postfixchanges and the former was not. Thus the LRC one would happily find a request that frees up enough space, wait on it, retire it and then find there was still not enough space!
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
New patches to fix the space calculation bug and to completely remove the polling path will be forth coming...
Hm, Jesse did dig out a regression where
gem_ringfillblows up on execlist. That igt is specifically to exercise this cornercases. I'm not sure whith bugzilla Jesse meant, there's two:https://bugs.freedesktop.org/show_bug.cgi?id=89001
https://bugs.freedesktop.org/show_bug.cgi?id=88865
I don't think the space calculation bug could cause the gem_ringfill failure. As noted above, even when the calculation gets it horribly wrong and flunks the wait for request path, the sit and poll path should still do the right thing. Plus the 88865 bug report I've already tried to reproduce and verified as fixed by the initial version of this patch set (i.e. without the space calc bug fix or the clean up of the fake request that follows it). It would go wrong pretty reliably on a clean nightly but never failed on my anti-OLR branch after quite a large amount of trying.
I've just realised that I somehow got completely the wrong bug number in the cover letter. So where patch zero talks about fixing a gem_ringfill bug, it was supposed to be BZ:88865 not BZ:4####! The second one, BZ:89001 certainly looks like the same issue but I don't have a SKL to test with.
Quoted 11 lines
Quoted 4 lines
Can you please check whether your fixes help for those issues two?
Also adding Jesse since he's chasing these atm.
Ah cool, sounds related at least. 89001 was the one I looked at yesterday. The worrying thing was that this bug caused a hard system hang. Not even the reset button worked... I guess we should have an HSD for that too so we can root cause the system part of it.
Jesse
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 56/56 drm/i915: Update a bunch of LRC functions to take requests
In reply to [email protected]From: John Harrison <[email protected]>
A bunch of the low level LRC functions were passing around ringbuf and ctx pairs. In a few cases, they took the r/c pair and a request as well. This is all quite messy and unnecesary.
Updated those functions to just take the request structure.
For: VIZ-5115
--- drivers/gpu/drm/i915/intel_lrc.c | 61 ++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 35 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +26 -35
@@ -494,25 +494,20 @@ void intel_lrc_irq_handler(struct intel_engine_cs *ring) ((u32)ring->next_context_status_buffer & 0x07) << 8); } -static int execlists_context_queue (struct intel_engine_cs *ring, -struct intel_context *to, -u32 tail, -struct drm_i915_gem_request *request) +static int execlists_context_queue (struct drm_i915_gem_request *request) { +struct intel_engine_cs *ring = request->ring;struct drm_i915_gem_request *cursor;struct drm_i915_private *dev_priv = ring->dev->dev_private;unsigned long flags;int num_elements =0 ; -if (to != ring->default_context) -intel_lr_context_pin (ring, to); - -WARN_ON (!request); -WARN_ON (to != request->ctx); +if (request->ctx != ring->default_context) +intel_lr_context_pin (ring, request->ctx);i915_gem_request_reference (request); - request->tail = tail; + request->tail = request->ringbuf->tail;intel_runtime_pm_get (dev_priv);
@@ -529,7 +524,7 @@ static int execlists_context_queue(struct intel_engine_cs *ring, struct drm_i915_gem_request, execlist_link); -if (to == tail_req->ctx) { +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);
@@ -636,7 +631,7 @@ static int logical_ring_wait_request(struct intel_ringbuffer *ringbuf,/* * intel_logical_ring_advance_and_submit() - advance the tail and submit the workload -* @ringbuf: Logical Ringbuffer to advance. +* @request: Request to advance the logical ringbuffer of. * * The tail is updated in our logical ringbuffer struct, not in the actual context. What * really happens during submission is that the context and current tail will be placed
@@ -644,32 +639,29 @@ static int logical_ring_wait_request(struct intel_ringbuffer *ringbuf,* point, the tail *inside* the context is updated and the ELSP written to. */ static void -intel_logical_ring_advance_and_submit (struct intel_ringbuffer *ringbuf, -struct intel_context *ctx, -struct drm_i915_gem_request *request) +intel_logical_ring_advance_and_submit (struct drm_i915_gem_request *request) { -struct intel_engine_cs *ring = ringbuf->ring; +struct intel_engine_cs *ring = request->ring; -intel_logical_ring_advance (ringbuf); +intel_logical_ring_advance (request->ringbuf);if (intel_ring_stopped (ring))return ; -execlists_context_queue (ring, ctx, ringbuf->tail, request); +execlists_context_queue (request); } -static int logical_ring_wait_for_space (struct intel_ringbuffer *ringbuf, -struct intel_context *ctx, +static int logical_ring_wait_for_space (struct drm_i915_gem_request *req,int bytes) { -struct intel_engine_cs *ring = ringbuf->ring; +struct intel_engine_cs *ring = req->ring;struct drm_device *dev = ring->dev;struct drm_i915_private *dev_priv = dev->dev_private;struct drm_i915_gem_request *local_req;unsigned long end;int ret; - ret =logical_ring_wait_request (ringbuf, bytes); + ret =logical_ring_wait_request (req->ringbuf, bytes);if (ret != -ENOSPC )return ret;
@@ -686,10 +678,10 @@ static int logical_ring_wait_for_space(struct intel_ringbuffer *ringbuf,* Thus the request cannot be submitted via i915_add_request() and * can not be waiting on by i915_gem_wait_request(). */ - ret = dev_priv->gt.alloc_request (ring, ctx, &local_req); + ret = dev_priv->gt.alloc_request (ring, req->ctx, &local_req);if (ret)return ret; -intel_logical_ring_advance_and_submit (ringbuf, ctx, local_req); +intel_logical_ring_advance_and_submit (local_req);/* With GEM the hangcheck timer should kick us out of the loop, * leaving it early runs the risk of corrupting GEM state (due
@@ -700,7 +692,7 @@ static int logical_ring_wait_for_space(struct intel_ringbuffer *ringbuf, ret =0 ; do { - if (intel_ring_space(ringbuf) >= bytes) + if (intel_ring_space(req->ringbuf) >= bytes) break; msleep(1);
@@ -727,14 +719,14 @@ static int logical_ring_wait_for_space(struct intel_ringbuffer *ringbuf,return ret; } -static int logical_ring_wrap_buffer (struct intel_ringbuffer *ringbuf, -struct intel_context *ctx) +static int logical_ring_wrap_buffer (struct drm_i915_gem_request *req) { +struct intel_ringbuffer *ringbuf = req->ringbuf;uint32_t __iomem *virt;int rem = ringbuf->size - ringbuf->tail;if (ringbuf->space < rem) { -int ret =logical_ring_wait_for_space (ringbuf, ctx, rem); +int ret =logical_ring_wait_for_space (req, rem);if (ret)return ret;
@@ -751,19 +743,19 @@ static int logical_ring_wrap_buffer(struct intel_ringbuffer *ringbuf,return 0 ; } -static int logical_ring_prepare (struct intel_ringbuffer *ringbuf, -struct intel_context *ctx,int bytes) +static int logical_ring_prepare (struct drm_i915_gem_request *req,int bytes) { +struct intel_ringbuffer *ringbuf = req->ringbuf;int ret;if (unlikely (ringbuf->tail + bytes > ringbuf->effective_size)) { - ret =logical_ring_wrap_buffer (ringbuf, ctx); + ret =logical_ring_wrap_buffer (req);if (unlikely (ret))return ret; }if (unlikely (ringbuf->space < bytes)) { - ret =logical_ring_wait_for_space (ringbuf, ctx, bytes); + ret =logical_ring_wait_for_space (req, bytes);if (unlikely (ret))return ret; }
@@ -799,8 +791,7 @@ static int intel_logical_ring_begin(struct drm_i915_gem_request *req,if (ret)return ret; - ret =logical_ring_prepare (req->ringbuf, req->ctx, - num_dwords *sizeof (uint32_t )); + ret =logical_ring_prepare (req, num_dwords *sizeof (uint32_t ));if (ret)return ret;
@@ -1334,7 +1325,7 @@ static int gen8_emit_request(struct drm_i915_gem_request *request)intel_logical_ring_emit (ringbuf,i915_gem_request_get_seqno (request));intel_logical_ring_emit (ringbuf,MI_USER_INTERRUPT );intel_logical_ring_emit (ringbuf,MI_NOOP ); -intel_logical_ring_advance_and_submit (ringbuf, request->ctx, request); +intel_logical_ring_advance_and_submit (request);return 0 ; }
Signature · 6 lines
1.7.9.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 54/56] drm/i915: Rename 'do_execbuf' to 'execbuf_submit'
In reply to [email protected]Quoted 62 lines · On 05/03/2015 13:57, [email protected] wrote:
From: John Harrison <[email protected]>
The submission portion of the execbuffer code path was abstracted into a function pointer indirection as part of the legacy vs execlist work. The two implementation functions are called '
i915_gem_ringbuffer_submission' and 'intel_execlists_submission' but the pointer was called 'do_execbuf'. There is already a 'i915_gem_do_execbuffer' function (which is what calls the pointer indirection). The name of the pointer is therefore considered to be backwards and should be changed.This patch renames it to '
execbuf_submit' which is hopefully a bit clearer.Signed-off-by John Harrison <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 6 +++--- drivers/gpu/drm/i915/i915_gem.c | 4 ++-- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-)drivers/gpu/drm/i915/i915_drv.h +3
-3@@ -1793,9 +1793,9 @@ struct drm_i915_private {int (*alloc_request)(struct intel_engine_cs *ring,struct intel_context *ctx,struct drm_i915_gem_request **req_out); -int (*do_execbuf)(struct i915_execbuffer_params *params, -struct drm_i915_gem_execbuffer2 *args, -struct list_head *vmas); +int (*execbuf_submit)(struct i915_execbuffer_params *params, +struct drm_i915_gem_execbuffer2 *args, +struct list_head *vmas);int (*init_rings)(struct drm_device *dev);void (*cleanup_ring)(struct intel_engine_cs *ring);void (*stop_ring)(struct intel_engine_cs *ring);drivers/gpu/drm/i915/i915_gem.c +2
-2@@ -4928,13 +4928,13 @@ int i915_gem_init(struct drm_device *dev)if (!i915.enable_execlists) { dev_priv->gt.alloc_request = intel_ring_alloc_request; - dev_priv->gt.do_execbuf = i915_gem_ringbuffer_submission; + dev_priv->gt.execbuf_submit = i915_gem_ringbuffer_submission; dev_priv->gt.init_rings = i915_gem_init_rings; dev_priv->gt.cleanup_ring = intel_cleanup_ring_buffer; dev_priv->gt.stop_ring = intel_stop_ring_buffer; }else { dev_priv->gt.alloc_request = intel_logical_ring_alloc_request; - dev_priv->gt.do_execbuf = intel_execlists_submission; + dev_priv->gt.execbuf_submit = intel_execlists_submission; dev_priv->gt.init_rings = intel_logical_rings_init; dev_priv->gt.cleanup_ring = intel_logical_ring_cleanup; dev_priv->gt.stop_ring = intel_logical_ring_stop;drivers/gpu/drm/i915/i915_gem_execbuffer.c +0
-0
drivers/gpu/drm/i915/i915_gem_execbuffer.c i915_gem_do_execbuffer(struct drm_device *dev, void *data, · line 1564
Quoted 8 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1
-1@@ -1558,7 +1558,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, params->batch_obj = batch_obj; params->ctx = ctx; - ret = dev_priv->gt.do_execbuf (params, args, &eb->vmas); + ret = dev_priv->gt.execbuf_submit (params, args, &eb->vmas); err:/*
Thanks,
Tomas
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 53/53 drm/i915: Move the request/file and request/pid association to creation time
In reply to [email protected]From: John Harrison <[email protected]>
In _i915_add_request(), the request is associated with a userland client. Specifically it is linked to the 'file' structure and the current user process is recorded. One problem here is that the current user process is not necessarily the same as when the request was submitted to the driver. This is especially true when the GPU scheduler arrives and decouples driver submission from hardware submission. Note also that it is only in the case where the add request comes from an execbuff call that there is a client to associate. Any other add request call is kernel only so does not need to do it.
This patch moves the client association into a separate function. This is then called from the execbuffer code path itself at a sensible time. It also removes the now redundant 'file' pointer from the add request parameter list.
An extra cleanup of the client association is also added to the request clean up code for the eventuality where the request is killed after association but before being submitted (e.g. due to out of memory error somewhere). Once the submission has happened, the request is on the request list and the regular request list removal will clear the association. Note that this still needs to happen at this point in time because the request might be kept floating around much longer (due to someone holding a reference count) and the client should not be worrying about this request after it has been retired.
For: VIZ-5115
--- drivers/gpu/drm/i915/i915_drv.h | 8 +++-- drivers/gpu/drm/i915/i915_gem.c | 49 +++++++++++++++++++--------- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 7 ++-- 3 files changed, 44 insertions(+), 20 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +5 -3
@@ -2199,6 +2199,9 @@ struct drm_i915_gem_request { };void i915_gem_request_free (struct kref *req_ref); +void i915_gem_request_remove_from_client (struct drm_i915_gem_request *request); +int i915_gem_request_add_to_client (struct drm_i915_gem_request *req, +struct drm_file *file);static inline uint32_t i915_gem_request_get_seqno (struct drm_i915_gem_request *req)
@@ -2831,13 +2834,12 @@ void i915_gem_cleanup_ringbuffer(struct drm_device *dev);int __must_check i915_gpu_idle (struct drm_device *dev);int __must_check i915_gem_suspend (struct drm_device *dev);int __i915_add_request (struct drm_i915_gem_request *req, -struct drm_file *file,struct drm_i915_gem_object *batch_obj,bool flush_caches);#define i915_add_request (req) \ - __i915_add_request(req, NULL, NULL, true) + __i915_add_request(req, NULL, true)#define i915_add_request_no_flush (req) \ - __i915_add_request(req, NULL, NULL, false) + __i915_add_request(req, NULL, false) int __i915_wait_request(struct drm_i915_gem_request *req, unsigned reset_counter, bool interruptible,
drivers/gpu/drm/i915/i915_gem.c +34 -15
79 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem_execbuffer.c +5 -2
@@ -996,8 +996,7 @@ i915_gem_execbuffer_retire_commands(struct i915_execbuffer_params *params) params->ring->gpu_caches_dirty = true;/* Add a breadcrumb for the completion of the batch buffer */ -return __i915_add_request (params->request, params->file, - params->batch_obj, true); +return __i915_add_request (params->request, params->batch_obj, true); } static int
@@ -1537,6 +1536,10 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,if (ret) goto err; + ret =i915_gem_request_add_to_client (params->request, file); +if (ret) + goto err; +/* * Save assorted stuff away to pass through to *_submission(). * NB: This data should be 'persistent' and not local as it will
Signature · 6 lines
1.7.9.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 53/53] drm/i915: Move the request/file and request/pid association to creation time
Quoted 141 lines · On 19/02/2015 17:18, [email protected] wrote:
From: John Harrison <[email protected]>
In
_i915_add_request(), the request is associated with a userland client. Specifically it is linked to the 'file' structure and the current user process is recorded. One problem here is that the current user process is not necessarily the same as when the request was submitted to the driver. This is especially true when the GPU scheduler arrives and decouples driver submission from hardware submission. Note also that it is only in the case where the add request comes from an execbuff call that there is a client to associate. Any other add request call is kernel only so does not need to do it.This patch moves the client association into a separate function. This is then called from the execbuffer code path itself at a sensible time. It also removes the now redundant 'file' pointer from the add request parameter list.
An extra cleanup of the client association is also added to the request clean up code for the eventuality where the request is killed after association but before being submitted (e.g. due to out of memory error somewhere). Once the submission has happened, the request is on the request list and the regular request list removal will clear the association. Note that this still needs to happen at this point in time because the request might be kept floating around much longer (due to someone holding a reference count) and the client should not be worrying about this request after it has been retired.
For: VIZ-5115
Signed-off-by John Harrison <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 8 +++-- drivers/gpu/drm/i915/i915_gem.c | 49 +++++++++++++++++++--------- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 7 ++-- 3 files changed, 44 insertions(+), 20 deletions(-)drivers/gpu/drm/i915/i915_drv.h +5
-3@@ -2199,6 +2199,9 @@ struct drm_i915_gem_request { };void i915_gem_request_free (struct kref *req_ref); +void i915_gem_request_remove_from_client (struct drm_i915_gem_request *request); +int i915_gem_request_add_to_client (struct drm_i915_gem_request *req, +struct drm_file *file);static inline uint32_t i915_gem_request_get_seqno (struct drm_i915_gem_request *req)@@ -2831,13 +2834,12 @@ void i915_gem_cleanup_ringbuffer(struct drm_device *dev);int __must_check i915_gpu_idle (struct drm_device *dev);int __must_check i915_gem_suspend (struct drm_device *dev);int __i915_add_request (struct drm_i915_gem_request *req, -struct drm_file *file,struct drm_i915_gem_object *batch_obj,bool flush_caches);#define i915_add_request (req) \ - __i915_add_request(req, NULL, NULL, true) + __i915_add_request(req, NULL, true)#define i915_add_request_no_flush (req) \ - __i915_add_request(req, NULL, NULL, false) + __i915_add_request(req, NULL, false) int __i915_wait_request(struct drm_i915_gem_request *req, unsigned reset_counter, bool interruptible,drivers/gpu/drm/i915/i915_gem.c +31
-15@@ -2401,7 +2401,6 @@ i915_gem_get_seqno(struct drm_device *dev, u32 *seqno) }int __i915_add_request (struct drm_i915_gem_request *request, -struct drm_file *file,struct drm_i915_gem_object *obj,bool flush_caches) {@@ -2463,19 +2462,6 @@ int __i915_add_request(struct drm_i915_gem_request *request, request->emitted_jiffies = jiffies;list_add_tail (&request->list, &ring->request_list); - request->file_priv =NULL ; - -if (file) { -struct drm_i915_file_private *file_priv = file->driver_priv; - -spin_lock (&file_priv->mm.lock); - request->file_priv = file_priv; -list_add_tail (&request->client_list, - &file_priv->mm.request_list); -spin_unlock (&file_priv->mm.lock); - - request->pid =get_pid (task_pid (current)); - }trace_i915_gem_request_add (request);@@ -2490,7 +2476,34 @@ int __i915_add_request(struct drm_i915_gem_request *request,return 0 ; } -static inline void +int i915_gem_request_add_to_client (struct drm_i915_gem_request *req, +struct drm_file *file) +{ +struct drm_i915_private *dev_private; +struct drm_i915_file_private *file_priv; + +WARN_ON (!req || !file || req->file_priv); + +if (!req || !file) +return -EINVAL ; + +if (req->file_priv) +return -EINVAL ; + + dev_private = req->ring->dev->dev_private; + file_priv = file->driver_priv; + +spin_lock (&file_priv->mm.lock); + req->file_priv = file_priv; +list_add_tail (&req->client_list, &file_priv->mm.request_list); +spin_unlock (&file_priv->mm.lock); + + req->pid =get_pid (task_pid (current)); + +return 0 ; +} + +inline void i915_gem_request_remove_from_client (struct drm_i915_gem_request *request) {struct drm_i915_file_private *file_priv = request->file_priv;@@ -2565,6 +2578,9 @@ void i915_gem_request_free(struct kref *req_ref) typeof(*req), ref);struct intel_context *ctx = req->ctx; +if (req->file_priv) +i915_gem_request_remove_from_client (req); +if (ctx) {if (i915.enable_execlists) {struct intel_engine_cs *ring = req->ring;
drivers/gpu/drm/i915/i915_gem.c i915_gem_ring_throttle(struct drm_device *dev, struct drm_file *file) · line 4141
Quoted 6 lines
drivers/gpu/drm/i915/i915_gem.c +3
-0@@ -4120,6 +4136,9 @@ i915_gem_ring_throttle(struct drm_device *dev, struct drm_file *file)if (time_after_eq (request->emitted_jiffies, recent_enough))break ; +if (!request->emitted_jiffies) +continue ; +
Please add a comment clarifying the purpose of the emitted_jiffies check above.
Thanks,
Tomas
Quoted 19 lines
drivers/gpu/drm/i915/i915_gem.c +0
-0target = request; } reset_counter =atomic_read (&dev_priv->gpu_error.reset_counter);drivers/gpu/drm/i915/i915_gem_execbuffer.c +1
-2@@ -996,8 +996,7 @@ i915_gem_execbuffer_retire_commands(struct i915_execbuffer_params *params) params->ring->gpu_caches_dirty = true;/* Add a breadcrumb for the completion of the batch buffer */ -return __i915_add_request (params->request, params->file, - params->batch_obj, true); +return __i915_add_request (params->request, params->batch_obj, true); } static int
drivers/gpu/drm/i915/i915_gem_execbuffer.c i915_gem_do_execbuffer(struct drm_device *dev, void *data, · line 1545
Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +4
-0@@ -1537,6 +1536,10 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,if (ret) goto err; + ret =i915_gem_request_add_to_client (params->request, file); +if (ret) + goto err; +/* * Save assorted stuff away to pass through to *_submission(). * NB: This data should be 'persistent' and not local as it will
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx