drm/i915: Convert mmio_flip::seqno to struct request
authorJohn Harrison <John.C.Harrison@Intel.com>
Mon, 24 Nov 2014 18:49:34 +0000 (18:49 +0000)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 3 Dec 2014 08:35:18 +0000 (09:35 +0100)
Converted the mmio_flip 'seqno' value to be a request structure as part of the
on going seqno to request changes. This includes reference counting the request
being saved away to ensure it can not be retired and freed while the flip code
is still waiting on it.

v2: Used the IRQ friendly request dereference call in the notify handler as that
code is called asynchronously without holding any useful mutex locks.

For: VIZ-4377
Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
Reviewed-by: Thomas Daniel <Thomas.Daniel@intel.com>
[danvet: Drop the _irq variant and use the normal reques unref,
wrapped in dev->struct_mutex per the discussion on the m-l.]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_drv.h

index 30857318df712c81a364a27d7066322be6c0aaca..61c402485f36b24924eeb50f8510009c8aa946b9 100644 (file)
@@ -9612,20 +9612,24 @@ 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 *intel_crtc =
+       struct intel_crtc *crtc =
                container_of(work, struct intel_crtc, mmio_flip.work);
-       struct intel_engine_cs *ring;
-       uint32_t seqno;
+       struct intel_mmio_flip *mmio_flip;
 
-       seqno = intel_crtc->mmio_flip.seqno;
-       ring = intel_crtc->mmio_flip.ring;
-
-       if (seqno)
-               WARN_ON(__i915_wait_seqno(ring, seqno,
-                                         intel_crtc->reset_counter,
+       mmio_flip = &crtc->mmio_flip;
+       if (mmio_flip->req)
+               WARN_ON(__i915_wait_seqno(i915_gem_request_get_ring(mmio_flip->req),
+                                         i915_gem_request_get_seqno(mmio_flip->req),
+                                         crtc->reset_counter,
                                          false, NULL, NULL) != 0);
 
-       intel_do_mmio_flip(intel_crtc);
+       intel_do_mmio_flip(crtc);
+       if (mmio_flip->req) {
+               mutex_lock(&crtc->base.dev->struct_mutex);
+               i915_gem_request_unreference(mmio_flip->req);
+               mutex_unlock(&crtc->base.dev->struct_mutex);
+       }
+       mmio_flip->req = NULL;
 }
 
 static int intel_queue_mmio_flip(struct drm_device *dev,
@@ -9637,9 +9641,8 @@ static int intel_queue_mmio_flip(struct drm_device *dev,
 {
        struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 
-       intel_crtc->mmio_flip.seqno =
-                            i915_gem_request_get_seqno(obj->last_write_req);
-       intel_crtc->mmio_flip.ring = obj->ring;
+       i915_gem_request_assign(&intel_crtc->mmio_flip.req,
+                               obj->last_write_req);
 
        schedule_work(&intel_crtc->mmio_flip.work);
 
index 5e81f097132c1e8fa9c035b7a2b00c176aae49ac..6f87e3cbd68d451680745f5cd4266e7d2a5177a5 100644 (file)
@@ -406,8 +406,7 @@ struct intel_pipe_wm {
 };
 
 struct intel_mmio_flip {
-       u32 seqno;
-       struct intel_engine_cs *ring;
+       struct drm_i915_gem_request *req;
        struct work_struct work;
 };