aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Elf <tomas.elf@intel.com>2015-07-09 10:30:57 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2015-07-13 16:42:39 -0400
commit94f7bbe1509731bdef651d7fb235b2c31fb23be8 (patch)
tree07731a4be3b5ba66f52d3c7e4dd73c8c08e945cd
parent9ea4feecc39dbed60496fa181d70fdb9d73c7250 (diff)
drm/i915: Snapshot seqno of most recently submitted request.
The hang checker needs to inspect whether or not the ring request list is empty as well as if the given engine has reached or passed the most recently submitted request. The problem with this is that the hang checker cannot grab the struct_mutex, which is required in order to safely inspect requests since requests might be deallocated during inspection. In the past we've had kernel panics due to this very unsynchronized access in the hang checker. One solution to this problem is to not inspect the requests directly since we're only interested in the seqno of the most recently submitted request - not the request itself. Instead the seqno of the most recently submitted request is stored separately, which the hang checker then inspects, circumventing the issue of synchronization from the hang checker entirely. This fixes a regression introduced in commit 44cdd6d219bc64f6810b8ed0023a4d4db9e0fe68 Author: John Harrison <John.C.Harrison@Intel.com> Date: Mon Nov 24 18:49:40 2014 +0000 drm/i915: Convert 'ring_idle()' to use requests not seqnos v2 (Chris Wilson): - Pass current engine seqno to ring_idle() from i915_hangcheck_elapsed() rather than compute it over again. - Remove extra whitespace. Issue: VIZ-5998 Signed-off-by: Tomas Elf <tomas.elf@intel.com> Cc: stable@vger.kernel.org Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> [danvet: Add regressing commit citation provided by Chris.] Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c1
-rw-r--r--drivers/gpu/drm/i915/i915_irq.c13
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.h7
3 files changed, 11 insertions, 10 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 248fd1ac7b3a..716e5acc3bb0 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2542,6 +2542,7 @@ int __i915_add_request(struct intel_engine_cs *ring,
2542 } 2542 }
2543 2543
2544 request->emitted_jiffies = jiffies; 2544 request->emitted_jiffies = jiffies;
2545 ring->last_submitted_seqno = request->seqno;
2545 list_add_tail(&request->list, &ring->request_list); 2546 list_add_tail(&request->list, &ring->request_list);
2546 request->file_priv = NULL; 2547 request->file_priv = NULL;
2547 2548
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index e6bb72dca3ff..984e2fe6688c 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -2706,18 +2706,11 @@ static void gen8_disable_vblank(struct drm_device *dev, int pipe)
2706 spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); 2706 spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
2707} 2707}
2708 2708
2709static struct drm_i915_gem_request *
2710ring_last_request(struct intel_engine_cs *ring)
2711{
2712 return list_entry(ring->request_list.prev,
2713 struct drm_i915_gem_request, list);
2714}
2715
2716static bool 2709static bool
2717ring_idle(struct intel_engine_cs *ring) 2710ring_idle(struct intel_engine_cs *ring, u32 seqno)
2718{ 2711{
2719 return (list_empty(&ring->request_list) || 2712 return (list_empty(&ring->request_list) ||
2720 i915_gem_request_completed(ring_last_request(ring), false)); 2713 i915_seqno_passed(seqno, ring->last_submitted_seqno));
2721} 2714}
2722 2715
2723static bool 2716static bool
@@ -2939,7 +2932,7 @@ static void i915_hangcheck_elapsed(struct work_struct *work)
2939 acthd = intel_ring_get_active_head(ring); 2932 acthd = intel_ring_get_active_head(ring);
2940 2933
2941 if (ring->hangcheck.seqno == seqno) { 2934 if (ring->hangcheck.seqno == seqno) {
2942 if (ring_idle(ring)) { 2935 if (ring_idle(ring, seqno)) {
2943 ring->hangcheck.action = HANGCHECK_IDLE; 2936 ring->hangcheck.action = HANGCHECK_IDLE;
2944 2937
2945 if (waitqueue_active(&ring->irq_queue)) { 2938 if (waitqueue_active(&ring->irq_queue)) {
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
index e539314ae87e..4be66f60504d 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.h
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
@@ -275,6 +275,13 @@ struct intel_engine_cs {
275 * Do we have some not yet emitted requests outstanding? 275 * Do we have some not yet emitted requests outstanding?
276 */ 276 */
277 struct drm_i915_gem_request *outstanding_lazy_request; 277 struct drm_i915_gem_request *outstanding_lazy_request;
278 /**
279 * Seqno of request most recently submitted to request_list.
280 * Used exclusively by hang checker to avoid grabbing lock while
281 * inspecting request list.
282 */
283 u32 last_submitted_seqno;
284
278 bool gpu_caches_dirty; 285 bool gpu_caches_dirty;
279 286
280 wait_queue_head_t irq_queue; 287 wait_queue_head_t irq_queue;