drm/i915: Don't use atomics for pg_dirty_rings
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 14 Apr 2015 15:35:19 +0000 (17:35 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 23 Apr 2015 19:06:02 +0000 (21:06 +0200)
It's already protected by the bkl^Wdev->struct_mutex. While at it
realign some related code.

Reviewed-by: Mika Kuoppala <mika.kuoppala@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
drivers/gpu/drm/i915/i915_gem_context.c
drivers/gpu/drm/i915/i915_gem_execbuffer.c

index 6b0962db2cf7bff7da1e4ae00d2f12125e153918..5a47eb5e3c5dcadb0c776dc7df7f48a970c1c1fc 100644 (file)
@@ -578,11 +578,9 @@ static inline bool should_skip_switch(struct intel_engine_cs *ring,
        if (to->remap_slice)
                return false;
 
-       if (to->ppgtt) {
-               if (from == to && !test_bit(ring->id,
-                               &to->ppgtt->pd_dirty_rings))
-                       return true;
-       }
+       if (to->ppgtt && from == to &&
+           !(intel_ring_flag(ring) & to->ppgtt->pd_dirty_rings))
+               return true;
 
        return false;
 }
@@ -668,7 +666,7 @@ static int do_switch(struct intel_engine_cs *ring,
                        goto unpin_out;
 
                /* Doing a PD load always reloads the page dirs */
-               clear_bit(ring->id, &to->ppgtt->pd_dirty_rings);
+               to->ppgtt->pd_dirty_rings &= ~intel_ring_flag(ring);
        }
 
        if (ring != &dev_priv->ring[RCS]) {
@@ -696,12 +694,14 @@ static int do_switch(struct intel_engine_cs *ring,
                 * space. This means we must enforce that a page table load
                 * occur when this occurs. */
        } else if (to->ppgtt &&
-                       test_and_clear_bit(ring->id, &to->ppgtt->pd_dirty_rings))
+                  (intel_ring_flag(ring) & to->ppgtt->pd_dirty_rings)) {
                hw_flags |= MI_FORCE_RESTORE;
+               to->ppgtt->pd_dirty_rings &= ~intel_ring_flag(ring);
+       }
 
        /* We should never emit switch_mm more than once */
        WARN_ON(needs_pd_load_pre(ring, to) &&
-                       needs_pd_load_post(ring, to, hw_flags));
+               needs_pd_load_post(ring, to, hw_flags));
 
        ret = mi_set_context(ring, to, hw_flags);
        if (ret)
index 1cf3468551a257f715898c4b8cee0cf98fcce1e3..7f69aa820458bb2c94e6979c966820edfc0bce46 100644 (file)
@@ -1248,9 +1248,8 @@ i915_gem_ringbuffer_submission(struct drm_device *dev, struct drm_file *file,
        if (ret)
                goto error;
 
-       if (ctx->ppgtt)
-               WARN(ctx->ppgtt->pd_dirty_rings & (1<<ring->id),
-                       "%s didn't clear reload\n", ring->name);
+       WARN(ctx->ppgtt && ctx->ppgtt->pd_dirty_rings & (1<<ring->id),
+            "%s didn't clear reload\n", ring->name);
 
        instp_mode = args->flags & I915_EXEC_CONSTANTS_MASK;
        instp_mask = I915_EXEC_CONSTANTS_MASK;