]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm/i915: Use atomic for dev_priv->mm.bsd_engine_dispatch_index
authorJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
Thu, 1 Sep 2016 11:58:21 +0000 (14:58 +0300)
committerJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
Thu, 1 Sep 2016 12:39:25 +0000 (15:39 +0300)
Use atomic type and operands for dev_priv->mm.bsd_engine_dispatch_index
to avoid one struct_mutex locking scenario.

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Imre Deak <imre.deak@intel.com>
Cc: Zhao Yakui <yakui.zhao@intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: http://patchwork.freedesktop.org/patch/msgid/1472731101-21982-1-git-send-email-joonas.lahtinen@linux.intel.com
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_gem.c
drivers/gpu/drm/i915/i915_gem_execbuffer.c

index c413587895cff1766952c920cbff87edf7dd1d5e..43d5298b821fc8e9a743991665dc8b8bc4ab0a85 100644 (file)
@@ -1338,7 +1338,7 @@ struct i915_gem_mm {
        bool interruptible;
 
        /* the indicator for dispatch video commands on two BSD rings */
-       unsigned int bsd_engine_dispatch_index;
+       atomic_t bsd_engine_dispatch_index;
 
        /** Bit 6 swizzling required for X tiling */
        uint32_t bit_6_swizzle_x;
index d37b44126942716eec1acc11da166a119865b081..2401818171f583dc2e09d5d42c8b8699891c55d5 100644 (file)
@@ -4622,6 +4622,8 @@ i915_gem_load_init(struct drm_device *dev)
 
        dev_priv->mm.interruptible = true;
 
+       atomic_set(&dev_priv->mm.bsd_engine_dispatch_index, 0);
+
        spin_lock_init(&dev_priv->fb_tracking.lock);
 }
 
index 57d096aef548bd7227cbe1838ab03f9e6df87f18..9432d4ce9ffb2a89eef34450c0a8b915b1affa61 100644 (file)
@@ -1535,13 +1535,9 @@ gen8_dispatch_bsd_engine(struct drm_i915_private *dev_priv,
        struct drm_i915_file_private *file_priv = file->driver_priv;
 
        /* Check whether the file_priv has already selected one ring. */
-       if ((int)file_priv->bsd_engine < 0) {
-               /* If not, use the ping-pong mechanism to select one. */
-               mutex_lock(&dev_priv->drm.struct_mutex);
-               file_priv->bsd_engine = dev_priv->mm.bsd_engine_dispatch_index;
-               dev_priv->mm.bsd_engine_dispatch_index ^= 1;
-               mutex_unlock(&dev_priv->drm.struct_mutex);
-       }
+       if ((int)file_priv->bsd_engine < 0)
+               file_priv->bsd_engine = atomic_fetch_xor(1,
+                        &dev_priv->mm.bsd_engine_dispatch_index);
 
        return file_priv->bsd_engine;
 }