Low hanging fruit take 2
Subsystems (2)
Lots of pickings here to improve both microbenchmarks and beyond across several generations. Have fun!
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/70 drm/i915: Cache last obj->pages location for i915_gem_object_get_page()
The biggest user of i915_gem_object_get_page() is the relocation processing during execbuffer. Typically userspace passes in a set of relocations in sorted order. Sadly, we alternate between relocations increasing from the start of the buffers, and relocations decreasing from the end. However the majority of consecutive lookups will still be in the same page. We could cache the start of the last sg chain, however for most callers, the entire sgl is inside a single chain and so we see no improve from the extra layer of caching.
v2: Avoid the double increment inside unlikely()
References: https://bugs.freedesktop.org/show_bug.cgi?id=88308
--- drivers/gpu/drm/i915/i915_drv.h | 31 ++++++++++++++++++++++++++----- drivers/gpu/drm/i915/i915_gem.c | 4 ++++ 2 files changed, 30 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +26 -5
@@ -1987,6 +1987,10 @@ struct drm_i915_gem_object {struct sg_table *pages;int pages_pin_count; +struct get_page { +struct scatterlist *sg; +int last; + } get_page;/* prime dma-buf support */ void *dma_buf_vmapping;
@@ -2665,15 +2669,32 @@ int i915_gem_obj_prepare_shmem_read(struct drm_i915_gem_object *obj, int *needs_clflush);int __must_check i915_gem_object_get_pages (struct drm_i915_gem_object *obj); -static inline struct page *i915_gem_object_get_page (struct drm_i915_gem_object *obj,int n) + +static inline int __sg_page_count (struct scatterlist *sg) +{ +return sg->length >>PAGE_SHIFT ; +} + +static inline struct page * +i915_gem_object_get_page (struct drm_i915_gem_object *obj,int n) { -struct sg_page_iter sg_iter; +if (WARN_ON (n >= obj->base.size >>PAGE_SHIFT )) +return NULL ; -for_each_sg_page (obj->pages->sgl, &sg_iter, obj->pages->nents, n) -return sg_page_iter_page (&sg_iter); +if (n < obj->get_page.last) { + obj->get_page.sg = obj->pages->sgl; + obj->get_page.last =0 ; + } + +while (obj->get_page.last +__sg_page_count (obj->get_page.sg) <= n) { + obj->get_page.last +=__sg_page_count (obj->get_page.sg++); +if (unlikely (sg_is_chain (obj->get_page.sg))) + obj->get_page.sg =sg_chain_ptr (obj->get_page.sg); + } -return NULL ; +return nth_page (sg_page (obj->get_page.sg), n - obj->get_page.last); } +static inline void i915_gem_object_pin_pages (struct drm_i915_gem_object *obj) {BUG_ON (obj->pages ==NULL );
drivers/gpu/drm/i915/i915_gem.c +4 -0
@@ -2178,6 +2178,10 @@ i915_gem_object_get_pages(struct drm_i915_gem_object *obj)return ret;list_add_tail (&obj->global_list, &dev_priv->mm.unbound_list); + + obj->get_page.sg = obj->pages->sgl; + obj->get_page.last =0 ; +return 0 ; }
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 01/70] drm/i915: Cache last obj->pages location for i915_gem_object_get_page()
Quoted 9 lines · Chris Wilson
The biggest user of
i915_gem_object_get_page()is the relocation processing during execbuffer. Typically userspace passes in a set of relocations in sorted order. Sadly, we alternate between relocations increasing from the start of the buffers, and relocations decreasing from the end. However the majority of consecutive lookups will still be in the same page. We could cache the start of the last sg chain, however for most callers, the entire sgl is inside a single chain and so we see no improve from the extra layer of caching.
Quoted 5 lines
v2: Avoid the double increment inside
unlikely()References: https://bugs.freedesktop.org/show_bug.cgi?id=88308
Signed-off-by Chris Wilson <[email protected]>Cc John Harrison <[email protected]>
Indeed this makes gem_exec_big a lot faster. Queued for -next, thanks for the patch. -Daniel
Quoted 80 lines
--- drivers/gpu/drm/i915/i915_drv.h | 31 ++++++++++++++++++++++++++----- drivers/gpu/drm/i915/i915_gem.c | 4 ++++ 2 files changed, 30 insertions(+), 5 deletions(-)drivers/gpu/drm/i915/i915_drv.h +26
-5@@ -1987,6 +1987,10 @@ struct drm_i915_gem_object {struct sg_table *pages;int pages_pin_count; +struct get_page { +struct scatterlist *sg; +int last; + } get_page;/* prime dma-buf support */ void *dma_buf_vmapping;@@ -2665,15 +2669,32 @@ int i915_gem_obj_prepare_shmem_read(struct drm_i915_gem_object *obj, int *needs_clflush);int __must_check i915_gem_object_get_pages (struct drm_i915_gem_object *obj); -static inline struct page *i915_gem_object_get_page (struct drm_i915_gem_object *obj,int n) + +static inline int __sg_page_count (struct scatterlist *sg) +{ +return sg->length >>PAGE_SHIFT ; +} + +static inline struct page * +i915_gem_object_get_page (struct drm_i915_gem_object *obj,int n) { -struct sg_page_iter sg_iter; +if (WARN_ON (n >= obj->base.size >>PAGE_SHIFT )) +return NULL ; -for_each_sg_page (obj->pages->sgl, &sg_iter, obj->pages->nents, n) -return sg_page_iter_page (&sg_iter); +if (n < obj->get_page.last) { + obj->get_page.sg = obj->pages->sgl; + obj->get_page.last =0 ; + } + +while (obj->get_page.last +__sg_page_count (obj->get_page.sg) <= n) { + obj->get_page.last +=__sg_page_count (obj->get_page.sg++); +if (unlikely (sg_is_chain (obj->get_page.sg))) + obj->get_page.sg =sg_chain_ptr (obj->get_page.sg); + } -return NULL ; +return nth_page (sg_page (obj->get_page.sg), n - obj->get_page.last); } +static inline void i915_gem_object_pin_pages (struct drm_i915_gem_object *obj) {BUG_ON (obj->pages ==NULL );drivers/gpu/drm/i915/i915_gem.c +4
-0@@ -2178,6 +2178,10 @@ i915_gem_object_get_pages(struct drm_i915_gem_object *obj)return ret;list_add_tail (&obj->global_list, &dev_priv->mm.unbound_list); + + obj->get_page.sg = obj->pages->sgl; + obj->get_page.last =0 ; +return 0 ; }Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/70 drm/i915: Fix the flip synchronisation to consider mmioflips
In reply to Chris WilsonCurrently we emit semaphore synchronisation as if we were going to flip using the target CS engine, but we then change our minds and do the flip using the CPU. Consequently we write instructions to the ring but never use them - even to the point of filling that ring up entirely and never submitting a request.
The wrinkle in the ointment is that we have to tell a white lie to pin-to-display for it to skip the synchronisation for mmioflips as we will create a task specifically for that slow synchronisation. An oddity of note is the discrepancy in requests that we tell to pin-display to serialise to and that we then eventually wait upon. This is due to a limitation in the i915_gem_object_sync() routine that will be lifted later.
--- drivers/gpu/drm/i915/intel_display.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_display.c +11 -2
@@ -10224,6 +10224,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,enum pipe pipe = intel_crtc->pipe;struct intel_unpin_work *work;struct intel_engine_cs *ring; +bool mmio_flip;int ret;/*
@@ -10321,15 +10322,23 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc, ring = &dev_priv->ring[RCS ]; } + mmio_flip =use_mmio_flip (ring, obj); + +/* When using CS flips, we want to emit semaphores between rings. +* However, when using mmio flips we will create a task to do the +* synchronisation, so all we want here is to pin the framebuffer +* into the display plane and skip any waits. +*/ ret =intel_pin_and_fence_fb_obj (crtc->primary, fb, - crtc->primary->state, ring); + crtc->primary->state, + mmio_flip ?i915_gem_request_get_ring (obj->last_read_req) : ring);if (ret) goto cleanup_pending; work->gtt_offset =intel_plane_obj_offset (to_intel_plane (primary), obj) + intel_crtc->dspaddr_offset; -if (use_mmio_flip (ring, obj)) { +if (mmio_flip) { ret =intel_queue_mmio_flip (dev, crtc, fb, obj, ring, page_flip_flags);if (ret)
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/70 drm/i915: Ensure cache flushes prior to doing CS flips
In reply to Chris WilsonSynchronising to an object active on the same ring is a no-op, for the benefit of execbuffer scheduler. However, for CS flips this means that we can forgo checking whether the last write request of the object is actually queued and more importantly whether the cache flush for the write was emitted.
--- drivers/gpu/drm/i915/intel_display.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/intel_display.c +6 -0
@@ -10347,6 +10347,12 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,i915_gem_request_assign (&work->flip_queued_req, obj->last_write_req); }else { +if (obj->last_write_req) { + ret =i915_gem_check_olr (obj->last_write_req); +if (ret) + goto cleanup_unpin; + } + ret = dev_priv->display.queue_flip (dev, crtc, fb, obj, ring, page_flip_flags);if (ret)
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 03/70] drm/i915: Ensure cache flushes prior to doing CS flips
Quoted 7 lines · Chris Wilson
Synchronising to an object active on the same ring is a no-op, for the benefit of execbuffer scheduler. However, for CS flips this means that we can forgo checking whether the last write request of the object is actually queued and more importantly whether the cache flush for the write was emitted.
Signed-off-by Chris Wilson <[email protected]>
Does this go boom in reality, i.e. bugzilla/igt? If so I guess this should be for 4.1+cc:stable? Otherwise I think I'll punt since olr is on its demise anyway.
-Daniel
Quoted 28 lines
--- drivers/gpu/drm/i915/intel_display.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/i915/intel_display.c +6
-0@@ -10347,6 +10347,12 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,i915_gem_request_assign (&work->flip_queued_req, obj->last_write_req); }else { +if (obj->last_write_req) { + ret =i915_gem_check_olr (obj->last_write_req); +if (ret) + goto cleanup_unpin; + } + ret = dev_priv->display.queue_flip (dev, crtc, fb, obj, ring, page_flip_flags);if (ret)Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 03/70] drm/i915: Ensure cache flushes prior to doing CS flips
Quoted 7 lines · Daniel Vetter
Quoted 6 lines · Chris Wilson
Synchronising to an object active on the same ring is a no-op, for the benefit of execbuffer scheduler. However, for CS flips this means that we can forgo checking whether the last write request of the object is actually queued and more importantly whether the cache flush for the write was emitted.
Quoted 5 lines
Quoted 1 line
Signed-off-by Chris Wilson <[email protected]>Does this go boom in reality, i.e. bugzilla/igt? If so I guess this should be for 4.1+cc:stable? Otherwise I think I'll punt since olr is on its demise anyway.
Who can say for sure? Maybe
https://bugs.freedesktop.org/show_bug.cgi?id=80948 it is cache dirt(?) without a known cause.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/70 drm/i915: Agressive downclocking on Baytrail
In reply to Chris WilsonReuse the same reclocking strategy for Baytail as on its bigger brethren, Sandybridge and Ivybridge. In particular, this makes the device quicker to reclock (both up and down) though the tendency now is to downclock more aggressively to compensate for the RPS boosts.
v2: Rebase
v3: Exclude Cherrytrail as Deepak was concerned that the increased number of register writes would wake the common powerwell too often.
--- drivers/gpu/drm/i915/i915_drv.h | 3 +++ drivers/gpu/drm/i915/i915_irq.c | 4 ++-- drivers/gpu/drm/i915/i915_reg.h | 2 -- drivers/gpu/drm/i915/intel_pm.c | 8 +++++++- 4 files changed, 12 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +3 -0
@@ -1036,6 +1036,9 @@ struct intel_gen6_power_mgmt {u8 rp0_freq;/* Non-overclocked max frequency. */ u32 cz_freq; +u8 up_threshold;/* Current %busy required to uplock */ +u8 down_threshold;/* Current %busy required to downclock */ +int last_adj;enum {LOW_POWER ,BETWEEN ,HIGH_POWER } power;
drivers/gpu/drm/i915/i915_irq.c +2 -2
@@ -1049,7 +1049,7 @@ static u32 vlv_wa_c0_ei(struct drm_i915_private *dev_priv, u32 pm_iir)if (pm_iir &GEN6_PM_RP_DOWN_EI_EXPIRED ) {if (!vlv_c0_above (dev_priv, &dev_priv->rps.down_ei, &now, -VLV_RP_DOWN_EI_THRESHOLD )) + dev_priv->rps.down_threshold)) events |=GEN6_PM_RP_DOWN_THRESHOLD ; dev_priv->rps.down_ei = now; }
@@ -1057,7 +1057,7 @@ static u32 vlv_wa_c0_ei(struct drm_i915_private *dev_priv, u32 pm_iir)if (pm_iir &GEN6_PM_RP_UP_EI_EXPIRED ) {if (vlv_c0_above (dev_priv, &dev_priv->rps.up_ei, &now, -VLV_RP_UP_EI_THRESHOLD )) + dev_priv->rps.up_threshold)) events |=GEN6_PM_RP_UP_THRESHOLD ; dev_priv->rps.up_ei = now; }
drivers/gpu/drm/i915/i915_reg.h +0 -2
@@ -671,8 +671,6 @@ enum skl_disp_power_wells {#define FB_FMAX_VMIN_FREQ_LO_MASK 0xf8000000#define VLV_CZ_CLOCK_TO_MILLI_SEC 100000 -#define VLV_RP_UP_EI_THRESHOLD 90 -#define VLV_RP_DOWN_EI_THRESHOLD 70/* vlv2 north clock has */ #define CCK_FUSE_REG 0x8
drivers/gpu/drm/i915/intel_pm.c +7 -1
@@ -3934,6 +3934,8 @@ static void gen6_set_rps_thresholds(struct drm_i915_private *dev_priv, u8 val) GEN6_RP_DOWN_IDLE_AVG); dev_priv->rps.power = new_power; + dev_priv->rps.up_threshold = threshold_up; + dev_priv->rps.down_threshold = threshold_down; dev_priv->rps.last_adj =0 ; }
@@ -4005,8 +4007,11 @@ static void valleyview_set_rps(struct drm_device *dev, u8 val) "Odd GPU freq value\n")) val &= ~1 ; -if (val != dev_priv->rps.cur_freq) +if (val != dev_priv->rps.cur_freq) {vlv_punit_write (dev_priv,PUNIT_REG_GPU_FREQ_REQ , val); +if (!IS_CHERRYVIEW (dev_priv)) +gen6_set_rps_thresholds (dev_priv, val); + }I915_WRITE (GEN6_PMINTRMSK ,gen6_rps_pm_mask (dev_priv, val));
@@ -4055,6 +4060,7 @@ static void vlv_set_rps_idle(struct drm_i915_private *dev_priv) & GENFREQSTATUS) == 0, 100))DRM_ERROR ("timed out waiting for Punit\n" ); +gen6_set_rps_thresholds (dev_priv, val);vlv_force_gfx_clock (dev_priv, false);I915_WRITE (GEN6_PMINTRMSK ,gen6_rps_pm_mask (dev_priv, val));
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 5/70 drm/i915: Fix computation of last_adjustment for RPS autotuning
In reply to Chris WilsonThe issue is that by computing the last_adj value after applying the clamping, we can end up with a bogus value for feeding into the next RPS autotuning step.
--- drivers/gpu/drm/i915/i915_irq.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-)
drivers/gpu/drm/i915/i915_irq.c +12 -15
@@ -1095,21 +1095,20 @@ static void gen6_pm_rps_work(struct work_struct *work) pm_iir |=vlv_wa_c0_ei (dev_priv, pm_iir); adj = dev_priv->rps.last_adj; + new_delay = dev_priv->rps.cur_freq;if (pm_iir &GEN6_PM_RP_UP_THRESHOLD ) {if (adj >0 ) adj *=2 ; -else { -/* CHV needs even encode values */ - adj =IS_CHERRYVIEW (dev_priv->dev) ?2 :1 ; - } - new_delay = dev_priv->rps.cur_freq + adj; - +else /* CHV needs even encode values */ + adj =IS_CHERRYVIEW (dev_priv) ?2 :1 ;/* * For better performance, jump directly * to RPe if we're below it. */ -if (new_delay < dev_priv->rps.efficient_freq) +if (new_delay < dev_priv->rps.efficient_freq - adj) { new_delay = dev_priv->rps.efficient_freq; + adj =0 ; + } }else if (pm_iir &GEN6_PM_RP_DOWN_TIMEOUT ) {if (dev_priv->rps.cur_freq > dev_priv->rps.efficient_freq) new_delay = dev_priv->rps.efficient_freq;
@@ -1119,24 +1118,22 @@ static void gen6_pm_rps_work(struct work_struct *work) }else if (pm_iir &GEN6_PM_RP_DOWN_THRESHOLD ) {if (adj <0 ) adj *=2 ; -else { -/* CHV needs even encode values */ - adj =IS_CHERRYVIEW (dev_priv->dev) ?-2 :-1 ; - } - new_delay = dev_priv->rps.cur_freq + adj; +else /* CHV needs even encode values */ + adj =IS_CHERRYVIEW (dev_priv) ?-2 :-1 ; }else {/* unknown event */ - new_delay = dev_priv->rps.cur_freq; + adj =0 ; } + dev_priv->rps.last_adj = adj; +/* sysfs frequency interfaces may have snuck in while servicing the * interrupt */ + new_delay += adj; new_delay =clamp_t (int, new_delay, dev_priv->rps.min_freq_softlimit, dev_priv->rps.max_freq_softlimit); - dev_priv->rps.last_adj = new_delay - dev_priv->rps.cur_freq; -intel_set_rps (dev_priv->dev, new_delay);mutex_unlock (&dev_priv->rps.hw_lock);
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 6/70 drm/i915: Fix race on unreferencing the wrong mmio-flip-request
In reply to Chris WilsonAs we perform the mmio-flip without any locking and then try to acquire the struct_mutex prior to dereferencing the request, it is possible for userspace to queue a new pageflip before the worker can finish clearing the old state - and then it will clear the new flip request. The result is that the new flip could be completed before the GPU has finished rendering.
The bugs stems from removing the seqno checking in commit 536f5b5e86b225dab94c7ff8061ae482b6077387
Author: Ander Conselvan de Oliveira <[email protected]> Date: Thu Nov 6 11:03:40 2014 +0200
drm/i915: Make mmio flip wait for seqno in the work function
--- drivers/gpu/drm/i915/i915_drv.h | 6 ++++-- drivers/gpu/drm/i915/intel_display.c | 39 ++++++++++++++++++------------------ drivers/gpu/drm/i915/intel_drv.h | 4 ++-- 3 files changed, 25 insertions(+), 24 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +4 -2
@@ -2140,10 +2140,12 @@ i915_gem_request_get_ring(struct drm_i915_gem_request *req)return req ? req->ring :NULL ; } -static inline void +static inline struct drm_i915_gem_request *i915_gem_request_reference (struct drm_i915_gem_request *req) { -kref_get (&req->ref); +if (req) +kref_get (&req->ref); +return req; } static inline void
drivers/gpu/drm/i915/intel_display.c +19 -20
@@ -10105,22 +10105,18 @@ static void intel_do_mmio_flip(struct intel_crtc *intel_crtc)static void intel_mmio_flip_work_func (struct work_struct *work) { -struct intel_crtc *crtc = - container_of(work, struct intel_crtc, mmio_flip.work); -struct intel_mmio_flip *mmio_flip; +struct intel_mmio_flip *mmio_flip = + container_of(work, struct intel_mmio_flip, work); - mmio_flip = &crtc->mmio_flip; -if (mmio_flip->req) -WARN_ON (__i915_wait_request (mmio_flip->req, - crtc->reset_counter, - false,NULL ,NULL ) !=0 ); +if (mmio_flip->rq) +WARN_ON (__i915_wait_request (mmio_flip->rq, + mmio_flip->crtc->reset_counter, + false,NULL ,NULL )); -intel_do_mmio_flip (crtc); -if (mmio_flip->req) { -mutex_lock (&crtc->base.dev->struct_mutex); -i915_gem_request_assign (&mmio_flip->req,NULL ); -mutex_unlock (&crtc->base.dev->struct_mutex); - } +intel_do_mmio_flip (mmio_flip->crtc); + +i915_gem_request_unreference__unlocked (mmio_flip->rq); +kfree (mmio_flip); } static int intel_queue_mmio_flip(struct drm_device *dev,
@@ -10130,12 +10126,17 @@ static int intel_queue_mmio_flip(struct drm_device *dev, struct intel_engine_cs *ring, uint32_t flags) { -struct intel_crtc *intel_crtc =to_intel_crtc (crtc); +struct intel_mmio_flip *mmio_flip; + + mmio_flip =kmalloc (sizeof (*mmio_flip),GFP_KERNEL ); +if (mmio_flip ==NULL ) +return -ENOMEM ; -i915_gem_request_assign (&intel_crtc->mmio_flip.req, - obj->last_write_req); + mmio_flip->rq =i915_gem_request_reference (obj->last_write_req); + mmio_flip->crtc =to_intel_crtc (crtc); -schedule_work (&intel_crtc->mmio_flip.work); +INIT_WORK (&mmio_flip->work, intel_mmio_flip_work_func); +schedule_work (&mmio_flip->work);return 0 ; }
@@ -13059,8 +13060,6 @@ static void intel_crtc_init(struct drm_device *dev, int pipe) dev_priv->plane_to_crtc_mapping[intel_crtc->plane] = &intel_crtc->base; dev_priv->pipe_to_crtc_mapping[intel_crtc->pipe] = &intel_crtc->base; -INIT_WORK (&intel_crtc->mmio_flip.work, intel_mmio_flip_work_func); -drm_crtc_helper_add (&intel_crtc->base, &intel_helper_funcs);WARN_ON (drm_crtc_index (&intel_crtc->base) != intel_crtc->pipe);
drivers/gpu/drm/i915/intel_drv.h +2 -2
@@ -403,8 +403,9 @@ struct intel_pipe_wm { };struct intel_mmio_flip { -struct drm_i915_gem_request *req;struct work_struct work; +struct drm_i915_gem_request *rq; +struct intel_crtc *crtc; };struct skl_pipe_wm {
@@ -489,7 +490,6 @@ struct intel_crtc { } wm;int scanline_offset; -struct intel_mmio_flip mmio_flip;struct intel_crtc_atomic_commit atomic; };
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 06/70] drm/i915: Fix race on unreferencing the wrong mmio-flip-request
Quoted 9 lines · Chris Wilson
As we perform the mmio-flip without any locking and then try to acquire the
struct_mutexprior to dereferencing the request, it is possible for userspace to queue a new pageflip before the worker can finish clearing the old state - and then it will clear the new flip request. The result is that the new flip could be completed before the GPU has finished rendering.The bugs stems from removing the seqno checking in commit
536f5b5e86b225dab94c7ff8061ae482b6077387
Quoted 7 lines
Author: Ander Conselvan de Oliveira <[email protected]> Date: Thu Nov 6 11:03:40 2014 +0200drm/i915: Make mmio flip wait for seqno in the work function
Signed-off-by Chris Wilson <[email protected]>Cc Ander Conselvan de Oliveira <[email protected]>
Usual question: Does this go boom/do we have an igt?
Quoted 12 lines
--- drivers/gpu/drm/i915/i915_drv.h | 6 ++++-- drivers/gpu/drm/i915/intel_display.c | 39 ++++++++++++++++++------------------ drivers/gpu/drm/i915/intel_drv.h | 4 ++-- 3 files changed, 25 insertions(+), 24 deletions(-)drivers/gpu/drm/i915/i915_drv.h +0
-0@@ -2140,10 +2140,12 @@ i915_gem_request_get_ring(struct drm_i915_gem_request *req)return req ? req->ring :NULL ;
drivers/gpu/drm/i915/i915_drv.h i915_gem_request_get_ring(struct drm_i915_gem_request *req) · line 2148
Quoted 10 lines
drivers/gpu/drm/i915/i915_drv.h +4
-2} -static inline void +static inline struct drm_i915_gem_request *i915_gem_request_reference (struct drm_i915_gem_request *req) { -kref_get (&req->ref); +if (req) +kref_get (&req->ref); +return req;
Neat pattern but since it's different than all the other reference counting functions I don't think it's a good idea ...
Quoted 76 lines
drivers/gpu/drm/i915/i915_drv.h +0
-0} static inline voiddrivers/gpu/drm/i915/intel_display.c +19
-20@@ -10105,22 +10105,18 @@ static void intel_do_mmio_flip(struct intel_crtc *intel_crtc)static void intel_mmio_flip_work_func (struct work_struct *work) { -struct intel_crtc *crtc = - container_of(work, struct intel_crtc, mmio_flip.work); -struct intel_mmio_flip *mmio_flip; +struct intel_mmio_flip *mmio_flip = + container_of(work, struct intel_mmio_flip, work); - mmio_flip = &crtc->mmio_flip; -if (mmio_flip->req) -WARN_ON (__i915_wait_request (mmio_flip->req, - crtc->reset_counter, - false,NULL ,NULL ) !=0 ); +if (mmio_flip->rq) +WARN_ON (__i915_wait_request (mmio_flip->rq, + mmio_flip->crtc->reset_counter, + false,NULL ,NULL )); -intel_do_mmio_flip (crtc); -if (mmio_flip->req) { -mutex_lock (&crtc->base.dev->struct_mutex); -i915_gem_request_assign (&mmio_flip->req,NULL ); -mutex_unlock (&crtc->base.dev->struct_mutex); - } +intel_do_mmio_flip (mmio_flip->crtc); + +i915_gem_request_unreference__unlocked (mmio_flip->rq); +kfree (mmio_flip); } static int intel_queue_mmio_flip(struct drm_device *dev,@@ -10130,12 +10126,17 @@ static int intel_queue_mmio_flip(struct drm_device *dev, struct intel_engine_cs *ring, uint32_t flags) { -struct intel_crtc *intel_crtc =to_intel_crtc (crtc); +struct intel_mmio_flip *mmio_flip; + + mmio_flip =kmalloc (sizeof (*mmio_flip),GFP_KERNEL ); +if (mmio_flip ==NULL ) +return -ENOMEM ; -i915_gem_request_assign (&intel_crtc->mmio_flip.req, - obj->last_write_req); + mmio_flip->rq =i915_gem_request_reference (obj->last_write_req); + mmio_flip->crtc =to_intel_crtc (crtc); -schedule_work (&intel_crtc->mmio_flip.work); +INIT_WORK (&mmio_flip->work, intel_mmio_flip_work_func); +schedule_work (&mmio_flip->work);return 0 ; }@@ -13059,8 +13060,6 @@ static void intel_crtc_init(struct drm_device *dev, int pipe) dev_priv->plane_to_crtc_mapping[intel_crtc->plane] = &intel_crtc->base; dev_priv->pipe_to_crtc_mapping[intel_crtc->pipe] = &intel_crtc->base; -INIT_WORK (&intel_crtc->mmio_flip.work, intel_mmio_flip_work_func); -drm_crtc_helper_add (&intel_crtc->base, &intel_helper_funcs);WARN_ON (drm_crtc_index (&intel_crtc->base) != intel_crtc->pipe);drivers/gpu/drm/i915/intel_drv.h +0
-0
drivers/gpu/drm/i915/intel_drv.h struct intel_pipe_wm { · line 407
Quoted 6 lines
drivers/gpu/drm/i915/intel_drv.h +1
-1@@ -403,8 +403,9 @@ struct intel_pipe_wm { };struct intel_mmio_flip { -struct drm_i915_gem_request *req;struct work_struct work; +struct drm_i915_gem_request *rq;
I haven't really followed the discussion with Tvrkto, but what exactly is the distinction between req and rq again? At least to me rq sounds more like a short-form for runqueue than request, so why not just leave it at req?
Besides these two nitpick patch looks good.
-Daniel
Quoted 19 lines
drivers/gpu/drm/i915/intel_drv.h +1
-1+struct intel_crtc *crtc; };struct skl_pipe_wm {@@ -489,7 +490,6 @@ struct intel_crtc { } wm;int scanline_offset; -struct intel_mmio_flip mmio_flip;struct intel_crtc_atomic_commit atomic; };Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 7/70 drm/i915: Boost GPU frequency if we detect outstanding pageflips
In reply to Chris WilsonIf we hit a vblank and see that have a pageflip queue but not yet processed, ensure that the GPU is running at maximum in order to clear the backlog. Pageflips are only queued for the following vblank, if we miss it, there will be a visible stutter. Boosting the GPU frequency doesn't prevent us from missing the target vblank, but it should help the subsequent frames hitting theirs.
v2: Reorder vblank vs flip-complete so that we only check for a missed flip after processing the completion events, and avoid spurious boosts.
v3: Rename missed_vblank
v4: Rebase
v5: Cancel the outstanding work in runtime suspend
v6: Rebase
v7: Rebase required fixing
--- drivers/gpu/drm/i915/intel_display.c | 11 ++++++++--- drivers/gpu/drm/i915/intel_drv.h | 2 ++ drivers/gpu/drm/i915/intel_pm.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_display.c +8 -3
@@ -10195,6 +10195,7 @@ void intel_check_page_flip(struct drm_device *dev, int pipe)struct drm_i915_private *dev_priv = dev->dev_private;struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];struct intel_crtc *intel_crtc =to_intel_crtc (crtc); +struct intel_unpin_work *work;WARN_ON (!in_interrupt ());
@@ -10202,12 +10203,16 @@ void intel_check_page_flip(struct drm_device *dev, int pipe)return ;spin_lock (&dev->event_lock); -if (intel_crtc->unpin_work &&__intel_pageflip_stall_check (dev, crtc)) { + work = intel_crtc->unpin_work; +if (work !=NULL &&__intel_pageflip_stall_check (dev, crtc)) {WARN_ONCE (1 ,"Kicking stuck page flip: queued at %d, now %d\n" , - intel_crtc->unpin_work->flip_queued_vblank, -drm_vblank_count (dev, pipe)); + work->flip_queued_vblank,drm_vblank_count (dev, pipe));page_flip_completed (intel_crtc); + work =NULL ; } +if (work !=NULL && +drm_vblank_count (dev, pipe) - work->flip_queued_vblank >1 ) +intel_queue_rps_boost_for_request (dev, work->flip_queued_req);spin_unlock (&dev->event_lock); }
drivers/gpu/drm/i915/intel_drv.h +2 -0
@@ -1263,6 +1263,8 @@ void gen6_rps_busy(struct drm_i915_private *dev_priv);void gen6_rps_reset_ei (struct drm_i915_private *dev_priv);void gen6_rps_idle (struct drm_i915_private *dev_priv);void gen6_rps_boost (struct drm_i915_private *dev_priv); +void intel_queue_rps_boost_for_request (struct drm_device *dev, +struct drm_i915_gem_request *rq);void ilk_wm_get_hw_state (struct drm_device *dev);void skl_wm_get_hw_state (struct drm_device *dev); void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
drivers/gpu/drm/i915/intel_pm.c +35 -0
@@ -6772,6 +6772,41 @@ int intel_freq_opcode(struct drm_i915_private *dev_priv, int val)return val /GT_FREQUENCY_MULTIPLIER ; } +struct request_boost { +struct work_struct work; +struct drm_i915_gem_request *rq; +}; + +static void __intel_rps_boost_work (struct work_struct *work) +{ + struct request_boost *boost = container_of(work, struct request_boost, work); + +if (!i915_gem_request_completed (boost->rq, true)) +gen6_rps_boost (to_i915 (boost->rq->ring->dev)); + +i915_gem_request_unreference__unlocked (boost->rq); +kfree (boost); +} + +void intel_queue_rps_boost_for_request (struct drm_device *dev, +struct drm_i915_gem_request *rq) +{ +struct request_boost *boost; + +if (rq ==NULL ||INTEL_INFO (dev)->gen <6 ) +return ; + + boost =kmalloc (sizeof (*boost),GFP_ATOMIC ); +if (boost ==NULL ) +return ; + +i915_gem_request_reference (rq); + boost->rq = rq; + +INIT_WORK (&boost->work, __intel_rps_boost_work); +queue_work (to_i915 (dev)->wq, &boost->work); +} +void intel_pm_setup (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 07/70] drm/i915: Boost GPU frequency if we detect outstanding pageflips
Quoted 16 lines · Chris Wilson
If we hit a vblank and see that have a pageflip queue but not yet processed, ensure that the GPU is running at maximum in order to clear the backlog. Pageflips are only queued for the following vblank, if we miss it, there will be a visible stutter. Boosting the GPU frequency doesn't prevent us from missing the target vblank, but it should help the subsequent frames hitting theirs.
v2: Reorder vblank vs flip-complete so that we only check for a missed flip after processing the completion events, and avoid spurious boosts.
v3: Rename
missed_vblank
v4: Rebase
v5: Cancel the outstanding work in runtime suspend
v6: Rebase
v7: Rebase required fixing
Quoted 4 lines
Signed-off-by Chris Wilson <[email protected]>Cc Daniel Vetter <[email protected]>Cc Ville Syrjälä <[email protected]>Cc Deepak S<[email protected]>
This one also had an r-b from Deepak already, I applied all the rps tuning patches from this series.
Thanks, Daniel
Quoted 100 lines
--- drivers/gpu/drm/i915/intel_display.c | 11 ++++++++--- drivers/gpu/drm/i915/intel_drv.h | 2 ++ drivers/gpu/drm/i915/intel_pm.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/intel_display.c +8
-3@@ -10195,6 +10195,7 @@ void intel_check_page_flip(struct drm_device *dev, int pipe)struct drm_i915_private *dev_priv = dev->dev_private;struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];struct intel_crtc *intel_crtc =to_intel_crtc (crtc); +struct intel_unpin_work *work;WARN_ON (!in_interrupt ());@@ -10202,12 +10203,16 @@ void intel_check_page_flip(struct drm_device *dev, int pipe)return ;spin_lock (&dev->event_lock); -if (intel_crtc->unpin_work &&__intel_pageflip_stall_check (dev, crtc)) { + work = intel_crtc->unpin_work; +if (work !=NULL &&__intel_pageflip_stall_check (dev, crtc)) {WARN_ONCE (1 ,"Kicking stuck page flip: queued at %d, now %d\n" , - intel_crtc->unpin_work->flip_queued_vblank, -drm_vblank_count (dev, pipe)); + work->flip_queued_vblank,drm_vblank_count (dev, pipe));page_flip_completed (intel_crtc); + work =NULL ; } +if (work !=NULL && +drm_vblank_count (dev, pipe) - work->flip_queued_vblank >1 ) +intel_queue_rps_boost_for_request (dev, work->flip_queued_req);spin_unlock (&dev->event_lock); }drivers/gpu/drm/i915/intel_drv.h +2
-0@@ -1263,6 +1263,8 @@ void gen6_rps_busy(struct drm_i915_private *dev_priv);void gen6_rps_reset_ei (struct drm_i915_private *dev_priv);void gen6_rps_idle (struct drm_i915_private *dev_priv);void gen6_rps_boost (struct drm_i915_private *dev_priv); +void intel_queue_rps_boost_for_request (struct drm_device *dev, +struct drm_i915_gem_request *rq);void ilk_wm_get_hw_state (struct drm_device *dev);void skl_wm_get_hw_state (struct drm_device *dev); void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,drivers/gpu/drm/i915/intel_pm.c +35
-0@@ -6772,6 +6772,41 @@ int intel_freq_opcode(struct drm_i915_private *dev_priv, int val)return val /GT_FREQUENCY_MULTIPLIER ; } +struct request_boost { +struct work_struct work; +struct drm_i915_gem_request *rq; +}; + +static void __intel_rps_boost_work (struct work_struct *work) +{ + struct request_boost *boost = container_of(work, struct request_boost, work); + +if (!i915_gem_request_completed (boost->rq, true)) +gen6_rps_boost (to_i915 (boost->rq->ring->dev)); + +i915_gem_request_unreference__unlocked (boost->rq); +kfree (boost); +} + +void intel_queue_rps_boost_for_request (struct drm_device *dev, +struct drm_i915_gem_request *rq) +{ +struct request_boost *boost; + +if (rq ==NULL ||INTEL_INFO (dev)->gen <6 ) +return ; + + boost =kmalloc (sizeof (*boost),GFP_ATOMIC ); +if (boost ==NULL ) +return ; + +i915_gem_request_reference (rq); + boost->rq = rq; + +INIT_WORK (&boost->work, __intel_rps_boost_work); +queue_work (to_i915 (dev)->wq, &boost->work); +} +void intel_pm_setup (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;Signature · 1 line
2.1.4
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 8/70 drm/i915: Deminish contribution of wait-boosting from clients
In reply to Chris WilsonWith boosting for missed pageflips, we have a much stronger indication of when we need to (temporarily) boost GPU frequency to ensure smooth delivery of frames. So now only allow each client to perform one RPS boost in each period of GPU activity due to stalling on results.
--- drivers/gpu/drm/i915/i915_debugfs.c | 39 +++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_drv.h | 9 ++++++--- drivers/gpu/drm/i915/i915_gem.c | 35 ++++++++------------------------- drivers/gpu/drm/i915/intel_drv.h | 3 ++- drivers/gpu/drm/i915/intel_pm.c | 18 ++++++++++++++--- 5 files changed, 70 insertions(+), 34 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +39 -0
@@ -2239,6 +2239,44 @@ static int i915_ppgtt_info(struct seq_file *m, void *data)return 0 ; } +static int i915_rps_boost_info (struct seq_file *m,void *data) +{ +struct drm_info_node *node = m->private; +struct drm_device *dev = node->minor->dev; +struct drm_i915_private *dev_priv = dev->dev_private; +struct drm_file *file; +int ret; + + ret =mutex_lock_interruptible (&dev->struct_mutex); +if (ret) +return ret; + + ret =mutex_lock_interruptible (&dev_priv->rps.hw_lock); +if (ret) + goto unlock; + +list_for_each_entry_reverse (file, &dev->filelist, lhead) { +struct drm_i915_file_private *file_priv = file->driver_priv; +struct task_struct *task; + +rcu_read_lock (); + task =pid_task (file->pid,PIDTYPE_PID ); +seq_printf (m,"%s [%d]: %d boosts%s\n" , + task ? task->comm :"<unknown>" , + task ? task->pid :-1 , + file_priv->rps_boosts, +list_empty (&file_priv->rps_boost) ?"" :", active" ); +rcu_read_unlock (); + } +seq_printf (m,"Kernel boosts: %d\n" , dev_priv->rps.boosts); + +mutex_unlock (&dev_priv->rps.hw_lock); +unlock: +mutex_unlock (&dev->struct_mutex); + +return ret; +} +static int i915_llc (struct seq_file *m,void *data) {struct drm_info_node *node = m->private;
@@ -4704,6 +4742,7 @@ static const struct drm_info_list i915_debugfs_list[] = { {"i915_ddb_info", i915_ddb_info, 0}, {"i915_sseu_status", i915_sseu_status, 0}, {"i915_drrs_status", i915_drrs_status, 0}, + {"i915_rps_boost_info", i915_rps_boost_info, 0}, };#define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
drivers/gpu/drm/i915/i915_drv.h +6 -3
@@ -1044,6 +1044,8 @@ struct intel_gen6_power_mgmt {bool enabled;struct delayed_work delayed_resume_work; +struct list_head clients; +unsigned boosts;/* manual wa residency calculations */ struct intel_rps_ei up_ei, down_ei;
@@ -2193,12 +2195,13 @@ struct drm_i915_file_private {struct {spinlock_t lock;struct list_head request_list; -struct delayed_work idle_work; } mm;struct idr context_idr; -atomic_t rps_wait_boost; -struct intel_engine_cs *bsd_ring; +struct list_head rps_boost; +struct intel_engine_cs *bsd_ring; + +unsigned rps_boosts; };/*
drivers/gpu/drm/i915/i915_gem.c +8 -27
@@ -1181,14 +1181,6 @@ static bool missed_irq(struct drm_i915_private *dev_priv,return test_bit (ring->id, &dev_priv->gpu_error.missed_irq_rings); } -static bool can_wait_boost (struct drm_i915_file_private *file_priv) -{ -if (file_priv ==NULL ) -return true; - -return !atomic_xchg (&file_priv->rps_wait_boost, true); -} -/** * __i915_wait_request - wait until execution of request has finished * @req: duh!
@@ -1230,13 +1222,8 @@ int __i915_wait_request(struct drm_i915_gem_request *req, timeout_expire = timeout ? jiffies +nsecs_to_jiffies_timeout ((u64)*timeout) :0 ; -if (INTEL_INFO (dev)->gen >=6 && ring->id ==RCS &&can_wait_boost (file_priv)) { -gen6_rps_boost (dev_priv); -if (file_priv) -mod_delayed_work (dev_priv->wq, - &file_priv->mm.idle_work, -msecs_to_jiffies (100 )); - } +if (ring->id ==RCS &&INTEL_INFO (dev)->gen >=6 ) +gen6_rps_boost (dev_priv, file_priv);if (!irq_test_in_progress &&WARN_ON (!ring->irq_get (ring)))return -ENODEV ;
@@ -5084,8 +5071,6 @@ void i915_gem_release(struct drm_device *dev, struct drm_file *file) {struct drm_i915_file_private *file_priv = file->driver_priv; -cancel_delayed_work_sync (&file_priv->mm.idle_work); -/* Clean up our request list when the client is going away, so that * later retire_requests won't dereference our soon-to-be-gone * file_priv.
@@ -5101,15 +5086,12 @@ void i915_gem_release(struct drm_device *dev, struct drm_file *file) request->file_priv =NULL ; }spin_unlock (&file_priv->mm.lock); -} - -static void -i915_gem_file_idle_work_handler (struct work_struct *work) -{ -struct drm_i915_file_private *file_priv = -container_of (work,typeof (*file_priv), mm.idle_work.work); -atomic_set (&file_priv->rps_wait_boost, false); +if (!list_empty (&file_priv->rps_boost)) { +mutex_lock (&to_i915 (dev)->rps.hw_lock); +list_del (&file_priv->rps_boost); +mutex_unlock (&to_i915 (dev)->rps.hw_lock); + } }int i915_gem_open (struct drm_device *dev,struct drm_file *file)
@@ -5126,11 +5108,10 @@ int i915_gem_open(struct drm_device *dev, struct drm_file *file) file->driver_priv = file_priv; file_priv->dev_priv = dev->dev_private; file_priv->file = file; +INIT_LIST_HEAD (&file_priv->rps_boost);spin_lock_init (&file_priv->mm.lock);INIT_LIST_HEAD (&file_priv->mm.request_list); -INIT_DELAYED_WORK (&file_priv->mm.idle_work, - i915_gem_file_idle_work_handler); ret =i915_gem_context_open (dev, file);if (ret)
drivers/gpu/drm/i915/intel_drv.h +2 -1
@@ -1262,7 +1262,8 @@ void gen6_update_ring_freq(struct drm_device *dev);void gen6_rps_busy (struct drm_i915_private *dev_priv);void gen6_rps_reset_ei (struct drm_i915_private *dev_priv);void gen6_rps_idle (struct drm_i915_private *dev_priv); -void gen6_rps_boost (struct drm_i915_private *dev_priv); +void gen6_rps_boost (struct drm_i915_private *dev_priv, +struct drm_i915_file_private *file_priv);void intel_queue_rps_boost_for_request (struct drm_device *dev,struct drm_i915_gem_request *rq);void ilk_wm_get_hw_state (struct drm_device *dev);
drivers/gpu/drm/i915/intel_pm.c +15 -3
@@ -4091,10 +4091,14 @@ void gen6_rps_idle(struct drm_i915_private *dev_priv) dev_priv->rps.last_adj =0 ;I915_WRITE (GEN6_PMINTRMSK ,0xffffffff ); } + +while (!list_empty (&dev_priv->rps.clients)) +list_del_init (dev_priv->rps.clients.next);mutex_unlock (&dev_priv->rps.hw_lock); } -void gen6_rps_boost (struct drm_i915_private *dev_priv) +void gen6_rps_boost (struct drm_i915_private *dev_priv, +struct drm_i915_file_private *file_priv) {u32 val;
@@ -4102,9 +4106,16 @@ void gen6_rps_boost(struct drm_i915_private *dev_priv) val = dev_priv->rps.max_freq_softlimit;if (dev_priv->rps.enabled && dev_priv->mm.busy && - dev_priv->rps.cur_freq < val) { + dev_priv->rps.cur_freq < val && + (file_priv ==NULL ||list_empty (&file_priv->rps_boost))) {intel_set_rps (dev_priv->dev, val); dev_priv->rps.last_adj =0 ; + +if (file_priv !=NULL ) { +list_add (&file_priv->rps_boost, &dev_priv->rps.clients); + file_priv->rps_boosts++; + }else + dev_priv->rps.boosts++; }mutex_unlock (&dev_priv->rps.hw_lock); }
@@ -6782,7 +6793,7 @@ static void __intel_rps_boost_work(struct work_struct *work) struct request_boost *boost = container_of(work, struct request_boost, work);if (!i915_gem_request_completed (boost->rq, true)) -gen6_rps_boost (to_i915 (boost->rq->ring->dev)); +gen6_rps_boost (to_i915 (boost->rq->ring->dev),NULL );i915_gem_request_unreference__unlocked (boost->rq);kfree (boost);
@@ -6815,6 +6826,7 @@ void intel_pm_setup(struct drm_device *dev)INIT_DELAYED_WORK (&dev_priv->rps.delayed_resume_work, intel_gen6_powersave_work); +INIT_LIST_HEAD (&dev_priv->rps.clients); dev_priv->pm.suspended = false; }
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 9/70 drm/i915: Re-enable RPS wait-boosting for all engines
In reply to Chris WilsonThis reverts commit ec5cc0f9b019af95e4571a9fa162d94294c8d90b
Author: Chris Wilson <[email protected]> Date: Thu Jun 12 10:28:55 2014 +0100
drm/i915: Restrict GPU boost to the RCS engine
The premise that media/blitter workloads are not affected by boosting is patently false with a trip through igt. The question that remains is what exactly is going wrong with the media workload that prompted this? Hopefully that would be fixed by the missing agressive downclocking, in addition to the extra restrictions imposed on how frequent a process is allowed to boost.
--- drivers/gpu/drm/i915/i915_gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +1 -1
@@ -1222,7 +1222,7 @@ int __i915_wait_request(struct drm_i915_gem_request *req, timeout_expire = timeout ? jiffies +nsecs_to_jiffies_timeout ((u64)*timeout) :0 ; -if (ring->id ==RCS &&INTEL_INFO (dev)->gen >=6 ) +if (INTEL_INFO (dev)->gen >=6 )gen6_rps_boost (dev_priv, file_priv);if (!irq_test_in_progress &&WARN_ON (!ring->irq_get (ring)))
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 10/70 drm/i915: Split i915_gem_batch_pool into its own header
In reply to Chris WilsonIn the next patch, I want to use the structure elsewhere and so require it defined earlier. Rather than move the definition to an earlier location where it feels very odd, place it in its own header file.
--- drivers/gpu/drm/i915/i915_drv.h | 13 +-------- drivers/gpu/drm/i915/i915_gem_batch_pool.c | 1 + drivers/gpu/drm/i915/i915_gem_batch_pool.h | 42 ++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 drivers/gpu/drm/i915/i915_gem_batch_pool.h
drivers/gpu/drm/i915/i915_drv.h +1 -12
@@ -37,6 +37,7 @@#include "intel_bios.h" #include "intel_ringbuffer.h" #include "intel_lrc.h" +#include "i915_gem_batch_pool.h" #include "i915_gem_gtt.h" #include "i915_gem_render_state.h" #include <linux/io-mapping.h>
@@ -1143,11 +1144,6 @@ struct intel_l3_parity {int which_slice; }; -struct i915_gem_batch_pool { -struct drm_device *dev; -struct list_head cache_list; -}; -struct i915_gem_mm {/** Memory allocator for GTT stolen memory */ struct drm_mm stolen;
@@ -3078,13 +3074,6 @@ void i915_destroy_error_state(struct drm_device *dev);void i915_get_extra_instdone (struct drm_device *dev,uint32_t *instdone);const char *i915_cache_level_str (struct drm_i915_private *i915,int type); -/* i915_gem_batch_pool.c */ -void i915_gem_batch_pool_init (struct drm_device *dev, -struct i915_gem_batch_pool *pool); -void i915_gem_batch_pool_fini (struct i915_gem_batch_pool *pool); -struct drm_i915_gem_object * -i915_gem_batch_pool_get (struct i915_gem_batch_pool *pool,size_t size); -/* i915_cmd_parser.c */ int i915_cmd_parser_get_version (void );int i915_cmd_parser_init_ring (struct intel_engine_cs *ring);
drivers/gpu/drm/i915/i915_gem_batch_pool.c +1 -0
@@ -23,6 +23,7 @@*/ #include "i915_drv.h" +#include "i915_gem_batch_pool.h" /** * DOC: batch pool
drivers/gpu/drm/i915/i915_gem_batch_pool.h new file +42 -0
42 lines not on this page · raw message
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 11/70 drm/i915: Tidy batch pool logic
In reply to Chris WilsonMove the madvise logic out of the execbuffer main path into the relatively rare allocation path, making the execbuffer manipulation less fragile.
--- drivers/gpu/drm/i915/i915_cmd_parser.c | 12 +++------ drivers/gpu/drm/i915/i915_gem_batch_pool.c | 39 +++++++++++++++--------------- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 13 ++++------ 3 files changed, 27 insertions(+), 37 deletions(-)
drivers/gpu/drm/i915/i915_cmd_parser.c +3 -9
@@ -869,6 +869,9 @@ static u32 *copy_batch(struct drm_i915_gem_object *dest_obj, batch_len + batch_start_offset > src_obj->base.size)return ERR_PTR (-E2BIG ); +if (WARN_ON (dest_obj->pages_pin_count ==0 )) +return ERR_PTR (-ENODEV ); + ret =i915_gem_obj_prepare_shmem_read (src_obj, &needs_clflush);if (ret) {DRM_DEBUG_DRIVER ("CMD: failed to prepare shadow batch\n" );
@@ -882,13 +885,6 @@ static u32 *copy_batch(struct drm_i915_gem_object *dest_obj, goto unpin_src; } - ret =i915_gem_object_get_pages (dest_obj); -if (ret) { -DRM_DEBUG_DRIVER ("CMD: Failed to get pages for shadow batch\n" ); - goto unmap_src; - } -i915_gem_object_pin_pages (dest_obj); - ret =i915_gem_object_set_to_cpu_domain (dest_obj, true);if (ret) {DRM_DEBUG_DRIVER ("CMD: Failed to set shadow batch to CPU\n" );
@@ -898,7 +894,6 @@ static u32 *copy_batch(struct drm_i915_gem_object *dest_obj, dst =vmap_batch (dest_obj,0 , batch_len);if (!dst) {DRM_DEBUG_DRIVER ("CMD: Failed to vmap shadow batch\n" ); -i915_gem_object_unpin_pages (dest_obj); ret = -ENOMEM ; goto unmap_src; }
@@ -1129,7 +1124,6 @@ int i915_parse_cmds(struct intel_engine_cs *ring, }vunmap (batch_base); -i915_gem_object_unpin_pages (shadow_batch_obj);return ret; }
drivers/gpu/drm/i915/i915_gem_batch_pool.c +19 -20
@@ -67,25 +67,23 @@ void i915_gem_batch_pool_fini(struct i915_gem_batch_pool *pool) struct drm_i915_gem_object, batch_pool_list); -WARN_ON (obj->active); - -list_del_init (&obj->batch_pool_list); +list_del (&obj->batch_pool_list);drm_gem_object_unreference (&obj->base); } }/** -* i915_gem_batch_pool_get() - select a buffer from the pool +* i915_gem_batch_pool_get() - allocate a buffer from the pool * @pool: the batch buffer pool * @size: the minimum desired size of the returned buffer * -* Finds or allocates a batch buffer in the pool with at least the requested -* size. The caller is responsible for any domain, active/inactive, or -* purgeability management for the returned buffer. +* Returns an inactive buffer from @pool with at least @size bytes, +* with the pages pinned. The caller must i915_gem_object_unpin_pages() +* on the returned object. * * Note: Callers must hold the struct_mutex * -* Return: the selected batch buffer object +* Return: the buffer object or an error pointer */ struct drm_i915_gem_object * i915_gem_batch_pool_get(struct i915_gem_batch_pool *pool,
@@ -97,8 +95,7 @@ i915_gem_batch_pool_get(struct i915_gem_batch_pool *pool,WARN_ON (!mutex_is_locked (&pool->dev->struct_mutex));list_for_each_entry_safe (tmp, next, - &pool->cache_list, batch_pool_list) { - + &pool->cache_list, batch_pool_list) {if (tmp->active)continue ;
@@ -114,25 +111,27 @@ i915_gem_batch_pool_get(struct i915_gem_batch_pool *pool,* but not 'too much' bigger. A better way to do this * might be to bucket the pool objects based on size. */ -if (tmp->base.size >= size && - tmp->base.size <= (2 * size)) { +if (tmp->base.size >= size && tmp->base.size <=2 * size) { obj = tmp;break ; } } -if (!obj) { +if (obj ==NULL ) { +int ret; + obj =i915_gem_alloc_object (pool->dev, size); -if (!obj) +if (obj ==NULL )return ERR_PTR (-ENOMEM ); -list_add_tail (&obj->batch_pool_list, &pool->cache_list); - } -else -/* Keep list in LRU order */ -list_move_tail (&obj->batch_pool_list, &pool->cache_list); + ret =i915_gem_object_get_pages (obj); +if (ret) +return ERR_PTR (ret); - obj->madv =I915_MADV_WILLNEED ; + obj->madv =I915_MADV_DONTNEED ; + } +list_move_tail (&obj->batch_pool_list, &pool->cache_list); +i915_gem_object_pin_pages (obj);return obj; }
drivers/gpu/drm/i915/i915_gem_execbuffer.c +5 -8
@@ -37,7 +37,6 @@#define __EXEC_OBJECT_HAS_FENCE (1<<30)#define __EXEC_OBJECT_NEEDS_MAP (1<<29)#define __EXEC_OBJECT_NEEDS_BIAS (1<<28) -#define __EXEC_OBJECT_PURGEABLE (1<<27)#define BATCH_OFFSET_BIAS (256*1024)
@@ -224,12 +223,7 @@ i915_gem_execbuffer_unreserve_vma(struct i915_vma *vma)if (entry->flags & __EXEC_OBJECT_HAS_PIN) vma->pin_count--; -if (entry->flags & __EXEC_OBJECT_PURGEABLE) - obj->madv =I915_MADV_DONTNEED ; - - entry->flags &= ~(__EXEC_OBJECT_HAS_FENCE | - __EXEC_OBJECT_HAS_PIN | - __EXEC_OBJECT_PURGEABLE); + entry->flags &= ~(__EXEC_OBJECT_HAS_FENCE | __EXEC_OBJECT_HAS_PIN); }static void eb_destroy (struct eb_vmas *eb)
@@ -1185,11 +1179,13 @@ i915_gem_execbuffer_parse(struct intel_engine_cs *ring,if (ret) goto err; +i915_gem_object_unpin_pages (shadow_batch_obj); +memset (shadow_exec_entry,0 ,sizeof (*shadow_exec_entry)); vma =i915_gem_obj_to_ggtt (shadow_batch_obj); vma->exec_entry = shadow_exec_entry; - vma->exec_entry->flags = __EXEC_OBJECT_PURGEABLE | __EXEC_OBJECT_HAS_PIN; + vma->exec_entry->flags = __EXEC_OBJECT_HAS_PIN;drm_gem_object_reference (&shadow_batch_obj->base);list_add_tail (&vma->exec_list, &eb->vmas);
@@ -1198,6 +1194,7 @@ i915_gem_execbuffer_parse(struct intel_engine_cs *ring,return shadow_batch_obj; err: +i915_gem_object_unpin_pages (shadow_batch_obj);if (ret == -EACCES )/* unhandled chained batch */ return batch_obj;else
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 12/70 drm/i915: Split the batch pool by engine
In reply to Chris WilsonI woke up one morning and found 50k objects sitting in the batch pool and every search seemed to iterate the entire list... Painting the screen in oils would provide a more fluid display.
One issue with the current design is that we only check for retirements on the current ring when preparing to submit a new batch. This means that we can have thousands of "active" batches on another ring that we have to walk over. The simplest way to avoid that is to split the pools per ring and then our LRU execution ordering will also ensure that the inactive buffers remain at the front.
v2: execlists still requires duplicate code.
v3: execlists requires more duplicate code
--- drivers/gpu/drm/i915/i915_debugfs.c | 33 ++++++++++++++++++------------ drivers/gpu/drm/i915/i915_dma.c | 1 - drivers/gpu/drm/i915/i915_drv.h | 8 -------- drivers/gpu/drm/i915/i915_gem.c | 2 -- drivers/gpu/drm/i915/i915_gem_batch_pool.c | 3 ++- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 3 +-- drivers/gpu/drm/i915/intel_lrc.c | 2 ++ drivers/gpu/drm/i915/intel_ringbuffer.c | 2 ++ drivers/gpu/drm/i915/intel_ringbuffer.h | 8 ++++++++ 9 files changed, 35 insertions(+), 27 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +20 -13
@@ -377,13 +377,17 @@ static void print_batch_pool_stats(struct seq_file *m, {struct drm_i915_gem_object *obj;struct file_stats stats; +struct intel_engine_cs *ring; +int i;memset (&stats,0 ,sizeof (stats)); -list_for_each_entry (obj, - &dev_priv->mm.batch_pool.cache_list, - batch_pool_list) -per_file_stats (0 , obj, &stats); +for_each_ring (ring, dev_priv, i) { +list_for_each_entry (obj, + &ring->batch_pool.cache_list, + batch_pool_list) +per_file_stats (0 , obj, &stats); + }print_file_stats (m,"batch pool" , stats); }
@@ -613,21 +617,24 @@ static int i915_gem_batch_pool_info(struct seq_file *m, void *data)struct drm_device *dev = node->minor->dev;struct drm_i915_private *dev_priv = dev->dev_private;struct drm_i915_gem_object *obj; +struct intel_engine_cs *ring;int count =0 ; -int ret; +int ret, i; ret =mutex_lock_interruptible (&dev->struct_mutex);if (ret)return ret; -seq_puts (m,"cache:\n" ); -list_for_each_entry (obj, - &dev_priv->mm.batch_pool.cache_list, - batch_pool_list) { -seq_puts (m," " ); -describe_obj (m, obj); -seq_putc (m,'\n' ); - count++; +for_each_ring (ring, dev_priv, i) { +seq_printf (m,"%s cache:\n" , ring->name); +list_for_each_entry (obj, + &ring->batch_pool.cache_list, + batch_pool_list) { +seq_puts (m," " ); +describe_obj (m, obj); +seq_putc (m,'\n' ); + count++; + } }seq_printf (m,"total: %d\n" , count);
drivers/gpu/drm/i915/i915_dma.c +0 -1
@@ -1076,7 +1076,6 @@ int i915_driver_unload(struct drm_device *dev)mutex_lock (&dev->struct_mutex);i915_gem_cleanup_ringbuffer (dev); -i915_gem_batch_pool_fini (&dev_priv->mm.batch_pool);i915_gem_context_fini (dev);mutex_unlock (&dev->struct_mutex);i915_gem_cleanup_stolen (dev);
drivers/gpu/drm/i915/i915_drv.h +0 -8
@@ -37,7 +37,6 @@#include "intel_bios.h" #include "intel_ringbuffer.h" #include "intel_lrc.h" -#include "i915_gem_batch_pool.h" #include "i915_gem_gtt.h" #include "i915_gem_render_state.h" #include <linux/io-mapping.h>
@@ -1157,13 +1156,6 @@ struct i915_gem_mm {*/ struct list_head unbound_list; -/* -* A pool of objects to use as shadow copies of client batch buffers -* when the command parser is enabled. Prevents the client from -* modifying the batch contents after software parsing. -*/ -struct i915_gem_batch_pool batch_pool; -/** Usable portion of the GTT for GEM */ unsigned long stolen_base;/* limited to low memory (32-bit) */
drivers/gpu/drm/i915/i915_gem.c +0 -2
@@ -5062,8 +5062,6 @@ i915_gem_load(struct drm_device *dev)i915_gem_shrinker_init (dev_priv); -i915_gem_batch_pool_init (dev, &dev_priv->mm.batch_pool); -mutex_init (&dev_priv->fb_tracking.lock); }
drivers/gpu/drm/i915/i915_gem_batch_pool.c +2 -1
@@ -96,8 +96,9 @@ i915_gem_batch_pool_get(struct i915_gem_batch_pool *pool,list_for_each_entry_safe (tmp, next, &pool->cache_list, batch_pool_list) { +/* The batches are strictly LRU ordered */ if (tmp->active) -continue ; +break ;/* While we're looping, do some clean up */ if (tmp->madv == __I915_MADV_PURGED) {
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -2
@@ -1156,12 +1156,11 @@ i915_gem_execbuffer_parse(struct intel_engine_cs *ring, u32 batch_len, bool is_master) { -struct drm_i915_private *dev_priv =to_i915 (batch_obj->base.dev);struct drm_i915_gem_object *shadow_batch_obj;struct i915_vma *vma;int ret; - shadow_batch_obj =i915_gem_batch_pool_get (&dev_priv->mm.batch_pool, + shadow_batch_obj =i915_gem_batch_pool_get (&ring->batch_pool,PAGE_ALIGN (batch_len));if (IS_ERR (shadow_batch_obj))return shadow_batch_obj;
drivers/gpu/drm/i915/intel_lrc.c +2 -0
@@ -1383,6 +1383,7 @@ void intel_logical_ring_cleanup(struct intel_engine_cs *ring) ring->cleanup (ring);i915_cmd_parser_fini_ring (ring); +i915_gem_batch_pool_fini (&ring->batch_pool);if (ring->status_page.obj) {kunmap (sg_page (ring->status_page.obj->pages->sgl));
@@ -1400,6 +1401,7 @@ static int logical_ring_init(struct drm_device *dev, struct intel_engine_cs *rin ring->dev = dev;INIT_LIST_HEAD (&ring->active_list);INIT_LIST_HEAD (&ring->request_list); +i915_gem_batch_pool_init (dev, &ring->batch_pool);init_waitqueue_head (&ring->irq_queue);INIT_LIST_HEAD (&ring->execlist_queue);
drivers/gpu/drm/i915/intel_ringbuffer.c +2 -0
@@ -1983,6 +1983,7 @@ static int intel_init_ring_buffer(struct drm_device *dev,INIT_LIST_HEAD (&ring->active_list);INIT_LIST_HEAD (&ring->request_list);INIT_LIST_HEAD (&ring->execlist_queue); +i915_gem_batch_pool_init (dev, &ring->batch_pool); ringbuf->size =32 *PAGE_SIZE ; ringbuf->ring = ring;memset (ring->semaphore.sync_seqno,0 ,sizeof (ring->semaphore.sync_seqno));
@@ -2061,6 +2062,7 @@ void intel_cleanup_ring_buffer(struct intel_engine_cs *ring)cleanup_status_page (ring);i915_cmd_parser_fini_ring (ring); +i915_gem_batch_pool_fini (&ring->batch_pool);kfree (ringbuf); ring->buffer =NULL ;
drivers/gpu/drm/i915/intel_ringbuffer.h +8 -0
@@ -2,6 +2,7 @@#define _INTEL_RINGBUFFER_H_#include <linux/hashtable.h> +#include "i915_gem_batch_pool.h" #define I915_CMD_HASH_ORDER 9
@@ -133,6 +134,13 @@ struct intel_engine_cs {struct drm_device *dev;struct intel_ringbuffer *buffer; +/* +* A pool of objects to use as shadow copies of client batch buffers +* when the command parser is enabled. Prevents the client from +* modifying the batch contents after software parsing. +*/ +struct i915_gem_batch_pool batch_pool; +struct intel_hw_status_page status_page;unsigned irq_refcount;/* protected by dev_priv->irq_lock */
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 13/70 drm/i915: Free batch pool when idle
In reply to Chris WilsonAt runtime, this helps ensure that the batch pools are kept trim and fast. Then at suspend, this releases memory that we do not need to restore. It also ties into the oom-notifier to ensure that we recover as much kernel memory as possible during OOM.
--- drivers/gpu/drm/i915/i915_gem.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +12 -1
@@ -2795,8 +2795,19 @@ i915_gem_idle_work_handler(struct work_struct *work) {struct drm_i915_private *dev_priv =container_of (work,typeof (*dev_priv), mm.idle_work.work); +struct drm_device *dev = dev_priv->dev; + +intel_mark_idle (dev); -intel_mark_idle (dev_priv->dev); +if (mutex_trylock (&dev->struct_mutex)) { +struct intel_engine_cs *ring; +int i; + +for_each_ring (ring, dev_priv, i) +i915_gem_batch_pool_fini (&ring->batch_pool); + +mutex_unlock (&dev->struct_mutex); + } }/**
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 14/70 drm/i915: Split batch pool into size buckets
In reply to Chris WilsonNow with the trimmed memcpy before the command parser, we try to allocate many different sizes of batches, predominantly one or two pages. We can therefore speed up searching for a good sized batch by keeping the objects of buckets of roughly the same size.
v2: Add a comment about bucket sizes
--- drivers/gpu/drm/i915/i915_debugfs.c | 46 ++++++++++++++++++---------- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/i915_gem.c | 2 +- drivers/gpu/drm/i915/i915_gem_batch_pool.c | 49 +++++++++++++++++++----------- drivers/gpu/drm/i915/i915_gem_batch_pool.h | 2 +- 5 files changed, 64 insertions(+), 37 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +30 -16
@@ -378,15 +378,17 @@ static void print_batch_pool_stats(struct seq_file *m,struct drm_i915_gem_object *obj;struct file_stats stats;struct intel_engine_cs *ring; -int i; +int i, j;memset (&stats,0 ,sizeof (stats));for_each_ring (ring, dev_priv, i) { -list_for_each_entry (obj, - &ring->batch_pool.cache_list, - batch_pool_list) -per_file_stats (0 , obj, &stats); +for (j =0 ; j <ARRAY_SIZE (ring->batch_pool.cache_list); j++) { +list_for_each_entry (obj, + &ring->batch_pool.cache_list[j], + batch_pool_link) +per_file_stats (0 , obj, &stats); + } }print_file_stats (m,"batch pool" , stats);
@@ -618,26 +620,38 @@ static int i915_gem_batch_pool_info(struct seq_file *m, void *data)struct drm_i915_private *dev_priv = dev->dev_private;struct drm_i915_gem_object *obj;struct intel_engine_cs *ring; -int count =0 ; -int ret, i; +int total =0 ; +int ret, i, j; ret =mutex_lock_interruptible (&dev->struct_mutex);if (ret)return ret;for_each_ring (ring, dev_priv, i) { -seq_printf (m,"%s cache:\n" , ring->name); -list_for_each_entry (obj, - &ring->batch_pool.cache_list, - batch_pool_list) { -seq_puts (m," " ); -describe_obj (m, obj); -seq_putc (m,'\n' ); - count++; +for (j =0 ; j <ARRAY_SIZE (ring->batch_pool.cache_list); j++) { +int count; + + count =0 ; +list_for_each_entry (obj, + &ring->batch_pool.cache_list[j], + batch_pool_link) + count++; +seq_printf (m,"%s cache[%d]: %d objects\n" , + ring->name, j, count); + +list_for_each_entry (obj, + &ring->batch_pool.cache_list[j], + batch_pool_link) { +seq_puts (m," " ); +describe_obj (m, obj); +seq_putc (m,'\n' ); + } + + total += count; } } -seq_printf (m,"total: %d\n" , count); +seq_printf (m,"total: %d\n" , total);mutex_unlock (&dev->struct_mutex);
drivers/gpu/drm/i915/i915_drv.h +1 -1
@@ -1911,7 +1911,7 @@ struct drm_i915_gem_object {/** Used in execbuf to temporarily hold a ref */ struct list_head obj_exec_link; -struct list_head batch_pool_list; +struct list_head batch_pool_link;/** * This is set if the object is on the active lists (has pending
drivers/gpu/drm/i915/i915_gem.c +1 -1
@@ -4450,7 +4450,7 @@ void i915_gem_object_init(struct drm_i915_gem_object *obj,INIT_LIST_HEAD (&obj->ring_list);INIT_LIST_HEAD (&obj->obj_exec_link);INIT_LIST_HEAD (&obj->vma_list); -INIT_LIST_HEAD (&obj->batch_pool_list); +INIT_LIST_HEAD (&obj->batch_pool_link); obj->ops = ops;
drivers/gpu/drm/i915/i915_gem_batch_pool.c +31 -18
90 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem_batch_pool.h +1 -1
@@ -29,7 +29,7 @@struct i915_gem_batch_pool {struct drm_device *dev; -struct list_head cache_list; +struct list_head cache_list[4 ]; };/* i915_gem_batch_pool.c */
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 15/70 drm/i915: Include active flag when describing objects in debugfs
In reply to Chris WilsonSince we use obj->active as a hint in many places throughout the code, knowing its state in debugfs is extremely useful.
--- drivers/gpu/drm/i915/i915_debugfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_debugfs.c +2 -1
@@ -123,8 +123,9 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)struct i915_vma *vma;int pin_count =0 ; - seq_printf(m, "%pK: %s%s%s %8zdKiB %02x %02x %x %x %x%s%s%s", + seq_printf(m, "%pK: %s%s%s%s %8zdKiB %02x %02x %x %x %x%s%s%s", &obj->base, + obj->active ? "*" : " ", get_pin_flag(obj), get_tiling_flag(obj), get_global_flag(obj),
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 15/70] drm/i915: Include active flag when describing objects in debugfs
Quoted 5 lines · Chris Wilson
Since we use
obj->activeas a hint in many places throughout the code, knowing its state in debugfs is extremely useful.Signed-off-by Chris Wilson <[email protected]>Reviewed-by Tvrtko Ursulin <[email protected]>
Merged all the batch pool tuning plus this one with Tvrtko's review.
Thanks, Daniel
Quoted 26 lines
--- drivers/gpu/drm/i915/i915_debugfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/i915_debugfs.c +2
-1@@ -123,8 +123,9 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)struct i915_vma *vma;int pin_count =0 ; - seq_printf(m, "%pK: %s%s%s %8zdKiB %02x %02x %x %x %x%s%s%s", + seq_printf(m, "%pK: %s%s%s%s %8zdKiB %02x %02x %x %x %x%s%s%s", &obj->base, + obj->active ? "*" : " ", get_pin_flag(obj), get_tiling_flag(obj), get_global_flag(obj),Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 16/70 drm/i915: Suppress empty lines from debugfs/i915_gem_objects
In reply to Chris WilsonThis is just so that I don't have to read about the batch pool on systems that are not using it! Rather than using a newline between the kernel clients and userspace clients, just distinguish the internal allocations with a '[k]'
--- drivers/gpu/drm/i915/i915_debugfs.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +13 -13
@@ -362,16 +362,18 @@ static int per_file_stats(int id, void *ptr, void *data)return 0 ; } -#define print_file_stats (m, name, stats) \ - seq_printf(m, "%s: %u objects, %zu bytes (%zu active, %zu inactive, %zu global, %zu shared, %zu unbound)\n", \ - name, \ - stats.count, \ - stats.total, \ - stats.active, \ - stats.inactive, \ - stats.global, \ - stats.shared, \ - stats.unbound) +#define print_file_stats (m, name, stats) do { \ + if (stats.count) \ + seq_printf(m, "%s: %u objects, %zu bytes (%zu active, %zu inactive, %zu global, %zu shared, %zu unbound)\n", \ + name, \ + stats.count, \ + stats.total, \ + stats.active, \ + stats.inactive, \ + stats.global, \ + stats.shared, \ + stats.unbound); \ +} while (0)static void print_batch_pool_stats (struct seq_file *m,struct drm_i915_private *dev_priv)
@@ -392,7 +394,7 @@ static void print_batch_pool_stats(struct seq_file *m, } } -print_file_stats (m,"batch pool" , stats); +print_file_stats (m,"[k]batch pool" , stats); }#define count_vmas (list, member) do { \
@@ -478,8 +480,6 @@ static int i915_gem_object_info(struct seq_file *m, void* data)seq_putc (m,'\n' );print_batch_pool_stats (m, dev_priv); - -seq_putc (m,'\n' );list_for_each_entry_reverse (file, &dev->filelist, lhead) {struct file_stats stats;struct task_struct *task;
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Daniel Vetter
AppliedRe: [PATCH 16/70] drm/i915: Suppress empty lines from debugfs/i915_gem_objects
Quoted 6 lines · Chris Wilson
This is just so that I don't have to read about the batch pool on systems that are not using it! Rather than using a newline between the kernel clients and userspace clients, just distinguish the internal allocations with a '[k]'
Signed-off-by Chris Wilson <[email protected]>
Queued for -next, thanks for the patch.
-Daniel
Quoted 62 lines
--- drivers/gpu/drm/i915/i915_debugfs.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +13
-13@@ -362,16 +362,18 @@ static int per_file_stats(int id, void *ptr, void *data)return 0 ; } -#define print_file_stats (m, name, stats) \ - seq_printf(m, "%s: %u objects, %zu bytes (%zu active, %zu inactive, %zu global, %zu shared, %zu unbound)\n", \ - name, \ - stats.count, \ - stats.total, \ - stats.active, \ - stats.inactive, \ - stats.global, \ - stats.shared, \ - stats.unbound) +#define print_file_stats (m, name, stats) do { \ + if (stats.count) \ + seq_printf(m, "%s: %u objects, %zu bytes (%zu active, %zu inactive, %zu global, %zu shared, %zu unbound)\n", \ + name, \ + stats.count, \ + stats.total, \ + stats.active, \ + stats.inactive, \ + stats.global, \ + stats.shared, \ + stats.unbound); \ +} while (0)static void print_batch_pool_stats (struct seq_file *m,struct drm_i915_private *dev_priv)@@ -392,7 +394,7 @@ static void print_batch_pool_stats(struct seq_file *m, } } -print_file_stats (m,"batch pool" , stats); +print_file_stats (m,"[k]batch pool" , stats); }#define count_vmas (list, member) do { \@@ -478,8 +480,6 @@ static int i915_gem_object_info(struct seq_file *m, void* data)seq_putc (m,'\n' );print_batch_pool_stats (m, dev_priv); - -seq_putc (m,'\n' );list_for_each_entry_reverse (file, &dev->filelist, lhead) {struct file_stats stats;struct task_struct *task;Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 17/70 drm/i915: Optimistically spin for the request completion
In reply to Chris WilsonThis provides a nice boost to mesa in swap bound scenarios (as mesa throttles itself to the previous frame and given the scenario that will complete shortly). It will also provide a good boost to systems running with semaphores disabled and so frequently waiting on the GPU as it switches rings. In the most favourable of microbenchmarks, this can increase performance by around 15% - though in practice improvements will be marginal and rarely noticeable.
v2: Account for user timeouts
v3: Limit the spinning to a single jiffie (~1us) at most. On an otherwise idle system, there is no scheduler contention and so without a limit we would spin until the GPU is ready.
v4: Drop forcewake - the lazy coherent access doesn't require it, and we have no reason to believe that the forcewake itself improves seqno coherency - it only adds delay.
--- drivers/gpu/drm/i915/i915_gem.c | 44 +++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +38 -6
@@ -1181,6 +1181,29 @@ static bool missed_irq(struct drm_i915_private *dev_priv,return test_bit (ring->id, &dev_priv->gpu_error.missed_irq_rings); } +static int __i915_spin_request (struct drm_i915_gem_request *rq) +{ +unsigned long timeout; + +if (i915_gem_request_get_ring (rq)->irq_refcount) +return -EBUSY ; + + timeout = jiffies +1 ; +while (!need_resched ()) { +if (i915_gem_request_completed (rq, true)) +return 0 ; + +if (time_after_eq (jiffies, timeout)) +break ; + +cpu_relax_lowlatency (); + } +if (i915_gem_request_completed (rq, false)) +return 0 ; + +return -EAGAIN ; +} +/** * __i915_wait_request - wait until execution of request has finished * @req: duh!
@@ -1225,12 +1248,20 @@ int __i915_wait_request(struct drm_i915_gem_request *req,if (INTEL_INFO (dev)->gen >=6 )gen6_rps_boost (dev_priv, file_priv); -if (!irq_test_in_progress &&WARN_ON (!ring->irq_get (ring))) -return -ENODEV ; -/* Record current time in case interrupted by signal, or wedged */ trace_i915_gem_request_wait_begin (req); before =ktime_get_raw_ns (); + +/* Optimistic spin for the next jiffie before touching IRQs */ + ret =__i915_spin_request (req); +if (ret ==0 ) + goto out; + +if (!irq_test_in_progress &&WARN_ON (!ring->irq_get (ring))) { + ret = -ENODEV ; + goto out; + } +for (;;) {struct timer_list timer;
@@ -1279,14 +1310,15 @@ int __i915_wait_request(struct drm_i915_gem_request *req,destroy_timer_on_stack (&timer); } } - now =ktime_get_raw_ns (); -trace_i915_gem_request_wait_end (req); -if (!irq_test_in_progress) ring->irq_put (ring);finish_wait (&ring->irq_queue, &wait); +out: + now =ktime_get_raw_ns (); +trace_i915_gem_request_wait_end (req); +if (timeout) {s64 tres = *timeout - (now - before);
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 17/70] drm/i915: Optimistically spin for the request completion
Quoted 16 lines · Chris Wilson
This provides a nice boost to mesa in swap bound scenarios (as mesa throttles itself to the previous frame and given the scenario that will complete shortly). It will also provide a good boost to systems running with semaphores disabled and so frequently waiting on the GPU as it switches rings. In the most favourable of microbenchmarks, this can increase performance by around 15% - though in practice improvements will be marginal and rarely noticeable.
v2: Account for user timeouts
v3: Limit the spinning to a single jiffie (~1us) at most. On an otherwise idle system, there is no scheduler contention and so without a limit we would spin until the GPU is ready.
v4: Drop forcewake - the lazy coherent access doesn't require it, and we have no reason to believe that the forcewake itself improves seqno coherency - it only adds delay.
Quoted 5 lines
Signed-off-by Chris Wilson <[email protected]>Cc Daniel Vetter <[email protected]>Cc Tvrtko Ursulin <[email protected]>Cc Eero Tamminen <[email protected]>Cc "Rantala, Valtteri" <[email protected]>
Eero/Valtterri, do you have perf data for this one?
Thanks, Daniel
Quoted 84 lines
--- drivers/gpu/drm/i915/i915_gem.c | 44 +++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-)drivers/gpu/drm/i915/i915_gem.c +38
-6@@ -1181,6 +1181,29 @@ static bool missed_irq(struct drm_i915_private *dev_priv,return test_bit (ring->id, &dev_priv->gpu_error.missed_irq_rings); } +static int __i915_spin_request (struct drm_i915_gem_request *rq) +{ +unsigned long timeout; + +if (i915_gem_request_get_ring (rq)->irq_refcount) +return -EBUSY ; + + timeout = jiffies +1 ; +while (!need_resched ()) { +if (i915_gem_request_completed (rq, true)) +return 0 ; + +if (time_after_eq (jiffies, timeout)) +break ; + +cpu_relax_lowlatency (); + } +if (i915_gem_request_completed (rq, false)) +return 0 ; + +return -EAGAIN ; +} +/** * __i915_wait_request - wait until execution of request has finished * @req: duh! @@ -1225,12 +1248,20 @@ int __i915_wait_request(struct drm_i915_gem_request *req,if (INTEL_INFO (dev)->gen >=6 )gen6_rps_boost (dev_priv, file_priv); -if (!irq_test_in_progress &&WARN_ON (!ring->irq_get (ring))) -return -ENODEV ; -/* Record current time in case interrupted by signal, or wedged */ trace_i915_gem_request_wait_begin (req); before =ktime_get_raw_ns (); + +/* Optimistic spin for the next jiffie before touching IRQs */ + ret =__i915_spin_request (req); +if (ret ==0 ) + goto out; + +if (!irq_test_in_progress &&WARN_ON (!ring->irq_get (ring))) { + ret = -ENODEV ; + goto out; + } +for (;;) {struct timer_list timer;@@ -1279,14 +1310,15 @@ int __i915_wait_request(struct drm_i915_gem_request *req,destroy_timer_on_stack (&timer); } } - now =ktime_get_raw_ns (); -trace_i915_gem_request_wait_end (req); -if (!irq_test_in_progress) ring->irq_put (ring);finish_wait (&ring->irq_queue, &wait); +out: + now =ktime_get_raw_ns (); +trace_i915_gem_request_wait_end (req); +if (timeout) {s64 tres = *timeout - (now - before);Signature · 1 line
2.1.4
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 17/70] drm/i915: Optimistically spin for the request completion
Hi,
Quoted 26 lines
-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Wednesday, April 08, 2015 2:40 PM
To: Chris Wilson
Cc: [email protected]; Daniel Vetter; Tvrtko Ursulin; Tamminen, Eero T; Rantala, Valtteri
Subject: Re: [PATCH 17/70] drm/i915: Optimistically spin for the request completionQuoted 16 lines · Chris Wilson
This provides a nice boost to mesa in swap bound scenarios (as mesa throttles itself to the previous frame and given the scenario that will complete shortly). It will also provide a good boost to systems running with semaphores disabled and so frequently waiting on the GPU as it switches rings. In the most favourable of microbenchmarks, this can increase performance by around 15% - though in practice improvements will be marginal and rarely noticeable.
v2: Account for user timeouts
v3: Limit the spinning to a single jiffie (~1us) at most. On an otherwise idle system, there is no scheduler contention and so without a limit we would spin until the GPU is ready.
v4: Drop forcewake - the lazy coherent access doesn't require it, and we have no reason to believe that the forcewake itself improves seqno coherency - it only adds delay.
Quoted 8 lines
Quoted 5 lines
Signed-off-by Chris Wilson <[email protected]>Cc Daniel Vetter <[email protected]>Cc Tvrtko Ursulin <[email protected]>Cc Eero Tamminen <[email protected]>Cc "Rantala, Valtteri" <[email protected]>Eero/Valtterri, do you have perf data for this one?
[Rantala, Valtteri]
I have issues with applying this patch to latest night, have to check that out.
Can you provide Git/branch that I could use?
--
Valtteri
Quoted 88 lines
Thanks, Daniel
drivers/gpu/drm/i915/i915_gem.c static bool missed_irq(struct drm_i915_private
Quoted 11 lines
--- drivers/gpu/drm/i915/i915_gem.c | 44 +++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/i915/i915_gem.cindexc7d9ee2f708a..47650327204e100644drivers/gpu/drm/i915/i915_gem.c +0
-0@@ -1181,6 +1181,29 @@ static bool missed_irq(struct drm_i915_private
*dev_priv,drivers/gpu/drm/i915/i915_gem.c int __i915_wait_request(struct
Quoted 29 lines
drivers/gpu/drm/i915/i915_gem.c +22
-0return test_bit (ring->id, &dev_priv->gpu_error.missed_irq_rings); } +static int __i915_spin_request (struct drm_i915_gem_request *rq) { +unsigned long timeout; + +if (i915_gem_request_get_ring (rq)->irq_refcount) +return -EBUSY ; + + timeout = jiffies +1 ; +while (!need_resched ()) { +if (i915_gem_request_completed (rq, true)) +return 0 ; + +if (time_after_eq (jiffies, timeout)) +break ; + +cpu_relax_lowlatency (); + } +if (i915_gem_request_completed (rq, false)) +return 0 ; + +return -EAGAIN ; +} +/** * __i915_wait_request - wait until execution of request has finished * @req: duh! @@ -1225,12 +1248,20 @@ int __i915_wait_request(struct
drm_i915_gem_request*req,drivers/gpu/drm/i915/i915_gem.c int __i915_wait_request(struct drm_i915_gem_request *req,
Quoted 7 lines
drivers/gpu/drm/i915/i915_gem.c +0
-3if (INTEL_INFO (dev)->gen >=6 )gen6_rps_boost (dev_priv, file_priv); -if (!irq_test_in_progress &&WARN_ON (!ring->irq_get (ring))) -return -ENODEV ; -/* Record current time in case interrupted by signal, or wedged */
drivers/gpu/drm/i915/i915_gem.c int __i915_wait_request(struct
Quoted 17 lines
drivers/gpu/drm/i915/i915_gem.c +11
-0trace_i915_gem_request_wait_begin (req); before =ktime_get_raw_ns (); + +/* Optimistic spin for the next jiffie before touching IRQs */ + ret =__i915_spin_request (req); +if (ret ==0 ) + goto out; + +if (!irq_test_in_progress &&WARN_ON (!ring->irq_get (ring))) { + ret = -ENODEV ; + goto out; + } +for (;;) {struct timer_list timer;@@ -1279,14 +1310,15 @@ int __i915_wait_request(struct
drm_i915_gem_request*req,Quoted 18 lines
drivers/gpu/drm/i915/i915_gem.c +4
-3destroy_timer_on_stack (&timer); } } - now =ktime_get_raw_ns (); -trace_i915_gem_request_wait_end (req); -if (!irq_test_in_progress) ring->irq_put (ring);finish_wait (&ring->irq_queue, &wait); +out: + now =ktime_get_raw_ns (); +trace_i915_gem_request_wait_end (req); +if (timeout) {s64 tres = *timeout - (now - before);
Quoted 8 lines
Quoted 3 lines
--
2.1.4--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki
Business Identity Code: 0357606 - 4
Domiciled in Helsinki
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 17/70] drm/i915: Optimistically spin for the request completion
Quoted 35 lines · Valtteri
Hi,
Quoted 32 lines
-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Wednesday, April 08, 2015 2:40 PM
To: Chris Wilson
Cc: [email protected]; Daniel Vetter; Tvrtko Ursulin; Tamminen, Eero T; Rantala, Valtteri
Subject: Re: [PATCH 17/70] drm/i915: Optimistically spin for the request completionQuoted 21 lines · Chris Wilson
This provides a nice boost to mesa in swap bound scenarios (as mesa throttles itself to the previous frame and given the scenario that will complete shortly). It will also provide a good boost to systems running with semaphores disabled and so frequently waiting on the GPU as it switches rings. In the most favourable of microbenchmarks, this can increase performance by around 15% - though in practice improvements will be marginal and rarely noticeable.
v2: Account for user timeouts
v3: Limit the spinning to a single jiffie (~1us) at most. On an otherwise idle system, there is no scheduler contention and so without a limit we would spin until the GPU is ready.
v4: Drop forcewake - the lazy coherent access doesn't require it, and we have no reason to believe that the forcewake itself improves seqno coherency - it only adds delay.Signed-off-by Chris Wilson <[email protected]>Cc Daniel Vetter <[email protected]>Cc Tvrtko Ursulin <[email protected]>Cc Eero Tamminen <[email protected]>Cc "Rantala, Valtteri" <[email protected]>
Quoted 6 lines
Quoted 2 lines
Eero/Valtterri, do you have perf data for this one?
[Rantala, Valtteri]
I have issues with applying this patch to latest night, have to check that out.Can you provide Git/branch that I could use?
It applies cleanly here afaict - you double-checked that you updated drm-intel.git? Just today I merged a pile of patches from Chris' series here.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 17/70] drm/i915: Optimistically spin for the request completion
In reply to Chris WilsonHi,
Quoted 16 lines · Chris Wilson
This provides a nice boost to mesa in swap bound scenarios (as mesa throttles itself to the previous frame and given the scenario that will complete shortly). It will also provide a good boost to systems running with semaphores disabled and so frequently waiting on the GPU as it switches rings. In the most favourable of microbenchmarks, this can increase performance by around 15% - though in practice improvements will be marginal and rarely noticeable.
v2: Account for user timeouts
v3: Limit the spinning to a single jiffie (~1us) at most. On an otherwise idle system, there is no scheduler contention and so without a limit we would spin until the GPU is ready.
v4: Drop forcewake - the lazy coherent access doesn't require it, and we have no reason to believe that the forcewake itself improves seqno coherency - it only adds delay.
Quoted 5 lines
Signed-off-by Chris Wilson <[email protected]>Cc Daniel Vetter <[email protected]>Cc Tvrtko Ursulin <[email protected]>Cc Eero Tamminen <[email protected]>Cc "Rantala, Valtteri" <[email protected]>
I already said that I already gave my r-b for this one. :)
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Daniel Vetter
AppliedRe: [PATCH 17/70] drm/i915: Optimistically spin for the request completion
Quoted 26 lines · Tvrtko Ursulin
Hi,
Quoted 16 lines · Chris Wilson
This provides a nice boost to mesa in swap bound scenarios (as mesa throttles itself to the previous frame and given the scenario that will complete shortly). It will also provide a good boost to systems running with semaphores disabled and so frequently waiting on the GPU as it switches rings. In the most favourable of microbenchmarks, this can increase performance by around 15% - though in practice improvements will be marginal and rarely noticeable.
v2: Account for user timeouts
v3: Limit the spinning to a single jiffie (~1us) at most. On an otherwise idle system, there is no scheduler contention and so without a limit we would spin until the GPU is ready.
v4: Drop forcewake - the lazy coherent access doesn't require it, and we have no reason to believe that the forcewake itself improves seqno coherency - it only adds delay.Quoted 5 lines
Signed-off-by Chris Wilson <[email protected]>Cc Daniel Vetter <[email protected]>Cc Tvrtko Ursulin <[email protected]>Cc Eero Tamminen <[email protected]>Cc "Rantala, Valtteri" <[email protected]>
Quoted 3 lines
I already said that I already gave my r-b for this one. :)
Reviewed-by Tvrtko Ursulin <[email protected]>
Queued for -next, thanks for the patch.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 18/70 drm/i915: Implement inter-engine read-read optimisations
In reply to Chris WilsonCurrently, we only track the last request globally across all engines. This prevents us from issuing concurrent read requests on e.g. the RCS and BCS engines (or more likely the render and media engines). Without semaphores, we incur costly stalls as we synchronise between rings - greatly impacting the current performance of Broadwell versus Haswell in certain workloads (like video decode). With the introduction of reference counted requests, it is much easier to track the last request per ring, as well as the last global write request so that we can optimise inter-engine read read requests (as well as better optimise certain CPU waits).
v2: Fix inverted readonly condition for nonblocking waits.
v3: Handle non-continguous engine array after waits
v4: Rebase, tidy, rewrite ring list debugging
v5: Use obj->active as a bitfield, it looks cool
v6: Micro-optimise, mostly involving moving code around
v7: Fix retire-requests-upto for execlists (and multiple rq->ringbuf)
v8: Rebase
Benchmark: igt/gem_read_read_speed
hsw:gt3e (with semaphores):
Before: Time to read-read 1024k: 275.794µs After: Time to read-read 1024k: 123.260µs
hsw:gt3e (w/o semaphores):
Before: Time to read-read 1024k: 230.433µs After: Time to read-read 1024k: 124.593µs
bdw-u (w/o semaphores): Before After Time to read-read 1x1: 26.274µs 10.350µs Time to read-read 128x128: 40.097µs 21.366µs Time to read-read 256x256: 77.087µs 42.608µs Time to read-read 512x512: 281.999µs 181.155µs Time to read-read 1024x1024: 1196.141µs 1118.223µs Time to read-read 2048x2048: 5639.072µs 5225.837µs Time to read-read 4096x4096: 22401.662µs 21137.067µs Time to read-read 8192x8192: 89617.735µs 85637.681µs
Testcase: igt/gem_concurrent_blit (read-read and friends)
read-read
--- drivers/gpu/drm/i915/i915_debugfs.c | 16 +- drivers/gpu/drm/i915/i915_drv.h | 19 +- drivers/gpu/drm/i915/i915_gem.c | 540 +++++++++++++++++++------------- drivers/gpu/drm/i915/i915_gem_context.c | 2 - drivers/gpu/drm/i915/i915_gem_debug.c | 92 ++---- drivers/gpu/drm/i915/i915_gpu_error.c | 19 +- drivers/gpu/drm/i915/intel_display.c | 6 +- drivers/gpu/drm/i915/intel_lrc.c | 19 +- drivers/gpu/drm/i915/intel_ringbuffer.c | 14 +- 9 files changed, 407 insertions(+), 320 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +11 -5
@@ -120,10 +120,13 @@ static inline const char *get_global_flag(struct drm_i915_gem_object *obj)static void describe_obj (struct seq_file *m,struct drm_i915_gem_object *obj) { +struct drm_i915_private *dev_priv =to_i915 (obj->base.dev); +struct intel_engine_cs *ring;struct i915_vma *vma;int pin_count =0 ; +int i; - seq_printf(m, "%pK: %s%s%s%s %8zdKiB %02x %02x %x %x %x%s%s%s", + seq_printf(m, "%pK: %s%s%s%s %8zdKiB %02x %02x [ ", &obj->base, obj->active ? "*" : " ", get_pin_flag(obj),
@@ -131,8 +134,11 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)get_global_flag (obj), obj->base.size /1024 , obj->base.read_domains, - obj->base.write_domain, -i915_gem_request_get_seqno (obj->last_read_req), + obj->base.write_domain); +for_each_ring (ring, dev_priv, i) +seq_printf (m,"%x " , +i915_gem_request_get_seqno (obj->last_read_req[i])); + seq_printf(m, "] %x %x%s%s%s", i915_gem_request_get_seqno(obj->last_write_req), i915_gem_request_get_seqno(obj->last_fenced_req), i915_cache_level_str(to_i915(obj->base.dev), obj->cache_level),
@@ -169,9 +175,9 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) *t ='\0' ;seq_printf (m," (%s mappable)" , s); } -if (obj->last_read_req !=NULL ) +if (obj->last_write_req !=NULL )seq_printf (m," (%s)" , -i915_gem_request_get_ring (obj->last_read_req)->name); +i915_gem_request_get_ring (obj->last_write_req)->name);if (obj->frontbuffer_bits)seq_printf (m," (frontbuffer: 0x%03x)" , obj->frontbuffer_bits); }
drivers/gpu/drm/i915/i915_drv.h +14 -5
@@ -500,7 +500,7 @@ struct drm_i915_error_state {struct drm_i915_error_buffer {u32 size;u32 name; -u32 rseqno, wseqno; +u32 rseqno[I915_NUM_RINGS ], wseqno;u32 gtt_offset;u32 read_domains;u32 write_domain;
@@ -1907,7 +1907,7 @@ struct drm_i915_gem_object {struct drm_mm_node *stolen;struct list_head global_list; -struct list_head ring_list; +struct list_head ring_list[I915_NUM_RINGS ];/** Used in execbuf to temporarily hold a ref */ struct list_head obj_exec_link;
@@ -1918,7 +1918,7 @@ struct drm_i915_gem_object {* rendering and so a non-zero seqno), and is not set if it i s on * inactive (ready to be unbound) list. */ - unsigned int active:1; + unsigned int active:I915_NUM_RINGS;/** * This is set if the object has been written to since last bound
@@ -1989,8 +1989,17 @@ struct drm_i915_gem_object {void *dma_buf_vmapping;int vmapping_count; -/** Breadcrumb of last rendering to the buffer. */ -struct drm_i915_gem_request *last_read_req; +/** Breadcrumb of last rendering to the buffer. +* There can only be one writer, but we allow for multiple readers. +* If there is a writer that necessarily implies that all other +* read requests are complete - but we may only be lazily clearing +* the read requests. A read request is naturally the most recent +* request on a ring, so we may have two different write and read +* requests on one ring where the write request is older than the +* read request. This allows for the CPU to read from an active +* buffer by only waiting for the write to complete. +* */ +struct drm_i915_gem_request *last_read_req[I915_NUM_RINGS ];struct drm_i915_gem_request *last_write_req;/** Breadcrumb of last fenced GPU access to the buffer. */ struct drm_i915_gem_request *last_fenced_req;
drivers/gpu/drm/i915/i915_gem.c +330 -210
805 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem_context.c +0 -2
@@ -768,8 +768,6 @@ static int do_switch(struct intel_engine_cs *ring,* swapped, but there is no way to do that yet. */ from->legacy_hw_ctx.rcs_state->dirty =1 ; -BUG_ON (i915_gem_request_get_ring ( - from->legacy_hw_ctx.rcs_state->last_read_req) != ring);/* obj is kept alive until the next request by its active ref */ i915_gem_object_ggtt_unpin (from->legacy_hw_ctx.rcs_state);
drivers/gpu/drm/i915/i915_gem_debug.c +22 -70
104 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gpu_error.c +13 -6
@@ -192,15 +192,20 @@ static void print_error_buffers(struct drm_i915_error_state_buf *m,struct drm_i915_error_buffer *err, int count) { + int i; +err_printf (m," %s [%d]:\n" , name, count);while (count--) { -err_printf (m," %08x %8u %02x %02x %x %x" , +err_printf (m," %08x %8u %02x %02x [ " , err->gtt_offset, err->size, err->read_domains, - err->write_domain, - err->rseqno, err->wseqno); + err->write_domain); +for (i =0 ; i <I915_NUM_RINGS ; i++) +err_printf (m,"%02x " , err->rseqno[i]); + +err_printf (m,"] %02x" , err->wseqno);err_puts (m,pin_flag (err->pinned));err_puts (m,tiling_flag (err->tiling));err_puts (m,dirty_flag (err->dirty));
@@ -679,10 +684,12 @@ static void capture_bo(struct drm_i915_error_buffer *err, struct i915_vma *vma) {struct drm_i915_gem_object *obj = vma->obj; +int i; err->size = obj->base.size; err->name = obj->base.name; - err->rseqno =i915_gem_request_get_seqno (obj->last_read_req); +for (i =0 ; i <I915_NUM_RINGS ; i++) + err->rseqno[i] =i915_gem_request_get_seqno (obj->last_read_req[i]); err->wseqno =i915_gem_request_get_seqno (obj->last_write_req); err->gtt_offset = vma->node.start; err->read_domains = obj->base.read_domains;
@@ -695,8 +702,8 @@ static void capture_bo(struct drm_i915_error_buffer *err, err->dirty = obj->dirty; err->purgeable = obj->madv !=I915_MADV_WILLNEED ; err->userptr = obj->userptr.mm !=NULL ; - err->ring = obj->last_read_req ? -i915_gem_request_get_ring (obj->last_read_req)->id :-1 ; + err->ring = obj->last_write_req ? +i915_gem_request_get_ring (obj->last_write_req)->id :-1 ; err->cache_level = obj->cache_level; }
drivers/gpu/drm/i915/intel_display.c +3 -3
@@ -10016,7 +10016,7 @@ static bool use_mmio_flip(struct intel_engine_cs *ring,else if (i915.enable_execlists)return true;else -return ring !=i915_gem_request_get_ring (obj->last_read_req); +return ring !=i915_gem_request_get_ring (obj->last_write_req); }static void skl_do_mmio_flip (struct intel_crtc *intel_crtc)
@@ -10321,7 +10321,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc, }else if (IS_IVYBRIDGE (dev) ||IS_HASWELL (dev)) { ring = &dev_priv->ring[BCS ]; }else if (INTEL_INFO (dev)->gen >=7 ) { - ring =i915_gem_request_get_ring (obj->last_read_req); + ring =i915_gem_request_get_ring (obj->last_write_req);if (ring ==NULL || ring->id !=RCS ) ring = &dev_priv->ring[BCS ]; }else {
@@ -10337,7 +10337,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,*/ ret =intel_pin_and_fence_fb_obj (crtc->primary, fb, crtc->primary->state, - mmio_flip ?i915_gem_request_get_ring (obj->last_read_req) : ring); + mmio_flip ?i915_gem_request_get_ring (obj->last_write_req) : ring);if (ret) goto cleanup_pending;
drivers/gpu/drm/i915/intel_lrc.c +8 -11
@@ -634,7 +634,8 @@ static int logical_ring_wait_request(struct intel_ringbuffer *ringbuf, {struct intel_engine_cs *ring = ringbuf->ring;struct drm_i915_gem_request *request; -int ret, new_space; +unsigned space; +int ret;if (intel_ring_space (ringbuf) >= bytes)return 0 ;
@@ -645,14 +646,13 @@ static int logical_ring_wait_request(struct intel_ringbuffer *ringbuf,* 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) +if (request->ringbuf != ringbuf)continue ;/* Would completion of this request free enough space? */ - new_space =__intel_ring_space (request->postfix, ringbuf->tail, - ringbuf->size); -if (new_space >= bytes) + space =__intel_ring_space (request->postfix, ringbuf->tail, + ringbuf->size); +if (space >= bytes)break ; }
@@ -663,11 +663,8 @@ static int logical_ring_wait_request(struct intel_ringbuffer *ringbuf,if (ret)return ret; -i915_gem_retire_requests_ring (ring); - -WARN_ON (intel_ring_space (ringbuf) < new_space); - -return intel_ring_space (ringbuf) >= bytes ?0 : -ENOSPC ; + ringbuf->space = space; +return 0 ; }/*
drivers/gpu/drm/i915/intel_ringbuffer.c +6 -8
@@ -2072,15 +2072,16 @@ static int intel_ring_wait_request(struct intel_engine_cs *ring, int n) {struct intel_ringbuffer *ringbuf = ring->buffer;struct drm_i915_gem_request *request; -int ret, new_space; +unsigned space; +int ret;if (intel_ring_space (ringbuf) >= n)return 0 ;list_for_each_entry (request, &ring->request_list, list) { - new_space =__intel_ring_space (request->postfix, ringbuf->tail, - ringbuf->size); -if (new_space >= n) + space =__intel_ring_space (request->postfix, ringbuf->tail, + ringbuf->size); +if (space >= n)break ; }
@@ -2091,10 +2092,7 @@ static int intel_ring_wait_request(struct intel_engine_cs *ring, int n)if (ret)return ret; -i915_gem_retire_requests_ring (ring); - -WARN_ON (intel_ring_space (ringbuf) < new_space); - + ringbuf->space = space;return 0 ; }
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 18/70] drm/i915: Implement inter-engine read-read optimisations
Quoted 11 lines · Chris Wilson
Currently, we only track the last request globally across all engines. This prevents us from issuing concurrent read requests on e.g. the RCS and BCS engines (or more likely the render and media engines). Without semaphores, we incur costly stalls as we synchronise between rings - greatly impacting the current performance of Broadwell versus Haswell in certain workloads (like video decode). With the introduction of reference counted requests, it is much easier to track the last request per ring, as well as the last global write request so that we can optimise inter-engine read read requests (as well as better optimise certain CPU waits).
Quoted 7 lines
v2: Fix inverted readonly condition for nonblocking waits.
v3: Handle non-continguous engine array after waits
v4: Rebase, tidy, rewrite ring list debugging
v5: Useobj->activeas a bitfield, it looks cool
v6: Micro-optimise, mostly involving moving code around
v7: Fix retire-requests-upto for execlists (and multiplerq->ringbuf)
v8: Rebase
I am still slightly concerned with the sequential ring req waiting in combination with optimistic spinning, but other than that looks good to me:
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 18/70] drm/i915: Implement inter-engine read-read optimisations
Quoted 21 lines · Tvrtko Ursulin
Quoted 11 lines · Chris Wilson
Currently, we only track the last request globally across all engines. This prevents us from issuing concurrent read requests on e.g. the RCS and BCS engines (or more likely the render and media engines). Without semaphores, we incur costly stalls as we synchronise between rings - greatly impacting the current performance of Broadwell versus Haswell in certain workloads (like video decode). With the introduction of reference counted requests, it is much easier to track the last request per ring, as well as the last global write request so that we can optimise inter-engine read read requests (as well as better optimise certain CPU waits).
Quoted 7 lines
v2: Fix inverted readonly condition for nonblocking waits.
v3: Handle non-continguous engine array after waits
v4: Rebase, tidy, rewrite ring list debugging
v5: Useobj->activeas a bitfield, it looks cool
v6: Micro-optimise, mostly involving moving code around
v7: Fix retire-requests-upto for execlists (and multiplerq->ringbuf)
v8: Rebase
Quoted 3 lines
I am still slightly concerned with the sequential ring req waiting in combination with optimistic spinning, but other than that looks good to me:
I hear you, I don't yet have a scenario where I care but with a little more refactoring (see next version) extending i915_wait_request to work on an array of requests will be a reasonalbly easy task.
Quoted 1 line
Reviewed-by Tvrtko Ursulin <[email protected]>
Thanks, but I have a new version on its way with minor changes.
Spotted an issue with Ironlake and do_idling() as well as slight refactoring.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 19/70 drm/i915: Inline check required for object syncing prior to execbuf
In reply to Chris WilsonThis trims a little overhead from the common case of not needing to synchronize between rings.
--- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +6 -3
@@ -909,9 +909,12 @@ i915_gem_execbuffer_move_to_gpu(struct intel_engine_cs *ring,list_for_each_entry (vma, vmas, exec_list) {struct drm_i915_gem_object *obj = vma->obj; - ret =i915_gem_object_sync (obj, ring); -if (ret) -return ret; + +if (obj->active & ~intel_ring_flag (ring)) { + ret =i915_gem_object_sync (obj, ring); +if (ret) +return ret; + }if (obj->base.write_domain &I915_GEM_DOMAIN_CPU ) flush_chipset |=i915_gem_clflush_object (obj, false);
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 20/70 drm/i915: Limit ring synchronisation (sw sempahores) RPS boosts
In reply to Chris WilsonRing switches can occur many times per frame, and are often out of control, causing frequent RPS boosting for no practical benefit. Treat the sw semaphore synchronisation as a separate client and only allow it to boost once per busy/idle cycle.
--- drivers/gpu/drm/i915/i915_debugfs.c | 1 + drivers/gpu/drm/i915/i915_drv.h | 34 ++++++++++++++++++---------------- drivers/gpu/drm/i915/i915_gem.c | 7 +++++-- drivers/gpu/drm/i915/intel_pm.c | 1 + 4 files changed, 25 insertions(+), 18 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +1 -0
@@ -2296,6 +2296,7 @@ static int i915_rps_boost_info(struct seq_file *m, void *data) list_empty(&file_priv->rps_boost) ? "" : ", active");rcu_read_unlock (); } +seq_printf (m,"Semaphore boosts: %d\n" , dev_priv->rps.semaphores.rps_boosts);seq_printf (m,"Kernel boosts: %d\n" , dev_priv->rps.boosts);mutex_unlock (&dev_priv->rps.hw_lock);
drivers/gpu/drm/i915/i915_drv.h +18 -16
@@ -268,6 +268,22 @@ struct drm_i915_private;struct i915_mm_struct ;struct i915_mmu_object ; +struct drm_i915_file_private { +struct drm_i915_private *dev_priv; +struct drm_file *file; + +struct { +spinlock_t lock; +struct list_head request_list; + } mm; +struct idr context_idr; + +struct list_head rps_boost; +struct intel_engine_cs *bsd_ring; + +unsigned rps_boosts; +}; +enum intel_dpll_id {DPLL_ID_PRIVATE =-1 ,/* non-shared dpll in use */ /* real shared dpll ids must be >= 0 */
@@ -1047,6 +1063,8 @@ struct intel_gen6_power_mgmt {struct list_head clients;unsigned boosts; +struct drm_i915_file_private semaphores; +/* manual wa residency calculations */ struct intel_rps_ei up_ei, down_ei;
@@ -2185,22 +2203,6 @@ static inline void i915_gem_request_assign(struct drm_i915_gem_request **pdst,* a later patch when the call to i915_seqno_passed() is obsoleted... */ -struct drm_i915_file_private { -struct drm_i915_private *dev_priv; -struct drm_file *file; - -struct { -spinlock_t lock; -struct list_head request_list; - } mm; -struct idr context_idr; - -struct list_head rps_boost; -struct intel_engine_cs *bsd_ring; - -unsigned rps_boosts; -}; -/* * A command that requires special handling by the command parser. */
drivers/gpu/drm/i915/i915_gem.c +5 -2
@@ -3045,9 +3045,12 @@ __i915_gem_object_sync(struct drm_i915_gem_object *obj,return ret;if (!i915_semaphore_is_enabled (obj->base.dev)) { +struct drm_i915_private *i915 =to_i915 (obj->base.dev); ret =__i915_wait_request (rq, -atomic_read (&to_i915 (obj->base.dev)->gpu_error.reset_counter), -to_i915 (obj->base.dev)->mm.interruptible,NULL ,NULL ); +atomic_read (&i915->gpu_error.reset_counter), + i915->mm.interruptible, +NULL , + &i915->rps.semaphores);if (ret)return ret;
drivers/gpu/drm/i915/intel_pm.c +1 -0
@@ -6827,6 +6827,7 @@ void intel_pm_setup(struct drm_device *dev)INIT_DELAYED_WORK (&dev_priv->rps.delayed_resume_work, intel_gen6_powersave_work);INIT_LIST_HEAD (&dev_priv->rps.clients); +INIT_LIST_HEAD (&dev_priv->rps.semaphores.rps_boost); dev_priv->pm.suspended = false; }
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 20/70] drm/i915: Limit ring synchronisation (sw sempahores) RPS boosts
Quoted 38 lines · Chris Wilson
Ring switches can occur many times per frame, and are often out of control, causing frequent RPS boosting for no practical benefit. Treat the sw semaphore synchronisation as a separate client and only allow it to boost once per busy/idle cycle.
Signed-off-by Chris Wilson <[email protected]>--- drivers/gpu/drm/i915/i915_debugfs.c | 1 + drivers/gpu/drm/i915/i915_drv.h | 34 ++++++++++++++++++---------------- drivers/gpu/drm/i915/i915_gem.c | 7 +++++-- drivers/gpu/drm/i915/intel_pm.c | 1 + 4 files changed, 25 insertions(+), 18 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +1
-0@@ -2296,6 +2296,7 @@ static int i915_rps_boost_info(struct seq_file *m, void *data) list_empty(&file_priv->rps_boost) ? "" : ", active");rcu_read_unlock (); } +seq_printf (m,"Semaphore boosts: %d\n" , dev_priv->rps.semaphores.rps_boosts);seq_printf (m,"Kernel boosts: %d\n" , dev_priv->rps.boosts);mutex_unlock (&dev_priv->rps.hw_lock);drivers/gpu/drm/i915/i915_drv.h +5
-0@@ -268,6 +268,22 @@ struct drm_i915_private;struct i915_mm_struct ;struct i915_mmu_object ; +struct drm_i915_file_private { +struct drm_i915_private *dev_priv; +struct drm_file *file; + +struct {
drivers/gpu/drm/i915/i915_drv.h struct drm_i915_private; · line 285
Quoted 10 lines
drivers/gpu/drm/i915/i915_drv.h +10
-0+spinlock_t lock; +struct list_head request_list; + } mm; +struct idr context_idr; + +struct list_head rps_boost; +struct intel_engine_cs *bsd_ring; + +unsigned rps_boosts; +};
This looks really confusing to me and feels a bit too much like abuse. I think extracting a tiny struct intel_rps_boost_client and switching the interfaces of gen6_rps_boost and __i915_wait_request over to it instead of using the file_priv would be a lot clearer.
Otherwise these two patches make a lot of sense, but can you please cc Deepak when resending for his ack/r-b?
Thanks, Daniel
Quoted 74 lines
drivers/gpu/drm/i915/i915_drv.h +3
-16+enum intel_dpll_id {DPLL_ID_PRIVATE =-1 ,/* non-shared dpll in use */ /* real shared dpll ids must be >= 0 */ @@ -1047,6 +1063,8 @@ struct intel_gen6_power_mgmt {struct list_head clients;unsigned boosts; +struct drm_i915_file_private semaphores; +/* manual wa residency calculations */ struct intel_rps_ei up_ei, down_ei;@@ -2185,22 +2203,6 @@ static inline void i915_gem_request_assign(struct drm_i915_gem_request **pdst,* a later patch when the call to i915_seqno_passed() is obsoleted... */ -struct drm_i915_file_private { -struct drm_i915_private *dev_priv; -struct drm_file *file; - -struct { -spinlock_t lock; -struct list_head request_list; - } mm; -struct idr context_idr; - -struct list_head rps_boost; -struct intel_engine_cs *bsd_ring; - -unsigned rps_boosts; -}; -/* * A command that requires special handling by the command parser. */ drivers/gpu/drm/i915/i915_gem.c +5
-2@@ -3045,9 +3045,12 @@ __i915_gem_object_sync(struct drm_i915_gem_object *obj,return ret;if (!i915_semaphore_is_enabled (obj->base.dev)) { +struct drm_i915_private *i915 =to_i915 (obj->base.dev); ret =__i915_wait_request (rq, -atomic_read (&to_i915 (obj->base.dev)->gpu_error.reset_counter), -to_i915 (obj->base.dev)->mm.interruptible,NULL ,NULL ); +atomic_read (&i915->gpu_error.reset_counter), + i915->mm.interruptible, +NULL , + &i915->rps.semaphores);if (ret)return ret;drivers/gpu/drm/i915/intel_pm.c +1
-0@@ -6827,6 +6827,7 @@ void intel_pm_setup(struct drm_device *dev)INIT_DELAYED_WORK (&dev_priv->rps.delayed_resume_work, intel_gen6_powersave_work);INIT_LIST_HEAD (&dev_priv->rps.clients); +INIT_LIST_HEAD (&dev_priv->rps.semaphores.rps_boost); dev_priv->pm.suspended = false; }Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 21/70 drm/i915: Limit mmio flip RPS boosts
In reply to Chris WilsonSince we will often pageflip to an active surface, we will often have to wait for the surface to be written before issuing the flip. Also we are likely to wait on that surface in plenty of time before the vblank. Since we have a mechanism for boosting when a flip misses the expected vblank, curtain the number of times we RPS boost when simply waiting for mmioflip.
--- drivers/gpu/drm/i915/i915_debugfs.c | 1 + drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_display.c | 4 +++- drivers/gpu/drm/i915/intel_drv.h | 1 + drivers/gpu/drm/i915/intel_pm.c | 1 + 5 files changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_debugfs.c +1 -0
@@ -2297,6 +2297,7 @@ static int i915_rps_boost_info(struct seq_file *m, void *data)rcu_read_unlock (); }seq_printf (m,"Semaphore boosts: %d\n" , dev_priv->rps.semaphores.rps_boosts); +seq_printf (m,"MMIO flip boosts: %d\n" , dev_priv->rps.mmioflips.rps_boosts);seq_printf (m,"Kernel boosts: %d\n" , dev_priv->rps.boosts);mutex_unlock (&dev_priv->rps.hw_lock);
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -1064,6 +1064,7 @@ struct intel_gen6_power_mgmt {unsigned boosts;struct drm_i915_file_private semaphores; +struct drm_i915_file_private mmioflips;/* manual wa residency calculations */ struct intel_rps_ei up_ei, down_ei;
drivers/gpu/drm/i915/intel_display.c +3 -1
@@ -10111,7 +10111,8 @@ static void intel_mmio_flip_work_func(struct work_struct *work)if (mmio_flip->rq)WARN_ON (__i915_wait_request (mmio_flip->rq, mmio_flip->crtc->reset_counter, - false,NULL ,NULL )); + false,NULL , + &mmio_flip->i915->rps.mmioflips));intel_do_mmio_flip (mmio_flip->crtc);
@@ -10132,6 +10133,7 @@ static int intel_queue_mmio_flip(struct drm_device *dev,if (mmio_flip ==NULL )return -ENOMEM ; + mmio_flip->i915 =to_i915 (dev); mmio_flip->rq =i915_gem_request_reference (obj->last_write_req); mmio_flip->crtc =to_intel_crtc (crtc);
drivers/gpu/drm/i915/intel_drv.h +1 -0
@@ -404,6 +404,7 @@ struct intel_pipe_wm {struct intel_mmio_flip {struct work_struct work; +struct drm_i915_private *i915;struct drm_i915_gem_request *rq;struct intel_crtc *crtc; };
drivers/gpu/drm/i915/intel_pm.c +1 -0
@@ -6828,6 +6828,7 @@ void intel_pm_setup(struct drm_device *dev) intel_gen6_powersave_work);INIT_LIST_HEAD (&dev_priv->rps.clients);INIT_LIST_HEAD (&dev_priv->rps.semaphores.rps_boost); +INIT_LIST_HEAD (&dev_priv->rps.mmioflips.rps_boost); dev_priv->pm.suspended = false; }
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 22/70 drm/i915: Reduce frequency of unspecific HSW reg debugging
In reply to Chris WilsonDelay the expensive read on the FPGA_DBG register from once per mmio to once per forcewake section when we are doing the general wellbeing check rather than the targetted error detection. This almost reduces the overhead of the debug facility (for example when submitting execlists) to zero whilst keeping the debug checks around.
v2: Enable one-shot mmio debugging from the interrupt check as well as a
safeguard to catch invalid display writes from outside the powerwell.
--- drivers/gpu/drm/i915/intel_uncore.c | 56 ++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 26 deletions(-)
drivers/gpu/drm/i915/intel_uncore.c +30 -26
@@ -149,6 +149,30 @@ fw_domains_put(struct drm_i915_private *dev_priv, enum forcewake_domains fw_doma }static void +hsw_unclaimed_reg_detect (struct drm_i915_private *dev_priv) +{ +static bool mmio_debug_once = true; + +if (i915.mmio_debug || !mmio_debug_once) +return ; + +if (__raw_i915_read32 (dev_priv,FPGA_DBG ) &FPGA_DBG_RM_NOCLAIM ) { +DRM_DEBUG ("Unclaimed register detected, " +"enabling oneshot unclaimed register reporting. " +"Please use i915.mmio_debug=N for more information.\n" ); +__raw_i915_write32 (dev_priv,FPGA_DBG ,FPGA_DBG_RM_NOCLAIM ); + i915.mmio_debug = mmio_debug_once--; + } +} + +static void +fw_domains_put_debug (struct drm_i915_private *dev_priv,enum forcewake_domains fw_domains) +{ +hsw_unclaimed_reg_detect (dev_priv); +fw_domains_put (dev_priv, fw_domains); +} + +static void fw_domains_posting_read (struct drm_i915_private *dev_priv) {struct intel_uncore_forcewake_domain *d;
@@ -561,23 +585,6 @@ hsw_unclaimed_reg_debug(struct drm_i915_private *dev_priv, u32 reg, bool read, } } -static void -hsw_unclaimed_reg_detect (struct drm_i915_private *dev_priv) -{ -static bool mmio_debug_once = true; - -if (i915.mmio_debug || !mmio_debug_once) -return ; - -if (__raw_i915_read32 (dev_priv,FPGA_DBG ) &FPGA_DBG_RM_NOCLAIM ) { -DRM_DEBUG ("Unclaimed register detected, " -"enabling oneshot unclaimed register reporting. " -"Please use i915.mmio_debug=N for more information.\n" ); -__raw_i915_write32 (dev_priv,FPGA_DBG ,FPGA_DBG_RM_NOCLAIM ); - i915.mmio_debug = mmio_debug_once--; - } -} -#define GEN2_READ_HEADER (x) \ u##x val = 0; \ assert_device_not_suspended(dev_priv);
@@ -829,7 +836,6 @@ hsw_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, bool trace)gen6_gt_check_fifodbg (dev_priv); \ } \hsw_unclaimed_reg_debug (dev_priv, reg, false, false); \ -hsw_unclaimed_reg_detect (dev_priv); \GEN6_WRITE_FOOTER ; \ }
@@ -871,7 +877,6 @@ gen8_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, bool trace__force_wake_get (dev_priv,FORCEWAKE_RENDER ); \ __raw_i915_write##x(dev_priv, reg, val); \ hsw_unclaimed_reg_debug(dev_priv, reg, false, false); \ - hsw_unclaimed_reg_detect(dev_priv); \ GEN6_WRITE_FOOTER; \ }
@@ -1120,6 +1125,10 @@ static void intel_uncore_fw_domains_init(struct drm_device *dev) FORCEWAKE, FORCEWAKE_ACK); } +if (HAS_FPGA_DBG_UNCLAIMED (dev) && + dev_priv->uncore.funcs.force_wake_put == fw_domains_put) + dev_priv->uncore.funcs.force_wake_put = fw_domains_put_debug; +/* All future platforms are expected to require complex power gating */ WARN_ON (dev_priv->uncore.fw_domains ==0 ); }
@@ -1411,11 +1420,6 @@ int intel_gpu_reset(struct drm_device *dev)void intel_uncore_check_errors (struct drm_device *dev) { -struct drm_i915_private *dev_priv = dev->dev_private; - -if (HAS_FPGA_DBG_UNCLAIMED (dev) && - (__raw_i915_read32 (dev_priv,FPGA_DBG ) &FPGA_DBG_RM_NOCLAIM )) { -DRM_ERROR ("Unclaimed register before interrupt\n" ); -__raw_i915_write32 (dev_priv,FPGA_DBG ,FPGA_DBG_RM_NOCLAIM ); - } +if (HAS_FPGA_DBG_UNCLAIMED (dev)) +hsw_unclaimed_reg_detect (to_i915 (dev)); }
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 23/70 drm/i915: Record ring->start address in error state
In reply to Chris WilsonThis is mostly useful for execlists where the rings switch between contexts (and so checking that the ring's start register matches the context is important).
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_gpu_error.c | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -471,6 +471,7 @@ struct drm_i915_error_state {u32 semaphore_seqno[I915_NUM_RINGS -1 ];/* Register state */ +u32 start;u32 tail;u32 head;u32 ctl;
drivers/gpu/drm/i915/i915_gpu_error.c +6 -4
@@ -256,10 +256,11 @@ static void i915_ring_error_state(struct drm_i915_error_state_buf *m,return ;err_printf (m,"%s command stream:\n" ,ring_str (ring_idx)); -err_printf (m," HEAD: 0x%08x\n" , ring->head); -err_printf (m," TAIL: 0x%08x\n" , ring->tail); -err_printf (m," CTL: 0x%08x\n" , ring->ctl); -err_printf (m," HWS: 0x%08x\n" , ring->hws); +err_printf (m," START: 0x%08x\n" , ring->start); +err_printf (m," HEAD: 0x%08x\n" , ring->head); +err_printf (m," TAIL: 0x%08x\n" , ring->tail); +err_printf (m," CTL: 0x%08x\n" , ring->ctl); +err_printf (m," HWS: 0x%08x\n" , ring->hws);err_printf (m," ACTHD: 0x%08x %08x\n" , (u32)(ring->acthd>>32 ), (u32 )ring->acthd);err_printf (m," IPEIR: 0x%08x\n" , ring->ipeir);err_printf (m," IPEHR: 0x%08x\n" , ring->ipehr);
@@ -890,6 +891,7 @@ static void i915_record_ring_state(struct drm_device *dev, ering->instpm =I915_READ (RING_INSTPM (ring->mmio_base)); ering->seqno = ring->get_seqno (ring, false); ering->acthd =intel_ring_get_active_head (ring); + ering->start =I915_READ_START (ring); ering->head =I915_READ_HEAD (ring); ering->tail =I915_READ_TAIL (ring); ering->ctl =I915_READ_CTL (ring);
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Daniel Vetter
AppliedRe: [PATCH 23/70] drm/i915: Record ring->start address in error state
Quoted 5 lines · Chris Wilson
This is mostly useful for execlists where the rings switch between contexts (and so checking that the ring's start register matches the context is important).
Signed-off-by Chris Wilson <[email protected]>
Queued for -next, thanks for the patch.
-Daniel
Quoted 52 lines
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_gpu_error.c | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-)drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -471,6 +471,7 @@ struct drm_i915_error_state {u32 semaphore_seqno[I915_NUM_RINGS -1 ];/* Register state */ +u32 start;u32 tail;u32 head;u32 ctl;drivers/gpu/drm/i915/i915_gpu_error.c +6
-4@@ -256,10 +256,11 @@ static void i915_ring_error_state(struct drm_i915_error_state_buf *m,return ;err_printf (m,"%s command stream:\n" ,ring_str (ring_idx)); -err_printf (m," HEAD: 0x%08x\n" , ring->head); -err_printf (m," TAIL: 0x%08x\n" , ring->tail); -err_printf (m," CTL: 0x%08x\n" , ring->ctl); -err_printf (m," HWS: 0x%08x\n" , ring->hws); +err_printf (m," START: 0x%08x\n" , ring->start); +err_printf (m," HEAD: 0x%08x\n" , ring->head); +err_printf (m," TAIL: 0x%08x\n" , ring->tail); +err_printf (m," CTL: 0x%08x\n" , ring->ctl); +err_printf (m," HWS: 0x%08x\n" , ring->hws);err_printf (m," ACTHD: 0x%08x %08x\n" , (u32)(ring->acthd>>32 ), (u32 )ring->acthd);err_printf (m," IPEIR: 0x%08x\n" , ring->ipeir);err_printf (m," IPEHR: 0x%08x\n" , ring->ipehr);@@ -890,6 +891,7 @@ static void i915_record_ring_state(struct drm_device *dev, ering->instpm =I915_READ (RING_INSTPM (ring->mmio_base)); ering->seqno = ring->get_seqno (ring, false); ering->acthd =intel_ring_get_active_head (ring); + ering->start =I915_READ_START (ring); ering->head =I915_READ_HEAD (ring); ering->tail =I915_READ_TAIL (ring); ering->ctl =I915_READ_CTL (ring);Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 24/70 drm/i915: Use simpler form of spin_lock_irq(execlist_lock)
In reply to Chris WilsonWe can use the simpler spinlock form to disable interrupts as we are always outside of an irq/softirq handler.
--- drivers/gpu/drm/i915/intel_lrc.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +4 -6
@@ -501,7 +501,6 @@ static int execlists_context_queue(struct intel_engine_cs *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)
@@ -528,7 +527,7 @@ static int execlists_context_queue(struct intel_engine_cs *ring,intel_runtime_pm_get (dev_priv); -spin_lock_irqsave (&ring->execlist_lock, flags); +spin_lock_irq (&ring->execlist_lock);list_for_each_entry (cursor, &ring->execlist_queue, execlist_link)if (++num_elements >2 )
@@ -554,7 +553,7 @@ static int execlists_context_queue(struct intel_engine_cs *ring,if (num_elements ==0 )execlists_context_unqueue (ring); -spin_unlock_irqrestore (&ring->execlist_lock, flags); +spin_unlock_irq (&ring->execlist_lock);return 0 ; }
@@ -936,7 +935,6 @@ void intel_execlists_retire_requests(struct intel_engine_cs *ring) {struct drm_i915_gem_request *req, *tmp;struct drm_i915_private *dev_priv = ring->dev->dev_private; -unsigned long flags;struct list_head retired_list;WARN_ON (!mutex_is_locked (&ring->dev->struct_mutex));
@@ -944,9 +942,9 @@ void intel_execlists_retire_requests(struct intel_engine_cs *ring)return ;INIT_LIST_HEAD (&retired_list); -spin_lock_irqsave (&ring->execlist_lock, flags); +spin_lock_irq (&ring->execlist_lock);list_replace_init (&ring->execlist_retired_req_list, &retired_list); -spin_unlock_irqrestore (&ring->execlist_lock, flags); +spin_unlock_irq (&ring->execlist_lock);list_for_each_entry_safe (req, tmp, &retired_list, execlist_link) {struct intel_context *ctx = req->ctx;
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 25/70 drm/i915: Use the global runtime-pm wakelock for a busy GPU for execlists
In reply to Chris WilsonWhen we submit a request to the GPU, we first take the rpm wakelock, and only release it once the GPU has been idle for a small period of time after all requests have been complete. This means that we are sure no new interrupt can arrive whilst we do not hold the rpm wakelock and so can drop the individual get/put around every single request inside execlists.
Note: to close one potential issue we should mark the GPU as busy earlier in __i915_add_request.
--- drivers/gpu/drm/i915/i915_gem.c | 1 - drivers/gpu/drm/i915/intel_lrc.c | 3 --- 2 files changed, 4 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +0 -1
@@ -2698,7 +2698,6 @@ static void i915_gem_reset_ring_cleanup(struct drm_i915_private *dev_priv, struct drm_i915_gem_request, execlist_link);list_del (&submit_req->execlist_link); -intel_runtime_pm_put (dev_priv);if (submit_req->ctx != ring->default_context)intel_lr_context_unpin (ring, submit_req->ctx);
drivers/gpu/drm/i915/intel_lrc.c +0 -3
@@ -525,8 +525,6 @@ static int execlists_context_queue(struct intel_engine_cs *ring, } request->tail = tail; -intel_runtime_pm_get (dev_priv); -spin_lock_irq (&ring->execlist_lock);list_for_each_entry (cursor, &ring->execlist_queue, execlist_link)
@@ -953,7 +951,6 @@ void intel_execlists_retire_requests(struct intel_engine_cs *ring)if (ctx_obj && (ctx != ring->default_context))intel_lr_context_unpin (ring, ctx); -intel_runtime_pm_put (dev_priv);list_del (&req->execlist_link);i915_gem_request_unreference (req); }
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 26/70 drm/i915: Map the execlists context regs once during pinning
In reply to Chris WilsonWhen we pin the execlists context on queuing, it the ideal time to map the register page that we need to update when we submit the request to the hardware (and keep it around for future requests).
This avoids having to do an atomic kmap on every submission. On the other hand, it does depend upon correct request construction.
v2: Rebase
--- drivers/gpu/drm/i915/i915_gem.c | 10 -- drivers/gpu/drm/i915/intel_lrc.c | 189 ++++++++++++-------------------- drivers/gpu/drm/i915/intel_lrc.h | 2 - drivers/gpu/drm/i915/intel_ringbuffer.h | 1 + 4 files changed, 73 insertions(+), 129 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +0 -10
@@ -2589,13 +2589,6 @@ void i915_gem_request_free(struct kref *req_ref)struct intel_context *ctx = req->ctx;if (ctx) { -if (i915.enable_execlists) { -struct intel_engine_cs *ring = req->ring; - -if (ctx != ring->default_context) -intel_lr_context_unpin (ring, ctx); - } -i915_gem_context_unreference (ctx); }
@@ -2699,9 +2692,6 @@ static void i915_gem_reset_ring_cleanup(struct drm_i915_private *dev_priv, execlist_link);list_del (&submit_req->execlist_link); -if (submit_req->ctx != ring->default_context) -intel_lr_context_unpin (ring, submit_req->ctx); -i915_gem_request_unreference (submit_req); }
drivers/gpu/drm/i915/intel_lrc.c +72 -117
260 lines not on this page · raw message
drivers/gpu/drm/i915/intel_lrc.h +0 -2
@@ -70,8 +70,6 @@ static inline void intel_logical_ring_emit(struct intel_ringbuffer *ringbuf,void intel_lr_context_free (struct intel_context *ctx);int intel_lr_context_deferred_create (struct intel_context *ctx,struct intel_engine_cs *ring); -void intel_lr_context_unpin (struct intel_engine_cs *ring, -struct intel_context *ctx);void intel_lr_context_reset (struct drm_device *dev,struct intel_context *ctx);
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -0
@@ -97,6 +97,7 @@ struct intel_ring_hangcheck {struct intel_ringbuffer {struct drm_i915_gem_object *obj;void __iomem *virtual_start; +uint32_t *regs;struct intel_engine_cs *ring;
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 27/70 drm/i915: Remove vestigal DRI1 ring quiescing code
In reply to Chris WilsonAfter the removal of DRI1, all access to the rings are through requests and so we can always be sure that there is a request to wait upon to free up available space. The fallback code only existed so that we could quiesce the GPU following unmediated access by DRI1.
v2: Rebase
--- drivers/gpu/drm/i915/i915_trace.h | 27 ---------------- drivers/gpu/drm/i915/intel_lrc.c | 57 +++------------------------------ drivers/gpu/drm/i915/intel_ringbuffer.c | 56 ++------------------------------ 3 files changed, 6 insertions(+), 134 deletions(-)
drivers/gpu/drm/i915/i915_trace.h +0 -27
@@ -597,33 +597,6 @@ DEFINE_EVENT(i915_gem_request, i915_gem_request_wait_end,TP_ARGS (req) ); -DECLARE_EVENT_CLASS (i915_ring, - TP_PROTO(struct intel_engine_cs *ring), -TP_ARGS (ring), - -TP_STRUCT__entry ( - __field(u32, dev) -__field (u32, ring) - ), - -TP_fast_assign ( - __entry->dev = ring->dev->primary->index; - __entry->ring = ring->id; - ), - -TP_printk ("dev=%u, ring=%u" , __entry->dev, __entry->ring) -); - -DEFINE_EVENT (i915_ring, i915_ring_wait_begin, - TP_PROTO(struct intel_engine_cs *ring), -TP_ARGS (ring) -); - -DEFINE_EVENT (i915_ring, i915_ring_wait_end, - TP_PROTO(struct intel_engine_cs *ring), -TP_ARGS (ring) -); - TRACE_EVENT(i915_flip_request, TP_PROTO(int plane, struct drm_i915_gem_object *obj),
drivers/gpu/drm/i915/intel_lrc.c +4 -53
75 lines not on this page · raw message
drivers/gpu/drm/i915/intel_ringbuffer.c +2 -54
74 lines not on this page · raw message
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 27/70] drm/i915: Remove vestigal DRI1 ring quiescing code
drivers/gpu/drm/i915/intel_lrc.c static int logical_ring_wait_request(struct intel_ringbuffer *ringbuf, · line 645
Quoted 7 lines · Chris Wilson
drivers/gpu/drm/i915/intel_lrc.c +1
-1@@ -640,7 +641,7 @@ static int logical_ring_wait_request(struct intel_ringbuffer *ringbuf,break ; } -if (&request->list == &ring->request_list) +if (WARN_ON (&request->list == &ring->request_list))return -ENOSPC ;
Checking for new_space < n (and initializing new_space to 0) would be a clearer check imo. But that's just a bikeshed. Same for the legacy one below.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 27/70] drm/i915: Remove vestigal DRI1 ring quiescing code
Quoted 5 lines · Daniel Vetter
Quoted 4 lines · Chris Wilson
(quoted diff) +0
-0@@ -640,7 +641,7 @@ static int logical_ring_wait_request(struct intel_ringbuffer *ringbuf, break; }
Quoted 7 lines
drivers/gpu/drm/i915/intel_lrc.c static int logical_ring_wait_request(struct intel_ringbuffer *ringbuf, · line 645
Quoted 3 lines
drivers/gpu/drm/i915/intel_lrc.c +1
-1-if (&request->list == &ring->request_list) +if (WARN_ON (&request->list == &ring->request_list))return -ENOSPC ;Checking for
new_space< n (and initializingnew_spaceto 0) would be a clearer check imo. But that's just a bikeshed. Same for the legacy one below.
If you watch later, I remove the double update of ringbuf->space. However, I am quite found of the if (iter == list_head) return -ENOSPC, so I am a bit biased.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 27/70] drm/i915: Remove vestigal DRI1 ring quiescing code
Quoted 14 lines · Chris Wilson
Quoted 5 lines · Daniel Vetter
Quoted 4 lines · Chris Wilson
(quoted diff) +0
-0@@ -640,7 +641,7 @@ static int logical_ring_wait_request(struct intel_ringbuffer *ringbuf, break; }Quoted 7 lines
drivers/gpu/drm/i915/intel_lrc.c static int logical_ring_wait_request(struct intel_ringbuffer *ringbuf, · line 645
Quoted 3 lines
drivers/gpu/drm/i915/intel_lrc.c +1
-1-if (&request->list == &ring->request_list) +if (WARN_ON (&request->list == &ring->request_list))return -ENOSPC ;Checking for
new_space< n (and initializingnew_spaceto 0) would be a clearer check imo. But that's just a bikeshed. Same for the legacy one below.
Quoted 3 lines
If you watch later, I remove the double update of
ringbuf->space. However, I am quite found of the if (iter ==list_head) return-ENOSPC, so I am a bit biased.
Oh it was mostly that I had to double-check the loop above (which was out of the diff context). With context it's all good. I'm a really lazy reviewer ;-)
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 28/70 drm/i915: Overhaul execlist submission
In reply to Chris WilsonThe list handling during submission was quite confusing as the retired requests were out of order - making it much harder in future to reduce the extra lists. Simplify the submission mechanism to explicitly track the actual requests current on each port and so trim the amount of work required to track hardware and making execlists more consistent with the GEM core.
v2: Rebase
--- drivers/gpu/drm/i915/i915_debugfs.c | 21 +-- drivers/gpu/drm/i915/i915_drv.h | 5 +- drivers/gpu/drm/i915/i915_gem.c | 17 +- drivers/gpu/drm/i915/intel_lrc.c | 306 ++++++++++++-------------------- drivers/gpu/drm/i915/intel_lrc.h | 1 - drivers/gpu/drm/i915/intel_ringbuffer.h | 3 +- 6 files changed, 136 insertions(+), 217 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +7 -14
@@ -1942,8 +1942,7 @@ static void i915_dump_lrc_obj(struct seq_file *m,return ; } -seq_printf (m,"CONTEXT: %s %u\n" , ring->name, -intel_execlists_ctx_id (ctx_obj)); +seq_printf (m,"CONTEXT: %s\n" , ring->name);if (!i915_gem_obj_ggtt_bound (ctx_obj))seq_puts (m,"\tNot bound in GGTT\n" );
@@ -2029,7 +2028,7 @@ static int i915_execlists(struct seq_file *m, void *data)intel_runtime_pm_get (dev_priv);for_each_ring (ring, dev_priv, ring_id) { -struct drm_i915_gem_request *head_req =NULL ; +struct drm_i915_gem_request *rq[2 ];int count =0 ;unsigned long flags;
@@ -2059,22 +2058,16 @@ static int i915_execlists(struct seq_file *m, void *data) }spin_lock_irqsave (&ring->execlist_lock, flags); +memcpy (rq, ring->execlist_port,sizeof (rq));list_for_each (cursor, &ring->execlist_queue) count++; - head_req =list_first_entry_or_null (&ring->execlist_queue, - struct drm_i915_gem_request, execlist_link);spin_unlock_irqrestore (&ring->execlist_lock, flags);seq_printf (m,"\t%d requests in queue\n" , count); -if (head_req) { -struct drm_i915_gem_object *ctx_obj; - - ctx_obj = head_req->ctx->engine[ring_id].state; -seq_printf (m,"\tHead request id: %u\n" , -intel_execlists_ctx_id (ctx_obj)); -seq_printf (m,"\tHead request tail: %u\n" , - head_req->tail); - } +seq_printf (m,"\tPort[0] seqno: %u\n" , + rq[0 ] ? rq[0 ]->seqno :0 ); +seq_printf (m,"\tPort[1] seqno: %u\n" , + rq[1 ] ? rq[1 ]->seqno :0 );seq_putc (m,'\n' ); }
drivers/gpu/drm/i915/i915_drv.h +1 -4
@@ -2137,14 +2137,11 @@ struct drm_i915_gem_request {/** Execlist link in the submission queue.*/ struct list_head execlist_link; - -/** Execlists no. of times this request has been sent to the ELSP */ -int elsp_submitted; - };int i915_gem_request_alloc (struct intel_engine_cs *ring,struct intel_context *ctx); +void i915_gem_request_retire (struct drm_i915_gem_request *request);void i915_gem_request_free (struct kref *req_ref); static inline uint32_t
drivers/gpu/drm/i915/i915_gem.c +8 -9
@@ -1354,7 +1354,7 @@ i915_gem_request_remove_from_client(struct drm_i915_gem_request *request)spin_unlock (&file_priv->mm.lock); } -static void i915_gem_request_retire (struct drm_i915_gem_request *request) +void i915_gem_request_retire (struct drm_i915_gem_request *request) {trace_i915_gem_request_retire (request);
@@ -2684,15 +2684,14 @@ static void i915_gem_reset_ring_cleanup(struct drm_i915_private *dev_priv,* are the ones that keep the context and ringbuffer backing objects * pinned in place. */ -while (!list_empty (&ring->execlist_queue)) { -struct drm_i915_gem_request *submit_req; - - submit_req =list_first_entry (&ring->execlist_queue, - struct drm_i915_gem_request, - execlist_link); -list_del (&submit_req->execlist_link); +if (i915.enable_execlists) { +spin_lock_irq (&ring->execlist_lock); +list_splice_tail_init (&ring->execlist_queue, + &ring->execlist_completed); +memset (&ring->execlist_port,0 ,sizeof (ring->execlist_port)); +spin_unlock_irq (&ring->execlist_lock); -i915_gem_request_unreference (submit_req); +intel_execlists_retire_requests (ring); }/*
drivers/gpu/drm/i915/intel_lrc.c +118 -188
415 lines not on this page · raw message
drivers/gpu/drm/i915/intel_lrc.h +0 -1
@@ -82,7 +82,6 @@ int intel_execlists_submission(struct drm_device *dev, struct drm_file *file,struct list_head *vmas, struct drm_i915_gem_object *batch_obj, u64 exec_start, u32 dispatch_flags); -u32 intel_execlists_ctx_id (struct drm_i915_gem_object *ctx_obj);void intel_lrc_irq_handler (struct intel_engine_cs *ring);void intel_execlists_retire_requests (struct intel_engine_cs *ring);
drivers/gpu/drm/i915/intel_ringbuffer.h +2 -1
@@ -239,8 +239,9 @@ struct intel_engine_cs {/* Execlists */ spinlock_t execlist_lock; +struct drm_i915_gem_request *execlist_port[2 ];struct list_head execlist_queue; -struct list_head execlist_retired_req_list; +struct list_head execlist_completed;u8 next_context_status_buffer;u32 irq_keep_mask;/* bitmask for interrupts that should not be masked */ int (*emit_request)(struct intel_ringbuffer *ringbuf,
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 29/70 drm/i915: Move the execlists retirement to the right spot
In reply to Chris WilsonWe want to run the execlists retire-ring callback whilst we retire the requests on a particular ring. Having done so, we know that the per-ring request list is the superset of all requests and so can simplify the is-idle check.
--- drivers/gpu/drm/i915/i915_gem.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +3 -9
@@ -2771,6 +2771,9 @@ i915_gem_retire_requests_ring(struct intel_engine_cs *ring)if (list_empty (&ring->active_list))return ; +if (i915.enable_execlists) +intel_execlists_retire_requests (ring); +/* Retire requests first as we use it above for the early return. * If we retire requests last, we may use a later seqno and so clear * the requests lists without clearing the active list, leading to
@@ -2826,15 +2829,6 @@ i915_gem_retire_requests(struct drm_device *dev)for_each_ring (ring, dev_priv, i) {i915_gem_retire_requests_ring (ring); idle &=list_empty (&ring->request_list); -if (i915.enable_execlists) { -unsigned long flags; - -spin_lock_irqsave (&ring->execlist_lock, flags); - idle &=list_empty (&ring->execlist_queue); -spin_unlock_irqrestore (&ring->execlist_lock, flags); - -intel_execlists_retire_requests (ring); - } }if (idle)
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 30/70 drm/i915: Map the ringbuffer using WB on LLC machines
In reply to Chris WilsonIf we have llc coherency, we can write directly into the ringbuffer using ordinary cached writes rather than forcing WC access.
--- drivers/gpu/drm/i915/intel_ringbuffer.c | 60 +++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_ringbuffer.c +49 -11
@@ -1907,11 +1907,35 @@ static int init_phys_status_page(struct intel_engine_cs *ring)void intel_unpin_ringbuffer_obj (struct intel_ringbuffer *ringbuf) { -iounmap (ringbuf->virtual_start); +if (HAS_LLC (ringbuf->obj->base.dev) && !ringbuf->obj->stolen) +vunmap (ringbuf->virtual_start); +else +iounmap (ringbuf->virtual_start); ringbuf->virtual_start =NULL ;i915_gem_object_ggtt_unpin (ringbuf->obj); } +static u32 *vmap_obj (struct drm_i915_gem_object *obj) +{ +struct sg_page_iter sg_iter; +struct page **pages; +void *addr; +int i; + + pages =drm_malloc_ab (obj->base.size >>PAGE_SHIFT ,sizeof (*pages)); +if (pages ==NULL ) +return NULL ; + + i =0 ; +for_each_sg_page (obj->pages->sgl, &sg_iter, obj->pages->nents,0 ) + pages[i++] =sg_page_iter_page (&sg_iter); + + addr =vmap (pages, i,0 ,PAGE_KERNEL ); +drm_free_large (pages); + +return addr; +} +int intel_pin_and_map_ringbuffer_obj (struct drm_device *dev,struct intel_ringbuffer *ringbuf) {
@@ -1923,17 +1947,31 @@ int intel_pin_and_map_ringbuffer_obj(struct drm_device *dev,if (ret)return ret; - ret =i915_gem_object_set_to_gtt_domain (obj, true); -if (ret) { -i915_gem_object_ggtt_unpin (obj); -return ret; - } +if (HAS_LLC (dev_priv) && !obj->stolen) { + ret =i915_gem_object_set_to_cpu_domain (obj, true); +if (ret) { +i915_gem_object_ggtt_unpin (obj); +return ret; + } - ringbuf->virtual_start =ioremap_wc (dev_priv->gtt.mappable_base + -i915_gem_obj_ggtt_offset (obj), ringbuf->size); -if (ringbuf->virtual_start ==NULL ) { -i915_gem_object_ggtt_unpin (obj); -return -EINVAL ; + ringbuf->virtual_start =vmap_obj (obj); +if (ringbuf->virtual_start ==NULL ) { +i915_gem_object_ggtt_unpin (obj); +return -ENOMEM ; + } + }else { + ret =i915_gem_object_set_to_gtt_domain (obj, true); +if (ret) { +i915_gem_object_ggtt_unpin (obj); +return ret; + } + + ringbuf->virtual_start =ioremap_wc (dev_priv->gtt.mappable_base + +i915_gem_obj_ggtt_offset (obj), ringbuf->size); +if (ringbuf->virtual_start ==NULL ) { +i915_gem_object_ggtt_unpin (obj); +return -EINVAL ; + } }return 0 ;
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 31/70 drm/i915: Refactor duplicate object vmap functions
In reply to Chris WilsonWe now have two implementations for vmapping a whole object, one for dma-buf and one for the ringbuffer. If we couple the vmapping into the obj->pages lifetime, then we can reuse an obj->vmapping for both and at the same time couple it into the shrinker.
--- drivers/gpu/drm/i915/i915_drv.h | 12 ++++--- drivers/gpu/drm/i915/i915_gem.c | 41 ++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_gem_dmabuf.c | 55 +++++---------------------------- drivers/gpu/drm/i915/intel_ringbuffer.c | 53 ++++++++++--------------------- 4 files changed, 72 insertions(+), 89 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +8 -4
@@ -2004,10 +2004,7 @@ struct drm_i915_gem_object {struct scatterlist *sg;int last; } get_page; - -/* prime dma-buf support */ -void *dma_buf_vmapping; -int vmapping_count; +void *vmapping;/** Breadcrumb of last rendering to the buffer. * There can only be one writer, but we allow for multiple readers.
@@ -2706,12 +2703,19 @@ static inline void i915_gem_object_pin_pages(struct drm_i915_gem_object *obj)BUG_ON (obj->pages ==NULL ); obj->pages_pin_count++; } +static inline void i915_gem_object_unpin_pages (struct drm_i915_gem_object *obj) {BUG_ON (obj->pages_pin_count ==0 ); obj->pages_pin_count--; } +void *__must_check i915_gem_object_pin_vmap (struct drm_i915_gem_object *obj); +static inline void i915_gem_object_unpin_vmap (struct drm_i915_gem_object *obj) +{ +i915_gem_object_unpin_pages (obj); +} +int __must_check i915_mutex_lock_interruptible (struct drm_device *dev);int i915_gem_object_sync (struct drm_i915_gem_object *obj,struct intel_engine_cs *to);
drivers/gpu/drm/i915/i915_gem.c +41 -0
53 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem_dmabuf.c +7 -48
84 lines not on this page · raw message
drivers/gpu/drm/i915/intel_ringbuffer.c +16 -37
82 lines not on this page · raw message
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 32/70 drm/i915: Treat ringbuffer writes as write to normal memory
In reply to Chris WilsonThe hardware is documentated as treating the TAIL register update as serialising, so we can relax the barriers when filling the rings.
--- drivers/gpu/drm/i915/intel_lrc.h | 6 +++--- drivers/gpu/drm/i915/intel_ringbuffer.h | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/intel_lrc.h +3 -3
@@ -52,8 +52,9 @@ int logical_ring_flush_all_caches(struct intel_ringbuffer *ringbuf,*/ static inline void intel_logical_ring_advance (struct intel_ringbuffer *ringbuf) { - ringbuf->tail &= ringbuf->size -1 ; +intel_ringbuffer_advance (ringbuf); } +/** * intel_logical_ring_emit() - write a DWORD to the ringbuffer. * @ringbuf: Ringbuffer to write to.
@@ -62,8 +63,7 @@ static inline void intel_logical_ring_advance(struct intel_ringbuffer *ringbuf)static inline void intel_logical_ring_emit (struct intel_ringbuffer *ringbuf,u32 data) { -iowrite32 (data, ringbuf->virtual_start + ringbuf->tail); - ringbuf->tail +=4 ; +intel_ringbuffer_emit (ringbuf, data); }/* Logical Ring Contexts */
drivers/gpu/drm/i915/intel_ringbuffer.h +12 -5
@@ -404,17 +404,24 @@ int intel_ring_alloc_request_extras(struct drm_i915_gem_request *request);int __must_check intel_ring_begin (struct intel_engine_cs *ring,int n);int __must_check intel_ring_cacheline_align (struct intel_engine_cs *ring); +static inline void intel_ringbuffer_emit (struct intel_ringbuffer *rb, +u32 data) +{ + *(uint32_t __force *)(rb->virtual_start + rb->tail) = data; + rb->tail +=4 ; +} +static inline void intel_ringbuffer_advance (struct intel_ringbuffer *rb) +{ + rb->tail &= rb->size -1 ; +}static inline void intel_ring_emit (struct intel_engine_cs *ring,u32 data) { -struct intel_ringbuffer *ringbuf = ring->buffer; -iowrite32 (data, ringbuf->virtual_start + ringbuf->tail); - ringbuf->tail +=4 ; +intel_ringbuffer_emit (ring->buffer, data); }static inline void intel_ring_advance (struct intel_engine_cs *ring) { -struct intel_ringbuffer *ringbuf = ring->buffer; - ringbuf->tail &= ringbuf->size -1 ; +intel_ringbuffer_advance (ring->buffer); }int __intel_ring_space (int head,int tail,int size);void intel_ring_update_space (struct intel_ringbuffer *ringbuf);
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 33/70 drm/i915: Use a separate slab for requests
In reply to Chris Wilsonrequests are even more frequently allocated than objects and equally benefit from having a dedicated slab.
v2: Rebase
--- drivers/gpu/drm/i915/i915_dma.c | 12 ++++++---- drivers/gpu/drm/i915/i915_drv.h | 4 +++- drivers/gpu/drm/i915/i915_gem.c | 41 +++++++++++++++++++-------------- drivers/gpu/drm/i915/intel_ringbuffer.c | 1 - 4 files changed, 35 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +8 -4
@@ -1010,8 +1010,10 @@ out_regs: put_bridge:pci_dev_put (dev_priv->bridge_dev); free_priv: -if (dev_priv->slab) -kmem_cache_destroy (dev_priv->slab); +if (dev_priv->requests) +kmem_cache_destroy (dev_priv->requests); +if (dev_priv->objects) +kmem_cache_destroy (dev_priv->objects);kfree (dev_priv);return ret; }
@@ -1094,8 +1096,10 @@ int i915_driver_unload(struct drm_device *dev)if (dev_priv->regs !=NULL )pci_iounmap (dev->pdev, dev_priv->regs); -if (dev_priv->slab) -kmem_cache_destroy (dev_priv->slab); +if (dev_priv->requests) +kmem_cache_destroy (dev_priv->requests); +if (dev_priv->objects) +kmem_cache_destroy (dev_priv->objects);pci_dev_put (dev_priv->bridge_dev);kfree (dev_priv);
drivers/gpu/drm/i915/i915_drv.h +3 -1
@@ -1578,7 +1578,8 @@ struct i915_virtual_gpu {struct drm_i915_private {struct drm_device *dev; -struct kmem_cache *slab; +struct kmem_cache *objects; +struct kmem_cache *requests;const struct intel_device_info info;
@@ -2070,6 +2071,7 @@ struct drm_i915_gem_request {struct kref ref;/** On Which ring this request was generated */ +struct drm_i915_private *i915;struct intel_engine_cs *ring;/** GEM sequence number associated with this request. */
drivers/gpu/drm/i915/i915_gem.c +24 -17
91 lines not on this page · raw message
drivers/gpu/drm/i915/intel_ringbuffer.c +0 -1
@@ -2162,7 +2162,6 @@ int intel_ring_idle(struct intel_engine_cs *ring)int intel_ring_alloc_request_extras (struct drm_i915_gem_request *request) { request->ringbuf = request->ring->buffer; -return 0 ; }
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 33/70] drm/i915: Use a separate slab for requests
Quoted 169 lines · Chris Wilson
requests are even more frequently allocated than objects and equally benefit from having a dedicated slab.
v2: Rebase
Signed-off-by Chris Wilson <[email protected]>--- drivers/gpu/drm/i915/i915_dma.c | 12 ++++++---- drivers/gpu/drm/i915/i915_drv.h | 4 +++- drivers/gpu/drm/i915/i915_gem.c | 41 +++++++++++++++++++-------------- drivers/gpu/drm/i915/intel_ringbuffer.c | 1 - 4 files changed, 35 insertions(+), 23 deletions(-)drivers/gpu/drm/i915/i915_dma.c +8
-4@@ -1010,8 +1010,10 @@ out_regs: put_bridge:pci_dev_put (dev_priv->bridge_dev); free_priv: -if (dev_priv->slab) -kmem_cache_destroy (dev_priv->slab); +if (dev_priv->requests) +kmem_cache_destroy (dev_priv->requests); +if (dev_priv->objects) +kmem_cache_destroy (dev_priv->objects);kfree (dev_priv);return ret; }@@ -1094,8 +1096,10 @@ int i915_driver_unload(struct drm_device *dev)if (dev_priv->regs !=NULL )pci_iounmap (dev->pdev, dev_priv->regs); -if (dev_priv->slab) -kmem_cache_destroy (dev_priv->slab); +if (dev_priv->requests) +kmem_cache_destroy (dev_priv->requests); +if (dev_priv->objects) +kmem_cache_destroy (dev_priv->objects);pci_dev_put (dev_priv->bridge_dev);kfree (dev_priv);drivers/gpu/drm/i915/i915_drv.h +3
-1@@ -1578,7 +1578,8 @@ struct i915_virtual_gpu {struct drm_i915_private {struct drm_device *dev; -struct kmem_cache *slab; +struct kmem_cache *objects; +struct kmem_cache *requests;const struct intel_device_info info;@@ -2070,6 +2071,7 @@ struct drm_i915_gem_request {struct kref ref;/** On Which ring this request was generated */ +struct drm_i915_private *i915;struct intel_engine_cs *ring;/** GEM sequence number associated with this request. */ drivers/gpu/drm/i915/i915_gem.c +24
-17@@ -381,13 +381,13 @@ out:void *i915_gem_object_alloc (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; -return kmem_cache_zalloc (dev_priv->slab,GFP_KERNEL ); +return kmem_cache_zalloc (dev_priv->objects,GFP_KERNEL ); }void i915_gem_object_free (struct drm_i915_gem_object *obj) {struct drm_i915_private *dev_priv = obj->base.dev->dev_private; -kmem_cache_free (dev_priv->slab, obj); +kmem_cache_free (dev_priv->objects, obj); } static int@@ -2633,43 +2633,45 @@ void i915_gem_request_free(struct kref *req_ref)i915_gem_context_unreference (ctx); } -kfree (req); +kmem_cache_free (req->i915->requests, req); }int i915_gem_request_alloc (struct intel_engine_cs *ring,struct intel_context *ctx) { +struct drm_i915_private *dev_priv =to_i915 (ring->dev); +struct drm_i915_gem_request *rq;int ret; -struct drm_i915_gem_request *request; -struct drm_i915_private *dev_private = ring->dev->dev_private;if (ring->outstanding_lazy_request)return 0 ; - request =kzalloc (sizeof (*request),GFP_KERNEL ); -if (request ==NULL ) + rq =kmem_cache_zalloc (dev_priv->requests,GFP_KERNEL ); +if (rq ==NULL )return -ENOMEM ; - ret =i915_gem_get_seqno (ring->dev, &request->seqno); +kref_init (&rq->ref); + rq->i915 = dev_priv; + + ret =i915_gem_get_seqno (ring->dev, &rq->seqno);if (ret) { -kfree (request); +kfree (rq);return ret; } -kref_init (&request->ref); - request->ring = ring; - request->uniq = dev_private->request_uniq++; + rq->ring = ring; + rq->uniq = dev_priv->request_uniq++;if (i915.enable_execlists) - ret =intel_logical_ring_alloc_request_extras (request, ctx); + ret =intel_logical_ring_alloc_request_extras (rq, ctx);else - ret =intel_ring_alloc_request_extras (request); + ret =intel_ring_alloc_request_extras (rq);if (ret) { -kfree (request); +kfree (rq);return ret; } - ring->outstanding_lazy_request = request; + ring->outstanding_lazy_request = rq;return 0 ; }@@ -5204,11 +5206,16 @@ i915_gem_load(struct drm_device *dev)struct drm_i915_private *dev_priv = dev->dev_private;int i; - dev_priv->slab = + dev_priv->objects =kmem_cache_create ("i915_gem_object" ,sizeof (struct drm_i915_gem_object ),0 ,SLAB_HWCACHE_ALIGN ,NULL ); + dev_priv->requests = +kmem_cache_create ("i915_gem_request" , +sizeof (struct drm_i915_gem_request ),0 , +SLAB_HWCACHE_ALIGN , +NULL );INIT_LIST_HEAD (&dev_priv->vm_list);i915_init_vm (dev_priv, &dev_priv->gtt.base);drivers/gpu/drm/i915/intel_ringbuffer.c +0
-0
drivers/gpu/drm/i915/intel_ringbuffer.c int intel_ring_idle(struct intel_engine_cs *ring) · line 2167
Quoted 7 lines
drivers/gpu/drm/i915/intel_ringbuffer.c +0
-1@@ -2162,7 +2162,6 @@ int intel_ring_idle(struct intel_engine_cs *ring)int intel_ring_alloc_request_extras (struct drm_i915_gem_request *request) { request->ringbuf = request->ring->buffer; -return 0 ; }
You missed a request allocation in execlists_context_queue in intel_lrc.c when !request. By the look of it that code could be changed to use i915_gem_request_alloc, unless there is any reason not to set the outstanding_lazy_request to the dummy request.
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 34/70 drm/i915: Use a separate slab for vmas
In reply to Chris Wilsonvma are more frequently allocated than objects and so should equally benefit from having a dedicated slab.
--- drivers/gpu/drm/i915/i915_dma.c | 4 ++++ drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_gem.c | 7 ++++++- drivers/gpu/drm/i915/i915_gem_gtt.c | 3 ++- 4 files changed, 13 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +4 -0
@@ -1012,6 +1012,8 @@ put_bridge: free_priv:if (dev_priv->requests)kmem_cache_destroy (dev_priv->requests); +if (dev_priv->vmas) +kmem_cache_destroy (dev_priv->vmas);if (dev_priv->objects)kmem_cache_destroy (dev_priv->objects);kfree (dev_priv);
@@ -1098,6 +1100,8 @@ int i915_driver_unload(struct drm_device *dev)if (dev_priv->requests)kmem_cache_destroy (dev_priv->requests); +if (dev_priv->vmas) +kmem_cache_destroy (dev_priv->vmas);if (dev_priv->objects)kmem_cache_destroy (dev_priv->objects);
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -1579,6 +1579,7 @@ struct i915_virtual_gpu {struct drm_i915_private {struct drm_device *dev;struct kmem_cache *objects; +struct kmem_cache *vmas;struct kmem_cache *requests;const struct intel_device_info info;
drivers/gpu/drm/i915/i915_gem.c +6 -1
@@ -4832,7 +4832,7 @@ void i915_gem_vma_destroy(struct i915_vma *vma)list_del (&vma->vma_link); -kfree (vma); +kmem_cache_free (to_i915 (vma->obj->base.dev)->vmas, vma); } static void
@@ -5211,6 +5211,11 @@ i915_gem_load(struct drm_device *dev)sizeof (struct drm_i915_gem_object ),0 ,SLAB_HWCACHE_ALIGN , NULL); + dev_priv->vmas = +kmem_cache_create ("i915_gem_vma" , +sizeof (struct i915_vma ),0 , +SLAB_HWCACHE_ALIGN , +NULL ); dev_priv->requests = kmem_cache_create("i915_gem_request", sizeof(struct drm_i915_gem_request), 0,
drivers/gpu/drm/i915/i915_gem_gtt.c +2 -1
@@ -2542,7 +2542,8 @@ __i915_gem_vma_create(struct drm_i915_gem_object *obj,if (WARN_ON (i915_is_ggtt (vm) != !!ggtt_view))return ERR_PTR (-EINVAL ); - vma =kzalloc (sizeof (*vma),GFP_KERNEL ); + + vma =kmem_cache_zalloc (to_i915 (obj->base.dev)->vmas,GFP_KERNEL );if (vma ==NULL )return ERR_PTR (-ENOMEM );
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 34/70] drm/i915: Use a separate slab for vmas
Quoted 4 lines · Chris Wilson
vma are more frequently allocated than objects and so should equally benefit from having a dedicated slab.
Signed-off-by Chris Wilson <[email protected]>
Merged these two moar-slab patches, thanks.
-Daniel
Quoted 87 lines
--- drivers/gpu/drm/i915/i915_dma.c | 4 ++++ drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_gem.c | 7 ++++++- drivers/gpu/drm/i915/i915_gem_gtt.c | 3 ++- 4 files changed, 13 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/i915_dma.c +4
-0@@ -1012,6 +1012,8 @@ put_bridge: free_priv:if (dev_priv->requests)kmem_cache_destroy (dev_priv->requests); +if (dev_priv->vmas) +kmem_cache_destroy (dev_priv->vmas);if (dev_priv->objects)kmem_cache_destroy (dev_priv->objects);kfree (dev_priv);@@ -1098,6 +1100,8 @@ int i915_driver_unload(struct drm_device *dev)if (dev_priv->requests)kmem_cache_destroy (dev_priv->requests); +if (dev_priv->vmas) +kmem_cache_destroy (dev_priv->vmas);if (dev_priv->objects)kmem_cache_destroy (dev_priv->objects);drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -1579,6 +1579,7 @@ struct i915_virtual_gpu {struct drm_i915_private {struct drm_device *dev;struct kmem_cache *objects; +struct kmem_cache *vmas;struct kmem_cache *requests;const struct intel_device_info info;drivers/gpu/drm/i915/i915_gem.c +6
-1@@ -4832,7 +4832,7 @@ void i915_gem_vma_destroy(struct i915_vma *vma)list_del (&vma->vma_link); -kfree (vma); +kmem_cache_free (to_i915 (vma->obj->base.dev)->vmas, vma); } static void@@ -5211,6 +5211,11 @@ i915_gem_load(struct drm_device *dev)sizeof (struct drm_i915_gem_object ),0 ,SLAB_HWCACHE_ALIGN , NULL); + dev_priv->vmas = +kmem_cache_create ("i915_gem_vma" , +sizeof (struct i915_vma ),0 , +SLAB_HWCACHE_ALIGN , +NULL ); dev_priv->requests = kmem_cache_create("i915_gem_request", sizeof(struct drm_i915_gem_request), 0,drivers/gpu/drm/i915/i915_gem_gtt.c +2
-1@@ -2542,7 +2542,8 @@ __i915_gem_vma_create(struct drm_i915_gem_object *obj,if (WARN_ON (i915_is_ggtt (vm) != !!ggtt_view))return ERR_PTR (-EINVAL ); - vma =kzalloc (sizeof (*vma),GFP_KERNEL ); + + vma =kmem_cache_zalloc (to_i915 (obj->base.dev)->vmas,GFP_KERNEL );if (vma ==NULL )return ERR_PTR (-ENOMEM );Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 35/70 drm/i915: Use the new rq->i915 field where appropriate
In reply to Chris WilsonIn a few cases, having a direct pointer to the drm_i915_private from the request is useful.
--- drivers/gpu/drm/i915/i915_gem.c | 11 ++++------- drivers/gpu/drm/i915/intel_pm.c | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +4 -7
@@ -1227,8 +1227,7 @@ int __i915_wait_request(struct drm_i915_gem_request *req, struct drm_i915_file_private *file_priv) {struct intel_engine_cs *ring =i915_gem_request_get_ring (req); -struct drm_device *dev = ring->dev; -struct drm_i915_private *dev_priv = dev->dev_private; +struct drm_i915_private *dev_priv = req->i915;const bool irq_test_in_progress =ACCESS_ONCE (dev_priv->gpu_error.test_irq_rings) &intel_ring_flag (ring);DEFINE_WAIT (wait);
@@ -1247,7 +1246,7 @@ int __i915_wait_request(struct drm_i915_gem_request *req, timeout_expire = timeout ? jiffies +nsecs_to_jiffies_timeout ((u64)*timeout) :0 ; -if (INTEL_INFO (dev)->gen >=6 ) +if (INTEL_INFO (dev_priv)->gen >=6 )gen6_rps_boost (dev_priv, file_priv);/* Record current time in case interrupted by signal, or wedged */
@@ -1404,18 +1403,16 @@ __i915_gem_request_retire__upto(struct drm_i915_gem_request *rq)int i915_wait_request (struct drm_i915_gem_request *req) { -struct drm_device *dev;struct drm_i915_private *dev_priv;bool interruptible;int ret;BUG_ON (req ==NULL ); - dev = req->ring->dev; - dev_priv = dev->dev_private; + dev_priv = req->i915; interruptible = dev_priv->mm.interruptible; -BUG_ON (!mutex_is_locked (&dev->struct_mutex)); +BUG_ON (!mutex_is_locked (&dev_priv->dev->struct_mutex)); ret =i915_gem_check_wedge (&dev_priv->gpu_error, interruptible);if (ret)
drivers/gpu/drm/i915/intel_pm.c +1 -1
@@ -6793,7 +6793,7 @@ static void __intel_rps_boost_work(struct work_struct *work) struct request_boost *boost = container_of(work, struct request_boost, work);if (!i915_gem_request_completed (boost->rq, true)) -gen6_rps_boost (to_i915 (boost->rq->ring->dev),NULL ); +gen6_rps_boost (boost->rq->i915,NULL );i915_gem_request_unreference__unlocked (boost->rq);kfree (boost);
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 36/70 drm/i915: Reduce the pointer dance of i915_is_ggtt()
In reply to Chris WilsonThe multiple levels of indirect do nothing but hinder the compiler and the pointer chasing turns to be quite painful but painless to fix.
--- drivers/gpu/drm/i915/i915_drv.h | 4 +--- drivers/gpu/drm/i915/i915_gem_gtt.c | 1 + drivers/gpu/drm/i915/i915_gem_gtt.h | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -3
@@ -2898,9 +2898,7 @@ bool i915_gem_obj_is_pinned(struct drm_i915_gem_object *obj); (&((struct drm_i915_private *)(obj)->base.dev->dev_private)->gtt.base)static inline bool i915_is_ggtt (struct i915_address_space *vm) { -struct i915_address_space *ggtt = - &((struct drm_i915_private *)(vm)->dev->dev_private)->gtt.base; -return vm == ggtt; +return vm->is_ggtt; } static inline struct i915_hw_ppgtt *
drivers/gpu/drm/i915/i915_gem_gtt.c +1 -0
@@ -2511,6 +2511,7 @@ int i915_gem_gtt_init(struct drm_device *dev)return ret; gtt->base.dev = dev; + gtt->base.is_ggtt = true;/* GMADR is the PCI mmio aperture into the global GTT. */ DRM_INFO("Memory usable by graphics device = %zdM\n",
drivers/gpu/drm/i915/i915_gem_gtt.h +2 -0
@@ -235,6 +235,8 @@ struct i915_address_space {unsigned long start;/* Start offset always 0 for dri2 */ size_t total;/* size addr space maps (ex. 2GB for ggtt) */ +bool is_ggtt; +struct {dma_addr_t addr;struct page *page;
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 37/70 drm/i915: Squash more pointer indirection for i915_is_gtt
In reply to Chris Wilson12:58 < jlahtine> there're actually equally many i915_is_ggtt(vma->vm) calls
12:58 < jlahtine> (one less)
12:59 < jlahtine> so while at it I'd make it vm->is_ggtt and vma->is_ggtt
12:59 < jlahtine> then get rid of the whole helper, maybe 13:00 < ickle> you preempted my beautiful macro
13:03 < ickle> just don't complain about the increased churn
* to be squashed into the previous patch if desired
--- drivers/gpu/drm/i915/i915_debugfs.c | 4 ++-- drivers/gpu/drm/i915/i915_drv.h | 7 +------ drivers/gpu/drm/i915/i915_gem.c | 32 ++++++++++++++---------------- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 5 ++--- drivers/gpu/drm/i915/i915_gem_gtt.c | 21 ++++++++++---------- drivers/gpu/drm/i915/i915_gem_gtt.h | 1 + drivers/gpu/drm/i915/i915_gpu_error.c | 2 +- drivers/gpu/drm/i915/i915_trace.h | 18 ++++++----------- 8 files changed, 39 insertions(+), 51 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +2 -2
@@ -156,7 +156,7 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)if (obj->fence_reg !=I915_FENCE_REG_NONE )seq_printf (m," (fence: %d)" , obj->fence_reg);list_for_each_entry (vma, &obj->vma_list, vma_link) { -if (!i915_is_ggtt (vma->vm)) +if (!vma->is_ggtt)seq_puts (m," (pp" );else seq_puts (m," (g" );
@@ -335,7 +335,7 @@ static int per_file_stats(int id, void *ptr, void *data)if (!drm_mm_node_allocated (&vma->node))continue ; -if (i915_is_ggtt (vma->vm)) { +if (vma->is_ggtt) { stats->global += obj->base.size;continue ; }
drivers/gpu/drm/i915/i915_drv.h +1 -6
@@ -2896,16 +2896,11 @@ bool i915_gem_obj_is_pinned(struct drm_i915_gem_object *obj);/* Some GGTT VM helpers */ #define i915_obj_to_ggtt (obj) \ (&((struct drm_i915_private *)(obj)->base.dev->dev_private)->gtt.base) -static inline bool i915_is_ggtt (struct i915_address_space *vm) -{ -return vm->is_ggtt; -}static inline struct i915_hw_ppgtt *i915_vm_to_ppgtt (struct i915_address_space *vm) { -WARN_ON (i915_is_ggtt (vm)); - +WARN_ON (vm->is_ggtt); return container_of(vm, struct i915_hw_ppgtt, base); }
drivers/gpu/drm/i915/i915_gem.c +15 -17
@@ -3200,8 +3200,7 @@ int i915_vma_unbind(struct i915_vma *vma)* cause memory corruption through use-after-free. */ -if (i915_is_ggtt (vma->vm) && - vma->ggtt_view.type ==I915_GGTT_VIEW_NORMAL ) { +if (vma->is_ggtt && vma->ggtt_view.type ==I915_GGTT_VIEW_NORMAL ) {i915_gem_object_finish_gtt (obj);/* release the fence reg _after_ flushing */
@@ -3215,7 +3214,7 @@ int i915_vma_unbind(struct i915_vma *vma) vma->unbind_vma (vma);list_del_init (&vma->mm_list); -if (i915_is_ggtt (vma->vm)) { +if (vma->is_ggtt) {if (vma->ggtt_view.type ==I915_GGTT_VIEW_NORMAL ) { obj->map_and_fenceable = false; }else if (vma->ggtt_view.pages) {
@@ -3658,7 +3657,7 @@ i915_gem_object_bind_to_vm(struct drm_i915_gem_object *obj,struct i915_vma *vma;int ret; -if (WARN_ON (i915_is_ggtt (vm) != !!ggtt_view)) +if (WARN_ON (vm->is_ggtt != !!ggtt_view))return ERR_PTR (-EINVAL ); fence_size = i915_gem_get_gtt_size(dev,
@@ -3756,8 +3755,7 @@ search_free:/* allocate before insert / bind */ if (vma->vm->allocate_va_range) { -trace_i915_va_alloc (vma->vm, vma->node.start, vma->node.size, -VM_TO_TRACE_NAME (vma->vm)); +trace_i915_va_alloc (vma->vm, vma->node.start, vma->node.size); ret = vma->vm->allocate_va_range (vma->vm, vma->node.start, vma->node.size);
@@ -4360,13 +4358,13 @@ i915_gem_object_do_pin(struct drm_i915_gem_object *obj,if (WARN_ON (vm == &dev_priv->mm.aliasing_ppgtt->base))return -ENODEV ; -if (WARN_ON (flags & (PIN_GLOBAL |PIN_MAPPABLE ) && !i915_is_ggtt (vm))) +if (WARN_ON (flags & (PIN_GLOBAL |PIN_MAPPABLE ) && !vm->is_ggtt))return -EINVAL ;if (WARN_ON ((flags & (PIN_MAPPABLE |PIN_GLOBAL )) ==PIN_MAPPABLE ))return -EINVAL ; -if (WARN_ON (i915_is_ggtt (vm) != !!ggtt_view)) +if (WARN_ON (vm->is_ggtt != !!ggtt_view))return -EINVAL ; vma = ggtt_view ? i915_gem_obj_to_ggtt_view(obj, ggtt_view) :
@@ -4456,7 +4454,7 @@ i915_gem_object_pin(struct drm_i915_gem_object *obj, uint64_t flags) {return i915_gem_object_do_pin (obj, vm, -i915_is_ggtt (vm) ? &i915_ggtt_view_normal :NULL , + vm->is_ggtt ? &i915_ggtt_view_normal :NULL , size, alignment, flags); }
@@ -4788,7 +4786,7 @@ struct i915_vma *i915_gem_obj_to_vma(struct drm_i915_gem_object *obj, {struct i915_vma *vma;list_for_each_entry (vma, &obj->vma_list, vma_link) { -if (i915_is_ggtt (vma->vm) && +if (vma->is_ggtt && vma->ggtt_view.type !=I915_GGTT_VIEW_NORMAL )continue ;if (vma->vm == vm)
@@ -4824,7 +4822,7 @@ void i915_gem_vma_destroy(struct i915_vma *vma) vm = vma->vm; -if (!i915_is_ggtt (vm)) +if (!vm->is_ggtt)i915_ppgtt_put (i915_vm_to_ppgtt (vm));list_del (&vma->vma_link);
@@ -5188,7 +5186,7 @@ init_ring_lists(struct intel_engine_cs *ring)void i915_init_vm (struct drm_i915_private *dev_priv,struct i915_address_space *vm) { -if (!i915_is_ggtt (vm)) +if (!vm->is_ggtt)drm_mm_init (&vm->mm, vm->start, vm->total); vm->dev = dev_priv->dev;INIT_LIST_HEAD (&vm->active_list);
@@ -5353,7 +5351,7 @@ i915_gem_obj_offset(struct drm_i915_gem_object *o,WARN_ON (vm == &dev_priv->mm.aliasing_ppgtt->base);list_for_each_entry (vma, &o->vma_list, vma_link) { -if (i915_is_ggtt (vma->vm) && +if (vma->is_ggtt && vma->ggtt_view.type !=I915_GGTT_VIEW_NORMAL )continue ;if (vma->vm == vm)
@@ -5361,7 +5359,7 @@ i915_gem_obj_offset(struct drm_i915_gem_object *o, }WARN (1 ,"%s vma for this object not found.\n" , -i915_is_ggtt (vm) ?"global" :"ppgtt" ); + vm->is_ggtt ?"global" :"ppgtt" );return -1 ; }
@@ -5387,7 +5385,7 @@ bool i915_gem_obj_bound(struct drm_i915_gem_object *o,struct i915_vma *vma;list_for_each_entry (vma, &o->vma_list, vma_link) { -if (i915_is_ggtt (vma->vm) && +if (vma->is_ggtt && vma->ggtt_view.type !=I915_GGTT_VIEW_NORMAL )continue ;if (vma->vm == vm &&drm_mm_node_allocated (&vma->node))
@@ -5434,7 +5432,7 @@ unsigned long i915_gem_obj_size(struct drm_i915_gem_object *o,BUG_ON (list_empty (&o->vma_list));list_for_each_entry (vma, &o->vma_list, vma_link) { -if (i915_is_ggtt (vma->vm) && +if (vma->is_ggtt && vma->ggtt_view.type !=I915_GGTT_VIEW_NORMAL )continue ;if (vma->vm == vm)
@@ -5447,7 +5445,7 @@ bool i915_gem_obj_is_pinned(struct drm_i915_gem_object *obj) {struct i915_vma *vma;list_for_each_entry (vma, &obj->vma_list, vma_link) { -if (i915_is_ggtt (vma->vm) && +if (vma->is_ggtt && vma->ggtt_view.type !=I915_GGTT_VIEW_NORMAL )continue ;if (vma->pin_count >0 )
drivers/gpu/drm/i915/i915_gem_execbuffer.c +2 -3
@@ -642,7 +642,7 @@ need_reloc_mappable(struct i915_vma *vma)if (entry->relocation_count ==0 )return false; -if (!i915_is_ggtt (vma->vm)) +if (!vma->is_ggtt)return false;/* See also use_cpu_reloc() */
@@ -661,8 +661,7 @@ eb_vma_misplaced(struct i915_vma *vma)struct drm_i915_gem_exec_object2 *entry = vma->exec_entry;struct drm_i915_gem_object *obj = vma->obj; -WARN_ON (entry->flags & __EXEC_OBJECT_NEEDS_MAP && - !i915_is_ggtt (vma->vm)); +WARN_ON (entry->flags & __EXEC_OBJECT_NEEDS_MAP && !vma->is_ggtt);if (entry->alignment && vma->node.start & (entry->alignment -1 ))
drivers/gpu/drm/i915/i915_gem_gtt.c +11 -10
@@ -1703,7 +1703,7 @@ void i915_gem_restore_gtt_mappings(struct drm_device *dev) container_of(vm, struct i915_hw_ppgtt, base); -if (i915_is_ggtt (vm)) +if (vm->is_ggtt) ppgtt = dev_priv->mm.aliasing_ppgtt; gen6_write_page_range(dev_priv, &ppgtt->pd,
@@ -1881,7 +1881,7 @@ static void i915_ggtt_bind_vma(struct i915_vma *vma,unsigned int flags = (cache_level ==I915_CACHE_NONE ) ?AGP_USER_MEMORY :AGP_USER_CACHED_MEMORY ; -BUG_ON (!i915_is_ggtt (vma->vm)); +BUG_ON (!vma->is_ggtt);intel_gtt_insert_sg_entries (vma->ggtt_view.pages, entry, flags); vma->bound =GLOBAL_BIND ; }
@@ -1901,7 +1901,7 @@ static void i915_ggtt_unbind_vma(struct i915_vma *vma)const unsigned int first = vma->node.start >>PAGE_SHIFT ;const unsigned int size = vma->obj->base.size >>PAGE_SHIFT ; -BUG_ON (!i915_is_ggtt (vma->vm)); +BUG_ON (!vma->is_ggtt); vma->bound =0 ;intel_gtt_clear_range (first, size); }
@@ -1919,7 +1919,7 @@ static void ggtt_bind_vma(struct i915_vma *vma,if (obj->gt_ro) flags |=PTE_READ_ONLY ; -if (i915_is_ggtt (vma->vm)) +if (vma->is_ggtt) pages = vma->ggtt_view.pages;/* If there is no aliasing PPGTT, or the caller needs a global mapping,
@@ -2541,7 +2541,7 @@ __i915_gem_vma_create(struct drm_i915_gem_object *obj, {struct i915_vma *vma; -if (WARN_ON (i915_is_ggtt (vm) != !!ggtt_view)) +if (WARN_ON (vm->is_ggtt != !!ggtt_view))return ERR_PTR (-EINVAL ); vma =kmem_cache_zalloc (to_i915 (obj->base.dev)->vmas,GFP_KERNEL );
@@ -2553,9 +2553,10 @@ __i915_gem_vma_create(struct drm_i915_gem_object *obj,INIT_LIST_HEAD (&vma->exec_list); vma->vm = vm; vma->obj = obj; + vma->is_ggtt = vm->is_ggtt;if (INTEL_INFO (vm->dev)->gen >=6 ) { -if (i915_is_ggtt (vm)) { +if (vm->is_ggtt) { vma->ggtt_view = *ggtt_view; vma->unbind_vma = ggtt_unbind_vma;
@@ -2565,14 +2566,14 @@ __i915_gem_vma_create(struct drm_i915_gem_object *obj, vma->bind_vma = ppgtt_bind_vma; } }else { -BUG_ON (!i915_is_ggtt (vm)); +BUG_ON (!vm->is_ggtt); vma->ggtt_view = *ggtt_view; vma->unbind_vma = i915_ggtt_unbind_vma; vma->bind_vma = i915_ggtt_bind_vma; }list_add_tail (&vma->vma_link, &obj->vma_list); -if (!i915_is_ggtt (vm)) +if (!vm->is_ggtt)i915_ppgtt_get (i915_vm_to_ppgtt (vm));return vma;
@@ -2587,7 +2588,7 @@ i915_gem_obj_lookup_or_create_vma(struct drm_i915_gem_object *obj, vma =i915_gem_obj_to_vma (obj, vm);if (!vma) vma =__i915_gem_vma_create (obj, vm, -i915_is_ggtt (vm) ? &i915_ggtt_view_normal :NULL ); + vm->is_ggtt ? &i915_ggtt_view_normal :NULL );return vma; }
@@ -2758,7 +2759,7 @@ i915_get_ggtt_vma_pages(struct i915_vma *vma)int i915_vma_bind (struct i915_vma *vma,enum i915_cache_level cache_level,u32 flags) { -if (i915_is_ggtt (vma->vm)) { +if (vma->is_ggtt) {int ret =i915_get_ggtt_vma_pages (vma);if (ret)
drivers/gpu/drm/i915/i915_gem_gtt.h +1 -0
@@ -160,6 +160,7 @@ struct i915_vma {#define LOCAL_BIND (1<<1)#define PTE_READ_ONLY (1<<2) unsigned int bound : 4; + unsigned is_ggtt : 1;/** * Support different GGTT views into the same object.
drivers/gpu/drm/i915/i915_gpu_error.c +1 -1
@@ -606,7 +606,7 @@ i915_error_object_create(struct drm_i915_private *dev_priv, dst->gtt_offset =-1 ; reloc_offset = dst->gtt_offset; -if (i915_is_ggtt (vm)) +if (vm->is_ggtt) vma =i915_gem_obj_to_ggtt (src); use_ggtt = (src->cache_level == I915_CACHE_NONE && vma && (vma->bound & GLOBAL_BIND) &&
drivers/gpu/drm/i915/i915_trace.h +6 -12
@@ -156,35 +156,29 @@ TRACE_EVENT(i915_vma_unbind, __entry->obj, __entry->offset, __entry->size, __entry->vm) ); -#define VM_TO_TRACE_NAME (vm) \ - (i915_is_ggtt(vm) ? "G" : \ - "P") -DECLARE_EVENT_CLASS (i915_va, - TP_PROTO(struct i915_address_space *vm, u64 start, u64 length, const char *name), -TP_ARGS (vm, start, length, name), + TP_PROTO(struct i915_address_space *vm, u64 start, u64 length), +TP_ARGS (vm, start, length),TP_STRUCT__entry ( __field(struct i915_address_space *, vm) __field(u64, start)__field (u64, end) -__string (name, name) ),TP_fast_assign ( __entry->vm = vm; __entry->start = start; __entry->end = start + length - 1; - __assign_str(name, name); ), -TP_printk ("vm=%p (%s), 0x%llx-0x%llx" , - __entry->vm,__get_str (name), __entry->start, __entry->end) +TP_printk ("vm=%p (%c), 0x%llx-0x%llx" , + __entry->vm, __entry->vm->is_ggtt ?'G' :'P' , __entry->start, __entry->end) );DEFINE_EVENT (i915_va, i915_va_alloc, - TP_PROTO(struct i915_address_space *vm, u64 start, u64 length, const char *name), -TP_ARGS (vm, start, length, name) + TP_PROTO(struct i915_address_space *vm, u64 start, u64 length), +TP_ARGS (vm, start, length) ); DECLARE_EVENT_CLASS(i915_page_table_entry,
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 38/70 drm/i915: Reduce locking in execlist command submission
In reply to Chris WilsonThis eliminates six needless spin lock/unlock pairs when writing out ELSP.
v2: Respin with my preferred colour.
v3: Mostly back to the original colour
--- drivers/gpu/drm/i915/i915_drv.h | 18 +++++++ drivers/gpu/drm/i915/intel_lrc.c | 16 +++--- drivers/gpu/drm/i915/intel_uncore.c | 98 ++++++++++++++++++++++++++++--------- 3 files changed, 103 insertions(+), 29 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +18 -0
@@ -2551,6 +2551,13 @@ void intel_uncore_forcewake_get(struct drm_i915_private *dev_priv, enum forcewake_domains domains);void intel_uncore_forcewake_put (struct drm_i915_private *dev_priv,enum forcewake_domains domains); +/* Like above but the caller must manage the uncore.lock itself. +* Must be used with I915_READ_FW and friends. +*/ +void intel_uncore_forcewake_get__locked (struct drm_i915_private *dev_priv, +enum forcewake_domains domains); +void intel_uncore_forcewake_put__locked (struct drm_i915_private *dev_priv, +enum forcewake_domains domains);void assert_forcewakes_inactive (struct drm_i915_private *dev_priv);static inline bool intel_vgpu_active (struct drm_device *dev) {
@@ -3249,6 +3256,17 @@ int intel_freq_opcode(struct drm_i915_private *dev_priv, int val);#define POSTING_READ (reg) (void)I915_READ_NOTRACE(reg)#define POSTING_READ16 (reg) (void)I915_READ16_NOTRACE(reg) +/* These are untraced mmio-accessors that are only valid to be used inside +* criticial sections inside IRQ handlers where forcewake is explicitly +* controlled. +* Think twice, and think again, before using these. +* Note: Should only be used between intel_uncore_forcewake_irqlock() and +* intel_uncore_forcewake_irqunlock(). +*/ +#define I915_READ_FW (reg__) readl(dev_priv->regs + (reg__)) +#define I915_WRITE_FW (reg__, val__) writel(val__, dev_priv->regs + (reg__)) +#define POSTING_READ_FW (reg__) (void)I915_READ_FW(reg__) +/* "Broadcast RGB" property */ #define INTEL_BROADCAST_RGB_AUTO 0#define INTEL_BROADCAST_RGB_FULL 1
drivers/gpu/drm/i915/intel_lrc.c +9 -7
@@ -278,17 +278,19 @@ static void execlists_submit_pair(struct intel_engine_cs *ring) desc[3 ] = ring->execlist_port[0 ]->seqno;/* Note: You must always write both descriptors in the order below. */ -intel_uncore_forcewake_get (dev_priv,FORCEWAKE_ALL ); -I915_WRITE (RING_ELSP (ring), desc[1 ]); -I915_WRITE (RING_ELSP (ring), desc[0 ]); -I915_WRITE (RING_ELSP (ring), desc[3 ]); +spin_lock (&dev_priv->uncore.lock); +intel_uncore_forcewake_get__locked (dev_priv,FORCEWAKE_ALL ); +I915_WRITE_FW (RING_ELSP (ring), desc[1 ]); +I915_WRITE_FW (RING_ELSP (ring), desc[0 ]); +I915_WRITE_FW (RING_ELSP (ring), desc[3 ]);/* The context is automatically loaded after the following */ -I915_WRITE (RING_ELSP (ring), desc[2 ]); +I915_WRITE_FW (RING_ELSP (ring), desc[2 ]);/* ELSP is a wo register, use another nearby reg for posting instead */ -POSTING_READ (RING_EXECLIST_STATUS (ring)); -intel_uncore_forcewake_put (dev_priv,FORCEWAKE_ALL ); +POSTING_READ_FW (RING_EXECLIST_STATUS (ring)); +intel_uncore_forcewake_put__locked (dev_priv,FORCEWAKE_ALL ); +spin_unlock (&dev_priv->uncore.lock); }static void execlists_context_unqueue (struct intel_engine_cs *ring)
drivers/gpu/drm/i915/intel_uncore.c +76 -22
141 lines not on this page · raw message
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 39/70 drm/i915: Reduce more locking in execlist command submission
In reply to Chris WilsonSlightly more extravagant than the previous patch is to use the I915_READ_FW() registers for all the bounded reads in intel_lrc_irq_handler - for even more spinlock reduction.
v2: Rebase
--- drivers/gpu/drm/i915/intel_lrc.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +21 -14
@@ -278,19 +278,12 @@ static void execlists_submit_pair(struct intel_engine_cs *ring) desc[3 ] = ring->execlist_port[0 ]->seqno;/* Note: You must always write both descriptors in the order below. */ -spin_lock (&dev_priv->uncore.lock); -intel_uncore_forcewake_get__locked (dev_priv,FORCEWAKE_ALL );I915_WRITE_FW (RING_ELSP (ring), desc[1 ]);I915_WRITE_FW (RING_ELSP (ring), desc[0 ]);I915_WRITE_FW (RING_ELSP (ring), desc[3 ]);/* The context is automatically loaded after the following */ I915_WRITE_FW (RING_ELSP (ring), desc[2 ]); - -/* ELSP is a wo register, use another nearby reg for posting instead */ -POSTING_READ_FW (RING_EXECLIST_STATUS (ring)); -intel_uncore_forcewake_put__locked (dev_priv,FORCEWAKE_ALL ); -spin_unlock (&dev_priv->uncore.lock); }static void execlists_context_unqueue (struct intel_engine_cs *ring)
@@ -379,31 +372,37 @@ void intel_lrc_irq_handler(struct intel_engine_cs *ring)u8 head, tail;u32 seqno =0 ; +spin_lock (&ring->execlist_lock); +spin_lock (&dev_priv->uncore.lock); +intel_uncore_forcewake_get__locked (dev_priv,FORCEWAKE_ALL ); + head = ring->next_context_status_buffer; - tail =I915_READ (RING_CONTEXT_STATUS_PTR (ring)) &0x7 ; + tail =I915_READ_FW (RING_CONTEXT_STATUS_PTR (ring)) &0x7 ;if (head > tail) tail +=6 ;while (head++ < tail) {u32 reg =RING_CONTEXT_STATUS_BUF (ring) + (head %6 )*8 ; -u32 status =I915_READ (reg); +u32 status =I915_READ_FW (reg);if (unlikely (status &GEN8_CTX_STATUS_PREEMPTED &&0 )) {DRM_ERROR ("Pre-empted request %x %s Lite Restore\n" , -I915_READ (reg +4 ), +I915_READ_FW (reg +4 ), status &GEN8_CTX_STATUS_LITE_RESTORE ?"with" :"without" ); }if (status & (GEN8_CTX_STATUS_ACTIVE_IDLE |GEN8_CTX_STATUS_ELEMENT_SWITCH )) - seqno =I915_READ (reg +4 ); + seqno =I915_READ_FW (reg +4 ); } ring->next_context_status_buffer = tail %6 ; -I915_WRITE (RING_CONTEXT_STATUS_PTR (ring), - (u32 )ring->next_context_status_buffer <<8 ); +I915_WRITE_FW (RING_CONTEXT_STATUS_PTR (ring), + (u32 )ring->next_context_status_buffer <<8 ); -spin_lock (&ring->execlist_lock);if (execlists_complete_requests (ring, seqno))execlists_context_unqueue (ring); + +intel_uncore_forcewake_put__locked (dev_priv,FORCEWAKE_ALL ); +spin_unlock (&dev_priv->uncore.lock);spin_unlock (&ring->execlist_lock); }
@@ -427,8 +426,16 @@ static int execlists_context_queue(struct intel_engine_cs *ring,list_add_tail (&request->execlist_link, &ring->execlist_queue);if (ring->execlist_port[0 ] ==NULL ) { +struct drm_i915_private *dev_priv =to_i915 (ring->dev); + +spin_lock (&dev_priv->uncore.lock); +intel_uncore_forcewake_get__locked (dev_priv,FORCEWAKE_ALL ); + ring->execlist_port[0 ] = request;execlists_submit_pair (ring); + +intel_uncore_forcewake_put__locked (dev_priv,FORCEWAKE_ALL ); +spin_unlock (&dev_priv->uncore.lock); }spin_unlock_irq (&ring->execlist_lock);
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 40/70 drm/i915: Reduce locking in gen8 IRQ handler
In reply to Chris WilsonSimilar in vain in reducing the number of unrequired spinlocks used for execlist command submission (where the forcewake is required but manually controlled), we know that the IRQ registers are outside of the powerwell and so we can access them directly. Since we now have direct access exported via I915_READ_FW/I915_WRITE_FW, lets put those to use in the irq handlers as well.
In the process, reorder the execlist submission to happen as early as possible.
v2: Restrict the untraced register mmio to just the GT path (i.e. the hotpath for execlists)
--- drivers/gpu/drm/i915/i915_irq.c | 47 ++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 24 deletions(-)
drivers/gpu/drm/i915/i915_irq.c +23 -24
@@ -1285,56 +1285,56 @@ static irqreturn_t gen8_gt_irq_handler(struct drm_device *dev,irqreturn_t ret =IRQ_NONE ;if (master_ctl & (GEN8_GT_RCS_IRQ |GEN8_GT_BCS_IRQ )) { - tmp =I915_READ (GEN8_GT_IIR (0 )); + tmp =I915_READ_FW (GEN8_GT_IIR (0 ));if (tmp) { -I915_WRITE (GEN8_GT_IIR (0 ), tmp); +I915_WRITE_FW (GEN8_GT_IIR (0 ), tmp); ret =IRQ_HANDLED ; rcs = tmp >>GEN8_RCS_IRQ_SHIFT ; ring = &dev_priv->ring[RCS ]; -if (rcs >_RENDER_USER_INTERRUPT ) -notify_ring (dev, ring);if (rcs >_CONTEXT_SWITCH_INTERRUPT )intel_lrc_irq_handler (ring); +if (rcs >_RENDER_USER_INTERRUPT ) +notify_ring (dev, ring); bcs = tmp >>GEN8_BCS_IRQ_SHIFT ; ring = &dev_priv->ring[BCS ]; -if (bcs >_RENDER_USER_INTERRUPT ) -notify_ring (dev, ring);if (bcs >_CONTEXT_SWITCH_INTERRUPT )intel_lrc_irq_handler (ring); +if (bcs >_RENDER_USER_INTERRUPT ) +notify_ring (dev, ring); }else DRM_ERROR ("The master control interrupt lied (GT0)!\n" ); }if (master_ctl & (GEN8_GT_VCS1_IRQ |GEN8_GT_VCS2_IRQ )) { - tmp =I915_READ (GEN8_GT_IIR (1 )); + tmp =I915_READ_FW (GEN8_GT_IIR (1 ));if (tmp) { -I915_WRITE (GEN8_GT_IIR (1 ), tmp); +I915_WRITE_FW (GEN8_GT_IIR (1 ), tmp); ret =IRQ_HANDLED ; vcs = tmp >>GEN8_VCS1_IRQ_SHIFT ; ring = &dev_priv->ring[VCS ]; -if (vcs >_RENDER_USER_INTERRUPT ) -notify_ring (dev, ring);if (vcs >_CONTEXT_SWITCH_INTERRUPT )intel_lrc_irq_handler (ring); +if (vcs >_RENDER_USER_INTERRUPT ) +notify_ring (dev, ring); vcs = tmp >>GEN8_VCS2_IRQ_SHIFT ; ring = &dev_priv->ring[VCS2 ]; -if (vcs >_RENDER_USER_INTERRUPT ) -notify_ring (dev, ring);if (vcs >_CONTEXT_SWITCH_INTERRUPT )intel_lrc_irq_handler (ring); +if (vcs >_RENDER_USER_INTERRUPT ) +notify_ring (dev, ring); }else DRM_ERROR ("The master control interrupt lied (GT1)!\n" ); }if (master_ctl &GEN8_GT_PM_IRQ ) { - tmp =I915_READ (GEN8_GT_IIR (2 )); + tmp =I915_READ_FW (GEN8_GT_IIR (2 ));if (tmp & dev_priv->pm_rps_events) { -I915_WRITE (GEN8_GT_IIR (2 ), - tmp & dev_priv->pm_rps_events); +I915_WRITE_FW (GEN8_GT_IIR (2 ), + tmp & dev_priv->pm_rps_events); ret =IRQ_HANDLED ;gen6_rps_irq_handler (dev_priv, tmp); }else
@@ -1342,17 +1342,17 @@ static irqreturn_t gen8_gt_irq_handler(struct drm_device *dev, }if (master_ctl &GEN8_GT_VECS_IRQ ) { - tmp =I915_READ (GEN8_GT_IIR (3 )); + tmp =I915_READ_FW (GEN8_GT_IIR (3 ));if (tmp) { -I915_WRITE (GEN8_GT_IIR (3 ), tmp); +I915_WRITE_FW (GEN8_GT_IIR (3 ), tmp); ret =IRQ_HANDLED ; vcs = tmp >>GEN8_VECS_IRQ_SHIFT ; ring = &dev_priv->ring[VECS ]; -if (vcs >_RENDER_USER_INTERRUPT ) -notify_ring (dev, ring);if (vcs >_CONTEXT_SWITCH_INTERRUPT )intel_lrc_irq_handler (ring); +if (vcs >_RENDER_USER_INTERRUPT ) +notify_ring (dev, ring); }else DRM_ERROR ("The master control interrupt lied (GT3)!\n" ); }
@@ -2178,13 +2178,12 @@ static irqreturn_t gen8_irq_handler(int irq, void *arg) aux_mask |=GEN9_AUX_CHANNEL_B |GEN9_AUX_CHANNEL_C |GEN9_AUX_CHANNEL_D ; - master_ctl =I915_READ (GEN8_MASTER_IRQ ); + master_ctl =I915_READ_FW (GEN8_MASTER_IRQ ); master_ctl &= ~GEN8_MASTER_IRQ_CONTROL ;if (!master_ctl)return IRQ_NONE ; -I915_WRITE (GEN8_MASTER_IRQ ,0 ); -POSTING_READ (GEN8_MASTER_IRQ ); +I915_WRITE_FW (GEN8_MASTER_IRQ ,0 );/* Find, clear, then process each source of interrupt */
@@ -2281,8 +2280,8 @@ static irqreturn_t gen8_irq_handler(int irq, void *arg) } -I915_WRITE (GEN8_MASTER_IRQ ,GEN8_MASTER_IRQ_CONTROL ); -POSTING_READ (GEN8_MASTER_IRQ ); +I915_WRITE_FW (GEN8_MASTER_IRQ ,GEN8_MASTER_IRQ_CONTROL ); +POSTING_READ_FW (GEN8_MASTER_IRQ );return ret; }
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 41/70 drm/i915: Tidy gen8 IRQ handler
In reply to Chris WilsonRemove some needless variables and parameter passing.
--- drivers/gpu/drm/i915/i915_irq.c | 113 +++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 64 deletions(-)
drivers/gpu/drm/i915/i915_irq.c +49 -64
@@ -985,8 +985,7 @@ static void ironlake_rps_change_irq_handler(struct drm_device *dev)return ; } -static void notify_ring (struct drm_device *dev, -struct intel_engine_cs *ring) +static void notify_ring (struct intel_engine_cs *ring) {if (!intel_ring_initialized (ring))return ;
@@ -1248,9 +1247,9 @@ static void ilk_gt_irq_handler(struct drm_device *dev, {if (gt_iir & (GT_RENDER_USER_INTERRUPT |GT_RENDER_PIPECTL_NOTIFY_INTERRUPT )) -notify_ring (dev, &dev_priv->ring[RCS ]); +notify_ring (&dev_priv->ring[RCS ]);if (gt_iir &ILK_BSD_USER_INTERRUPT ) -notify_ring (dev, &dev_priv->ring[VCS ]); +notify_ring (&dev_priv->ring[VCS ]); } static void snb_gt_irq_handler(struct drm_device *dev,
@@ -1260,11 +1259,11 @@ static void snb_gt_irq_handler(struct drm_device *dev,if (gt_iir & (GT_RENDER_USER_INTERRUPT |GT_RENDER_PIPECTL_NOTIFY_INTERRUPT )) -notify_ring (dev, &dev_priv->ring[RCS ]); +notify_ring (&dev_priv->ring[RCS ]);if (gt_iir >_BSD_USER_INTERRUPT ) -notify_ring (dev, &dev_priv->ring[VCS ]); +notify_ring (&dev_priv->ring[VCS ]);if (gt_iir >_BLT_USER_INTERRUPT ) -notify_ring (dev, &dev_priv->ring[BCS ]); +notify_ring (&dev_priv->ring[BCS ]); if (gt_iir & (GT_BLT_CS_ERROR_INTERRUPT | GT_BSD_CS_ERROR_INTERRUPT |
@@ -1275,63 +1274,65 @@ static void snb_gt_irq_handler(struct drm_device *dev,ivybridge_parity_error_irq_handler (dev, gt_iir); } -static irqreturn_t gen8_gt_irq_handler (struct drm_device *dev, -struct drm_i915_private *dev_priv, +static irqreturn_t gen8_gt_irq_handler (struct drm_i915_private *dev_priv,u32 master_ctl) { -struct intel_engine_cs *ring; -u32 rcs, bcs, vcs; -uint32_t tmp =0 ;irqreturn_t ret =IRQ_NONE ;if (master_ctl & (GEN8_GT_RCS_IRQ |GEN8_GT_BCS_IRQ )) { - tmp =I915_READ_FW (GEN8_GT_IIR (0 )); +u32 tmp =I915_READ_FW (GEN8_GT_IIR (0 ));if (tmp) {I915_WRITE_FW (GEN8_GT_IIR (0 ), tmp); ret =IRQ_HANDLED ; - rcs = tmp >>GEN8_RCS_IRQ_SHIFT ; - ring = &dev_priv->ring[RCS ]; -if (rcs >_CONTEXT_SWITCH_INTERRUPT ) -intel_lrc_irq_handler (ring); -if (rcs >_RENDER_USER_INTERRUPT ) -notify_ring (dev, ring); - - bcs = tmp >>GEN8_BCS_IRQ_SHIFT ; - ring = &dev_priv->ring[BCS ]; -if (bcs >_CONTEXT_SWITCH_INTERRUPT ) -intel_lrc_irq_handler (ring); -if (bcs >_RENDER_USER_INTERRUPT ) -notify_ring (dev, ring); +if (tmp & (GT_CONTEXT_SWITCH_INTERRUPT <<GEN8_RCS_IRQ_SHIFT )) +intel_lrc_irq_handler (&dev_priv->ring[RCS ]); +if (tmp & (GT_RENDER_USER_INTERRUPT <<GEN8_RCS_IRQ_SHIFT )) +notify_ring (&dev_priv->ring[RCS ]); + +if (tmp & (GT_CONTEXT_SWITCH_INTERRUPT <<GEN8_BCS_IRQ_SHIFT )) +intel_lrc_irq_handler (&dev_priv->ring[BCS ]); +if (tmp & (GT_RENDER_USER_INTERRUPT <<GEN8_BCS_IRQ_SHIFT )) +notify_ring (&dev_priv->ring[BCS ]); }else DRM_ERROR ("The master control interrupt lied (GT0)!\n" ); }if (master_ctl & (GEN8_GT_VCS1_IRQ |GEN8_GT_VCS2_IRQ )) { - tmp =I915_READ_FW (GEN8_GT_IIR (1 )); +u32 tmp =I915_READ_FW (GEN8_GT_IIR (1 ));if (tmp) {I915_WRITE_FW (GEN8_GT_IIR (1 ), tmp); ret =IRQ_HANDLED ; - vcs = tmp >>GEN8_VCS1_IRQ_SHIFT ; - ring = &dev_priv->ring[VCS ]; -if (vcs >_CONTEXT_SWITCH_INTERRUPT ) -intel_lrc_irq_handler (ring); -if (vcs >_RENDER_USER_INTERRUPT ) -notify_ring (dev, ring); - - vcs = tmp >>GEN8_VCS2_IRQ_SHIFT ; - ring = &dev_priv->ring[VCS2 ]; -if (vcs >_CONTEXT_SWITCH_INTERRUPT ) -intel_lrc_irq_handler (ring); -if (vcs >_RENDER_USER_INTERRUPT ) -notify_ring (dev, ring); +if (tmp & (GT_CONTEXT_SWITCH_INTERRUPT <<GEN8_VCS1_IRQ_SHIFT )) +intel_lrc_irq_handler (&dev_priv->ring[VCS ]); +if (tmp & (GT_RENDER_USER_INTERRUPT <<GEN8_VCS1_IRQ_SHIFT )) +notify_ring (&dev_priv->ring[VCS ]); + +if (tmp & (GT_CONTEXT_SWITCH_INTERRUPT <<GEN8_VCS2_IRQ_SHIFT )) +intel_lrc_irq_handler (&dev_priv->ring[VCS2 ]); +if (tmp & (GT_RENDER_USER_INTERRUPT <<GEN8_VCS2_IRQ_SHIFT )) +notify_ring (&dev_priv->ring[VCS2 ]); }else DRM_ERROR ("The master control interrupt lied (GT1)!\n" ); } +if (master_ctl &GEN8_GT_VECS_IRQ ) { +u32 tmp =I915_READ_FW (GEN8_GT_IIR (3 )); +if (tmp) { +I915_WRITE_FW (GEN8_GT_IIR (3 ), tmp); + ret =IRQ_HANDLED ; + +if (tmp & (GT_CONTEXT_SWITCH_INTERRUPT <<GEN8_VECS_IRQ_SHIFT )) +intel_lrc_irq_handler (&dev_priv->ring[VECS ]); +if (tmp & (GT_RENDER_USER_INTERRUPT <<GEN8_VECS_IRQ_SHIFT )) +notify_ring (&dev_priv->ring[VECS ]); + }else +DRM_ERROR ("The master control interrupt lied (GT3)!\n" ); + } +if (master_ctl &GEN8_GT_PM_IRQ ) { - tmp =I915_READ_FW (GEN8_GT_IIR (2 )); +u32 tmp =I915_READ_FW (GEN8_GT_IIR (2 ));if (tmp & dev_priv->pm_rps_events) {I915_WRITE_FW (GEN8_GT_IIR (2 ), tmp & dev_priv->pm_rps_events);
@@ -1341,22 +1342,6 @@ static irqreturn_t gen8_gt_irq_handler(struct drm_device *dev,DRM_ERROR ("The master control interrupt lied (PM)!\n" ); } -if (master_ctl &GEN8_GT_VECS_IRQ ) { - tmp =I915_READ_FW (GEN8_GT_IIR (3 )); -if (tmp) { -I915_WRITE_FW (GEN8_GT_IIR (3 ), tmp); - ret =IRQ_HANDLED ; - - vcs = tmp >>GEN8_VECS_IRQ_SHIFT ; - ring = &dev_priv->ring[VECS ]; -if (vcs >_CONTEXT_SWITCH_INTERRUPT ) -intel_lrc_irq_handler (ring); -if (vcs >_RENDER_USER_INTERRUPT ) -notify_ring (dev, ring); - }else -DRM_ERROR ("The master control interrupt lied (GT3)!\n" ); - } -return ret; }
@@ -1651,7 +1636,7 @@ static void gen6_rps_irq_handler(struct drm_i915_private *dev_priv, u32 pm_iir)if (HAS_VEBOX (dev_priv->dev)) {if (pm_iir &PM_VEBOX_USER_INTERRUPT ) -notify_ring (dev_priv->dev, &dev_priv->ring[VECS ]); +notify_ring (&dev_priv->ring[VECS ]);if (pm_iir &PM_VEBOX_CS_ERROR_INTERRUPT )DRM_DEBUG ("Command parser error, pm_iir 0x%08x\n" , pm_iir);
@@ -1845,7 +1830,7 @@ static irqreturn_t cherryview_irq_handler(int irq, void *arg)I915_WRITE (VLV_IIR , iir); } -gen8_gt_irq_handler (dev, dev_priv, master_ctl); +gen8_gt_irq_handler (dev_priv, master_ctl);/* Call regardless, as some status bits might not be * signalled in iir */
@@ -2187,7 +2172,7 @@ static irqreturn_t gen8_irq_handler(int irq, void *arg)/* Find, clear, then process each source of interrupt */ - ret =gen8_gt_irq_handler (dev, dev_priv, master_ctl); + ret =gen8_gt_irq_handler (dev_priv, master_ctl);if (master_ctl &GEN8_DE_MISC_IRQ ) { tmp =I915_READ (GEN8_DE_MISC_IIR );
@@ -3692,7 +3677,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg) new_iir =I915_READ16 (IIR );/* Flush posted writes */ if (iir &I915_USER_INTERRUPT ) -notify_ring (dev, &dev_priv->ring[RCS ]); +notify_ring (&dev_priv->ring[RCS ]);for_each_pipe (dev_priv, pipe) {int plane = pipe;
@@ -3883,7 +3868,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg) new_iir =I915_READ (IIR );/* Flush posted writes */ if (iir &I915_USER_INTERRUPT ) -notify_ring (dev, &dev_priv->ring[RCS ]); +notify_ring (&dev_priv->ring[RCS ]);for_each_pipe (dev_priv, pipe) {int plane = pipe;
@@ -4110,9 +4095,9 @@ static irqreturn_t i965_irq_handler(int irq, void *arg) new_iir =I915_READ (IIR );/* Flush posted writes */ if (iir &I915_USER_INTERRUPT ) -notify_ring (dev, &dev_priv->ring[RCS ]); +notify_ring (&dev_priv->ring[RCS ]);if (iir &I915_BSD_USER_INTERRUPT ) -notify_ring (dev, &dev_priv->ring[VCS ]); +notify_ring (&dev_priv->ring[VCS ]);for_each_pipe (dev_priv, pipe) { if (pipe_stats[pipe] & PIPE_START_VBLANK_INTERRUPT_STATUS &&
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 41/70] drm/i915: Tidy gen8 IRQ handler
Quoted 3 lines · Chris Wilson
Remove some needless variables and parameter passing.
Signed-off-by Chris Wilson <[email protected]>
Merged 3 patches up to this one, thanks.
-Daniel
Quoted 232 lines
--- drivers/gpu/drm/i915/i915_irq.c | 113 +++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 64 deletions(-)drivers/gpu/drm/i915/i915_irq.c +49
-64@@ -985,8 +985,7 @@ static void ironlake_rps_change_irq_handler(struct drm_device *dev)return ; } -static void notify_ring (struct drm_device *dev, -struct intel_engine_cs *ring) +static void notify_ring (struct intel_engine_cs *ring) {if (!intel_ring_initialized (ring))return ;@@ -1248,9 +1247,9 @@ static void ilk_gt_irq_handler(struct drm_device *dev, {if (gt_iir & (GT_RENDER_USER_INTERRUPT |GT_RENDER_PIPECTL_NOTIFY_INTERRUPT )) -notify_ring (dev, &dev_priv->ring[RCS ]); +notify_ring (&dev_priv->ring[RCS ]);if (gt_iir &ILK_BSD_USER_INTERRUPT ) -notify_ring (dev, &dev_priv->ring[VCS ]); +notify_ring (&dev_priv->ring[VCS ]); } static void snb_gt_irq_handler(struct drm_device *dev,@@ -1260,11 +1259,11 @@ static void snb_gt_irq_handler(struct drm_device *dev,if (gt_iir & (GT_RENDER_USER_INTERRUPT |GT_RENDER_PIPECTL_NOTIFY_INTERRUPT )) -notify_ring (dev, &dev_priv->ring[RCS ]); +notify_ring (&dev_priv->ring[RCS ]);if (gt_iir >_BSD_USER_INTERRUPT ) -notify_ring (dev, &dev_priv->ring[VCS ]); +notify_ring (&dev_priv->ring[VCS ]);if (gt_iir >_BLT_USER_INTERRUPT ) -notify_ring (dev, &dev_priv->ring[BCS ]); +notify_ring (&dev_priv->ring[BCS ]); if (gt_iir & (GT_BLT_CS_ERROR_INTERRUPT | GT_BSD_CS_ERROR_INTERRUPT |@@ -1275,63 +1274,65 @@ static void snb_gt_irq_handler(struct drm_device *dev,ivybridge_parity_error_irq_handler (dev, gt_iir); } -static irqreturn_t gen8_gt_irq_handler (struct drm_device *dev, -struct drm_i915_private *dev_priv, +static irqreturn_t gen8_gt_irq_handler (struct drm_i915_private *dev_priv,u32 master_ctl) { -struct intel_engine_cs *ring; -u32 rcs, bcs, vcs; -uint32_t tmp =0 ;irqreturn_t ret =IRQ_NONE ;if (master_ctl & (GEN8_GT_RCS_IRQ |GEN8_GT_BCS_IRQ )) { - tmp =I915_READ_FW (GEN8_GT_IIR (0 )); +u32 tmp =I915_READ_FW (GEN8_GT_IIR (0 ));if (tmp) {I915_WRITE_FW (GEN8_GT_IIR (0 ), tmp); ret =IRQ_HANDLED ; - rcs = tmp >>GEN8_RCS_IRQ_SHIFT ; - ring = &dev_priv->ring[RCS ]; -if (rcs >_CONTEXT_SWITCH_INTERRUPT ) -intel_lrc_irq_handler (ring); -if (rcs >_RENDER_USER_INTERRUPT ) -notify_ring (dev, ring); - - bcs = tmp >>GEN8_BCS_IRQ_SHIFT ; - ring = &dev_priv->ring[BCS ]; -if (bcs >_CONTEXT_SWITCH_INTERRUPT ) -intel_lrc_irq_handler (ring); -if (bcs >_RENDER_USER_INTERRUPT ) -notify_ring (dev, ring); +if (tmp & (GT_CONTEXT_SWITCH_INTERRUPT <<GEN8_RCS_IRQ_SHIFT )) +intel_lrc_irq_handler (&dev_priv->ring[RCS ]); +if (tmp & (GT_RENDER_USER_INTERRUPT <<GEN8_RCS_IRQ_SHIFT )) +notify_ring (&dev_priv->ring[RCS ]); + +if (tmp & (GT_CONTEXT_SWITCH_INTERRUPT <<GEN8_BCS_IRQ_SHIFT )) +intel_lrc_irq_handler (&dev_priv->ring[BCS ]); +if (tmp & (GT_RENDER_USER_INTERRUPT <<GEN8_BCS_IRQ_SHIFT )) +notify_ring (&dev_priv->ring[BCS ]); }else DRM_ERROR ("The master control interrupt lied (GT0)!\n" ); }if (master_ctl & (GEN8_GT_VCS1_IRQ |GEN8_GT_VCS2_IRQ )) { - tmp =I915_READ_FW (GEN8_GT_IIR (1 )); +u32 tmp =I915_READ_FW (GEN8_GT_IIR (1 ));if (tmp) {I915_WRITE_FW (GEN8_GT_IIR (1 ), tmp); ret =IRQ_HANDLED ; - vcs = tmp >>GEN8_VCS1_IRQ_SHIFT ; - ring = &dev_priv->ring[VCS ]; -if (vcs >_CONTEXT_SWITCH_INTERRUPT ) -intel_lrc_irq_handler (ring); -if (vcs >_RENDER_USER_INTERRUPT ) -notify_ring (dev, ring); - - vcs = tmp >>GEN8_VCS2_IRQ_SHIFT ; - ring = &dev_priv->ring[VCS2 ]; -if (vcs >_CONTEXT_SWITCH_INTERRUPT ) -intel_lrc_irq_handler (ring); -if (vcs >_RENDER_USER_INTERRUPT ) -notify_ring (dev, ring); +if (tmp & (GT_CONTEXT_SWITCH_INTERRUPT <<GEN8_VCS1_IRQ_SHIFT )) +intel_lrc_irq_handler (&dev_priv->ring[VCS ]); +if (tmp & (GT_RENDER_USER_INTERRUPT <<GEN8_VCS1_IRQ_SHIFT )) +notify_ring (&dev_priv->ring[VCS ]); + +if (tmp & (GT_CONTEXT_SWITCH_INTERRUPT <<GEN8_VCS2_IRQ_SHIFT )) +intel_lrc_irq_handler (&dev_priv->ring[VCS2 ]); +if (tmp & (GT_RENDER_USER_INTERRUPT <<GEN8_VCS2_IRQ_SHIFT )) +notify_ring (&dev_priv->ring[VCS2 ]); }else DRM_ERROR ("The master control interrupt lied (GT1)!\n" ); } +if (master_ctl &GEN8_GT_VECS_IRQ ) { +u32 tmp =I915_READ_FW (GEN8_GT_IIR (3 )); +if (tmp) { +I915_WRITE_FW (GEN8_GT_IIR (3 ), tmp); + ret =IRQ_HANDLED ; + +if (tmp & (GT_CONTEXT_SWITCH_INTERRUPT <<GEN8_VECS_IRQ_SHIFT )) +intel_lrc_irq_handler (&dev_priv->ring[VECS ]); +if (tmp & (GT_RENDER_USER_INTERRUPT <<GEN8_VECS_IRQ_SHIFT )) +notify_ring (&dev_priv->ring[VECS ]); + }else +DRM_ERROR ("The master control interrupt lied (GT3)!\n" ); + } +if (master_ctl &GEN8_GT_PM_IRQ ) { - tmp =I915_READ_FW (GEN8_GT_IIR (2 )); +u32 tmp =I915_READ_FW (GEN8_GT_IIR (2 ));if (tmp & dev_priv->pm_rps_events) {I915_WRITE_FW (GEN8_GT_IIR (2 ), tmp & dev_priv->pm_rps_events);@@ -1341,22 +1342,6 @@ static irqreturn_t gen8_gt_irq_handler(struct drm_device *dev,DRM_ERROR ("The master control interrupt lied (PM)!\n" ); } -if (master_ctl &GEN8_GT_VECS_IRQ ) { - tmp =I915_READ_FW (GEN8_GT_IIR (3 )); -if (tmp) { -I915_WRITE_FW (GEN8_GT_IIR (3 ), tmp); - ret =IRQ_HANDLED ; - - vcs = tmp >>GEN8_VECS_IRQ_SHIFT ; - ring = &dev_priv->ring[VECS ]; -if (vcs >_CONTEXT_SWITCH_INTERRUPT ) -intel_lrc_irq_handler (ring); -if (vcs >_RENDER_USER_INTERRUPT ) -notify_ring (dev, ring); - }else -DRM_ERROR ("The master control interrupt lied (GT3)!\n" ); - } -return ret; }@@ -1651,7 +1636,7 @@ static void gen6_rps_irq_handler(struct drm_i915_private *dev_priv, u32 pm_iir)if (HAS_VEBOX (dev_priv->dev)) {if (pm_iir &PM_VEBOX_USER_INTERRUPT ) -notify_ring (dev_priv->dev, &dev_priv->ring[VECS ]); +notify_ring (&dev_priv->ring[VECS ]);if (pm_iir &PM_VEBOX_CS_ERROR_INTERRUPT )DRM_DEBUG ("Command parser error, pm_iir 0x%08x\n" , pm_iir);@@ -1845,7 +1830,7 @@ static irqreturn_t cherryview_irq_handler(int irq, void *arg)I915_WRITE (VLV_IIR , iir); } -gen8_gt_irq_handler (dev, dev_priv, master_ctl); +gen8_gt_irq_handler (dev_priv, master_ctl);/* Call regardless, as some status bits might not be * signalled in iir */ @@ -2187,7 +2172,7 @@ static irqreturn_t gen8_irq_handler(int irq, void *arg)/* Find, clear, then process each source of interrupt */ - ret =gen8_gt_irq_handler (dev, dev_priv, master_ctl); + ret =gen8_gt_irq_handler (dev_priv, master_ctl);if (master_ctl &GEN8_DE_MISC_IRQ ) { tmp =I915_READ (GEN8_DE_MISC_IIR );@@ -3692,7 +3677,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg) new_iir =I915_READ16 (IIR );/* Flush posted writes */ if (iir &I915_USER_INTERRUPT ) -notify_ring (dev, &dev_priv->ring[RCS ]); +notify_ring (&dev_priv->ring[RCS ]);for_each_pipe (dev_priv, pipe) {int plane = pipe;@@ -3883,7 +3868,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg) new_iir =I915_READ (IIR );/* Flush posted writes */ if (iir &I915_USER_INTERRUPT ) -notify_ring (dev, &dev_priv->ring[RCS ]); +notify_ring (&dev_priv->ring[RCS ]);for_each_pipe (dev_priv, pipe) {int plane = pipe;@@ -4110,9 +4095,9 @@ static irqreturn_t i965_irq_handler(int irq, void *arg) new_iir =I915_READ (IIR );/* Flush posted writes */ if (iir &I915_USER_INTERRUPT ) -notify_ring (dev, &dev_priv->ring[RCS ]); +notify_ring (&dev_priv->ring[RCS ]);if (iir &I915_BSD_USER_INTERRUPT ) -notify_ring (dev, &dev_priv->ring[VCS ]); +notify_ring (&dev_priv->ring[VCS ]);for_each_pipe (dev_priv, pipe) { if (pipe_stats[pipe] & PIPE_START_VBLANK_INTERRUPT_STATUS &&Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 42/70 drm/i915: Remove request retirement before each batch
In reply to Chris WilsonThis reimplements the denial-of-service protection against igt from
commit 227f782e4667fc622810bce8be8ccdeee45f89c2
Author: Chris Wilson <[email protected]> Date: Thu May 15 10:41:42 2014 +0100
drm/i915: Retire requests before creating a new one
and transfers the stall from before each batch into a new close handler. The issue is that the stall is increasing latency between batches which is detrimental in some cases (especially coupled with execlists) to keeping the GPU well fed. Also we make the observation that retiring requests can of itself free objects (and requests) and therefore makes a good first step when shrinking. However, we do wish to do a retire before forcing an allocation of a new batch pool object (prior to an execbuffer), but we make the optimisation that we only need to do so if the oldest available batch pool object is active.
--- drivers/gpu/drm/i915/i915_drv.c | 1 + drivers/gpu/drm/i915/i915_drv.h | 3 ++- drivers/gpu/drm/i915/i915_gem.c | 17 ++++++++++++++++- drivers/gpu/drm/i915/i915_gem_batch_pool.c | 21 +++++++++++++++------ drivers/gpu/drm/i915/i915_gem_batch_pool.h | 6 +++++- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 2 -- drivers/gpu/drm/i915/i915_gem_shrinker.c | 2 ++ drivers/gpu/drm/i915/intel_lrc.c | 2 +- drivers/gpu/drm/i915/intel_ringbuffer.c | 2 +- 9 files changed, 43 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +1 -0
@@ -1593,6 +1593,7 @@ static struct drm_driver driver = { .debugfs_init = i915_debugfs_init, .debugfs_cleanup = i915_debugfs_cleanup, #endif + .gem_close_object = i915_gem_close_object, .gem_free_object = i915_gem_free_object, .gem_vm_ops = &i915_gem_vm_ops,
drivers/gpu/drm/i915/i915_drv.h +2 -1
@@ -2649,6 +2649,8 @@ struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev, size_t size);void i915_init_vm (struct drm_i915_private *dev_priv,struct i915_address_space *vm); +void i915_gem_close_object (struct drm_gem_object *obj, +struct drm_file *file);void i915_gem_free_object (struct drm_gem_object *obj);void i915_gem_vma_destroy (struct i915_vma *vma);
@@ -2769,7 +2771,6 @@ struct drm_i915_gem_request * i915_gem_find_active_request(struct intel_engine_cs *ring);bool i915_gem_retire_requests (struct drm_device *dev); -void i915_gem_retire_requests_ring (struct intel_engine_cs *ring);int __must_check i915_gem_check_wedge (struct i915_gpu_error *error,bool interruptible);int __must_check i915_gem_check_olr (struct drm_i915_gem_request *req);
drivers/gpu/drm/i915/i915_gem.c +16 -1
@@ -2201,6 +2201,10 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj)for (i =0 ; i < page_count; i++) { page =shmem_read_mapping_page_gfp (mapping, i, gfp);if (IS_ERR (page)) { +i915_gem_retire_requests (dev_priv->dev); + page =shmem_read_mapping_page_gfp (mapping, i, gfp); + } +if (IS_ERR (page)) { i915_gem_shrink(dev_priv, page_count, I915_SHRINK_BOUND |
@@ -2803,7 +2807,7 @@ void i915_gem_reset(struct drm_device *dev)/** * This function clears the request list as sequence numbers are passed. */ -void +static void i915_gem_retire_requests_ring (struct intel_engine_cs *ring) {WARN_ON (i915_verify_lists (ring->dev));
@@ -2955,6 +2959,17 @@ retire:return 0 ; } +void i915_gem_close_object (struct drm_gem_object *gem, +struct drm_file *file) +{ +struct drm_i915_gem_object *obj =to_intel_bo (gem); + +if (obj->active &&mutex_trylock (&obj->base.dev->struct_mutex)) { + (void )i915_gem_object_flush_active (obj); +mutex_unlock (&obj->base.dev->struct_mutex); + } +} +/** * i915_gem_wait_ioctl - implements DRM_IOCTL_I915_GEM_WAIT * @DRM_IOCTL_ARGS: standard ioctl arguments
drivers/gpu/drm/i915/i915_gem_batch_pool.c +15 -6
@@ -44,12 +44,13 @@* @dev: the drm device * @pool: the batch buffer pool */ -void i915_gem_batch_pool_init (struct drm_device *dev, +void i915_gem_batch_pool_init (struct intel_engine_cs *ring,struct i915_gem_batch_pool *pool) {int n; - pool->dev = dev; + pool->dev = ring->dev; + pool->ring = ring;for (n =0 ; n <ARRAY_SIZE (pool->cache_list); n++)INIT_LIST_HEAD (&pool->cache_list[n]);
@@ -98,7 +99,7 @@ i915_gem_batch_pool_get(struct i915_gem_batch_pool *pool, size_t size) {struct drm_i915_gem_object *obj =NULL ; -struct drm_i915_gem_object *tmp, *next; +struct drm_i915_gem_object *tmp;struct list_head *list;int n;
@@ -113,10 +114,18 @@ i915_gem_batch_pool_get(struct i915_gem_batch_pool *pool, n =ARRAY_SIZE (pool->cache_list) -1 ; list = &pool->cache_list[n]; -list_for_each_entry_safe (tmp, next, list, batch_pool_link) { +list_for_each_entry (tmp, list, batch_pool_link) {/* The batches are strictly LRU ordered */ -if (tmp->active) -break ; +if (tmp->active) { +struct drm_i915_gem_request *rq; + + rq = tmp->last_read_req[pool->ring->id]; +if (!i915_gem_request_completed (rq, true)) +break ; + +BUG_ON (tmp->active & ~intel_ring_flag (pool->ring)); +BUG_ON (tmp->last_write_req); + }/* While we're looping, do some clean up */ if (tmp->madv == __I915_MADV_PURGED) {
drivers/gpu/drm/i915/i915_gem_batch_pool.h +5 -1
@@ -27,13 +27,17 @@#include "i915_drv.h" +struct drm_device ; +struct intel_engine_cs ; +struct i915_gem_batch_pool {struct drm_device *dev; +struct intel_engine_cs *ring;struct list_head cache_list[4 ]; };/* i915_gem_batch_pool.c */ -void i915_gem_batch_pool_init (struct drm_device *dev, +void i915_gem_batch_pool_init (struct intel_engine_cs *ring,struct i915_gem_batch_pool *pool);void i915_gem_batch_pool_fini (struct i915_gem_batch_pool *pool); struct drm_i915_gem_object*
drivers/gpu/drm/i915/i915_gem_execbuffer.c +0 -2
@@ -697,8 +697,6 @@ i915_gem_execbuffer_reserve(struct intel_engine_cs *ring,bool has_fenced_gpu_access =INTEL_INFO (ring->dev)->gen <4 ;int retry; -i915_gem_retire_requests_ring (ring); - vm = list_first_entry(vmas, struct i915_vma, exec_list)->vm;INIT_LIST_HEAD (&ordered_vmas);
drivers/gpu/drm/i915/i915_gem_shrinker.c +2 -0
@@ -204,6 +204,8 @@ i915_gem_shrinker_count(struct shrinker *shrinker, struct shrink_control *sc)if (!i915_gem_shrinker_lock (dev, &unlock))return 0 ; +i915_gem_retire_requests (dev); + count =0 ;list_for_each_entry (obj, &dev_priv->mm.unbound_list, global_list)if (obj->pages_pin_count ==0 )
drivers/gpu/drm/i915/intel_lrc.c +1 -1
@@ -1238,7 +1238,7 @@ static int logical_ring_init(struct drm_device *dev, struct intel_engine_cs *rin ring->dev = dev;INIT_LIST_HEAD (&ring->active_list);INIT_LIST_HEAD (&ring->request_list); -i915_gem_batch_pool_init (dev, &ring->batch_pool); +i915_gem_batch_pool_init (ring, &ring->batch_pool);init_waitqueue_head (&ring->irq_queue);INIT_LIST_HEAD (&ring->execlist_queue);
drivers/gpu/drm/i915/intel_ringbuffer.c +1 -1
@@ -2000,7 +2000,7 @@ static int intel_init_ring_buffer(struct drm_device *dev,INIT_LIST_HEAD (&ring->active_list);INIT_LIST_HEAD (&ring->request_list);INIT_LIST_HEAD (&ring->execlist_queue); -i915_gem_batch_pool_init (dev, &ring->batch_pool); +i915_gem_batch_pool_init (ring, &ring->batch_pool); ringbuf->size =32 *PAGE_SIZE ; ringbuf->ring = ring;memset (ring->semaphore.sync_seqno,0 ,sizeof (ring->semaphore.sync_seqno));
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 43/70 drm/i915: Cache the GGTT offset for the execlists context
In reply to Chris WilsonThe offset doesn't change once the context is pinned, but the lookup turns out to be comparatively costly as it gets repeated for every request.
v2: Rebase
--- drivers/gpu/drm/i915/intel_lrc.c | 23 +++++++++++++---------- drivers/gpu/drm/i915/intel_ringbuffer.h | 1 + 2 files changed, 14 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +13 -10
@@ -230,8 +230,8 @@ int intel_sanitize_enable_execlists(struct drm_device *dev, int enable_execlistsreturn 0 ; } -static uint32_t execlists_ctx_descriptor (struct intel_engine_cs *ring, -struct drm_i915_gem_object *ctx_obj) +static uint32_t execlists_ctx_descriptor (struct intel_engine_cs *engine, +uint32_t ggtt_offset) {uint32_t desc;
@@ -239,27 +239,28 @@ static uint32_t execlists_ctx_descriptor(struct intel_engine_cs *ring, desc |=LEGACY_CONTEXT <<GEN8_CTX_MODE_SHIFT ; desc |=GEN8_CTX_L3LLC_COHERENT ; desc |=GEN8_CTX_PRIVILEGE ; - desc |=i915_gem_obj_ggtt_offset (ctx_obj); + desc |= ggtt_offset;/* TODO: WaDisableLiteRestore when we start using semaphore * signalling between Command Streamers */ /* desc |= GEN8_CTX_FORCE_RESTORE; */ /* WaEnableForceRestoreInCtxtDescForVCS:skl */ -if (IS_GEN9 (ring->dev) &&INTEL_REVID (ring->dev) <=SKL_REVID_B0 && - (ring->id ==BCS || ring->id ==VCS || - ring->id ==VECS || ring->id ==VCS2 )) +if (IS_GEN9 (engine->dev) &&INTEL_REVID (engine->dev) <=SKL_REVID_B0 && + (engine->id ==BCS || engine->id ==VCS || + engine->id ==VECS || engine->id ==VCS2 )) desc |=GEN8_CTX_FORCE_RESTORE ;return desc; } -static uint32_t execlists_request_write_tail (struct intel_engine_cs *ring, +static uint32_t execlists_request_write_tail (struct intel_engine_cs *engine,struct drm_i915_gem_request *rq) { - rq->ctx->engine[ring->id].ringbuf->regs[CTX_RING_TAIL +1 ] = rq->tail; -return execlists_ctx_descriptor (ring, rq->ctx->engine[ring->id].state); +struct intel_ringbuffer *ring = rq->ctx->engine[engine->id].ringbuf; + ring->regs[CTX_RING_TAIL +1 ] = rq->tail; +return execlists_ctx_descriptor (engine, ring->ggtt_offset); }static void execlists_submit_pair (struct intel_engine_cs *ring)
@@ -510,7 +511,8 @@ static int intel_lr_context_pin(struct intel_engine_cs *ring,if (ret) goto reset_pin_count; -if (WARN_ON (i915_gem_obj_ggtt_offset (ctx_obj) &0xFFFFFFFF00000FFFULL )) { + ringbuf->ggtt_offset =i915_gem_obj_ggtt_offset (ctx_obj); +if (WARN_ON (ringbuf->ggtt_offset &0xFFFFFFFF00000FFFULL )) { ret = -ENODEV ; goto unpin_ctx_obj; }
@@ -533,6 +535,7 @@ reset_pin_count:return ret; } +int intel_logical_ring_alloc_request_extras (struct drm_i915_gem_request *request,struct intel_context *ctx) {
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -0
@@ -98,6 +98,7 @@ struct intel_ringbuffer {struct drm_i915_gem_object *obj;void __iomem *virtual_start;uint32_t *regs; +uint32_t ggtt_offset;struct intel_engine_cs *ring;
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 44/70 drm/i915: Prefer to check for idleness in worker rather than sync-flush
In reply to Chris Wilson--- drivers/gpu/drm/i915/i915_gem.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +6 -1
@@ -2570,7 +2570,6 @@ int __i915_add_request(struct intel_engine_cs *ring,i915_queue_hangcheck (ring->dev); -cancel_delayed_work_sync (&dev_priv->mm.idle_work);queue_delayed_work (dev_priv->wq, &dev_priv->mm.retire_work,round_jiffies_up_relative (HZ ));
@@ -2908,6 +2907,12 @@ i915_gem_idle_work_handler(struct work_struct *work)struct drm_i915_private *dev_priv =container_of (work,typeof (*dev_priv), mm.idle_work.work);struct drm_device *dev = dev_priv->dev; +struct intel_engine_cs *ring; +int i; + +for_each_ring (ring, dev_priv, i) +if (!list_empty (&ring->request_list)) +return ;intel_mark_idle (dev);
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Daniel Vetter
AppliedRe: [PATCH 44/70] drm/i915: Prefer to check for idleness in worker rather than sync-flush
Quoted 1 line · Chris Wilson
Signed-off-by Chris Wilson <[email protected]>
Queued for -next, thanks for the patch.
-Daniel
Quoted 36 lines
--- drivers/gpu/drm/i915/i915_gem.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/i915_gem.c +6
-1@@ -2570,7 +2570,6 @@ int __i915_add_request(struct intel_engine_cs *ring,i915_queue_hangcheck (ring->dev); -cancel_delayed_work_sync (&dev_priv->mm.idle_work);queue_delayed_work (dev_priv->wq, &dev_priv->mm.retire_work,round_jiffies_up_relative (HZ ));@@ -2908,6 +2907,12 @@ i915_gem_idle_work_handler(struct work_struct *work)struct drm_i915_private *dev_priv =container_of (work,typeof (*dev_priv), mm.idle_work.work);struct drm_device *dev = dev_priv->dev; +struct intel_engine_cs *ring; +int i; + +for_each_ring (ring, dev_priv, i) +if (!list_empty (&ring->request_list)) +return ;intel_mark_idle (dev);Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 45/70 drm/i915: Remove request->uniq
In reply to Chris WilsonWe already assign a unique identifier to every request: seqno. That someone felt like adding a second one without even mentioning why and tweaking ABI smells very fishy.
Fixes regression from
commit b3a38998f042b862f5ba4d7f2268f3a8dfb4883a
Author: Nick Hoath <[email protected]> Date: Thu Feb 19 16:30:47 2015 +0000
drm/i915: Fix a use after free, and unbalanced refcounting
v2: Rebase
--- drivers/gpu/drm/i915/i915_drv.h | 4 ---- drivers/gpu/drm/i915/i915_gem.c | 1 - drivers/gpu/drm/i915/i915_trace.h | 13 ++++--------- 3 files changed, 4 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -4
@@ -1843,8 +1843,6 @@ struct drm_i915_private {void (*stop_ring)(struct intel_engine_cs *ring); } gt; -uint32_t request_uniq; -/* * NOTE: This is the dri1/ums dungeon, don't add stuff here. Your patch * will be rejected. Instead look for a better place.
@@ -2120,8 +2118,6 @@ struct drm_i915_gem_request {/** process identifier submitting this request */ struct pid *pid; -uint32_t uniq; -/** * The ELSP only accepts two elements at a time, so we queue * context/tail pairs on a given queue (ring->execlist_queue) until the
drivers/gpu/drm/i915/i915_gem.c +0 -1
@@ -2660,7 +2660,6 @@ int i915_gem_request_alloc(struct intel_engine_cs *ring, } rq->ring = ring; - rq->uniq = dev_priv->request_uniq++;if (i915.enable_execlists) ret =intel_logical_ring_alloc_request_extras (rq, ctx);
drivers/gpu/drm/i915/i915_trace.h +4 -9
@@ -499,7 +499,6 @@ DECLARE_EVENT_CLASS(i915_gem_request,TP_STRUCT__entry (__field (u32 ,dev )__field (u32, ring) -__field (u32, uniq)__field (u32, seqno) ),
@@ -508,13 +507,11 @@ DECLARE_EVENT_CLASS(i915_gem_request,i915_gem_request_get_ring (req); __entry->dev = ring->dev->primary->index; __entry->ring = ring->id; - __entry->uniq = req ? req->uniq :0 ; __entry->seqno =i915_gem_request_get_seqno (req); ), -TP_printk ("dev=%u, ring=%u, uniq=%u, seqno=%u" , - __entry->dev, __entry->ring, __entry->uniq, - __entry->seqno) +TP_printk ("dev=%u, ring=%u, seqno=%u" , + __entry->dev, __entry->ring, __entry->seqno) ); DEFINE_EVENT(i915_gem_request, i915_gem_request_add,
@@ -559,7 +556,6 @@ TRACE_EVENT(i915_gem_request_wait_begin,TP_STRUCT__entry (__field (u32 ,dev )__field (u32, ring) -__field (u32, uniq)__field (u32, seqno)__field (bool, blocking) ),
@@ -575,14 +571,13 @@ TRACE_EVENT(i915_gem_request_wait_begin,i915_gem_request_get_ring (req); __entry->dev = ring->dev->primary->index; __entry->ring = ring->id; - __entry->uniq = req ? req->uniq :0 ; __entry->seqno =i915_gem_request_get_seqno (req); __entry->blocking =mutex_is_locked (&ring->dev->struct_mutex); ), -TP_printk ("dev=%u, ring=%u, uniq=%u, seqno=%u, blocking=%s" , - __entry->dev, __entry->ring, __entry->uniq, +TP_printk ("dev=%u, ring=%u, seqno=%u, blocking=%s" , + __entry->dev, __entry->ring, __entry->seqno, __entry->blocking ?"yes (NB)" :"no" ) );
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Daniel Vetter
AppliedRe: [PATCH 45/70] drm/i915: Remove request->uniq
Quoted 11 lines · Chris Wilson
We already assign a unique identifier to every request: seqno. That someone felt like adding a second one without even mentioning why and tweaking ABI smells very fishy.
Fixes regression from
commitb3a38998f042b862f5ba4d7f2268f3a8dfb4883aAuthor: Nick Hoath <[email protected]> Date: Thu Feb 19 16:30:47 2015 +0000drm/i915: Fix a use after free, and unbalanced refcounting
Quoted 7 lines
v2: Rebase
Signed-off-by Chris Wilson <[email protected]>Cc Nick Hoath <[email protected]>Cc Thomas Daniel <[email protected]>Cc Daniel Vetter <[email protected]>Cc Jani Nikula <[email protected]>
Queued for -next, thanks for the patch.
-Daniel
Quoted 96 lines
--- drivers/gpu/drm/i915/i915_drv.h | 4 ---- drivers/gpu/drm/i915/i915_gem.c | 1 - drivers/gpu/drm/i915/i915_trace.h | 13 ++++--------- 3 files changed, 4 insertions(+), 14 deletions(-)drivers/gpu/drm/i915/i915_drv.h +0
-4@@ -1843,8 +1843,6 @@ struct drm_i915_private {void (*stop_ring)(struct intel_engine_cs *ring); } gt; -uint32_t request_uniq; -/* * NOTE: This is the dri1/ums dungeon, don't add stuff here. Your patch * will be rejected. Instead look for a better place. @@ -2120,8 +2118,6 @@ struct drm_i915_gem_request {/** process identifier submitting this request */ struct pid *pid; -uint32_t uniq; -/** * The ELSP only accepts two elements at a time, so we queue * context/tail pairs on a given queue (ring->execlist_queue) until the drivers/gpu/drm/i915/i915_gem.c +0
-1@@ -2660,7 +2660,6 @@ int i915_gem_request_alloc(struct intel_engine_cs *ring, } rq->ring = ring; - rq->uniq = dev_priv->request_uniq++;if (i915.enable_execlists) ret =intel_logical_ring_alloc_request_extras (rq, ctx);drivers/gpu/drm/i915/i915_trace.h +4
-9@@ -499,7 +499,6 @@ DECLARE_EVENT_CLASS(i915_gem_request,TP_STRUCT__entry (__field (u32 ,dev )__field (u32, ring) -__field (u32, uniq)__field (u32, seqno) ),@@ -508,13 +507,11 @@ DECLARE_EVENT_CLASS(i915_gem_request,i915_gem_request_get_ring (req); __entry->dev = ring->dev->primary->index; __entry->ring = ring->id; - __entry->uniq = req ? req->uniq :0 ; __entry->seqno =i915_gem_request_get_seqno (req); ), -TP_printk ("dev=%u, ring=%u, uniq=%u, seqno=%u" , - __entry->dev, __entry->ring, __entry->uniq, - __entry->seqno) +TP_printk ("dev=%u, ring=%u, seqno=%u" , + __entry->dev, __entry->ring, __entry->seqno) ); DEFINE_EVENT(i915_gem_request, i915_gem_request_add,@@ -559,7 +556,6 @@ TRACE_EVENT(i915_gem_request_wait_begin,TP_STRUCT__entry (__field (u32 ,dev )__field (u32, ring) -__field (u32, uniq)__field (u32, seqno)__field (bool, blocking) ),@@ -575,14 +571,13 @@ TRACE_EVENT(i915_gem_request_wait_begin,i915_gem_request_get_ring (req); __entry->dev = ring->dev->primary->index; __entry->ring = ring->id; - __entry->uniq = req ? req->uniq :0 ; __entry->seqno =i915_gem_request_get_seqno (req); __entry->blocking =mutex_is_locked (&ring->dev->struct_mutex); ), -TP_printk ("dev=%u, ring=%u, uniq=%u, seqno=%u, blocking=%s" , - __entry->dev, __entry->ring, __entry->uniq, +TP_printk ("dev=%u, ring=%u, seqno=%u, blocking=%s" , + __entry->dev, __entry->ring, __entry->seqno, __entry->blocking ?"yes (NB)" :"no" ) );Signature · 1 line
2.1.4
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 46/70 drm/i915: Cache the reset_counter for the request
In reply to Chris WilsonInstead of querying the reset counter before every access to the ring, query it the first time we touch the ring, and do a final compare when submitting the request. For correctness, we need to then sanitize how the reset_counter is incremented to prevent broken submission and waiting across resets, in the process fixing the persistent -EIO we still see today on failed waits.
v2: Rebase
--- drivers/gpu/drm/i915/i915_drv.c | 32 +++++++----- drivers/gpu/drm/i915/i915_drv.h | 29 +++++++---- drivers/gpu/drm/i915/i915_gem.c | 87 ++++++++++++++------------------- drivers/gpu/drm/i915/i915_irq.c | 28 ++++------- drivers/gpu/drm/i915/intel_display.c | 10 ++-- drivers/gpu/drm/i915/intel_lrc.c | 7 --- drivers/gpu/drm/i915/intel_ringbuffer.c | 6 --- 7 files changed, 87 insertions(+), 112 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +19 -13
@@ -827,6 +827,8 @@ int i915_resume_legacy(struct drm_device *dev)int i915_reset (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; +struct i915_gpu_error *error = &dev_priv->gpu_error; +unsigned reset_counter;bool simulated;int ret;
@@ -836,17 +838,23 @@ int i915_reset(struct drm_device *dev)intel_reset_gt_powersave (dev);mutex_lock (&dev->struct_mutex); + reset_counter =atomic_inc_return (&error->reset_counter); +if (WARN_ON (__i915_reset_in_progress (reset_counter))) { +atomic_set_mask (I915_WEDGED , &error->reset_counter); +mutex_unlock (&dev->struct_mutex); +return -EIO ; + }i915_gem_reset (dev); - simulated = dev_priv->gpu_error.stop_rings !=0 ; + simulated = error->stop_rings !=0 ; ret =intel_gpu_reset (dev);/* Also reset the gpu hangman. */ if (simulated) {DRM_INFO ("Simulated gpu hang, resetting stop_rings\n" ); - dev_priv->gpu_error.stop_rings =0 ; + error->stop_rings =0 ;if (ret == -ENODEV ) {DRM_INFO ("Reset not implemented, but ignoring " "error for simulated gpu hangs\n" );
@@ -859,8 +867,7 @@ int i915_reset(struct drm_device *dev)if (ret) {DRM_ERROR ("Failed to reset chip: %i\n" , ret); -mutex_unlock (&dev->struct_mutex); -return ret; + goto error; }intel_overlay_reset (dev_priv);
@@ -879,20 +886,14 @@ int i915_reset(struct drm_device *dev)* was running at the time of the reset (i.e. we weren't VT * switched away). */ - -/* Used to prevent gem_check_wedged returning -EAGAIN during gpu reset */ - dev_priv->gpu_error.reload_in_reset = true; - ret =i915_gem_init_hw (dev); - - dev_priv->gpu_error.reload_in_reset = false; - -mutex_unlock (&dev->struct_mutex);if (ret) {DRM_ERROR ("Failed hw init on reset %d\n" , ret); -return ret; + goto error; } +mutex_unlock (&dev->struct_mutex); +/* * rps/rc6 re-init is necessary to restore state lost after the * reset and the re-install of gt irqs. Skip for ironlake per
@@ -903,6 +904,11 @@ int i915_reset(struct drm_device *dev)intel_enable_gt_powersave (dev);return 0 ; + +error: +atomic_set_mask (I915_WEDGED , &error->reset_counter); +mutex_unlock (&dev->struct_mutex); +return ret; }static int i915_pci_probe (struct pci_dev *pdev,const struct pci_device_id *ent)
drivers/gpu/drm/i915/i915_drv.h +20 -9
@@ -1308,9 +1308,6 @@ struct i915_gpu_error {/* For missed irq/seqno simulation. */ unsigned int test_irq_rings; - -/* Used to prevent gem_check_wedged returning -EAGAIN during gpu reset */ -bool reload_in_reset; };enum modeset_restore {
@@ -2072,6 +2069,7 @@ struct drm_i915_gem_request {/** On Which ring this request was generated */ struct drm_i915_private *i915;struct intel_engine_cs *ring; +unsigned reset_counter;/** GEM sequence number associated with this request. */ uint32_t seqno;
@@ -2767,24 +2765,38 @@ struct drm_i915_gem_request * i915_gem_find_active_request(struct intel_engine_cs *ring);bool i915_gem_retire_requests (struct drm_device *dev); -int __must_check i915_gem_check_wedge (struct i915_gpu_error *error, +int __must_check i915_gem_check_wedge (unsigned reset_counter,bool interruptible);int __must_check i915_gem_check_olr (struct drm_i915_gem_request *req); +static inline u32 i915_reset_counter (struct i915_gpu_error *error) +{ +return atomic_read (&error->reset_counter); +} + +static inline bool __i915_reset_in_progress (u32 reset) +{ +return unlikely (reset & (I915_RESET_IN_PROGRESS_FLAG |I915_WEDGED )); +} + +static inline bool __i915_terminally_wedged (u32 reset) +{ +return reset &I915_WEDGED ; +} +static inline bool i915_reset_in_progress (struct i915_gpu_error *error) { -return unlikely (atomic_read (&error->reset_counter) - & (I915_RESET_IN_PROGRESS_FLAG |I915_WEDGED )); +return __i915_reset_in_progress (i915_reset_counter (error)); }static inline bool i915_terminally_wedged (struct i915_gpu_error *error) { -return atomic_read (&error->reset_counter) &I915_WEDGED ; +return __i915_terminally_wedged (i915_reset_counter (error)); }static inline u32 i915_reset_count (struct i915_gpu_error *error) { -return ((atomic_read (&error->reset_counter) & ~I915_WEDGED ) +1 ) /2 ; +return ((i915_reset_counter (error) & ~I915_WEDGED ) +1 ) /2 ; }static inline bool i915_stop_ring_allow_ban (struct drm_i915_private *dev_priv)
@@ -2816,7 +2828,6 @@ int __i915_add_request(struct intel_engine_cs *ring,#define i915_add_request (ring) \ __i915_add_request(ring, NULL, NULL)int __i915_wait_request (struct drm_i915_gem_request *req, -unsigned reset_counter,bool interruptible,s64 *timeout,struct drm_i915_file_private *file_priv);
drivers/gpu/drm/i915/i915_gem.c +36 -51
247 lines not on this page · raw message
drivers/gpu/drm/i915/i915_irq.c +9 -19
@@ -2299,6 +2299,13 @@ static void i915_error_wake_up(struct drm_i915_private *dev_priv,wake_up_all (&dev_priv->gpu_error.reset_queue); } +static bool reset_pending (struct i915_gpu_error *error) +{ +unsigned reset_counter =i915_reset_counter (error); +return (__i915_reset_in_progress (reset_counter) && + !__i915_terminally_wedged (reset_counter)); +} +/** * i915_reset_and_wakeup - do process context error handling work *
@@ -2308,7 +2315,6 @@ static void i915_error_wake_up(struct drm_i915_private *dev_priv,static void i915_reset_and_wakeup (struct drm_device *dev) {struct drm_i915_private *dev_priv =to_i915 (dev); -struct i915_gpu_error *error = &dev_priv->gpu_error;char *error_event[] = {I915_ERROR_UEVENT "=1" ,NULL };char *reset_event[] = {I915_RESET_UEVENT "=1" ,NULL };char *reset_done_event[] = {I915_ERROR_UEVENT "=0" ,NULL };
@@ -2326,7 +2332,7 @@ static void i915_reset_and_wakeup(struct drm_device *dev)* the reset in-progress bit is only ever set by code outside of this * work we don't need to worry about any other races. */ -if (i915_reset_in_progress (error) && !i915_terminally_wedged (error)) { +if (reset_pending (&dev_priv->gpu_error)) {DRM_DEBUG_DRIVER ("resetting chip\n" );kobject_uevent_env (&dev->primary->kdev->kobj,KOBJ_CHANGE , reset_event);
@@ -2354,25 +2360,9 @@ static void i915_reset_and_wakeup(struct drm_device *dev)intel_runtime_pm_put (dev_priv); -if (ret ==0 ) { -/* -* After all the gem state is reset, increment the reset -* counter and wake up everyone waiting for the reset to -* complete. -* -* Since unlock operations are a one-sided barrier only, -* we need to insert a barrier here to order any seqno -* updates before -* the counter increment. -*/ -smp_mb__before_atomic (); -atomic_inc (&dev_priv->gpu_error.reset_counter); - +if (ret ==0 )kobject_uevent_env (&dev->primary->kdev->kobj,KOBJ_CHANGE , reset_done_event); - }else { -atomic_set_mask (I915_WEDGED , &error->reset_counter); - }/* * Note: The wake_up also serves as a memory barrier so that
drivers/gpu/drm/i915/intel_display.c +3 -7
@@ -3196,8 +3196,7 @@ static bool intel_crtc_has_pending_flip(struct drm_crtc *crtc)struct intel_crtc *intel_crtc =to_intel_crtc (crtc);bool pending; -if (i915_reset_in_progress (&dev_priv->gpu_error) || - intel_crtc->reset_counter !=atomic_read (&dev_priv->gpu_error.reset_counter)) +if (intel_crtc->reset_counter !=i915_reset_counter (&dev_priv->gpu_error))return false;spin_lock_irq (&dev->event_lock);
@@ -9689,8 +9688,7 @@ static bool page_flip_finished(struct intel_crtc *crtc)struct drm_device *dev = crtc->base.dev;struct drm_i915_private *dev_priv = dev->dev_private; -if (i915_reset_in_progress (&dev_priv->gpu_error) || - crtc->reset_counter !=atomic_read (&dev_priv->gpu_error.reset_counter)) +if (crtc->reset_counter !=i915_reset_counter (&dev_priv->gpu_error))return true;/*
@@ -10109,9 +10107,7 @@ static void intel_mmio_flip_work_func(struct work_struct *work) container_of(work, struct intel_mmio_flip, work);if (mmio_flip->rq) -WARN_ON (__i915_wait_request (mmio_flip->rq, - mmio_flip->crtc->reset_counter, - false,NULL , +WARN_ON (__i915_wait_request (mmio_flip->rq, false,NULL , &mmio_flip->i915->rps.mmioflips));intel_do_mmio_flip (mmio_flip->crtc);
drivers/gpu/drm/i915/intel_lrc.c +0 -7
@@ -676,15 +676,8 @@ static int intel_logical_ring_begin(struct intel_ringbuffer *ringbuf, struct intel_context *ctx, int num_dwords) {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;
drivers/gpu/drm/i915/intel_ringbuffer.c +0 -6
@@ -2189,14 +2189,8 @@ static int __intel_ring_prepare(struct intel_engine_cs *ring,int intel_ring_begin (struct intel_engine_cs *ring,int num_dwords) { -struct drm_i915_private *dev_priv = ring->dev->dev_private;int ret; - ret =i915_gem_check_wedge (&dev_priv->gpu_error, - dev_priv->mm.interruptible); -if (ret) -return ret; - ret =__intel_ring_prepare (ring, num_dwords *sizeof (uint32_t ));if (ret)return ret;
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 47/70 drm/i915: Allocate context objects from stolen
In reply to Chris WilsonAs we never expose context objects directly to userspace, we can forgo allocating a first-class GEM object for them and prefer to use the limited resource of reserved/stolen memory for them. Note this means that their initial contents are undefined.
However, a downside of using stolen objects for execlists is that we cannot access the physical address directly (thanks MCH!) which prevents their use.
--- drivers/gpu/drm/i915/i915_gem_context.c | 4 +++- drivers/gpu/drm/i915/intel_lrc.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_gem_context.c +3 -1
@@ -157,7 +157,9 @@ i915_gem_alloc_context_obj(struct drm_device *dev, size_t size)struct drm_i915_gem_object *obj;int ret; - obj =i915_gem_alloc_object (dev, size); + obj =i915_gem_object_create_stolen (dev, size); +if (obj ==NULL ) + obj =i915_gem_alloc_object (dev, size);if (obj ==NULL )return ERR_PTR (-ENOMEM );
drivers/gpu/drm/i915/intel_lrc.c +1 -1
@@ -1711,7 +1711,7 @@ int intel_lr_context_deferred_create(struct intel_context *ctx, context_size =round_up (get_lr_context_size (ring),4096 ); - ctx_obj =i915_gem_alloc_context_obj (dev, context_size); + ctx_obj =i915_gem_alloc_object (dev, context_size);if (IS_ERR (ctx_obj)) { ret =PTR_ERR (ctx_obj);DRM_DEBUG_DRIVER ("Alloc LRC backing obj failed: %d\n" , ret);
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Daniel Vetter
AppliedRe: [PATCH 47/70] drm/i915: Allocate context objects from stolen
Quoted 10 lines · Chris Wilson
As we never expose context objects directly to userspace, we can forgo allocating a first-class GEM object for them and prefer to use the limited resource of reserved/stolen memory for them. Note this means that their initial contents are undefined.
However, a downside of using stolen objects for execlists is that we cannot access the physical address directly (thanks MCH!) which prevents their use.
Signed-off-by Chris Wilson <[email protected]>
Queued for -next, thanks for the patch.
-Daniel
Quoted 40 lines
--- drivers/gpu/drm/i915/i915_gem_context.c | 4 +++- drivers/gpu/drm/i915/intel_lrc.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/i915_gem_context.c +3
-1@@ -157,7 +157,9 @@ i915_gem_alloc_context_obj(struct drm_device *dev, size_t size)struct drm_i915_gem_object *obj;int ret; - obj =i915_gem_alloc_object (dev, size); + obj =i915_gem_object_create_stolen (dev, size); +if (obj ==NULL ) + obj =i915_gem_alloc_object (dev, size);if (obj ==NULL )return ERR_PTR (-ENOMEM );drivers/gpu/drm/i915/intel_lrc.c +1
-1@@ -1711,7 +1711,7 @@ int intel_lr_context_deferred_create(struct intel_context *ctx, context_size =round_up (get_lr_context_size (ring),4096 ); - ctx_obj =i915_gem_alloc_context_obj (dev, context_size); + ctx_obj =i915_gem_alloc_object (dev, context_size);if (IS_ERR (ctx_obj)) { ret =PTR_ERR (ctx_obj);DRM_DEBUG_DRIVER ("Alloc LRC backing obj failed: %d\n" , ret);Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 48/70 drm/i915: Introduce an internal allocator for disposable private objects
In reply to Chris WilsonQuite a few of our objects used for internal hardware programming do not benefit from being swappable or from being zero initialised. As such they do not benefit from using a shmemfs backing storage and since they are internal and never directly exposed to the user, we do not need to worry about providing a filp. For these we can use an drm_i915_gem_object wrapper around a sg_table of plain struct page. They are not swapped backed and not automatically pinned. If they are reaped by the shrinker, the pages are released and the contents discarded. For the internal use case, this is fine as for example, ringbuffers are pinned from being written by a request to be read by the hardware. Once they are idle, they can be discarded entirely. As such they are a good match for execlist ringbuffers and a small varierty of other internal objects.
--- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/i915_drv.h | 5 + drivers/gpu/drm/i915/i915_gem_batch_pool.c | 25 ++--- drivers/gpu/drm/i915/i915_gem_internal.c | 149 +++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_gem_render_state.c | 2 +- drivers/gpu/drm/i915/intel_ringbuffer.c | 10 +- 6 files changed, 168 insertions(+), 24 deletions(-) create mode 100644 drivers/gpu/drm/i915/i915_gem_internal.c
drivers/gpu/drm/i915/Makefile +1 -0
@@ -27,6 +27,7 @@ i915-y += i915_cmd_parser.o \ i915_gem_evict.o \ i915_gem_execbuffer.o \ i915_gem_gtt.o \ + i915_gem_internal.o \ i915_gem.o \ i915_gem_shrinker.o \ i915_gem_stolen.o \
drivers/gpu/drm/i915/i915_drv.h +5 -0
@@ -3027,6 +3027,11 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,u32 gtt_offset, u32 size); +/* i915_gem_internal.c */ +struct drm_i915_gem_object * +i915_gem_object_create_internal (struct drm_device *dev, +unsigned size); +/* i915_gem_shrinker.c */ unsigned long i915_gem_shrink(struct drm_i915_private *dev_priv, long target,
drivers/gpu/drm/i915/i915_gem_batch_pool.c +7 -18
@@ -101,7 +101,7 @@ i915_gem_batch_pool_get(struct i915_gem_batch_pool *pool,struct drm_i915_gem_object *obj =NULL ;struct drm_i915_gem_object *tmp;struct list_head *list; -int n; +int n, ret;WARN_ON (!mutex_is_locked (&pool->dev->struct_mutex));
@@ -127,13 +127,6 @@ i915_gem_batch_pool_get(struct i915_gem_batch_pool *pool,BUG_ON (tmp->last_write_req); } -/* While we're looping, do some clean up */ -if (tmp->madv == __I915_MADV_PURGED) { -list_del (&tmp->batch_pool_link); -drm_gem_object_unreference (&tmp->base); -continue ; - } -if (tmp->base.size >= size) { obj = tmp;break ;
@@ -141,20 +134,16 @@ i915_gem_batch_pool_get(struct i915_gem_batch_pool *pool, }if (obj ==NULL ) { -int ret; - - obj =i915_gem_alloc_object (pool->dev, size); + obj =i915_gem_object_create_internal (pool->dev, size);if (obj ==NULL )return ERR_PTR (-ENOMEM ); - - ret =i915_gem_object_get_pages (obj); -if (ret) -return ERR_PTR (ret); - - obj->madv =I915_MADV_DONTNEED ; } -list_move_tail (&obj->batch_pool_link, list); + ret =i915_gem_object_get_pages (obj); +if (ret) +return ERR_PTR (ret); +i915_gem_object_pin_pages (obj); +list_move_tail (&obj->batch_pool_link, list);return obj; }
drivers/gpu/drm/i915/i915_gem_internal.c new file +149 -0
149 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem_render_state.c +1 -1
@@ -57,7 +57,7 @@ static int render_state_init(struct render_state *so, struct drm_device *dev)if (so->rodata->batch_items *4 >4096 )return -EINVAL ; - so->obj =i915_gem_alloc_object (dev,4096 ); + so->obj =i915_gem_object_create_internal (dev,4096 );if (so->obj ==NULL )return -ENOMEM ;
drivers/gpu/drm/i915/intel_ringbuffer.c +5 -5
@@ -669,7 +669,7 @@ intel_init_pipe_control(struct intel_engine_cs *ring)WARN_ON (ring->scratch.obj); - ring->scratch.obj =i915_gem_alloc_object (ring->dev,4096 ); + ring->scratch.obj =i915_gem_object_create_internal (ring->dev,4096 );if (ring->scratch.obj ==NULL ) {DRM_ERROR ("Failed to allocate seqno page\n" ); ret = -ENOMEM ;
@@ -1845,7 +1845,7 @@ static int init_status_page(struct intel_engine_cs *ring)unsigned flags;int ret; - obj =i915_gem_alloc_object (ring->dev,4096 ); + obj =i915_gem_object_create_internal (ring->dev,4096 );if (obj ==NULL ) {DRM_ERROR ("Failed to allocate status page\n" );return -ENOMEM ;
@@ -1971,7 +1971,7 @@ int intel_alloc_ringbuffer_obj(struct drm_device *dev,if (!HAS_LLC (dev)) obj =i915_gem_object_create_stolen (dev, ringbuf->size);if (obj ==NULL ) - obj =i915_gem_alloc_object (dev, ringbuf->size); + obj =i915_gem_object_create_internal (dev, ringbuf->size);if (obj ==NULL )return -ENOMEM ;
@@ -2446,7 +2446,7 @@ int intel_init_render_ring_buffer(struct drm_device *dev)if (INTEL_INFO (dev)->gen >=8 ) {if (i915_semaphore_is_enabled (dev)) { - obj =i915_gem_alloc_object (dev,4096 ); + obj =i915_gem_object_create_internal (dev,4096 );if (obj ==NULL ) {DRM_ERROR ("Failed to allocate semaphore bo. Disabling semaphores\n" ); i915.semaphores =0 ;
@@ -2552,7 +2552,7 @@ int intel_init_render_ring_buffer(struct drm_device *dev)/* Workaround batchbuffer to combat CS tlb bug. */ if (HAS_BROKEN_CS_TLB (dev)) { - obj =i915_gem_alloc_object (dev,I830_WA_SIZE ); + obj =i915_gem_object_create_internal (dev,I830_WA_SIZE );if (obj ==NULL ) {DRM_ERROR ("Failed to allocate batch bo\n" );return -ENOMEM ;
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 49/70 drm/i915: Do not zero initialise page tables
In reply to Chris WilsonAfter we successfully allocate them, we will fill them with their initial contents (either the chain of page tables, or a pointer to the scratch page).
Regression from
commit 06fda602dbca9c59d87db7da71192e4b54c9f5ff
Author: Ben Widawsky <[email protected]> Date: Tue Feb 24 16:22:36 2015 +0000
drm/i915: Create page table allocators
--- drivers/gpu/drm/i915/i915_gem_gtt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +1 -1
@@ -429,7 +429,7 @@ static struct i915_page_directory_entry *alloc_pd_single(void)if (!pd)return ERR_PTR (-ENOMEM ); - pd->page =alloc_page (GFP_KERNEL | __GFP_ZERO); + pd->page =alloc_page (GFP_KERNEL );if (!pd->page) {kfree (pd);return ERR_PTR (-ENOMEM );
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 50/70 drm/i915: The argument for postfix is redundant
In reply to Chris WilsonWe are conservative on the amount of free space available in the ring to avoid overruning the potential MI_INTERRUPT after the seqno write. Further undermining the justification for the change was that it was applied incorrectly.
--- drivers/gpu/drm/i915/i915_drv.h | 14 ++------------ drivers/gpu/drm/i915/i915_gem.c | 9 +-------- drivers/gpu/drm/i915/i915_gpu_error.c | 2 +- drivers/gpu/drm/i915/intel_dvo.c | 2 +- drivers/gpu/drm/i915/intel_lrc.c | 8 +++----- drivers/gpu/drm/i915/intel_ringbuffer.c | 2 +- 6 files changed, 9 insertions(+), 28 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -12
@@ -2074,18 +2074,8 @@ struct drm_i915_gem_request {/** GEM sequence number associated with this request. */ uint32_t seqno; -/** Position in the ringbuffer of the start of the request */ -u32 head; - -/** -* Position in the ringbuffer of the start of the postfix. -* This is required to calculate the maximum available ringbuffer -* space without overwriting the postfix. -*/ -u32 postfix; - -/** Position in the ringbuffer of the end of the whole request */ -u32 tail; +/** Position in the ringbuffer of the request */ +u32 head, tail;/** * Context and ring buffer related to this request
drivers/gpu/drm/i915/i915_gem.c +1 -8
@@ -1359,7 +1359,7 @@ void i915_gem_request_retire(struct drm_i915_gem_request *request)* Note this requires that we are always called in request * completion order. */ - request->ringbuf->last_retired_head = request->postfix; + request->ringbuf->last_retired_head = request->tail;list_del_init (&request->list);i915_gem_request_remove_from_client (request);
@@ -2495,13 +2495,6 @@ int __i915_add_request(struct intel_engine_cs *ring,return ret; } -/* Record the position of the start of the request so that -* should we detect the updated seqno part-way through the -* GPU processing the request, we never over-estimate the -* position of the head. -*/ - request->postfix =intel_ring_get_tail (ringbuf); -if (i915.enable_execlists) { ret = ring->emit_request (ringbuf, request);if (ret)
drivers/gpu/drm/i915/i915_gpu_error.c +1 -1
@@ -1072,7 +1072,7 @@ static void i915_gem_record_rings(struct drm_device *dev, erq = &error->ring[i].requests[count++]; erq->seqno = request->seqno; erq->jiffies = request->emitted_jiffies; - erq->tail = request->postfix; + erq->tail = request->tail; } } }
drivers/gpu/drm/i915/intel_dvo.c +1 -1
@@ -496,7 +496,7 @@ void intel_dvo_init(struct drm_device *dev)int gpio;bool dvoinit;enum pipe pipe; -uint32_t dpll[2 ]; +uint32_t dpll[I915_MAX_PIPES ];/* Allow the I2C driver info to specify the GPIO to be used in * special cases, but otherwise default to what's defined
drivers/gpu/drm/i915/intel_lrc.c +3 -5
@@ -409,7 +409,6 @@ void intel_lrc_irq_handler(struct intel_engine_cs *ring)static int execlists_context_queue (struct intel_engine_cs *ring,struct intel_context *to, -u32 tail,struct drm_i915_gem_request *request) {if (WARN_ON (request ==NULL ))
@@ -421,8 +420,6 @@ static int execlists_context_queue(struct intel_engine_cs *ring,i915_gem_request_reference (request);WARN_ON (to != request->ctx); - request->tail = tail; -spin_lock_irq (&ring->execlist_lock);list_add_tail (&request->execlist_link, &ring->execlist_queue);
@@ -574,7 +571,7 @@ static int logical_ring_wait_for_space(struct intel_ringbuffer *ringbuf,continue ;/* Would completion of this request free enough space? */ - space =__intel_ring_space (request->postfix, ringbuf->tail, + space =__intel_ring_space (request->tail, ringbuf->tail, ringbuf->size);if (space >= bytes)break ;
@@ -608,11 +605,12 @@ intel_logical_ring_advance_and_submit(struct intel_ringbuffer *ringbuf,struct intel_engine_cs *ring = ringbuf->ring;intel_logical_ring_advance (ringbuf); + request->tail = ringbuf->tail;if (intel_ring_stopped (ring))return ; -execlists_context_queue (ring, ctx, ringbuf->tail, request); +execlists_context_queue (ring, ctx, request); } static int logical_ring_wrap_buffer(struct intel_ringbuffer *ringbuf,
drivers/gpu/drm/i915/intel_ringbuffer.c +1 -1
@@ -2096,7 +2096,7 @@ static int ring_wait_for_space(struct intel_engine_cs *ring, int n)return 0 ;list_for_each_entry (request, &ring->request_list, list) { - space =__intel_ring_space (request->postfix, ringbuf->tail, + space =__intel_ring_space (request->tail, ringbuf->tail, ringbuf->size);if (space >= n)break ;
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 50/70] drm/i915: The argument for postfix is redundant
Quoted 6 lines · Chris Wilson
We are conservative on the amount of free space available in the ring to avoid overruning the potential
MI_INTERRUPTafter the seqno write. Further undermining the justification for the change was that it was applied incorrectly.Signed-off-by Chris Wilson <[email protected]>
Hm, where are we conservative with our estimates? Could we just wait for req->head instead? And I don't see what's been implemented wrongly with postfix.
Looking at
commit a71d8d94525e8fd855c0466fb586ae1cb008f3a2
Author: Chris Wilson <[email protected]> Date: Wed Feb 15 11:25:36 2012 +0000
drm/i915: Record the tail at each request and use it to estimate the head
->postfix does get updated where ->tail was, Nick just renamed it from ->tail to ->postfix since execlist used ->tail with a different meaning.
Or do I miss something?
drivers/gpu/drm/i915/intel_dvo.c void intel_dvo_init(struct drm_device *dev) · line 499
Quoted 10 lines
drivers/gpu/drm/i915/intel_dvo.c +1
-1@@ -496,7 +496,7 @@ void intel_dvo_init(struct drm_device *dev)int gpio;bool dvoinit;enum pipe pipe; -uint32_t dpll[2 ]; +uint32_t dpll[I915_MAX_PIPES ];
Unrelated change and there's indeed only 2 dvo plls ever on gen2. -Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 50/70] drm/i915: The argument for postfix is redundant
Quoted 11 lines · Daniel Vetter
Quoted 6 lines · Chris Wilson
We are conservative on the amount of free space available in the ring to avoid overruning the potential
MI_INTERRUPTafter the seqno write. Further undermining the justification for the change was that it was applied incorrectly.Signed-off-by Chris Wilson <[email protected]>Hm, where are we conservative with our estimates? Could we just wait for
req->headinstead? And I don't see what's been implemented wrongly with postfix.
It took more patches for it to get fixed, when it wasn't actually broken as the calculation of space remaining is conservative. req->head would be a reasonable compromise to the addition of another variable, and the extra bit of hysteresis here would probably be useful. Hmm.
Quoted 6 lines
Looking at
commit
a71d8d94525e8fd855c0466fb586ae1cb008f3a2Author: Chris Wilson <[email protected]> Date: Wed Feb 15 11:25:36 2012 +0000
Quoted 6 lines
drm/i915: Record the tail at each request and use it to estimate the head
->postfix does get updated where ->tail was, Nick just renamed it from ->tail to ->postfix since execlist used ->tail with a different meaning.
Or do I miss something?
tail was always the position of the end of the request.
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/i915/intel_dvo.c +0
-0
Quoted 8 lines
drivers/gpu/drm/i915/intel_dvo.c void intel_dvo_init(struct drm_device *dev) · line 499
Quoted 6 lines
drivers/gpu/drm/i915/intel_dvo.c +1
-1@@ -496,7 +496,7 @@ void intel_dvo_init(struct drm_device *dev)int gpio;bool dvoinit;enum pipe pipe; -uint32_t dpll[2 ]; +uint32_t dpll[I915_MAX_PIPES ];Unrelated change and there's indeed only 2 dvo plls ever on gen2.
Accidental squashing for a compiler warning.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 50/70] drm/i915: The argument for postfix is redundant
Quoted 24 lines · Chris Wilson
Quoted 11 lines · Daniel Vetter
Quoted 6 lines · Chris Wilson
We are conservative on the amount of free space available in the ring to avoid overruning the potential
MI_INTERRUPTafter the seqno write. Further undermining the justification for the change was that it was applied incorrectly.Signed-off-by Chris Wilson <[email protected]>Hm, where are we conservative with our estimates? Could we just wait for
req->headinstead? And I don't see what's been implemented wrongly with postfix.It took more patches for it to get fixed, when it wasn't actually broken as the calculation of space remaining is conservative.
req->headwould be a reasonable compromise to the addition of another variable, and the extra bit of hysteresis here would probably be useful. Hmm.Quoted 6 lines
Looking at
commit
a71d8d94525e8fd855c0466fb586ae1cb008f3a2Author: Chris Wilson <[email protected]> Date: Wed Feb 15 11:25:36 2012 +0000
Quoted 8 lines
Quoted 6 lines
drm/i915: Record the tail at each request and use it to estimate the head
->postfix does get updated where ->tail was, Nick just renamed it from ->tail to ->postfix since execlist used ->tail with a different meaning.
Or do I miss something?
tail was always the position of the end of the request.
In the above referenced commit request->tail is sampled _before_ we call ->add_request and all that stuff. That seems to have changed in
commit 6d3d8274bc45de4babb62d64562d92af984dd238
Author: Nick Hoath <[email protected]> Date: Thu Jan 15 13:10:39 2015 +0000
drm/i915: Subsume intel_ctx_submit_request in to drm_i915_gem_request
by essentially doing an s/request->tail/request->postfix/ and adding a new request->tail (real tail) to satisfy execlist.
-Daniel
Quoted 19 lines
Quoted 13 lines
drivers/gpu/drm/i915/intel_dvo.c void intel_dvo_init(struct drm_device *dev) · line 499
Quoted 11 lines
drivers/gpu/drm/i915/intel_dvo.c +1
-1@@ -496,7 +496,7 @@ void intel_dvo_init(struct drm_device *dev)int gpio;bool dvoinit;enum pipe pipe; -uint32_t dpll[2 ]; +uint32_t dpll[I915_MAX_PIPES ];Unrelated change and there's indeed only 2 dvo plls ever on gen2.
Accidental squashing for a compiler warning.
-ChrisSignature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 50/70] drm/i915: The argument for postfix is redundant
Quoted 37 lines · Daniel Vetter
Quoted 24 lines · Chris Wilson
Quoted 11 lines · Daniel Vetter
Quoted 6 lines · Chris Wilson
We are conservative on the amount of free space available in the ring to avoid overruning the potential
MI_INTERRUPTafter the seqno write. Further undermining the justification for the change was that it was applied incorrectly.Signed-off-by Chris Wilson <[email protected]>Hm, where are we conservative with our estimates? Could we just wait for
req->headinstead? And I don't see what's been implemented wrongly with postfix.It took more patches for it to get fixed, when it wasn't actually broken as the calculation of space remaining is conservative.
req->headwould be a reasonable compromise to the addition of another variable, and the extra bit of hysteresis here would probably be useful. Hmm.Quoted 6 lines
Looking at
commit
a71d8d94525e8fd855c0466fb586ae1cb008f3a2Author: Chris Wilson <[email protected]> Date: Wed Feb 15 11:25:36 2012 +0000Quoted 8 lines
Quoted 6 lines
drm/i915: Record the tail at each request and use it to estimate the head
->postfix does get updated where ->tail was, Nick just renamed it from ->tail to ->postfix since execlist used ->tail with a different meaning.
Or do I miss something?
tail was always the position of the end of the request.
In the above referenced commit
request->tailis sampled _before_ we call ->add_request and all that stuff. That seems to have changed in
Quoted 8 lines
commit
6d3d8274bc45de4babb62d64562d92af984dd238Author: Nick Hoath <[email protected]> Date: Thu Jan 15 13:10:39 2015 +0000drm/i915: Subsume
intel_ctx_submit_requestin todrm_i915_gem_requestby essentially doing an s/request->tail/request->postfix/ and adding a new
request->tail(real tail) to satisfy execlist.
Oh sorry, execlists was broken. Quel surprise. The model should have been to add the breadcrumb, grab the tail for the end of the request, submit to engine
http://cgit.freedesktop.org/~ickle/linux-2.6/tree/drivers/gpu/drm/i915/i915_gem_request.c#n378
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 51/70 drm/i915: Record the position of the start of the request
In reply to Chris WilsonNot only does it make for good documentation and debugging aide, but it is also vital for when we want to unwind requests - such as when throwing away an incomplete request.
v2: Rebase
--- drivers/gpu/drm/i915/i915_gem.c | 13 ++++++++---- drivers/gpu/drm/i915/i915_gem_context.c | 9 +-------- drivers/gpu/drm/i915/intel_lrc.c | 35 --------------------------------- drivers/gpu/drm/i915/intel_lrc.h | 2 -- 4 files changed, 10 insertions(+), 49 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +9 -4
@@ -2462,7 +2462,6 @@ int __i915_add_request(struct intel_engine_cs *ring,struct drm_i915_private *dev_priv = ring->dev->dev_private;struct drm_i915_gem_request *request;struct intel_ringbuffer *ringbuf; -u32 request_start;int ret; request = ring->outstanding_lazy_request;
@@ -2477,7 +2476,6 @@ int __i915_add_request(struct intel_engine_cs *ring, }else ringbuf = ring->buffer; - request_start =intel_ring_get_tail (ringbuf);/* * Emit any outstanding flushes - execbuf can fail to emit the flush * after having emitted the batchbuffer command. Hence we need to fix
@@ -2505,7 +2503,6 @@ int __i915_add_request(struct intel_engine_cs *ring,return ret; } - request->head = request_start; request->tail =intel_ring_get_tail (ringbuf);/* Whilst this request exists, batch_obj will be on the
@@ -2652,6 +2649,7 @@ int i915_gem_request_alloc(struct intel_engine_cs *ring,return ret; } + rq->head =intel_ring_get_tail (rq->ringbuf); ring->outstanding_lazy_request = rq;return 0 ; }
@@ -2736,7 +2734,14 @@ static void i915_gem_reset_ring_cleanup(struct drm_i915_private *dev_priv, }/* This may not have been flushed before the reset, so clean it now */ -i915_gem_request_assign (&ring->outstanding_lazy_request,NULL ); +if (ring->outstanding_lazy_request) { +struct drm_i915_gem_request *request; + + request = ring->outstanding_lazy_request; + request->ringbuf->tail = request->head; + +i915_gem_request_assign (&ring->outstanding_lazy_request,NULL ); + } }void i915_gem_restore_fences (struct drm_device *dev)
drivers/gpu/drm/i915/i915_gem_context.c +1 -8
@@ -298,15 +298,8 @@ void i915_gem_context_reset(struct drm_device *dev)struct drm_i915_private *dev_priv = dev->dev_private;int i; -if (i915.enable_execlists) { -struct intel_context *ctx; - -list_for_each_entry (ctx, &dev_priv->context_list, link) { -intel_lr_context_reset (dev, ctx); - } - +if (i915.enable_execlists)return ; - }for (i =0 ; i <I915_NUM_RINGS ; i++) {struct intel_engine_cs *ring = &dev_priv->ring[i];
drivers/gpu/drm/i915/intel_lrc.c +0 -35
@@ -1804,38 +1804,3 @@ error_unpin_ctx:drm_gem_object_unreference (&ctx_obj->base);return ret; } - -void intel_lr_context_reset (struct drm_device *dev, -struct intel_context *ctx) -{ -struct drm_i915_private *dev_priv = dev->dev_private; -struct intel_engine_cs *ring; -int i; - -for_each_ring (ring, dev_priv, i) { -struct drm_i915_gem_object *ctx_obj = - ctx->engine[ring->id].state; -struct intel_ringbuffer *ringbuf = - ctx->engine[ring->id].ringbuf; -uint32_t *reg_state; -struct page *page; - -if (!ctx_obj) -continue ; - -if (i915_gem_object_get_pages (ctx_obj)) { -WARN (1 ,"Failed get_pages for context obj\n" ); -continue ; - } - page =i915_gem_object_get_page (ctx_obj,1 ); - reg_state =kmap_atomic (page); - - reg_state[CTX_RING_HEAD +1 ] =0 ; - reg_state[CTX_RING_TAIL +1 ] =0 ; - -kunmap_atomic (reg_state); - - ringbuf->head =0 ; - ringbuf->tail =0 ; - } -}
drivers/gpu/drm/i915/intel_lrc.h +0 -2
@@ -70,8 +70,6 @@ static inline void intel_logical_ring_emit(struct intel_ringbuffer *ringbuf,void intel_lr_context_free (struct intel_context *ctx);int intel_lr_context_deferred_create (struct intel_context *ctx,struct intel_engine_cs *ring); -void intel_lr_context_reset (struct drm_device *dev, -struct intel_context *ctx);/* Execlists */ int intel_sanitize_enable_execlists (struct drm_device *dev,int enable_execlists);
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 52/70 drm/i915: Cache the execlist ctx descriptor
In reply to Chris Wilson--- drivers/gpu/drm/i915/intel_lrc.c | 56 +++++++++++++++++---------------- drivers/gpu/drm/i915/intel_ringbuffer.h | 3 +- 2 files changed, 31 insertions(+), 28 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +29 -27
@@ -230,37 +230,13 @@ int intel_sanitize_enable_execlists(struct drm_device *dev, int enable_execlistsreturn 0 ; } -static uint32_t execlists_ctx_descriptor (struct intel_engine_cs *engine, -uint32_t ggtt_offset) -{ -uint32_t desc; - - desc =GEN8_CTX_VALID ; - desc |=LEGACY_CONTEXT <<GEN8_CTX_MODE_SHIFT ; - desc |=GEN8_CTX_L3LLC_COHERENT ; - desc |=GEN8_CTX_PRIVILEGE ; - desc |= ggtt_offset; - -/* TODO: WaDisableLiteRestore when we start using semaphore -* signalling between Command Streamers */ -/* desc |= GEN8_CTX_FORCE_RESTORE; */ - -/* WaEnableForceRestoreInCtxtDescForVCS:skl */ -if (IS_GEN9 (engine->dev) &&INTEL_REVID (engine->dev) <=SKL_REVID_B0 && - (engine->id ==BCS || engine->id ==VCS || - engine->id ==VECS || engine->id ==VCS2 )) - desc |=GEN8_CTX_FORCE_RESTORE ; - -return desc; -} -static uint32_t execlists_request_write_tail (struct intel_engine_cs *engine,struct drm_i915_gem_request *rq) {struct intel_ringbuffer *ring = rq->ctx->engine[engine->id].ringbuf; ring->regs[CTX_RING_TAIL +1 ] = rq->tail; -return execlists_ctx_descriptor (engine, ring->ggtt_offset); +return ring->descriptor; }static void execlists_submit_pair (struct intel_engine_cs *ring)
@@ -498,6 +474,7 @@ static int intel_lr_context_pin(struct intel_engine_cs *ring, {struct drm_i915_gem_object *ctx_obj = ctx->engine[ring->id].state;struct intel_ringbuffer *ringbuf = ctx->engine[ring->id].ringbuf; +u32 ggtt_offset;int ret;WARN_ON (!mutex_is_locked (&ring->dev->struct_mutex));
@@ -508,11 +485,12 @@ static int intel_lr_context_pin(struct intel_engine_cs *ring,if (ret) goto reset_pin_count; - ringbuf->ggtt_offset =i915_gem_obj_ggtt_offset (ctx_obj); -if (WARN_ON (ringbuf->ggtt_offset &0xFFFFFFFF00000FFFULL )) { + ggtt_offset =i915_gem_obj_ggtt_offset (ctx_obj); +if (WARN_ON (ggtt_offset &0xFFFFFFFF00000FFFULL )) { ret = -ENODEV ; goto unpin_ctx_obj; } + ringbuf->descriptor = ggtt_offset | ring->execlist_ctx_descriptor; ret =intel_pin_and_map_ringbuffer_obj (ring->dev, ringbuf);if (ret)
@@ -1222,6 +1200,28 @@ void intel_logical_ring_cleanup(struct intel_engine_cs *ring) } } +static uint32_t base_ctx_descriptor (struct intel_engine_cs *engine) +{ +uint32_t desc; + + desc =GEN8_CTX_VALID ; + desc |=LEGACY_CONTEXT <<GEN8_CTX_MODE_SHIFT ; + desc |=GEN8_CTX_L3LLC_COHERENT ; + desc |=GEN8_CTX_PRIVILEGE ; + +/* TODO: WaDisableLiteRestore when we start using semaphore +* signalling between Command Streamers */ +/* desc |= GEN8_CTX_FORCE_RESTORE; */ + +/* WaEnableForceRestoreInCtxtDescForVCS:skl */ +if (IS_GEN9 (engine->dev) &&INTEL_REVID (engine->dev) <=SKL_REVID_B0 && + (engine->id ==BCS || engine->id ==VCS || + engine->id ==VECS || engine->id ==VCS2 )) + desc |=GEN8_CTX_FORCE_RESTORE ; + +return desc; +} +static int logical_ring_init (struct drm_device *dev,struct intel_engine_cs *ring) {int ret;
@@ -1243,6 +1243,8 @@ static int logical_ring_init(struct drm_device *dev, struct intel_engine_cs *rinif (ret)return ret; + ring->execlist_ctx_descriptor =base_ctx_descriptor (ring); + ret =intel_lr_context_deferred_create (ring->default_context, ring);return ret;
drivers/gpu/drm/i915/intel_ringbuffer.h +2 -1
@@ -98,7 +98,7 @@ struct intel_ringbuffer {struct drm_i915_gem_object *obj;void __iomem *virtual_start;uint32_t *regs; -uint32_t ggtt_offset; +uint32_t descriptor;struct intel_engine_cs *ring;
@@ -243,6 +243,7 @@ struct intel_engine_cs {struct drm_i915_gem_request *execlist_port[2 ];struct list_head execlist_queue;struct list_head execlist_completed; +u32 execlist_ctx_descriptor;u8 next_context_status_buffer;u32 irq_keep_mask;/* bitmask for interrupts that should not be masked */ int (*emit_request)(struct intel_ringbuffer *ringbuf,
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 53/70 drm/i915: Eliminate vmap overhead for cmd parser
In reply to Chris WilsonWith a little complexity to handle cmds straddling page boundaries, we can completely avoiding having to vmap the batch and the shadow batch objects whilst running the command parser.
On ivb i7-3720MQ:
x11perf -dot before 54.3M, after 53.2M (max 203M) glxgears before 7110 fps, after 7300 fps (max 7860 fps)
Before:
Time to blt 16384 bytes x 1: 12.400µs, 1.2GiB/s
Time to blt 16384 bytes x 4096: 3.055µs, 5.0GiB/s
After:
Time to blt 16384 bytes x 1: 8.600µs, 1.8GiB/s
Time to blt 16384 bytes x 4096: 2.456µs, 6.2GiB/s
Removing the vmap is mostly a win, except we lose in a few cases where the batch size is greater than a page due to the extra complexity (loss of a simple cache efficient large copy, and boundary handling).
v2: Reorder so that we do check oacontrol remaining set at end-of-batch
--- drivers/gpu/drm/i915/i915_cmd_parser.c | 299 ++++++++++++++++----------------- 1 file changed, 148 insertions(+), 151 deletions(-)
drivers/gpu/drm/i915/i915_cmd_parser.c +148 -151
@@ -818,100 +818,6 @@ static bool valid_reg(const u32 *table, int count, u32 addr)return false; } -static u32 *vmap_batch (struct drm_i915_gem_object *obj, -unsigned start,unsigned len) -{ -int i; -void *addr =NULL ; -struct sg_page_iter sg_iter; -int first_page = start >>PAGE_SHIFT ; -int last_page = (len + start +4095 ) >>PAGE_SHIFT ; -int npages = last_page - first_page; -struct page **pages; - - pages =drm_malloc_ab (npages,sizeof (*pages)); -if (pages ==NULL ) { -DRM_DEBUG_DRIVER ("Failed to get space for pages\n" ); - goto finish; - } - - i =0 ; -for_each_sg_page (obj->pages->sgl, &sg_iter, obj->pages->nents, first_page) { - pages[i++] =sg_page_iter_page (&sg_iter); -if (i == npages) -break ; - } - - addr =vmap (pages, i,0 ,PAGE_KERNEL ); -if (addr ==NULL ) { -DRM_DEBUG_DRIVER ("Failed to vmap pages\n" ); - goto finish; - } - -finish: -if (pages) -drm_free_large (pages); -return (u32 *)addr; -} - -/* Returns a vmap'd pointer to dest_obj, which the caller must unmap */ -static u32 *copy_batch (struct drm_i915_gem_object *dest_obj, -struct drm_i915_gem_object *src_obj, -u32 batch_start_offset, -u32 batch_len) -{ -int needs_clflush =0 ; -void *src_base, *src; -void *dst =NULL ; -int ret; - -if (batch_len > dest_obj->base.size || - batch_len + batch_start_offset > src_obj->base.size) -return ERR_PTR (-E2BIG ); - -if (WARN_ON (dest_obj->pages_pin_count ==0 )) -return ERR_PTR (-ENODEV ); - - ret =i915_gem_obj_prepare_shmem_read (src_obj, &needs_clflush); -if (ret) { -DRM_DEBUG_DRIVER ("CMD: failed to prepare shadow batch\n" ); -return ERR_PTR (ret); - } - - src_base =vmap_batch (src_obj, batch_start_offset, batch_len); -if (!src_base) { -DRM_DEBUG_DRIVER ("CMD: Failed to vmap batch\n" ); - ret = -ENOMEM ; - goto unpin_src; - } - - ret =i915_gem_object_set_to_cpu_domain (dest_obj, true); -if (ret) { -DRM_DEBUG_DRIVER ("CMD: Failed to set shadow batch to CPU\n" ); - goto unmap_src; - } - - dst =vmap_batch (dest_obj,0 , batch_len); -if (!dst) { -DRM_DEBUG_DRIVER ("CMD: Failed to vmap shadow batch\n" ); - ret = -ENOMEM ; - goto unmap_src; - } - - src = src_base +offset_in_page (batch_start_offset); -if (needs_clflush) -drm_clflush_virt_range (src, batch_len); - -memcpy (dst, src, batch_len); - -unmap_src: -vunmap (src_base); -unpin_src: -i915_gem_object_unpin_pages (src_obj); - -return ret ?ERR_PTR (ret) : dst; -} -/** * i915_needs_cmd_parser() - should a given ring use software command parsing? * @ring: the ring in question
@@ -1046,16 +952,34 @@ int i915_parse_cmds(struct intel_engine_cs *ring, u32 batch_len, bool is_master) { -u32 *cmd, *batch_base, *batch_end; +u32 tmp[128 ]; +struct sg_page_iter src_iter, dst_iter; +const struct drm_i915_cmd_descriptor *desc; +int needs_clflush =0 ; +void *src, *dst; +unsigned in, out; +u32 *buf, partial =0 , length;struct drm_i915_cmd_descriptor default_desc = {0 };bool oacontrol_set = false;/* OACONTROL tracking. See check_cmd() */ int ret =0 ; - batch_base =copy_batch (shadow_batch_obj, batch_obj, - batch_start_offset, batch_len); -if (IS_ERR (batch_base)) { -DRM_DEBUG_DRIVER ("CMD: Failed to copy batch\n" ); -return PTR_ERR (batch_base); +if (batch_len > shadow_batch_obj->base.size || + batch_len + batch_start_offset > batch_obj->base.size) +return -E2BIG ; + +if (WARN_ON (shadow_batch_obj->pages_pin_count ==0 )) +return -ENODEV ; + + ret =i915_gem_obj_prepare_shmem_read (batch_obj, &needs_clflush); +if (ret) { +DRM_DEBUG_DRIVER ("CMD: failed to prepare shadow batch\n" ); +return ret; + } + + ret =i915_gem_object_set_to_cpu_domain (shadow_batch_obj, true); +if (ret) { +DRM_DEBUG_DRIVER ("CMD: Failed to set shadow batch to CPU\n" ); + goto unpin; }/*
@@ -1063,68 +987,141 @@ int i915_parse_cmds(struct intel_engine_cs *ring,* large or larger and copy_batch() will write MI_NOPs to the extra * space. Parsing should be faster in some cases this way. */ - batch_end = batch_base + (batch_len /sizeof (*batch_end)); + ret = -EINVAL ; + +__sg_page_iter_start (&dst_iter, + shadow_batch_obj->pages->sgl, + shadow_batch_obj->pages->nents, +0 ); +__sg_page_iter_next (&dst_iter); + dst =kmap_atomic (sg_page_iter_page (&dst_iter)); + + in =offset_in_page (batch_start_offset); + out =0 ; +for_each_sg_page (batch_obj->pages->sgl, + &src_iter, + batch_obj->pages->nents, + batch_start_offset >>PAGE_SHIFT ) { +u32 this, i, j, k; +u32 *cmd, *page_end, *batch_end; + + this = batch_len; +if (this >PAGE_SIZE - in) + this =PAGE_SIZE - in; + + src =kmap_atomic (sg_page_iter_page (&src_iter)); +if (needs_clflush) +drm_clflush_virt_range (src + in, this); + + i = this; + j = in; +do { +/* We keep dst around so that we do not blow +* the CPU caches immediately after the copy (due +* to the kunmap_atomic(dst) doing a TLB flush. +*/ +if (out ==PAGE_SIZE ) { +__sg_page_iter_next (&dst_iter); +kunmap_atomic (dst); + dst =kmap_atomic (sg_page_iter_page (&dst_iter)); + out =0 ; + } - cmd = batch_base; -while (cmd < batch_end) { -const struct drm_i915_cmd_descriptor *desc; -u32 length; + k = i; +if (k >PAGE_SIZE - out) + k =PAGE_SIZE - out; +if (k ==PAGE_SIZE ) +copy_page (dst, src); +else +memcpy (dst + out, src + j, k); + + out += k; + j += k; + i -= k; + }while (i); + + cmd = src + in; + page_end = (void *)cmd + this; + batch_end = (void *)cmd + batch_len; + +if (partial) { +memcpy (tmp + partial, cmd, (length - partial)*4 ); + cmd -= partial; + partial =0 ; + buf = tmp; + goto check; + } -if (*cmd ==MI_BATCH_BUFFER_END ) -break ; +do { +if (*cmd ==MI_BATCH_BUFFER_END ) { +if (oacontrol_set) { +DRM_DEBUG_DRIVER ("CMD: batch set OACONTROL but did not clear it\n" ); + ret = -EINVAL ; + }else + ret =0 ; + goto unmap; + } - desc =find_cmd (ring, *cmd, &default_desc); -if (!desc) { -DRM_DEBUG_DRIVER ("CMD: Unrecognized command: 0x%08X\n" , - *cmd); - ret = -EINVAL ; -break ; - } + desc =find_cmd (ring, *cmd, &default_desc); +if (!desc) { +DRM_DEBUG_DRIVER ("CMD: Unrecognized command: 0x%08X\n" , + *cmd); + goto unmap; + } -/* -* If the batch buffer contains a chained batch, return an -* error that tells the caller to abort and dispatch the -* workload as a non-secure batch. -*/ -if (desc->cmd.value ==MI_BATCH_BUFFER_START ) { - ret = -EACCES ; -break ; - } +/* +* If the batch buffer contains a chained batch, return an +* error that tells the caller to abort and dispatch the +* workload as a non-secure batch. +*/ +if (desc->cmd.value ==MI_BATCH_BUFFER_START ) { + ret = -EACCES ; + goto unmap; + } -if (desc->flags &CMD_DESC_FIXED ) - length = desc->length.fixed; -else - length = ((*cmd & desc->length.mask) +LENGTH_BIAS ); - -if ((batch_end - cmd) < length) { -DRM_DEBUG_DRIVER ("CMD: Command length exceeds batch length: 0x%08X length=%u batchlen=%td\n" , - *cmd, - length, - batch_end - cmd); - ret = -EINVAL ; -break ; - } +if (desc->flags &CMD_DESC_FIXED ) + length = desc->length.fixed; +else + length = ((*cmd & desc->length.mask) +LENGTH_BIAS ); + +if (cmd + length > page_end) { +if (length + cmd > batch_end) { +DRM_DEBUG_DRIVER ("CMD: Command length exceeds batch length: 0x%08X length=%u batchlen=%td\n" , + *cmd, length, batch_end - cmd); + goto unmap; + } + +if (WARN_ON (length >sizeof (tmp)/4 )) { + ret = -ENODEV ; + goto unmap; + } + + partial = page_end - cmd; +memcpy (tmp, cmd, partial*4 ); +break ; + } -if (!check_cmd (ring, desc, cmd, is_master, &oacontrol_set)) { - ret = -EINVAL ; -break ; - } + buf = cmd; +check: +if (!check_cmd (ring, desc, buf, is_master, &oacontrol_set)) + goto unmap; - cmd += length; - } + cmd += length; + }while (cmd < page_end); -if (oacontrol_set) { -DRM_DEBUG_DRIVER ("CMD: batch set OACONTROL but did not clear it\n" ); - ret = -EINVAL ; - } + batch_len -= this; +if (batch_len ==0 ) +break ; -if (cmd >= batch_end) { -DRM_DEBUG_DRIVER ("CMD: Got to the end of the buffer w/o a BBE cmd!\n" ); - ret = -EINVAL ; +kunmap_atomic (src); + in =0 ; } -vunmap (batch_base); - +unmap: +kunmap_atomic (src); +kunmap_atomic (dst); +unpin: +i915_gem_object_unpin_pages (batch_obj);return ret; }
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 54/70 drm/i915: Cache last cmd descriptor when parsing
In reply to Chris WilsonThe cmd parser has the biggest impact on the BLT ring, because it is relatively verbose composed to the other engines as the vertex data is inline. It also typically has runs of repeating commands (again since the vertex data is inline, it typically has sequences of XY_SETUP_BLT, XY_SCANLINE_BLT..) We can easily reduce the impact of cmdparsing on benchmarks by then caching the last descriptor and comparing it against the next command header. To get maximum benefit, we also want to take advantage of skipping a few validations and length determinations if the header is unchanged between commands.
ivb i7-3720QM:
x11perf -dot: before 52.3M, after 124M (max 203M)
glxgears: before 7310 fps, after 7550 fps (max 7860 fps)
v2: Fix initial cached cmd descriptor to match MI_NOOP.
--- drivers/gpu/drm/i915/i915_cmd_parser.c | 129 +++++++++++++++------------------ drivers/gpu/drm/i915/i915_drv.h | 10 +-- 2 files changed, 62 insertions(+), 77 deletions(-)
drivers/gpu/drm/i915/i915_cmd_parser.c +57 -72
@@ -754,6 +754,9 @@ void i915_cmd_parser_fini_ring(struct intel_engine_cs *ring)fini_hash_table (ring); } +/* +* Returns a pointer to a descriptor for the command specified by cmd_header. +*/ static const struct drm_i915_cmd_descriptor *find_cmd_in_table (struct intel_engine_cs *ring,u32 cmd_header)
@@ -773,37 +776,6 @@ find_cmd_in_table(struct intel_engine_cs *ring,return NULL ; } -/* -* Returns a pointer to a descriptor for the command specified by cmd_header. -* -* The caller must supply space for a default descriptor via the default_desc -* parameter. If no descriptor for the specified command exists in the ring's -* command parser tables, this function fills in default_desc based on the -* ring's default length encoding and returns default_desc. -*/ -static const struct drm_i915_cmd_descriptor * -find_cmd (struct intel_engine_cs *ring, -u32 cmd_header, -struct drm_i915_cmd_descriptor *default_desc) -{ -const struct drm_i915_cmd_descriptor *desc; -u32 mask; - - desc =find_cmd_in_table (ring, cmd_header); -if (desc) -return desc; - - mask = ring->get_cmd_length_mask (cmd_header); -if (!mask) -return NULL ; - -BUG_ON (!default_desc); - default_desc->flags =CMD_DESC_SKIP ; - default_desc->length.mask = mask; - -return default_desc; -} -static bool valid_reg (const u32 *table,int count,u32 addr) {if (table && count !=0 ) {
@@ -844,17 +816,6 @@ static bool check_cmd(const struct intel_engine_cs *ring,const bool is_master, bool *oacontrol_set) { - if (desc->flags & CMD_DESC_REJECT) { - DRM_DEBUG_DRIVER("CMD: Rejected command: 0x%08X\n", *cmd); -return false; - } - -if ((desc->flags &CMD_DESC_MASTER ) && !is_master) { -DRM_DEBUG_DRIVER ("CMD: Rejected master-only command: 0x%08X\n" , - *cmd); -return false; - } - if (desc->flags & CMD_DESC_REGISTER) { u32 reg_addr = cmd[desc->reg.offset] & desc->reg.mask;
@@ -954,12 +915,13 @@ int i915_parse_cmds(struct intel_engine_cs *ring, {u32 tmp[128 ];struct sg_page_iter src_iter, dst_iter; -const struct drm_i915_cmd_descriptor *desc; +struct drm_i915_cmd_descriptor default_desc = {CMD_DESC_SKIP }; +const struct drm_i915_cmd_descriptor *desc = &default_desc; +u32 last_cmd_header =0 ;int needs_clflush =0 ;void *src, *dst;unsigned in, out; -u32 *buf, partial =0 , length; -struct drm_i915_cmd_descriptor default_desc = {0 }; +u32 *buf, partial =0 , length =1 ;bool oacontrol_set = false;/* OACONTROL tracking. See check_cmd() */ int ret =0 ;
@@ -1053,37 +1015,60 @@ int i915_parse_cmds(struct intel_engine_cs *ring, } do { - if (*cmd == MI_BATCH_BUFFER_END) { - if (oacontrol_set) { - DRM_DEBUG_DRIVER("CMD: batch set OACONTROL but did not clear it\n"); - ret = -EINVAL; - } else - ret = 0; - goto unmap; - } + if (*cmd != last_cmd_header) { + if (*cmd == MI_BATCH_BUFFER_END) { + if (unlikely(oacontrol_set)) { + DRM_DEBUG_DRIVER("CMD: batch set OACONTROL but did not clear it\n"); + ret = -EINVAL; + } else + ret = 0; + goto unmap; + } - desc = find_cmd(ring, *cmd, &default_desc); - if (!desc) { - DRM_DEBUG_DRIVER("CMD: Unrecognized command: 0x%08X\n", - *cmd); - goto unmap; - } + desc = find_cmd_in_table(ring, *cmd); + if (desc) { + if (unlikely(desc->flags & CMD_DESC_REJECT)) { + DRM_DEBUG_DRIVER("CMD: Rejected command: 0x%08X\n", *cmd); + goto unmap; + } + + if (unlikely((desc->flags & CMD_DESC_MASTER) && !is_master)) { + DRM_DEBUG_DRIVER("CMD: Rejected master-only command: 0x%08X\n", *cmd); + goto unmap; + } + + /* + * If the batch buffer contains a + * chained batch, return an error that + * tells the caller to abort and + * dispatch the workload as a + * non-secure batch. + */ + if (unlikely(desc->cmd.value == MI_BATCH_BUFFER_START)) { + ret = -EACCES; + goto unmap; + } + + if (desc->flags & CMD_DESC_FIXED) + length = desc->length.fixed; + else + length = (*cmd & desc->length.mask) + LENGTH_BIAS; + } else { + u32 mask = ring->get_cmd_length_mask(*cmd); + if (unlikely(!mask)) { + DRM_DEBUG_DRIVER("CMD: Unrecognized command: 0x%08X\n", *cmd); + goto unmap; + } + + default_desc.length.mask = mask; + desc = &default_desc; + + length = (*cmd & mask) + LENGTH_BIAS; + } - /* - * If the batch buffer contains a chained batch, return an - * error that tells the caller to abort and dispatch the - * workload as a non-secure batch. - */ - if (desc->cmd.value == MI_BATCH_BUFFER_START) { - ret = -EACCES; - goto unmap; + last_cmd_header = *cmd; } - if (desc->flags & CMD_DESC_FIXED) - length = desc->length.fixed; - else - length = ((*cmd & desc->length.mask) + LENGTH_BIAS); - if (cmd + length > page_end) { if (length + cmd > batch_end) { DRM_DEBUG_DRIVER("CMD: Command length exceeds batch length: 0x%08X length=%u batchlen=%td\n",
drivers/gpu/drm/i915/i915_drv.h +5 -5
@@ -2205,12 +2205,12 @@ struct drm_i915_cmd_descriptor {* is the DRM master */ u32 flags; +#define CMD_DESC_SKIP (0)#define CMD_DESC_FIXED (1<<0) -#define CMD_DESC_SKIP (1<<1) -#define CMD_DESC_REJECT (1<<2) -#define CMD_DESC_REGISTER (1<<3) -#define CMD_DESC_BITMASK (1<<4) -#define CMD_DESC_MASTER (1<<5) +#define CMD_DESC_REJECT (1<<1) +#define CMD_DESC_REGISTER (1<<2) +#define CMD_DESC_BITMASK (1<<3) +#define CMD_DESC_MASTER (1<<4)/* * The command's unique identification bits and the bitmask to get them.
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 55/70 drm/i915: Use WC copies on !llc platforms for the command parser
In reply to Chris WilsonSince we blow the TLB caches by using kmap/kunmap, we may as well go the whole hog and see if declaring our destination page as WC is faster than keeping it as WB and using clflush. It should be!
--- drivers/gpu/drm/i915/i915_cmd_parser.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_cmd_parser.c +13 -4
@@ -918,8 +918,9 @@ int i915_parse_cmds(struct intel_engine_cs *ring,struct drm_i915_cmd_descriptor default_desc = {CMD_DESC_SKIP };const struct drm_i915_cmd_descriptor *desc = &default_desc;u32 last_cmd_header =0 ; -int needs_clflush =0 ;void *src, *dst; +int src_needs_clflush =0 ; +bool dst_needs_clflush;unsigned in, out;u32 *buf, partial =0 , length =1 ;bool oacontrol_set = false;/* OACONTROL tracking. See check_cmd() */
@@ -932,13 +933,17 @@ int i915_parse_cmds(struct intel_engine_cs *ring,if (WARN_ON (shadow_batch_obj->pages_pin_count ==0 ))return -ENODEV ; - ret =i915_gem_obj_prepare_shmem_read (batch_obj, &needs_clflush); + ret =i915_gem_obj_prepare_shmem_read (batch_obj, &src_needs_clflush);if (ret) {DRM_DEBUG_DRIVER ("CMD: failed to prepare shadow batch\n" );return ret; } - ret =i915_gem_object_set_to_cpu_domain (shadow_batch_obj, true); + dst_needs_clflush = !INTEL_INFO (shadow_batch_obj->base.dev)->has_llc; +if (dst_needs_clflush) + ret =i915_gem_object_set_to_gtt_domain (shadow_batch_obj, true); +else + ret =i915_gem_object_set_to_cpu_domain (shadow_batch_obj, true);if (ret) {DRM_DEBUG_DRIVER ("CMD: Failed to set shadow batch to CPU\n" ); goto unpin;
@@ -972,7 +977,7 @@ int i915_parse_cmds(struct intel_engine_cs *ring, this =PAGE_SIZE - in; src =kmap_atomic (sg_page_iter_page (&src_iter)); -if (needs_clflush) +if (src_needs_clflush)drm_clflush_virt_range (src + in, this); i = this;
@@ -984,6 +989,8 @@ int i915_parse_cmds(struct intel_engine_cs *ring,*/ if (out ==PAGE_SIZE ) {__sg_page_iter_next (&dst_iter); +if (dst_needs_clflush) +drm_clflush_virt_range (dst,PAGE_SIZE );kunmap_atomic (dst); dst =kmap_atomic (sg_page_iter_page (&dst_iter)); out =0 ;
@@ -1104,6 +1111,8 @@ check: unmap:kunmap_atomic (src); +if (dst_needs_clflush) +drm_clflush_virt_range (dst,PAGE_SIZE );kunmap_atomic (dst); unpin:i915_gem_object_unpin_pages (batch_obj);
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 56/70 drm/i915: Cache kmap between relocations
In reply to Chris WilsonWhen doing relocations, we have to obtain a mapping to the page containing the target address. This is either a kmap or iomap depending on GPU and its cache coherency. Neighbouring relocation entries are typically within the same page and so we can cache our kmapping between them and avoid those pesky TLB flushes.
Note that there is some sleight-of-hand in how the slow relocate works as the reloc_entry_cache implies pagefaults disabled (as we are inside a kmap_atomic section). However, the slow relocate code is meant to be the fallback from the atomic fast path failing. Fortunately it works as we already have performed the copy_from_user for the relocation array (no more pagefaults there) and the kmap_atomic cache is enabled after we have waited upon an active buffer (so no more sleeping in atomic). Magic!
--- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 145 +++++++++++++++++++---------- 1 file changed, 96 insertions(+), 49 deletions(-)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +96 -49
@@ -248,9 +248,48 @@ static inline int use_cpu_reloc(struct drm_i915_gem_object *obj) obj->cache_level != I915_CACHE_NONE); } +struct reloc_entry_cache { +void *vaddr; +unsigned page; +enum {KMAP ,IOMAP } type; +}; + +static void reloc_entry_cache_init (struct reloc_entry_cache *cache) +{ + cache->page =-1 ; + cache->vaddr =NULL ; +} + +static void reloc_entry_cache_fini (struct reloc_entry_cache *cache) +{ +if (cache->vaddr ==NULL ) +return ; + +switch (cache->type) { +case KMAP :kunmap_atomic (cache->vaddr);break ; +case IOMAP :io_mapping_unmap_atomic (cache->vaddr);break ; + } +} + +static void *reloc_kmap (struct drm_i915_gem_object *obj, +struct reloc_entry_cache *cache, +int page) +{ +if (cache->page != page) { +if (cache->vaddr) +kunmap_atomic (cache->vaddr); + cache->page = page; + cache->vaddr =kmap_atomic (i915_gem_object_get_page (obj, page)); + cache->type =KMAP ; + } + +return cache->vaddr; +} +static int relocate_entry_cpu (struct drm_i915_gem_object *obj,struct drm_i915_gem_relocation_entry *reloc, +struct reloc_entry_cache *cache,uint64_t target_offset) {struct drm_device *dev = obj->base.dev;
@@ -263,30 +302,41 @@ relocate_entry_cpu(struct drm_i915_gem_object *obj,if (ret)return ret; - vaddr =kmap_atomic (i915_gem_object_get_page (obj, - reloc->offset >>PAGE_SHIFT )); + vaddr =reloc_kmap (obj, cache, reloc->offset >>PAGE_SHIFT ); *(uint32_t *)(vaddr + page_offset) =lower_32_bits (delta);if (INTEL_INFO (dev)->gen >=8 ) { - page_offset =offset_in_page (page_offset +sizeof (uint32_t )); - -if (page_offset ==0 ) { -kunmap_atomic (vaddr); - vaddr =kmap_atomic (i915_gem_object_get_page (obj, - (reloc->offset +sizeof (uint32_t )) >>PAGE_SHIFT )); + page_offset +=sizeof (uint32_t ); +if (page_offset ==PAGE_SIZE ) { + vaddr =reloc_kmap (obj, cache, cache->page +1 ); + page_offset =0 ; } - *(uint32_t *)(vaddr + page_offset) =upper_32_bits (delta); } -kunmap_atomic (vaddr); -return 0 ; } +static void *reloc_iomap (struct drm_i915_private *i915, +struct reloc_entry_cache *cache, +uint64_t offset) +{ +if (cache->page != offset >>PAGE_SHIFT ) { +if (cache->vaddr) +io_mapping_unmap_atomic (cache->vaddr); + cache->page = offset >>PAGE_SHIFT ; + cache->vaddr = +io_mapping_map_atomic_wc (i915->gtt.mappable, + offset &PAGE_MASK ); + cache->type =IOMAP ; + } + +return cache->vaddr; +}static int relocate_entry_gtt (struct drm_i915_gem_object *obj,struct drm_i915_gem_relocation_entry *reloc, +struct reloc_entry_cache *cache,uint64_t target_offset) {struct drm_device *dev = obj->base.dev;
@@ -307,26 +357,17 @@ relocate_entry_gtt(struct drm_i915_gem_object *obj,/* Map the page containing the relocation we're going to perform. */ offset =i915_gem_obj_ggtt_offset (obj); offset += reloc->offset; - reloc_page =io_mapping_map_atomic_wc (dev_priv->gtt.mappable, - offset &PAGE_MASK ); + reloc_page =reloc_iomap (dev_priv, cache, offset);iowrite32 (lower_32_bits (delta), reloc_page +offset_in_page (offset));if (INTEL_INFO (dev)->gen >=8 ) { offset +=sizeof (uint32_t ); - -if (offset_in_page (offset) ==0 ) { -io_mapping_unmap_atomic (reloc_page); - reloc_page = -io_mapping_map_atomic_wc (dev_priv->gtt.mappable, - offset); - } - +if (offset_in_page (offset) ==0 ) + reloc_page =reloc_iomap (dev_priv, cache, offset);iowrite32 (upper_32_bits (delta), reloc_page +offset_in_page (offset)); } -io_mapping_unmap_atomic (reloc_page); -return 0 ; }
@@ -342,6 +383,7 @@ clflush_write32(void *addr, uint32_t value)static int relocate_entry_clflush (struct drm_i915_gem_object *obj,struct drm_i915_gem_relocation_entry *reloc, +struct reloc_entry_cache *cache,uint64_t target_offset) {struct drm_device *dev = obj->base.dev;
@@ -354,31 +396,26 @@ relocate_entry_clflush(struct drm_i915_gem_object *obj,if (ret)return ret; - vaddr =kmap_atomic (i915_gem_object_get_page (obj, - reloc->offset >>PAGE_SHIFT )); + vaddr =reloc_kmap (obj, cache, reloc->offset >>PAGE_SHIFT );clflush_write32 (vaddr + page_offset,lower_32_bits (delta));if (INTEL_INFO (dev)->gen >=8 ) { - page_offset =offset_in_page (page_offset +sizeof (uint32_t )); - -if (page_offset ==0 ) { -kunmap_atomic (vaddr); - vaddr =kmap_atomic (i915_gem_object_get_page (obj, - (reloc->offset +sizeof (uint32_t )) >>PAGE_SHIFT )); + page_offset +=sizeof (uint32_t ); +if (page_offset ==PAGE_SIZE ) { + vaddr =reloc_kmap (obj, cache, cache->page +1 ); + page_offset =0 ; } -clflush_write32 (vaddr + page_offset,upper_32_bits (delta)); } -kunmap_atomic (vaddr); -return 0 ; }static int i915_gem_execbuffer_relocate_entry (struct drm_i915_gem_object *obj,struct eb_vmas *eb, -struct drm_i915_gem_relocation_entry *reloc) +struct drm_i915_gem_relocation_entry *reloc, +struct reloc_entry_cache *cache) {struct drm_device *dev = obj->base.dev;struct drm_gem_object *target_obj;
@@ -463,11 +500,11 @@ i915_gem_execbuffer_relocate_entry(struct drm_i915_gem_object *obj,return -EFAULT ;if (use_cpu_reloc (obj)) - ret =relocate_entry_cpu (obj, reloc, target_offset); + ret =relocate_entry_cpu (obj, reloc, cache, target_offset);else if (obj->map_and_fenceable) - ret =relocate_entry_gtt (obj, reloc, target_offset); + ret =relocate_entry_gtt (obj, reloc, cache, target_offset);else if (cpu_has_clflush) - ret =relocate_entry_clflush (obj, reloc, target_offset); + ret =relocate_entry_clflush (obj, reloc, cache, target_offset);else {WARN_ONCE (1 ,"Impossible case in relocation handling\n" ); ret = -ENODEV ;
@@ -490,9 +527,11 @@ i915_gem_execbuffer_relocate_vma(struct i915_vma *vma,struct drm_i915_gem_relocation_entry stack_reloc[N_RELOC (512 )];struct drm_i915_gem_relocation_entry __user *user_relocs;struct drm_i915_gem_exec_object2 *entry = vma->exec_entry; -int remain, ret; +struct reloc_entry_cache cache; +int remain, ret =0 ; user_relocs =to_user_ptr (entry->relocs_ptr); +reloc_entry_cache_init (&cache); remain = entry->relocation_count;while (remain) {
@@ -502,21 +541,24 @@ i915_gem_execbuffer_relocate_vma(struct i915_vma *vma, count =ARRAY_SIZE (stack_reloc); remain -= count; -if (__copy_from_user_inatomic (r, user_relocs, count*sizeof (r[0 ]))) -return -EFAULT ; +if (__copy_from_user_inatomic (r, user_relocs, count*sizeof (r[0 ]))) { + ret = -EFAULT ; + goto out; + } do { u64 offset = r->presumed_offset; - ret = i915_gem_execbuffer_relocate_entry(vma->obj, eb, r); + ret = i915_gem_execbuffer_relocate_entry(vma->obj, eb, r, &cache); if (ret) - return ret; + goto out; if (r->presumed_offset != offset && __copy_to_user_inatomic(&user_relocs->presumed_offset, &r->presumed_offset, sizeof(r->presumed_offset))) { - return -EFAULT; + ret = -EFAULT; + goto out; } user_relocs++;
@@ -524,7 +566,9 @@ i915_gem_execbuffer_relocate_vma(struct i915_vma *vma, }while (--count); } -return 0 ; +out: +reloc_entry_cache_fini (&cache); +return ret;#undef N_RELOC }
@@ -534,15 +578,18 @@ i915_gem_execbuffer_relocate_vma_slow(struct i915_vma *vma, struct drm_i915_gem_relocation_entry *relocs) {const struct drm_i915_gem_exec_object2 *entry = vma->exec_entry; -int i, ret; +struct reloc_entry_cache cache; +int i, ret =0 ; +reloc_entry_cache_init (&cache);for (i =0 ; i < entry->relocation_count; i++) { - ret =i915_gem_execbuffer_relocate_entry (vma->obj, eb, &relocs[i]); + ret =i915_gem_execbuffer_relocate_entry (vma->obj, eb, &relocs[i], &cache);if (ret) -return ret; +break ; } +reloc_entry_cache_fini (&cache); -return 0 ; +return ret; } static int
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 57/70 drm/i915: intel_ring_initialized() must be simple and inline
In reply to Chris WilsonFixes regression from
commit 48d823878d64f93163f5a949623346748bbce1b4
Author: Oscar Mateo <[email protected]> Date: Thu Jul 24 17:04:23 2014 +0100
drm/i915/bdw: Generic logical ring init and cleanup
--- drivers/gpu/drm/i915/intel_lrc.c | 18 ++++++++++++++++- drivers/gpu/drm/i915/intel_ringbuffer.c | 35 +++++++++++++++------------------ drivers/gpu/drm/i915/intel_ringbuffer.h | 6 +++++- 3 files changed, 38 insertions(+), 21 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +17 -1
@@ -1241,12 +1241,28 @@ static int logical_ring_init(struct drm_device *dev, struct intel_engine_cs *rin ret =i915_cmd_parser_init_ring (ring);if (ret) -return ret; + goto error; ring->execlist_ctx_descriptor =base_ctx_descriptor (ring); ret =intel_lr_context_deferred_create (ring->default_context, ring); +if (ret) + goto error; + +return 0 ; +error: +if (ring->cleanup) + ring->cleanup (ring); + +i915_cmd_parser_fini_ring (ring); +i915_gem_batch_pool_fini (&ring->batch_pool); + +if (ring->status_page.obj) { +kunmap (sg_page (ring->status_page.obj->pages->sgl)); + ring->status_page.obj =NULL ; + } + ring->dev =NULL ;return ret; }
drivers/gpu/drm/i915/intel_ringbuffer.c +16 -19
@@ -33,23 +33,6 @@#include "i915_trace.h" #include "intel_drv.h" -bool -intel_ring_initialized (struct intel_engine_cs *ring) -{ -struct drm_device *dev = ring->dev; - -if (!dev) -return false; - -if (i915.enable_execlists) { -struct intel_context *dctx = ring->default_context; -struct intel_ringbuffer *ringbuf = dctx->engine[ring->id].ringbuf; - -return ringbuf->obj; - }else -return ring->buffer && ring->buffer->obj; -} -int __intel_ring_space (int head,int tail,int size) {int space = head - tail;
@@ -1992,8 +1975,10 @@ static int intel_init_ring_buffer(struct drm_device *dev,WARN_ON (ring->buffer); ringbuf =kzalloc (sizeof (*ringbuf),GFP_KERNEL ); -if (!ringbuf) -return -ENOMEM ; +if (!ringbuf) { + ret = -ENOMEM ; + goto error; + } ring->buffer = ringbuf; ring->dev = dev;
@@ -2050,8 +2035,18 @@ static int intel_init_ring_buffer(struct drm_device *dev,return 0 ; error: +if (ring->cleanup) + ring->cleanup (ring); + +cleanup_status_page (ring); + +i915_cmd_parser_fini_ring (ring); +i915_gem_batch_pool_fini (&ring->batch_pool); +kfree (ringbuf); ring->buffer =NULL ; + + ring->dev =NULL ;return ret; }
@@ -2083,6 +2078,8 @@ void intel_cleanup_ring_buffer(struct intel_engine_cs *ring)kfree (ringbuf); ring->buffer =NULL ; + + ring->dev =NULL ; }static int ring_wait_for_space (struct intel_engine_cs *ring,int n)
drivers/gpu/drm/i915/intel_ringbuffer.h +5 -1
@@ -327,7 +327,11 @@ struct intel_engine_cs {u32 (*get_cmd_length_mask)(u32 cmd_header); }; -bool intel_ring_initialized (struct intel_engine_cs *ring); +static inline bool +intel_ring_initialized (struct intel_engine_cs *ring) +{ +return ring->dev !=NULL ; +}static inline unsigned intel_ring_flag (struct intel_engine_cs *ring)
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
cover drm/i915: intel_ring_initialized() must be simple and inline
Based on Chris Wilson's patch from 6 months ago, rebased and adapted.
The idea is to use ring->dev as an indicator showing which engines have been initialised and are therefore to be included in iterations that use for_each_ring(). This allows us to avoid multiple memory references and a (non-inlined) function call on each iteration of each such loop.
This version differs from Chris' primarily in the error cleanup paths, where initialisation has failed and we therefore want to mark an engine as NOT initialised. I have made the ring_cleanup() functions callable from the failure path of the ring_init() code, rather than duplicating all the steps to tear down a partially-constructed state. This also increases symmetry; ring->dev is set at the start of ring_init, and cleared at the end of ring_cleanup, in both the normal and error cases.
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/1 drm/i915: intel_ring_initialized() must be simple and inline
Based on Chris Wilson's patch from 6 months ago, rebased and adapted.
The current implementation of intel_ring_initialized() is too heavyweight; it's a non-inlined function that chases several levels of pointers. This wouldn't matter too much if it were rarely called, but it's used inside the iterator test of for_each_ring() and is therefore called quite frequently. So let's make it simple and inline ...
The idea here is to use ring->dev as an indicator showing which engines have been initialised and are therefore to be included in iterations that use for_each_ring(). This allows us to avoid multiple memory references and a (non-inlined) function call on each iteration of each such loop.
Fixes regression from
commit 48d823878d64f93163f5a949623346748bbce1b4
Author: Oscar Mateo <[email protected]>
Date: Thu Jul 24 17:04:23 2014 +0100
drm/i915/bdw: Generic logical ring init and cleanup
--- drivers/gpu/drm/i915/intel_lrc.c | 17 +++++++++----- drivers/gpu/drm/i915/intel_ringbuffer.c | 39 +++++++++++---------------------- drivers/gpu/drm/i915/intel_ringbuffer.h | 6 ++++- 3 files changed, 30 insertions(+), 32 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +12 -5
@@ -1894,8 +1894,10 @@ void intel_logical_ring_cleanup(struct intel_engine_cs *ring) dev_priv = ring->dev->dev_private; -intel_logical_ring_stop (ring); -WARN_ON ((I915_READ_MODE (ring) &MODE_IDLE ) ==0 ); +if (ring->buffer) { +intel_logical_ring_stop (ring); +WARN_ON ((I915_READ_MODE (ring) &MODE_IDLE ) ==0 ); + }if (ring->cleanup) ring->cleanup (ring);
@@ -1909,6 +1911,7 @@ void intel_logical_ring_cleanup(struct intel_engine_cs *ring) }lrc_destroy_wa_ctx_obj (ring); + ring->dev =NULL ; }static int logical_ring_init (struct drm_device *dev,struct intel_engine_cs *ring)
@@ -1931,11 +1934,11 @@ static int logical_ring_init(struct drm_device *dev, struct intel_engine_cs *rin ret =i915_cmd_parser_init_ring (ring);if (ret) -return ret; + goto error; ret =intel_lr_context_deferred_alloc (ring->default_context, ring);if (ret) -return ret; + goto error;/* As this is the default context, always pin it */ ret = intel_lr_context_do_pin(
@@ -1946,9 +1949,13 @@ static int logical_ring_init(struct drm_device *dev, struct intel_engine_cs *rinDRM_ERROR ("Failed to pin and map ringbuffer %s: %d\n" , ring->name, ret); -return ret; + goto error; } +return 0 ; + +error: +intel_logical_ring_cleanup (ring);return ret; }
drivers/gpu/drm/i915/intel_ringbuffer.c +13 -26
@@ -33,23 +33,6 @@#include "i915_trace.h" #include "intel_drv.h" -bool -intel_ring_initialized (struct intel_engine_cs *ring) -{ -struct drm_device *dev = ring->dev; - -if (!dev) -return false; - -if (i915.enable_execlists) { -struct intel_context *dctx = ring->default_context; -struct intel_ringbuffer *ringbuf = dctx->engine[ring->id].ringbuf; - -return ringbuf->obj; - }else -return ring->buffer && ring->buffer->obj; -} -int __intel_ring_space (int head,int tail,int size) {int space = head - tail;
@@ -2167,8 +2150,10 @@ static int intel_init_ring_buffer(struct drm_device *dev,init_waitqueue_head (&ring->irq_queue); ringbuf =intel_engine_create_ringbuffer (ring,32 *PAGE_SIZE ); -if (IS_ERR (ringbuf)) -return PTR_ERR (ringbuf); +if (IS_ERR (ringbuf)) { + ret =PTR_ERR (ringbuf); + goto error; + } ring->buffer = ringbuf;if (I915_NEED_GFX_HWS (dev)) {
@@ -2197,8 +2182,7 @@ static int intel_init_ring_buffer(struct drm_device *dev,return 0 ; error: -intel_ringbuffer_free (ringbuf); - ring->buffer =NULL ; +intel_cleanup_ring_buffer (ring);return ret; }
@@ -2211,12 +2195,14 @@ void intel_cleanup_ring_buffer(struct intel_engine_cs *ring) dev_priv =to_i915 (ring->dev); -intel_stop_ring_buffer (ring); -WARN_ON (!IS_GEN2 (ring->dev) && (I915_READ_MODE (ring) &MODE_IDLE ) ==0 ); +if (ring->buffer) { +intel_stop_ring_buffer (ring); +WARN_ON (!IS_GEN2 (ring->dev) && (I915_READ_MODE (ring) &MODE_IDLE ) ==0 ); -intel_unpin_ringbuffer_obj (ring->buffer); -intel_ringbuffer_free (ring->buffer); - ring->buffer =NULL ; +intel_unpin_ringbuffer_obj (ring->buffer); +intel_ringbuffer_free (ring->buffer); + ring->buffer =NULL ; + }if (ring->cleanup) ring->cleanup (ring);
@@ -2225,6 +2211,7 @@ void intel_cleanup_ring_buffer(struct intel_engine_cs *ring)i915_cmd_parser_fini_ring (ring);i915_gem_batch_pool_fini (&ring->batch_pool); + ring->dev =NULL ; }static int ring_wait_for_space (struct intel_engine_cs *ring,int n)
drivers/gpu/drm/i915/intel_ringbuffer.h +5 -1
@@ -350,7 +350,11 @@ struct intel_engine_cs {u32 (*get_cmd_length_mask)(u32 cmd_header); }; -bool intel_ring_initialized (struct intel_engine_cs *ring); +static inline bool +intel_ring_initialized (struct intel_engine_cs *ring) +{ +return ring->dev !=NULL ; +}static inline unsigned intel_ring_flag (struct intel_engine_cs *ring)
Signature · 7 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Daniel Vetter
AppliedRe: [PATCH 1/1] drm/i915: intel_ring_initialized() must be simple and inline
Quoted 18 lines · Dave Gordon
Based on Chris Wilson's patch from 6 months ago, rebased and adapted.
The current implementation of
intel_ring_initialized()is too heavyweight; it's a non-inlined function that chases several levels of pointers. This wouldn't matter too much if it were rarely called, but it's used inside the iterator test offor_each_ring()and is therefore called quite frequently. So let's make it simple and inline ...The idea here is to use
ring->devas an indicator showing which engines have been initialised and are therefore to be included in iterations that usefor_each_ring(). This allows us to avoid multiple memory references and a (non-inlined) function call on each iteration of each such loop.Fixes regression from
commit48d823878d64f93163f5a949623346748bbce1b4
Author: Oscar Mateo <[email protected]>
Date: Thu Jul 24 17:04:23 2014 +0100
Quoted 4 lines
drm/i915/bdw: Generic logical ring init and cleanup
Signed-off-by Chris Wilson <[email protected]>Signed-off-by Dave Gordon <[email protected]>
Queued for -next, thanks for the patch.
-Daniel
Quoted 164 lines
--- drivers/gpu/drm/i915/intel_lrc.c | 17 +++++++++----- drivers/gpu/drm/i915/intel_ringbuffer.c | 39 +++++++++++---------------------- drivers/gpu/drm/i915/intel_ringbuffer.h | 6 ++++- 3 files changed, 30 insertions(+), 32 deletions(-)drivers/gpu/drm/i915/intel_lrc.c +12
-5@@ -1894,8 +1894,10 @@ void intel_logical_ring_cleanup(struct intel_engine_cs *ring) dev_priv = ring->dev->dev_private; -intel_logical_ring_stop (ring); -WARN_ON ((I915_READ_MODE (ring) &MODE_IDLE ) ==0 ); +if (ring->buffer) { +intel_logical_ring_stop (ring); +WARN_ON ((I915_READ_MODE (ring) &MODE_IDLE ) ==0 ); + }if (ring->cleanup) ring->cleanup (ring);@@ -1909,6 +1911,7 @@ void intel_logical_ring_cleanup(struct intel_engine_cs *ring) }lrc_destroy_wa_ctx_obj (ring); + ring->dev =NULL ; }static int logical_ring_init (struct drm_device *dev,struct intel_engine_cs *ring)@@ -1931,11 +1934,11 @@ static int logical_ring_init(struct drm_device *dev, struct intel_engine_cs *rin ret =i915_cmd_parser_init_ring (ring);if (ret) -return ret; + goto error; ret =intel_lr_context_deferred_alloc (ring->default_context, ring);if (ret) -return ret; + goto error;/* As this is the default context, always pin it */ ret = intel_lr_context_do_pin(@@ -1946,9 +1949,13 @@ static int logical_ring_init(struct drm_device *dev, struct intel_engine_cs *rinDRM_ERROR ("Failed to pin and map ringbuffer %s: %d\n" , ring->name, ret); -return ret; + goto error; } +return 0 ; + +error: +intel_logical_ring_cleanup (ring);return ret; }drivers/gpu/drm/i915/intel_ringbuffer.c +13
-26@@ -33,23 +33,6 @@#include "i915_trace.h" #include "intel_drv.h" -bool -intel_ring_initialized (struct intel_engine_cs *ring) -{ -struct drm_device *dev = ring->dev; - -if (!dev) -return false; - -if (i915.enable_execlists) { -struct intel_context *dctx = ring->default_context; -struct intel_ringbuffer *ringbuf = dctx->engine[ring->id].ringbuf; - -return ringbuf->obj; - }else -return ring->buffer && ring->buffer->obj; -} -int __intel_ring_space (int head,int tail,int size) {int space = head - tail;@@ -2167,8 +2150,10 @@ static int intel_init_ring_buffer(struct drm_device *dev,init_waitqueue_head (&ring->irq_queue); ringbuf =intel_engine_create_ringbuffer (ring,32 *PAGE_SIZE ); -if (IS_ERR (ringbuf)) -return PTR_ERR (ringbuf); +if (IS_ERR (ringbuf)) { + ret =PTR_ERR (ringbuf); + goto error; + } ring->buffer = ringbuf;if (I915_NEED_GFX_HWS (dev)) {@@ -2197,8 +2182,7 @@ static int intel_init_ring_buffer(struct drm_device *dev,return 0 ; error: -intel_ringbuffer_free (ringbuf); - ring->buffer =NULL ; +intel_cleanup_ring_buffer (ring);return ret; }@@ -2211,12 +2195,14 @@ void intel_cleanup_ring_buffer(struct intel_engine_cs *ring) dev_priv =to_i915 (ring->dev); -intel_stop_ring_buffer (ring); -WARN_ON (!IS_GEN2 (ring->dev) && (I915_READ_MODE (ring) &MODE_IDLE ) ==0 ); +if (ring->buffer) { +intel_stop_ring_buffer (ring); +WARN_ON (!IS_GEN2 (ring->dev) && (I915_READ_MODE (ring) &MODE_IDLE ) ==0 ); -intel_unpin_ringbuffer_obj (ring->buffer); -intel_ringbuffer_free (ring->buffer); - ring->buffer =NULL ; +intel_unpin_ringbuffer_obj (ring->buffer); +intel_ringbuffer_free (ring->buffer); + ring->buffer =NULL ; + }if (ring->cleanup) ring->cleanup (ring);@@ -2225,6 +2211,7 @@ void intel_cleanup_ring_buffer(struct intel_engine_cs *ring)i915_cmd_parser_fini_ring (ring);i915_gem_batch_pool_fini (&ring->batch_pool); + ring->dev =NULL ; }static int ring_wait_for_space (struct intel_engine_cs *ring,int n)drivers/gpu/drm/i915/intel_ringbuffer.h +5
-1@@ -350,7 +350,11 @@ struct intel_engine_cs {u32 (*get_cmd_length_mask)(u32 cmd_header); }; -bool intel_ring_initialized (struct intel_engine_cs *ring); +static inline bool +intel_ring_initialized (struct intel_engine_cs *ring) +{ +return ring->dev !=NULL ; +}static inline unsigned intel_ring_flag (struct intel_engine_cs *ring)Signature · 7 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 58/70 drm/i915: Before shrink_all we only need to idle the GPU
In reply to Chris WilsonWe can forgo an evict-everything here in favour of the simpler i915_gpu_idle() as the shrinker operation itself will unbind any vma as required. The simplicity allows us to ignore any errors whilst idling and still force the request retirement to run.
--- drivers/gpu/drm/i915/i915_gem_shrinker.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem_shrinker.c +7 -1
@@ -158,7 +158,13 @@ i915_gem_shrink(struct drm_i915_private *dev_priv,*/ unsigned long i915_gem_shrink_all (struct drm_i915_private *dev_priv) { -i915_gem_evict_everything (dev_priv->dev); +int ignore; + + ignore =i915_gpu_idle (dev_priv->dev); + (void )ignore; + +i915_gem_retire_requests (dev_priv->dev); +return i915_gem_shrink (dev_priv,LONG_MAX ,I915_SHRINK_BOUND |I915_SHRINK_UNBOUND ); }
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 59/70 drm/i915: Simplify object is-pinned checking for shrinker
In reply to Chris WilsonWhen looking for viable candidates to shrink, we only want objects that are not pinned. However to do so we performed a double iteration over the vma in the objects, first looking for the pin-count, then looking for allocations. We can do both at once and be slightly more explicit in our validity test.
--- drivers/gpu/drm/i915/i915_gem_shrinker.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem_shrinker.c +5 -3
@@ -190,9 +190,12 @@ static int num_vma_bound(struct drm_i915_gem_object *obj)struct i915_vma *vma;int count =0 ; -list_for_each_entry (vma, &obj->vma_list, vma_link) +list_for_each_entry (vma, &obj->vma_list, vma_link) {if (drm_mm_node_allocated (&vma->node)) count++; +if (vma->pin_count) + count++; + }return count; }
@@ -218,8 +221,7 @@ i915_gem_shrinker_count(struct shrinker *shrinker, struct shrink_control *sc) count += obj->base.size >>PAGE_SHIFT ;list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list) { -if (!i915_gem_obj_is_pinned (obj) && - obj->pages_pin_count ==num_vma_bound (obj)) +if (obj->pages_pin_count ==num_vma_bound (obj)) count += obj->base.size >>PAGE_SHIFT ; }
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 59/70 drm/i915: Simplify object is-pinned checking for shrinker
In reply to Chris WilsonWhen looking for viable candidates to shrink, we only want objects that are not pinned. However to do so we performed a double iteration over the vma in the objects, first looking for the pin-count, then looking for allocations. We can do both at once and be slightly more explicit in our validity test.
--- drivers/gpu/drm/i915/i915_gem_shrinker.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem_shrinker.c +5 -3
@@ -190,9 +190,12 @@ static int num_vma_bound(struct drm_i915_gem_object *obj)struct i915_vma *vma;int count =0 ; -list_for_each_entry (vma, &obj->vma_list, vma_link) +list_for_each_entry (vma, &obj->vma_list, vma_link) {if (drm_mm_node_allocated (&vma->node)) count++; +if (vma->pin_count) + count++; + }return count; }
@@ -218,8 +221,7 @@ i915_gem_shrinker_count(struct shrinker *shrinker, struct shrink_control *sc) count += obj->base.size >>PAGE_SHIFT ;list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list) { -if (!i915_gem_obj_is_pinned (obj) && - obj->pages_pin_count ==num_vma_bound (obj)) +if (obj->pages_pin_count ==num_vma_bound (obj)) count += obj->base.size >>PAGE_SHIFT ; }
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 60/70 drm/i915: Make evict-everything more robust
Since we are operating at the global level, we can simply iterate over the bound list using the robust method developed for the shrinker.
--- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/i915_gem_evict.c | 54 +++++++++++++++++------------- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 2 +- 3 files changed, 32 insertions(+), 26 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
@@ -2994,7 +2994,7 @@ int __must_check i915_gem_evict_something(struct drm_device *dev,int __must_check i915_gem_evict_range (struct drm_device *dev,struct i915_address_space *vm,unsigned long start,unsigned long end); -int i915_gem_evict_vm (struct i915_address_space *vm,bool do_idle); +int i915_gem_evict_vm (struct i915_address_space *vm);int i915_gem_evict_everything (struct drm_device *dev);/* belongs in i915_gem_gtt.h */
drivers/gpu/drm/i915/i915_gem_evict.c +30 -24
92 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -1
@@ -820,7 +820,7 @@ err:list_for_each_entry (vma, vmas, exec_list)i915_gem_execbuffer_unreserve_vma (vma); - ret =i915_gem_evict_vm (vm, true); + ret =i915_gem_evict_vm (vm);if (ret)return ret; }while (1 );
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 61/70 drm/i915: Make fb_tracking.lock a spinlock
In reply to Chris WilsonWe only need a very lightweight mechanism here as the locking is only used for co-ordinating a bitfield.
Also double check that the object is still pinned to the display plane before processing the state change.
--- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/i915_gem.c | 2 +- drivers/gpu/drm/i915/intel_frontbuffer.c | 40 +++++++++++++++++--------------- 3 files changed, 23 insertions(+), 21 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
@@ -1545,7 +1545,7 @@ struct intel_pipe_crc { };struct i915_frontbuffer_tracking { -struct mutex lock; +spinlock_t lock;/* * Tracking bits for delayed frontbuffer flushing du to gpu activity or
drivers/gpu/drm/i915/i915_gem.c +1 -1
@@ -5260,7 +5260,7 @@ i915_gem_load(struct drm_device *dev)i915_gem_shrinker_init (dev_priv); -mutex_init (&dev_priv->fb_tracking.lock); +spin_lock_init (&dev_priv->fb_tracking.lock); }void i915_gem_release (struct drm_device *dev,struct drm_file *file)
drivers/gpu/drm/i915/intel_frontbuffer.c +21 -19
@@ -139,16 +139,14 @@ void intel_fb_obj_invalidate(struct drm_i915_gem_object *obj,WARN_ON (!mutex_is_locked (&dev->struct_mutex)); -if (!obj->frontbuffer_bits) +if (!obj->frontbuffer_bits || !obj->pin_display)return ;if (ring) { -mutex_lock (&dev_priv->fb_tracking.lock); - dev_priv->fb_tracking.busy_bits - |= obj->frontbuffer_bits; - dev_priv->fb_tracking.flip_bits - &= ~obj->frontbuffer_bits; -mutex_unlock (&dev_priv->fb_tracking.lock); +spin_lock (&dev_priv->fb_tracking.lock); + dev_priv->fb_tracking.busy_bits |= obj->frontbuffer_bits; + dev_priv->fb_tracking.flip_bits &= ~obj->frontbuffer_bits; +spin_unlock (&dev_priv->fb_tracking.lock); }intel_mark_fb_busy (dev, obj->frontbuffer_bits, ring);
@@ -175,9 +173,12 @@ void intel_frontbuffer_flush(struct drm_device *dev,struct drm_i915_private *dev_priv = dev->dev_private;/* Delay flushing when rings are still busy.*/ -mutex_lock (&dev_priv->fb_tracking.lock); +spin_lock (&dev_priv->fb_tracking.lock); frontbuffer_bits &= ~dev_priv->fb_tracking.busy_bits; -mutex_unlock (&dev_priv->fb_tracking.lock); +spin_unlock (&dev_priv->fb_tracking.lock); + +if (frontbuffer_bits ==0 ) +return ;intel_mark_fb_busy (dev, frontbuffer_bits,NULL );
@@ -204,21 +205,21 @@ void intel_fb_obj_flush(struct drm_i915_gem_object *obj,WARN_ON (!mutex_is_locked (&dev->struct_mutex)); -if (!obj->frontbuffer_bits) +if (!obj->frontbuffer_bits || !obj->pin_display)return ; frontbuffer_bits = obj->frontbuffer_bits;if (retire) { -mutex_lock (&dev_priv->fb_tracking.lock); +spin_lock (&dev_priv->fb_tracking.lock);/* Filter out new bits since rendering started. */ frontbuffer_bits &= dev_priv->fb_tracking.busy_bits; - dev_priv->fb_tracking.busy_bits &= ~frontbuffer_bits; -mutex_unlock (&dev_priv->fb_tracking.lock); +spin_unlock (&dev_priv->fb_tracking.lock); } -intel_frontbuffer_flush (dev, frontbuffer_bits); +if (frontbuffer_bits) +intel_frontbuffer_flush (dev, frontbuffer_bits); }/**
@@ -238,11 +239,11 @@ void intel_frontbuffer_flip_prepare(struct drm_device *dev, {struct drm_i915_private *dev_priv = dev->dev_private; -mutex_lock (&dev_priv->fb_tracking.lock); +spin_lock (&dev_priv->fb_tracking.lock); dev_priv->fb_tracking.flip_bits |= frontbuffer_bits;/* Remove stale busy bits due to the old buffer. */ dev_priv->fb_tracking.busy_bits &= ~frontbuffer_bits; -mutex_unlock (&dev_priv->fb_tracking.lock); +spin_unlock (&dev_priv->fb_tracking.lock); }/**
@@ -260,11 +261,12 @@ void intel_frontbuffer_flip_complete(struct drm_device *dev, {struct drm_i915_private *dev_priv = dev->dev_private; -mutex_lock (&dev_priv->fb_tracking.lock); +spin_lock (&dev_priv->fb_tracking.lock);/* Mask any cancelled flips. */ frontbuffer_bits &= dev_priv->fb_tracking.flip_bits; dev_priv->fb_tracking.flip_bits &= ~frontbuffer_bits; -mutex_unlock (&dev_priv->fb_tracking.lock); +spin_unlock (&dev_priv->fb_tracking.lock); -intel_frontbuffer_flush (dev, frontbuffer_bits); +if (frontbuffer_bits) +intel_frontbuffer_flush (dev, frontbuffer_bits); }
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 61/70] drm/i915: Make fb_tracking.lock a spinlock
Quoted 66 lines · Chris Wilson
We only need a very lightweight mechanism here as the locking is only used for co-ordinating a bitfield.
Also double check that the object is still pinned to the display plane before processing the state change.
Signed-off-by Chris Wilson <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/i915_gem.c | 2 +- drivers/gpu/drm/i915/intel_frontbuffer.c | 40 +++++++++++++++++--------------- 3 files changed, 23 insertions(+), 21 deletions(-)drivers/gpu/drm/i915/i915_drv.h +1
-1@@ -1545,7 +1545,7 @@ struct intel_pipe_crc { };struct i915_frontbuffer_tracking { -struct mutex lock; +spinlock_t lock;/* * Tracking bits for delayed frontbuffer flushing du to gpu activity or drivers/gpu/drm/i915/i915_gem.c +1
-1@@ -5260,7 +5260,7 @@ i915_gem_load(struct drm_device *dev)i915_gem_shrinker_init (dev_priv); -mutex_init (&dev_priv->fb_tracking.lock); +spin_lock_init (&dev_priv->fb_tracking.lock); }void i915_gem_release (struct drm_device *dev,struct drm_file *file)drivers/gpu/drm/i915/intel_frontbuffer.c +5
-7@@ -139,16 +139,14 @@ void intel_fb_obj_invalidate(struct drm_i915_gem_object *obj,WARN_ON (!mutex_is_locked (&dev->struct_mutex)); -if (!obj->frontbuffer_bits) +if (!obj->frontbuffer_bits || !obj->pin_display)return ;if (ring) { -mutex_lock (&dev_priv->fb_tracking.lock); - dev_priv->fb_tracking.busy_bits - |= obj->frontbuffer_bits; - dev_priv->fb_tracking.flip_bits - &= ~obj->frontbuffer_bits; -mutex_unlock (&dev_priv->fb_tracking.lock); +spin_lock (&dev_priv->fb_tracking.lock); + dev_priv->fb_tracking.busy_bits |= obj->frontbuffer_bits; + dev_priv->fb_tracking.flip_bits &= ~obj->frontbuffer_bits; +spin_unlock (&dev_priv->fb_tracking.lock); }intel_mark_fb_busy (dev, obj->frontbuffer_bits, ring);
drivers/gpu/drm/i915/intel_frontbuffer.c void intel_frontbuffer_flush(struct drm_device *dev, · line 178
Quoted 8 lines
drivers/gpu/drm/i915/intel_frontbuffer.c +2
-2@@ -175,9 +173,12 @@ void intel_frontbuffer_flush(struct drm_device *dev,struct drm_i915_private *dev_priv = dev->dev_private;/* Delay flushing when rings are still busy.*/ -mutex_lock (&dev_priv->fb_tracking.lock); +spin_lock (&dev_priv->fb_tracking.lock); frontbuffer_bits &= ~dev_priv->fb_tracking.busy_bits; -mutex_unlock (&dev_priv->fb_tracking.lock); +spin_unlock (&dev_priv->fb_tracking.lock);
Looks like you could just remove the lock here in process.
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 61/70] drm/i915: Make fb_tracking.lock a spinlock
Quoted 8 lines · Tvrtko Ursulin
drivers/gpu/drm/i915/intel_frontbuffer.c void intel_frontbuffer_flush(struct drm_device *dev, · line 178
Quoted 6 lines
drivers/gpu/drm/i915/intel_frontbuffer.c +2
-2/* Delay flushing when rings are still busy.*/ -mutex_lock (&dev_priv->fb_tracking.lock); +spin_lock (&dev_priv->fb_tracking.lock); frontbuffer_bits &= ~dev_priv->fb_tracking.busy_bits; -mutex_unlock (&dev_priv->fb_tracking.lock); +spin_unlock (&dev_priv->fb_tracking.lock);Looks like you could just remove the lock here in process.
...as in we are always protected by struct_mutex? I think Daniel was planning for a future where that was guaranteed.
Anyway my v2 patch does:
void __intel_fb_obj_invalidate(struct drm_i915_gem_object *obj,
struct intel_engine_cs *ring, enum fb_op_origin origin);
static inline void intel_fb_obj_invalidate(struct drm_i915_gem_object *obj,
struct intel_engine_cs *ring, enum fb_op_origin origin)
{
if (!obj->frontbuffer_bits || !obj->pin_display)
return;
__intel_fb_obj_invalidate(obj, ring, origin);
}As the function call overhead itself was annoying me in the execbuffer profiles.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 61/70] drm/i915: Make fb_tracking.lock a spinlock
Quoted 10 lines · Chris Wilson
Quoted 8 lines · Tvrtko Ursulin
drivers/gpu/drm/i915/intel_frontbuffer.c void intel_frontbuffer_flush(struct drm_device *dev, · line 178
Quoted 6 lines
/* Delay flushing when rings are still busy.*/
drivers/gpu/drm/i915/intel_frontbuffer.c +2
-2-mutex_lock (&dev_priv->fb_tracking.lock); +spin_lock (&dev_priv->fb_tracking.lock); frontbuffer_bits &= ~dev_priv->fb_tracking.busy_bits; -mutex_unlock (&dev_priv->fb_tracking.lock); +spin_unlock (&dev_priv->fb_tracking.lock);Looks like you could just remove the lock here in process.
Quoted 2 lines
...as in we are always protected by
struct_mutex? I think Daniel was planning for a future where that was guaranteed.
No, it always looks to be updated with a single write - so I don't see why have a lock for this read?
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 62/70 drm/i915: Reduce locking inside busy ioctl
In reply to Chris WilsonWe can do the trivial check for an inactive buffer without acquiring the struct_mutex reducing contention. If we are required to flush the object and check for retirements, then we do indeed have to resort to taking the struct_mutex
--- drivers/gpu/drm/i915/i915_gem.c | 49 ++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +26 -23
@@ -4522,34 +4522,37 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,struct drm_i915_gem_object *obj;int ret; - ret =i915_mutex_lock_interruptible (dev); -if (ret) -return ret; - obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle)); -if (&obj->base ==NULL ) { - ret = -ENOENT ; - goto unlock; - } +if (&obj->base ==NULL ) +return -ENOENT ; -/* Count all active objects as busy, even if they are currently not used -* by the gpu. Users of this interface expect objects to eventually -* become non-busy without any further actions, therefore emit any -* necessary flushes here. -*/ - ret =i915_gem_object_flush_active (obj); -if (ret) - goto unref; +if (obj->active) { + ret =i915_mutex_lock_interruptible (dev); +if (ret) + goto unref; -BUILD_BUG_ON (I915_NUM_RINGS >16 ); - args->busy = obj->active <<16 ; -if (obj->last_write_req) - args->busy |= obj->last_write_req->ring->id; +/* Count all active objects as busy, even if they are +* currently not used by the gpu. Users of this interface +* expect objects to eventually become non-busy without any +* further actions, therefore emit any necessary flushes here. +*/ + ret =i915_gem_object_flush_active (obj); +if (ret ==0 ) { +BUILD_BUG_ON (I915_NUM_RINGS >16 ); + args->busy = obj->active <<16 ; +if (obj->last_write_req) + args->busy |= obj->last_write_req->ring->id; + } +drm_gem_object_unreference (&obj->base); +mutex_unlock (&dev->struct_mutex); + }else { + ret =0 ; + args->busy =0 ; unref: -drm_gem_object_unreference (&obj->base); -unlock: -mutex_unlock (&dev->struct_mutex); +drm_gem_object_unreference_unlocked (&obj->base); + } +return ret; }
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 63/70 drm/i915: Reduce locking inside swfinish ioctl
In reply to Chris WilsonWe only need to take the struct_mutex if the object is pinned to the display engine and so requires checking for clflush. (The race with userspace pinning the object to a framebuffer is irrelevant.)
--- drivers/gpu/drm/i915/i915_gem.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +16 -13
@@ -1606,25 +1606,28 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data, {struct drm_i915_gem_sw_finish *args = data;struct drm_i915_gem_object *obj; -int ret =0 ; - - ret =i915_mutex_lock_interruptible (dev); -if (ret) -return ret; +int ret; obj =to_intel_bo (drm_gem_object_lookup (dev, file, args->handle)); -if (&obj->base ==NULL ) { - ret = -ENOENT ; - goto unlock; - } +if (&obj->base ==NULL ) +return -ENOENT ;/* Pinned buffers may be scanout, so flush the cache */ -if (obj->pin_display) +if (obj->pin_display) { + ret =i915_mutex_lock_interruptible (dev); +if (ret) + goto unref; +i915_gem_object_flush_cpu_write_domain (obj); -drm_gem_object_unreference (&obj->base); -unlock: -mutex_unlock (&dev->struct_mutex); +drm_gem_object_unreference (&obj->base); +mutex_unlock (&dev->struct_mutex); + }else { + ret =0 ; +unref: +drm_gem_object_unreference_unlocked (&obj->base); + } +return ret; }
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 63/70] drm/i915: Reduce locking inside swfinish ioctl
drivers/gpu/drm/i915/i915_gem.c i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data, · line 1619
Quoted 6 lines · Chris Wilson
/* Pinned buffers may be scanout, so flush the cache */drivers/gpu/drm/i915/i915_gem.c +4
-1-if (obj->pin_display) +if (obj->pin_display) { + ret =i915_mutex_lock_interruptible (dev); +if (ret) + goto unref;
I think and ACCESS_ONCE here and in the previous one would be good. Wanted to do that and merge both, but they seem to conflict with the lack of read-read ...
-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 63/70] drm/i915: Reduce locking inside swfinish ioctl
Quoted 11 lines · Daniel Vetter
drivers/gpu/drm/i915/i915_gem.c i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data, · line 1619
Quoted 6 lines · Chris Wilson
/* Pinned buffers may be scanout, so flush the cache */drivers/gpu/drm/i915/i915_gem.c +4
-1-if (obj->pin_display) +if (obj->pin_display) { + ret =i915_mutex_lock_interruptible (dev); +if (ret) + goto unref;I think and
ACCESS_ONCEhere and in the previous one would be good. Wanted to do that and merge both, but they seem to conflict with the lack of read-read ...
What do you want to accomplish with ACCESS_ONCE()? Unfortunately as we can't use it on bitfields.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 63/70] drm/i915: Reduce locking inside swfinish ioctl
Quoted 9 lines · Chris Wilson
Quoted 8 lines · Daniel Vetter
Quoted 6 lines · Chris Wilson
/* Pinned buffers may be scanout, so flush the cache */drivers/gpu/drm/i915/i915_gem.c +4
-1-if (obj->pin_display) +if (obj->pin_display) { + ret =i915_mutex_lock_interruptible (dev); +if (ret) + goto unref;
Quoted 6 lines
Quoted 3 lines
I think and
ACCESS_ONCEhere and in the previous one would be good. Wanted to do that and merge both, but they seem to conflict with the lack of read-read ...What do you want to accomplish with
ACCESS_ONCE()? Unfortunately as we can't use it on bitfields.
making sure that gcc doesn't reload the variable when it shuffles basic blocks around. Admittedly unlikely. The point is not to do an atomic load but just to ensure that we have a consistent value, no matter how obtained so. But I guess we need to open-code the ACCESS_ONCE with a (volatile bool) cast.
The other reason is that it serves as a nice reminder to the reader that something tricky is going on, and that the lockless reading of ->pin_display is intentional.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 63/70] drm/i915: Reduce locking inside swfinish ioctl
Quoted 23 lines · Daniel Vetter
Quoted 9 lines · Chris Wilson
Quoted 8 lines · Daniel Vetter
Quoted 6 lines · Chris Wilson
/* Pinned buffers may be scanout, so flush the cache */drivers/gpu/drm/i915/i915_gem.c +4
-1-if (obj->pin_display) +if (obj->pin_display) { + ret =i915_mutex_lock_interruptible (dev); +if (ret) + goto unref;Quoted 6 lines
Quoted 3 lines
I think and
ACCESS_ONCEhere and in the previous one would be good. Wanted to do that and merge both, but they seem to conflict with the lack of read-read ...What do you want to accomplish with
ACCESS_ONCE()? Unfortunately as we can't use it on bitfields.making sure that gcc doesn't reload the variable when it shuffles basic blocks around. Admittedly unlikely. The point is not to do an atomic load but just to ensure that we have a consistent value, no matter how obtained so. But I guess we need to open-code the
ACCESS_ONCEwith a (volatile bool) cast.
Quoted 3 lines
The other reason is that it serves as a nice reminder to the reader that something tricky is going on, and that the lockless reading of ->pin_display is intentional.
Ok, that's just what I thought you wanted. We can hope that the optimistic_read() is more friendly (presupposing Linus actually adds it).
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 64/70 drm/i915: Remove pinned check from madvise ioctl
In reply to Chris WilsonWe don't need to incur the overhead of checking whether the object is pinned prior to changing its madvise. If the object is pinned, the madvise will not take effect until it is unpinned and so we cannot free the pages being pointed at by hardware. Marking a pinned object with allocated pages as DONTNEED will not trigger any undue warnings. The check is therefore superfluous, and by removing it we can remove a linear walk over all the vma the object has.
--- drivers/gpu/drm/i915/i915_gem.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +0 -6
@@ -4593,11 +4593,6 @@ i915_gem_madvise_ioctl(struct drm_device *dev, void *data, goto unlock; } -if (i915_gem_obj_is_pinned (obj)) { - ret = -EINVAL ; - goto out; - } -if (obj->pages && obj->tiling_mode !=I915_TILING_NONE && dev_priv->quirks &QUIRK_PIN_SWIZZLED_PAGES ) {
@@ -4616,7 +4611,6 @@ i915_gem_madvise_ioctl(struct drm_device *dev, void *data, args->retained = obj->madv != __I915_MADV_PURGED; -out:drm_gem_object_unreference (&obj->base); unlock:mutex_unlock (&dev->struct_mutex);
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 65/70 drm/i915: Reduce locking for gen6+ GT interrupts
In reply to Chris Wilson--- drivers/gpu/drm/i915/i915_irq.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/i915_irq.c +10 -14
@@ -2090,9 +2090,8 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)intel_uncore_check_errors (dev);/* disable master interrupt before clearing iir */ - de_ier =I915_READ (DEIER ); -I915_WRITE (DEIER , de_ier & ~DE_MASTER_IRQ_CONTROL ); -POSTING_READ (DEIER ); + de_ier =I915_READ_FW (DEIER ); +I915_WRITE_FW (DEIER , de_ier & ~DE_MASTER_IRQ_CONTROL );/* Disable south interrupts. We'll only write to SDEIIR once, so further * interrupts will will be stored on its back queue, and then we'll be
@@ -2100,16 +2099,15 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)* it, we'll get an interrupt if SDEIIR still has something to process * due to its back queue). */ if (!HAS_PCH_NOP (dev)) { - sde_ier =I915_READ (SDEIER ); -I915_WRITE (SDEIER ,0 ); -POSTING_READ (SDEIER ); + sde_ier =I915_READ_FW (SDEIER ); +I915_WRITE_FW (SDEIER ,0 ); }/* Find, clear, then process each source of interrupt */ - gt_iir =I915_READ (GTIIR ); + gt_iir =I915_READ_FW (GTIIR );if (gt_iir) { -I915_WRITE (GTIIR , gt_iir); +I915_WRITE_FW (GTIIR , gt_iir); ret =IRQ_HANDLED ;if (INTEL_INFO (dev)->gen >=6 )snb_gt_irq_handler (dev, dev_priv, gt_iir);
@@ -2136,12 +2134,10 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg) } } -I915_WRITE (DEIER , de_ier); -POSTING_READ (DEIER ); -if (!HAS_PCH_NOP (dev)) { -I915_WRITE (SDEIER , sde_ier); -POSTING_READ (SDEIER ); - } +I915_WRITE_FW (DEIER , de_ier); +if (!HAS_PCH_NOP (dev)) +I915_WRITE_FW (SDEIER , sde_ier); +POSTING_READ_FW (DEIER );return ret; }
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 66/70 drm/i915: Remove obj->pin_mappable
In reply to Chris WilsonThe obj->pin_mappable flag only exists for debug purposes and is a hindrance that is mistreated with rotated GGTT views. For debug purposes, it suffices to mark objects with pin_display as being of note.
--- drivers/gpu/drm/i915/i915_debugfs.c | 6 +++--- drivers/gpu/drm/i915/i915_drv.h | 1 - drivers/gpu/drm/i915/i915_gem.c | 6 +----- 3 files changed, 4 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +3 -3
@@ -166,9 +166,9 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) }if (obj->stolen)seq_printf (m," (stolen: %08llx)" , obj->stolen->start); -if (obj->pin_mappable || obj->fault_mappable) { +if (obj->pin_display || obj->fault_mappable) {char s[3 ], *t = s; -if (obj->pin_mappable) +if (obj->pin_display) *t++ ='p' ;if (obj->fault_mappable) *t++ ='f' ;
@@ -464,7 +464,7 @@ static int i915_gem_object_info(struct seq_file *m, void* data) size +=i915_gem_obj_ggtt_size (obj); ++count; } -if (obj->pin_mappable) { +if (obj->pin_display) { mappable_size +=i915_gem_obj_ggtt_size (obj); ++mappable_count; }
drivers/gpu/drm/i915/i915_drv.h +0 -1
@@ -1980,7 +1980,6 @@ struct drm_i915_gem_object {* accurate mappable working set. */ unsigned int fault_mappable:1; - unsigned int pin_mappable:1; unsigned int pin_display:1;/*
drivers/gpu/drm/i915/i915_gem.c +1 -5
@@ -4445,9 +4445,6 @@ i915_gem_object_do_pin(struct drm_i915_gem_object *obj,WARN_ON (flags &PIN_MAPPABLE && !obj->map_and_fenceable); vma->pin_count++; -if (flags &PIN_MAPPABLE ) - obj->pin_mappable |= true; -return 0 ; }
@@ -4487,8 +4484,7 @@ i915_gem_object_ggtt_unpin_view(struct drm_i915_gem_object *obj,WARN_ON (vma->pin_count ==0 );WARN_ON (!i915_gem_obj_ggtt_bound_view (obj, view)); -if (--vma->pin_count ==0 && view->type ==I915_GGTT_VIEW_NORMAL ) - obj->pin_mappable = false; + --vma->pin_count; }bool
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 66/70] drm/i915: Remove obj->pin_mappable
Quoted 64 lines · Chris Wilson
The
obj->pin_mappableflag only exists for debug purposes and is a hindrance that is mistreated with rotated GGTT views. For debug purposes, it suffices to mark objects withpin_displayas being of note.Signed-off-by Chris Wilson <[email protected]>--- drivers/gpu/drm/i915/i915_debugfs.c | 6 +++--- drivers/gpu/drm/i915/i915_drv.h | 1 - drivers/gpu/drm/i915/i915_gem.c | 6 +----- 3 files changed, 4 insertions(+), 9 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +3
-3@@ -166,9 +166,9 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) }if (obj->stolen)seq_printf (m," (stolen: %08llx)" , obj->stolen->start); -if (obj->pin_mappable || obj->fault_mappable) { +if (obj->pin_display || obj->fault_mappable) {char s[3 ], *t = s; -if (obj->pin_mappable) +if (obj->pin_display) *t++ ='p' ;if (obj->fault_mappable) *t++ ='f' ;@@ -464,7 +464,7 @@ static int i915_gem_object_info(struct seq_file *m, void* data) size +=i915_gem_obj_ggtt_size (obj); ++count; } -if (obj->pin_mappable) { +if (obj->pin_display) { mappable_size +=i915_gem_obj_ggtt_size (obj); ++mappable_count; }drivers/gpu/drm/i915/i915_drv.h +0
-1@@ -1980,7 +1980,6 @@ struct drm_i915_gem_object {* accurate mappable working set. */ unsigned int fault_mappable:1; - unsigned int pin_mappable:1; unsigned int pin_display:1;/* drivers/gpu/drm/i915/i915_gem.c +0
-3@@ -4445,9 +4445,6 @@ i915_gem_object_do_pin(struct drm_i915_gem_object *obj,WARN_ON (flags &PIN_MAPPABLE && !obj->map_and_fenceable); vma->pin_count++; -if (flags &PIN_MAPPABLE ) - obj->pin_mappable |= true; -return 0 ; }
drivers/gpu/drm/i915/i915_gem.c i915_gem_object_ggtt_unpin_view(struct drm_i915_gem_object *obj, · line 4490
Quoted 9 lines
drivers/gpu/drm/i915/i915_gem.c +1
-2@@ -4487,8 +4484,7 @@ i915_gem_object_ggtt_unpin_view(struct drm_i915_gem_object *obj,WARN_ON (vma->pin_count ==0 );WARN_ON (!i915_gem_obj_ggtt_bound_view (obj, view)); -if (--vma->pin_count ==0 && view->type ==I915_GGTT_VIEW_NORMAL ) - obj->pin_mappable = false; + --vma->pin_count; }bool
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Daniel Vetter
AppliedRe: [PATCH 66/70] drm/i915: Remove obj->pin_mappable
Quoted 73 lines · Tvrtko Ursulin
Quoted 71 lines · Chris Wilson
The
obj->pin_mappableflag only exists for debug purposes and is a hindrance that is mistreated with rotated GGTT views. For debug purposes, it suffices to mark objects withpin_displayas being of note.Signed-off-by Chris Wilson <[email protected]>--- drivers/gpu/drm/i915/i915_debugfs.c | 6 +++--- drivers/gpu/drm/i915/i915_drv.h | 1 - drivers/gpu/drm/i915/i915_gem.c | 6 +----- 3 files changed, 4 insertions(+), 9 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +3
-3@@ -166,9 +166,9 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) }if (obj->stolen)seq_printf (m," (stolen: %08llx)" , obj->stolen->start); -if (obj->pin_mappable || obj->fault_mappable) { +if (obj->pin_display || obj->fault_mappable) {char s[3 ], *t = s; -if (obj->pin_mappable) +if (obj->pin_display) *t++ ='p' ;if (obj->fault_mappable) *t++ ='f' ;@@ -464,7 +464,7 @@ static int i915_gem_object_info(struct seq_file *m, void* data) size +=i915_gem_obj_ggtt_size (obj); ++count; } -if (obj->pin_mappable) { +if (obj->pin_display) { mappable_size +=i915_gem_obj_ggtt_size (obj); ++mappable_count; }drivers/gpu/drm/i915/i915_drv.h +0
-1@@ -1980,7 +1980,6 @@ struct drm_i915_gem_object {* accurate mappable working set. */ unsigned int fault_mappable:1; - unsigned int pin_mappable:1; unsigned int pin_display:1;/* drivers/gpu/drm/i915/i915_gem.c +1
-5@@ -4445,9 +4445,6 @@ i915_gem_object_do_pin(struct drm_i915_gem_object *obj,WARN_ON (flags &PIN_MAPPABLE && !obj->map_and_fenceable); vma->pin_count++; -if (flags &PIN_MAPPABLE ) - obj->pin_mappable |= true; -return 0 ; }@@ -4487,8 +4484,7 @@ i915_gem_object_ggtt_unpin_view(struct drm_i915_gem_object *obj,WARN_ON (vma->pin_count ==0 );WARN_ON (!i915_gem_obj_ggtt_bound_view (obj, view)); -if (--vma->pin_count ==0 && view->type ==I915_GGTT_VIEW_NORMAL ) - obj->pin_mappable = false; + --vma->pin_count; }
Quoted 4 lines
drivers/gpu/drm/i915/i915_gem.c i915_gem_object_ggtt_unpin_view(struct drm_i915_gem_object *obj, · line 4490
Quoted 2 lines
drivers/gpu/drm/i915/i915_gem.c +0
-0bool Reviewed-by Tvrtko Ursulin <[email protected]>
Queued for -next, thanks for the patch.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 67/70 drm/i915: Start passing around i915_vma from execbuffer
In reply to Chris WilsonDuring execbuffer we look up the i915_vma in order to reserver them in the VM. However, we then do a double lookup of the vma in order to then pin them, all because we lack the necessary interfaces to operate on i915_vma.
--- drivers/gpu/drm/i915/i915_drv.h | 13 +++ drivers/gpu/drm/i915/i915_gem.c | 170 ++++++++++++++--------------- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 114 ++++++++++--------- 3 files changed, 154 insertions(+), 143 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +13 -0
@@ -2637,6 +2637,19 @@ void i915_gem_close_object(struct drm_gem_object *obj,void i915_gem_free_object (struct drm_gem_object *obj);void i915_gem_vma_destroy (struct i915_vma *vma); +int __must_check +i915_vma_pin (struct i915_vma *vma, +uint32_t size, +uint32_t alignment, +uint64_t flags); + +static inline void i915_vma_unpin (struct i915_vma *vma) +{ +WARN_ON (vma->pin_count ==0 ); +WARN_ON (!drm_mm_node_allocated (&vma->node)); + vma->pin_count--; +} +#define PIN_MAPPABLE 0x1#define PIN_NONBLOCK 0x2#define PIN_GLOBAL 0x4
drivers/gpu/drm/i915/i915_gem.c +85 -85
276 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem_execbuffer.c +56 -58
222 lines not on this page · raw message
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 68/70 drm/i915: Simplify vma-walker for i915_gem_objects
In reply to Chris WilsonWhen walking the vma of the GGTT, we already have the node size available, so no need to do a double lookup. To further simplify, just ignore the mappable counts, which will be useful for inspecting other VM later.
--- drivers/gpu/drm/i915/i915_debugfs.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +5 -11
@@ -405,12 +405,8 @@ static void print_batch_pool_stats(struct seq_file *m,#define count_vmas (list, member) do { \ list_for_each_entry(vma, list, member) { \ - size += i915_gem_obj_ggtt_size(vma->obj); \ + size += vma->node.size; \ ++count; \ - if (vma->obj->map_and_fenceable) { \ - mappable_size += i915_gem_obj_ggtt_size(vma->obj); \ - ++mappable_count; \ - } \ } \ } while (0)
@@ -440,15 +436,13 @@ static int i915_gem_object_info(struct seq_file *m, void* data)seq_printf (m,"%u [%u] objects, %zu [%zu] bytes in gtt\n" , count, mappable_count, size, mappable_size); - size = count = mappable_size = mappable_count =0 ; + size = count =0 ;count_vmas (&vm->active_list, mm_list); -seq_printf (m," %u [%u] active objects, %zu [%zu] bytes\n" , - count, mappable_count, size, mappable_size); +seq_printf (m," %u active objects, %zu bytes\n" , count, size); - size = count = mappable_size = mappable_count =0 ; + size = count =0 ;count_vmas (&vm->inactive_list, mm_list); -seq_printf (m," %u [%u] inactive objects, %zu [%zu] bytes\n" , - count, mappable_count, size, mappable_size); +seq_printf (m," %u inactive objects, %zu bytes\n" , count, size); size = count = purgeable_size = purgeable_count =0 ;list_for_each_entry (obj, &dev_priv->mm.unbound_list, global_list) {
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 69/70 drm/i915: Skip holding an object reference for execbuf preparation
In reply to Chris WilsonThis is a golden oldie! We can shave a couple of locked instructions for about 10% of the per-object overhead by not taking an extra kref whilst reserving objects for an execbuf. Due to lock management this is safe, as we cannot lose the original object reference without the lock. Equally, because this relies on the heavy BKL^W struct_mutex, it is also likely to be only a temporary optimisation until we have fine grained locking. (That's what we said 5 years ago!)
--- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 3 --- 1 file changed, 3 deletions(-)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +0 -3
@@ -142,7 +142,6 @@ eb_lookup_vmas(struct eb_vmas *eb, goto err; } -drm_gem_object_reference (&obj->base);list_add_tail (&obj->obj_exec_link, &objects); }spin_unlock (&file->table_lock);
@@ -260,7 +259,6 @@ static void eb_destroy(struct eb_vmas *eb) exec_list);list_del_init (&vma->exec_list);i915_gem_execbuffer_unreserve_vma (vma); -drm_gem_object_unreference (&vma->obj->base); }kfree (eb); }
@@ -873,7 +871,6 @@ i915_gem_execbuffer_relocate_slow(struct drm_device *dev, vma = list_first_entry(&eb->vmas, struct i915_vma, exec_list);list_del_init (&vma->exec_list);i915_gem_execbuffer_unreserve_vma (vma); -drm_gem_object_unreference (&vma->obj->base); }mutex_unlock (&dev->struct_mutex);
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 70/70 drm/i915: Use vma as the primary token for managing binding
In reply to Chris WilsonThis is a nasty patch that does multiple things:
1. Fixes the obj->pin_display confusion (separated out by Tvrtko).
2. Simplifies the view API
3. Introduces a vma hashtable for lookups (optimising for OglDrvCtx, igt/gem_ctx_thrash and friends)
4. Introduces the VMA as the binding token used. That is when you bind your object your given a VMA cookie which you then use for all queries (such as how much and where in the VM am I) and then to unbind. This is to try and kill all the repeated i915_obj_to_vma() when we already have the vma. This is less successful than hoped (~90% is a trivial conversion that naturally operates with i915_vma rather than the obj. The biggest sticking point is the atomic modesetting where we do not have the ability to track per-instance data.)
--- drivers/gpu/drm/i915/i915_debugfs.c | 8 +- drivers/gpu/drm/i915/i915_drv.h | 56 +++--- drivers/gpu/drm/i915/i915_gem.c | 282 +++++++++------------------ drivers/gpu/drm/i915/i915_gem_context.c | 52 +++-- drivers/gpu/drm/i915/i915_gem_evict.c | 2 +- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 46 +++-- drivers/gpu/drm/i915/i915_gem_gtt.c | 103 ++++++---- drivers/gpu/drm/i915/i915_gem_gtt.h | 3 +- drivers/gpu/drm/i915/i915_gem_render_state.c | 22 +-- drivers/gpu/drm/i915/i915_gem_render_state.h | 1 + drivers/gpu/drm/i915/i915_gem_shrinker.c | 4 +- drivers/gpu/drm/i915/i915_gem_stolen.c | 6 +- drivers/gpu/drm/i915/i915_gem_userptr.c | 2 +- drivers/gpu/drm/i915/i915_gpu_error.c | 6 +- drivers/gpu/drm/i915/intel_display.c | 59 +++--- drivers/gpu/drm/i915/intel_drv.h | 10 +- drivers/gpu/drm/i915/intel_fbdev.c | 9 +- drivers/gpu/drm/i915/intel_lrc.c | 34 ++-- drivers/gpu/drm/i915/intel_overlay.c | 39 ++-- drivers/gpu/drm/i915/intel_ringbuffer.c | 127 +++++++----- drivers/gpu/drm/i915/intel_ringbuffer.h | 2 + 21 files changed, 433 insertions(+), 440 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +4 -4
@@ -114,7 +114,7 @@ static const char *get_tiling_flag(struct drm_i915_gem_object *obj)static inline const char *get_global_flag (struct drm_i915_gem_object *obj) { -return i915_gem_obj_to_ggtt (obj) ?"g" :" " ; +return i915_gem_obj_to_ggtt (obj,NULL ) ?"g" :" " ; } static void
@@ -146,7 +146,7 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) obj->madv == I915_MADV_DONTNEED ? " purgeable" : "");if (obj->base.name)seq_printf (m," (name: %d)" , obj->base.name); -list_for_each_entry (vma, &obj->vma_list, vma_link) { +list_for_each_entry (vma, &obj->vma_list, obj_link) {if (vma->pin_count >0 ) pin_count++; }
@@ -155,7 +155,7 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)seq_printf (m," (display)" );if (obj->fence_reg !=I915_FENCE_REG_NONE )seq_printf (m," (fence: %d)" , obj->fence_reg); -list_for_each_entry (vma, &obj->vma_list, vma_link) { +list_for_each_entry (vma, &obj->vma_list, obj_link) {if (!vma->is_ggtt)seq_puts (m," (pp" );else
@@ -329,7 +329,7 @@ static int per_file_stats(int id, void *ptr, void *data) stats->shared += obj->base.size;if (USES_FULL_PPGTT (obj->base.dev)) { -list_for_each_entry (vma, &obj->vma_list, vma_link) { +list_for_each_entry (vma, &obj->vma_list, obj_link) {struct i915_hw_ppgtt *ppgtt;if (!drm_mm_node_allocated (&vma->node))
drivers/gpu/drm/i915/i915_drv.h +28 -28
152 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem.c +96 -186
555 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem_context.c +25 -27
121 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem_evict.c +1 -1
@@ -331,7 +331,7 @@ i915_gem_evict_everything(struct drm_device *dev)list_move_tail (&obj->global_list, &still_in_list);drm_gem_object_reference (&obj->base); -list_for_each_entry_safe (vma, v, &obj->vma_list, vma_link) +list_for_each_entry_safe (vma, v, &obj->vma_list, obj_link)if (WARN_ON (i915_vma_unbind (vma)))break ;drm_gem_object_unreference (&obj->base);
drivers/gpu/drm/i915/i915_gem_execbuffer.c +22 -24
104 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem_gtt.c +70 -33
170 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem_gtt.h +2 -1
@@ -174,7 +174,8 @@ struct i915_vma {/** This object's place on the active/inactive lists */ struct list_head mm_list; -struct list_head vma_link;/* Link in the object's VMA list */ +struct list_head obj_link;/* Link in the object's VMA list */ +struct hlist_node obj_node;/** This vma's place in the batchbuffer or on the eviction list */ struct list_head exec_list;
drivers/gpu/drm/i915/i915_gem_render_state.c +11 -11
@@ -47,7 +47,7 @@ render_state_get_rodata(struct drm_device *dev, const int gen)static int render_state_init (struct render_state *so,struct drm_device *dev) { -int ret; +struct i915_vma *vma; so->gen =INTEL_INFO (dev)->gen; so->rodata =render_state_get_rodata (dev, so->gen);
@@ -61,16 +61,16 @@ static int render_state_init(struct render_state *so, struct drm_device *dev)if (so->obj ==NULL )return -ENOMEM ; - ret =i915_gem_obj_ggtt_pin (so->obj,4096 ,0 ); -if (ret) - goto free_gem; + vma =i915_gem_obj_ggtt_pin (so->obj,0 ,0 ); +if (IS_ERR (vma)) { +drm_gem_object_unreference (&so->obj->base); +return PTR_ERR (vma); + } - so->ggtt_offset =i915_gem_obj_ggtt_offset (so->obj); -return 0 ; + so->vma = vma; + so->ggtt_offset = vma->node.start; -free_gem: -drm_gem_object_unreference (&so->obj->base); -return ret; +return 0 ; }static int render_state_setup (struct render_state *so)
@@ -124,7 +124,7 @@ static int render_state_setup(struct render_state *so)void i915_gem_render_state_fini (struct render_state *so) { -i915_gem_object_ggtt_unpin (so->obj); +i915_vma_unpin (so->vma);drm_gem_object_unreference (&so->obj->base); }
@@ -171,7 +171,7 @@ int i915_gem_render_state_init(struct intel_engine_cs *ring)if (ret) goto out; -i915_vma_move_to_active (i915_gem_obj_to_ggtt (so.obj), ring); +i915_vma_move_to_active (so.vma, ring); ret =__i915_add_request (ring,NULL , so.obj);/* __i915_add_request moves object to inactive if it fails */
drivers/gpu/drm/i915/i915_gem_render_state.h +1 -0
@@ -35,6 +35,7 @@ struct intel_renderstate_rodata {struct render_state {const struct intel_renderstate_rodata *rodata;struct drm_i915_gem_object *obj; +struct i915_vma *vma;u64 ggtt_offset;int gen; };
drivers/gpu/drm/i915/i915_gem_shrinker.c +2 -2
@@ -127,7 +127,7 @@ i915_gem_shrink(struct drm_i915_private *dev_priv,/* For the unbound phase, this should be a no-op! */ list_for_each_entry_safe (vma, v, - &obj->vma_list, vma_link) + &obj->vma_list, obj_link)if (i915_vma_unbind (vma))break ;
@@ -190,7 +190,7 @@ static int num_vma_bound(struct drm_i915_gem_object *obj)struct i915_vma *vma;int count =0 ; -list_for_each_entry (vma, &obj->vma_list, vma_link) { +list_for_each_entry (vma, &obj->vma_list, obj_link) {if (drm_mm_node_allocated (&vma->node)) count++;if (vma->pin_count)
drivers/gpu/drm/i915/i915_gem_stolen.c +3 -3
@@ -514,7 +514,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,if (gtt_offset ==I915_GTT_OFFSET_NONE )return obj; - vma =i915_gem_obj_lookup_or_create_vma (obj, ggtt); + vma =i915_gem_obj_lookup_or_create_vma (obj, ggtt,NULL );if (IS_ERR (vma)) { ret =PTR_ERR (vma); goto err_out;
@@ -533,9 +533,9 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,DRM_DEBUG_KMS ("failed to allocate stolen GTT space\n" ); goto err_vma; } - } - vma->bound |=GLOBAL_BIND ; + vma->bound |=GLOBAL_BIND ; + }list_add_tail (&obj->global_list, &dev_priv->mm.bound_list);list_add_tail (&vma->mm_list, &ggtt->inactive_list);
drivers/gpu/drm/i915/i915_gem_userptr.c +1 -1
@@ -79,7 +79,7 @@ static unsigned long cancel_userptr(struct drm_i915_gem_object *obj) was_interruptible = dev_priv->mm.interruptible; dev_priv->mm.interruptible = false; -list_for_each_entry_safe (vma, tmp, &obj->vma_list, vma_link) { +list_for_each_entry_safe (vma, tmp, &obj->vma_list, obj_link) {int ret =i915_vma_unbind (vma);WARN_ON (ret && ret != -EIO ); }
drivers/gpu/drm/i915/i915_gpu_error.c +3 -3
@@ -607,7 +607,7 @@ i915_error_object_create(struct drm_i915_private *dev_priv, reloc_offset = dst->gtt_offset;if (vm->is_ggtt) - vma =i915_gem_obj_to_ggtt (src); + vma =i915_gem_obj_to_ggtt (src,NULL ); use_ggtt = (src->cache_level ==I915_CACHE_NONE && vma && (vma->bound &GLOBAL_BIND ) && reloc_offset + num_pages *PAGE_SIZE <= dev_priv->gtt.mappable_end);
@@ -737,7 +737,7 @@ static u32 capture_pinned_bo(struct drm_i915_error_buffer *err,if (err == last)break ; -list_for_each_entry (vma, &obj->vma_list, vma_link) +list_for_each_entry (vma, &obj->vma_list, obj_link)if (vma->vm == vm && vma->pin_count >0 )capture_bo (err++, vma); }
@@ -1096,7 +1096,7 @@ static void i915_gem_capture_vm(struct drm_i915_private *dev_priv, error->active_bo_count[ndx] = i;list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list) { -list_for_each_entry (vma, &obj->vma_list, vma_link) +list_for_each_entry (vma, &obj->vma_list, obj_link)if (vma->vm == vm && vma->pin_count >0 ) i++; }
drivers/gpu/drm/i915/intel_display.c +36 -23
149 lines not on this page · raw message
drivers/gpu/drm/i915/intel_drv.h +5 -5
@@ -960,10 +960,10 @@ bool intel_get_load_detect_pipe(struct drm_connector *connector,void intel_release_load_detect_pipe (struct drm_connector *connector,struct intel_load_detect_pipe *old,struct drm_modeset_acquire_ctx *ctx); -int intel_pin_and_fence_fb_obj (struct drm_plane *plane, -struct drm_framebuffer *fb, -const struct drm_plane_state *plane_state, -struct intel_engine_cs *pipelined); +struct i915_vma *intel_pin_and_fence_fb_obj (struct drm_plane *plane, +struct drm_framebuffer *fb, +const struct drm_plane_state *plane_state, +struct intel_engine_cs *pipelined);struct drm_framebuffer * __intel_framebuffer_create(struct drm_device *dev, struct drm_mode_fb_cmd2 *mode_cmd,
@@ -977,7 +977,7 @@ int intel_prepare_plane_fb(struct drm_plane *plane, const struct drm_plane_state *new_state);void intel_cleanup_plane_fb (struct drm_plane *plane,struct drm_framebuffer *fb, -const struct drm_plane_state *old_state); +const struct drm_plane_state *state); int intel_plane_atomic_get_property(struct drm_plane *plane, const struct drm_plane_state *state, struct drm_property *property,
drivers/gpu/drm/i915/intel_fbdev.c +6 -3
@@ -119,6 +119,7 @@ static int intelfb_alloc(struct drm_fb_helper *helper,struct drm_device *dev = helper->dev;struct drm_mode_fb_cmd2 mode_cmd = {};struct drm_i915_gem_object *obj; +struct i915_vma *vma;int size, ret;/* we don't do packed 24bpp */
@@ -151,13 +152,15 @@ static int intelfb_alloc(struct drm_fb_helper *helper, }/* Flush everything out, we'll be doing GTT only from now on */ - ret =intel_pin_and_fence_fb_obj (NULL , fb,NULL ,NULL ); -if (ret) { + vma =intel_pin_and_fence_fb_obj (NULL , fb,NULL ,NULL ); +if (IS_ERR (vma)) { + ret =PTR_ERR (vma);DRM_ERROR ("failed to pin obj: %d\n" , ret); goto out_fb; } ifbdev->fb =to_intel_framebuffer (fb); +//ifbdev->vma = vma; return 0 ;
@@ -279,7 +282,7 @@ static int intelfb_create(struct drm_fb_helper *helper,return 0 ; out_unpin: -i915_gem_object_ggtt_unpin (obj); +//intel_unpin_fb_obj(&ifbdev->fb->base, NULL); drm_gem_object_unreference (&obj->base); out_unlock:mutex_unlock (&dev->struct_mutex);
drivers/gpu/drm/i915/intel_lrc.c +20 -14
@@ -475,17 +475,20 @@ static int intel_lr_context_pin(struct intel_engine_cs *ring,struct drm_i915_gem_object *ctx_obj = ctx->engine[ring->id].state;struct intel_ringbuffer *ringbuf = ctx->engine[ring->id].ringbuf;u32 ggtt_offset; +struct i915_vma *vma;int ret;WARN_ON (!mutex_is_locked (&ring->dev->struct_mutex));if (ctx->engine[ring->id].pin_count++)return 0 ; - ret =i915_gem_obj_ggtt_pin (ctx_obj,GEN8_LR_CONTEXT_ALIGN ,0 ); -if (ret) + vma =i915_gem_obj_ggtt_pin (ctx_obj,GEN8_LR_CONTEXT_ALIGN ,0 ); +if (IS_ERR (vma)) { + ret =PTR_ERR (vma); goto reset_pin_count; + } - ggtt_offset =i915_gem_obj_ggtt_offset (ctx_obj); + ggtt_offset = vma->node.start;if (WARN_ON (ggtt_offset &0xFFFFFFFF00000FFFULL )) { ret = -ENODEV ; goto unpin_ctx_obj;
@@ -500,17 +503,17 @@ static int intel_lr_context_pin(struct intel_engine_cs *ring, ringbuf->regs[CTX_RING_BUFFER_START +1 ] =i915_gem_obj_ggtt_offset (ringbuf->obj); + ctx->engine[ring->id].vma = vma;return 0 ; unpin_ctx_obj: -i915_gem_object_ggtt_unpin (ctx_obj); +i915_vma_unpin (vma); reset_pin_count: ctx->engine[ring->id].pin_count =0 ;return ret; } -int intel_logical_ring_alloc_request_extras (struct drm_i915_gem_request *request,struct intel_context *ctx) {
@@ -778,17 +781,18 @@ int intel_execlists_submission(struct drm_device *dev, struct drm_file *file,static void intel_lr_context_unpin (struct intel_engine_cs *ring,struct intel_context *ctx) { -struct drm_i915_gem_object *ctx_obj = ctx->engine[ring->id].state;struct intel_ringbuffer *ringbuf = ctx->engine[ring->id].ringbuf;if (--ctx->engine[ring->id].pin_count)return ; -kunmap (i915_gem_object_get_page (ctx_obj,1 )); +kunmap (i915_gem_object_get_page (ctx->engine[ring->id].state,1 )); ringbuf->regs =NULL ;intel_unpin_ringbuffer_obj (ringbuf); -i915_gem_object_ggtt_unpin (ctx_obj); + +i915_vma_unpin (ctx->engine[ring->id].vma); + ctx->engine[ring->id].vma =NULL ; }void intel_execlists_retire_requests (struct intel_engine_cs *ring)
@@ -1147,7 +1151,7 @@ static int intel_lr_context_render_state_init(struct intel_engine_cs *ring,if (ret) goto out; -i915_vma_move_to_active (i915_gem_obj_to_ggtt (so.obj), ring); +i915_vma_move_to_active (so.vma, ring); ret =__i915_add_request (ring, file, so.obj);/* intel_logical_ring_add_request moves object to inactive if it
@@ -1735,12 +1739,14 @@ int intel_lr_context_deferred_create(struct intel_context *ctx, }if (is_global_default_ctx) { - ret =i915_gem_obj_ggtt_pin (ctx_obj,GEN8_LR_CONTEXT_ALIGN ,0 ); -if (ret) { -DRM_DEBUG_DRIVER ("Pin LRC backing obj failed: %d\n" , - ret); +struct i915_vma *vma; + + vma =i915_gem_obj_ggtt_pin (ctx_obj,GEN8_LR_CONTEXT_ALIGN ,0 ); +if (IS_ERR (vma)) { +DRM_DEBUG_DRIVER ("Pin LRC backing obj failed: %ld\n" , +PTR_ERR (vma));drm_gem_object_unreference (&ctx_obj->base); -return ret; +return PTR_ERR (vma); } }
drivers/gpu/drm/i915/intel_overlay.c +22 -17
@@ -170,8 +170,8 @@ struct overlay_registers {struct intel_overlay {struct drm_device *dev;struct intel_crtc *crtc; -struct drm_i915_gem_object *vid_bo; -struct drm_i915_gem_object *old_vid_bo; +struct drm_i915_gem_object *vid_bo, *old_vid_bo; +struct i915_vma *vid_vma, *old_vid_vma;bool active;bool pfit_active;u32 pfit_vscale_ratio;/* shifted-point number, (1<<12) == 1.0 */
@@ -197,7 +197,7 @@ intel_overlay_map_regs(struct intel_overlay *overlay) regs = (struct overlay_registers __iomem *)overlay->reg_bo->phys_handle->vaddr; else regs =io_mapping_map_wc (dev_priv->gtt.mappable, -i915_gem_obj_ggtt_offset (overlay->reg_bo)); + overlay->flip_addr);return regs; }
@@ -299,7 +299,7 @@ static void intel_overlay_release_old_vid_tail(struct intel_overlay *overlay) {struct drm_i915_gem_object *obj = overlay->old_vid_bo; -i915_gem_object_ggtt_unpin (obj); +i915_gem_object_unpin_from_display_plane (overlay->old_vid_vma);drm_gem_object_unreference (&obj->base); overlay->old_vid_bo =NULL ;
@@ -718,6 +718,7 @@ static int intel_overlay_do_put_image(struct intel_overlay *overlay,struct drm_device *dev = overlay->dev;u32 swidth, swidthsw, sheight, ostride;enum pipe pipe = overlay->crtc->pipe; +struct i915_vma *vma;WARN_ON (!mutex_is_locked (&dev->struct_mutex));WARN_ON (!drm_modeset_is_locked (&dev->mode_config.connection_mutex));
@@ -726,10 +727,9 @@ static int intel_overlay_do_put_image(struct intel_overlay *overlay,if (ret !=0 )return ret; - ret =i915_gem_object_pin_to_display_plane (new_bo,0 ,NULL , - &i915_ggtt_view_normal); -if (ret !=0 ) -return ret; + vma =i915_gem_object_pin_to_display_plane (new_bo,0 ,NULL ,NULL ); +if (IS_ERR (vma)) +return PTR_ERR (vma); ret =i915_gem_object_put_fence (new_bo);if (ret)
@@ -772,7 +772,7 @@ static int intel_overlay_do_put_image(struct intel_overlay *overlay, swidth = params->src_w; swidthsw =calc_swidthsw (overlay->dev, params->offset_Y, tmp_width); sheight = params->src_h; -iowrite32 (i915_gem_obj_ggtt_offset (new_bo) + params->offset_Y, ®s->OBUF_0Y); +iowrite32 (vma->node.start + params->offset_Y, ®s->OBUF_0Y); ostride = params->stride_Y;if (params->format &I915_OVERLAY_YUV_PLANAR ) {
@@ -786,8 +786,8 @@ static int intel_overlay_do_put_image(struct intel_overlay *overlay, params->src_w/uv_hscale); swidthsw |=max_t (u32, tmp_U, tmp_V) <<16 ; sheight |= (params->src_h/uv_vscale) <<16 ; -iowrite32 (i915_gem_obj_ggtt_offset (new_bo) + params->offset_U, ®s->OBUF_0U); -iowrite32 (i915_gem_obj_ggtt_offset (new_bo) + params->offset_V, ®s->OBUF_0V); +iowrite32 (vma->node.start + params->offset_U, ®s->OBUF_0U); +iowrite32 (vma->node.start + params->offset_V, ®s->OBUF_0V); ostride |= params->stride_UV <<16 ; }
@@ -812,7 +812,9 @@ static int intel_overlay_do_put_image(struct intel_overlay *overlay, INTEL_FRONTBUFFER_OVERLAY(pipe)); overlay->old_vid_bo = overlay->vid_bo; + overlay->old_vid_vma = overlay->vid_vma; overlay->vid_bo = new_bo; + overlay->vid_vma = vma;intel_frontbuffer_flip (dev,INTEL_FRONTBUFFER_OVERLAY (pipe));
@@ -820,7 +822,7 @@ static int intel_overlay_do_put_image(struct intel_overlay *overlay,return 0 ; out_unpin: -i915_gem_object_ggtt_unpin (new_bo); +i915_gem_object_unpin_from_display_plane (vma);return ret; }
@@ -1383,12 +1385,15 @@ void intel_setup_overlay(struct drm_device *dev) } overlay->flip_addr = reg_bo->phys_handle->busaddr; }else { - ret =i915_gem_obj_ggtt_pin (reg_bo,PAGE_SIZE ,PIN_MAPPABLE ); -if (ret) { +struct i915_vma *vma; + + vma =i915_gem_obj_ggtt_pin (reg_bo,PAGE_SIZE ,PIN_MAPPABLE ); +if (IS_ERR (vma)) {DRM_ERROR ("failed to pin overlay register bo\n" ); + ret =PTR_ERR (vma); goto out_free_bo; } - overlay->flip_addr =i915_gem_obj_ggtt_offset (reg_bo); + overlay->flip_addr = vma->node.start; ret =i915_gem_object_set_to_gtt_domain (reg_bo, true);if (ret) {
@@ -1466,7 +1471,7 @@ intel_overlay_map_regs_atomic(struct intel_overlay *overlay) overlay->reg_bo->phys_handle->vaddr; else regs =io_mapping_map_atomic_wc (dev_priv->gtt.mappable, -i915_gem_obj_ggtt_offset (overlay->reg_bo)); + overlay->flip_addr);return regs; }
@@ -1499,7 +1504,7 @@ intel_overlay_capture_error_state(struct drm_device *dev)if (OVERLAY_NEEDS_PHYSICAL (overlay->dev)) error->base = (__force long )overlay->reg_bo->phys_handle->vaddr;else - error->base =i915_gem_obj_ggtt_offset (overlay->reg_bo); + error->base = overlay->flip_addr; regs =intel_overlay_map_regs_atomic (overlay);if (!regs)
drivers/gpu/drm/i915/intel_ringbuffer.c +73 -54
224 lines not on this page · raw message
drivers/gpu/drm/i915/intel_ringbuffer.h +2 -0
@@ -101,6 +101,7 @@ struct intel_ringbuffer {uint32_t descriptor;struct intel_engine_cs *ring; +struct i915_vma *vma;u32 head;u32 tail;
@@ -289,6 +290,7 @@ struct intel_engine_cs {struct {struct drm_i915_gem_object *obj; +struct i915_vma *vma;u32 gtt_offset;volatile u32 *cpu_page; } scratch;
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx