drm/i915: Convert i915_semaphores_is_enabled over to early sanitize
authorChris Wilson <chris@chris-wilson.co.uk>
Wed, 20 Jul 2016 12:31:57 +0000 (13:31 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Wed, 20 Jul 2016 12:40:43 +0000 (13:40 +0100)
Rather than recomputing whether semaphores are enabled, we can do that
computation once during early initialisation as the i915.semaphores
module parameter is now read-only.

s/i915_semaphores_is_enabled/i915.semaphores/

v2: Add the state to the debug dmesg as well

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: http://patchwork.freedesktop.org/patch/msgid/1469005202-9659-10-git-send-email-chris@chris-wilson.co.uk
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1469017917-15134-9-git-send-email-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/i915_debugfs.c
drivers/gpu/drm/i915/i915_drv.c
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_gem.c
drivers/gpu/drm/i915/i915_gem_context.c
drivers/gpu/drm/i915/i915_gpu_error.c
drivers/gpu/drm/i915/intel_ringbuffer.c

index 618f8cf210fc52757ffcaf2d6a8c28b7da82b47c..9aa62c5b5f6551ea76771bd3be3bb1df7682c806 100644 (file)
@@ -3220,7 +3220,7 @@ static int i915_semaphore_status(struct seq_file *m, void *unused)
        enum intel_engine_id id;
        int j, ret;
 
-       if (!i915_semaphore_is_enabled(dev_priv)) {
+       if (!i915.semaphores) {
                seq_puts(m, "Semaphores are disabled\n");
                return 0;
        }
index c5b7b8e0678a354d2a529c53d33c128d722f39c7..83afdd0597b576c003f3e64db65fe92ef995bc0a 100644 (file)
@@ -228,27 +228,6 @@ static void intel_detect_pch(struct drm_device *dev)
        pci_dev_put(pch);
 }
 
-bool i915_semaphore_is_enabled(struct drm_i915_private *dev_priv)
-{
-       if (INTEL_GEN(dev_priv) < 6)
-               return false;
-
-       if (i915.semaphores >= 0)
-               return i915.semaphores;
-
-       /* TODO: make semaphores and Execlists play nicely together */
-       if (i915.enable_execlists)
-               return false;
-
-#ifdef CONFIG_INTEL_IOMMU
-       /* Enable semaphores on SNB when IO remapping is off */
-       if (IS_GEN6(dev_priv) && intel_iommu_gfx_mapped)
-               return false;
-#endif
-
-       return true;
-}
-
 static int i915_getparam(struct drm_device *dev, void *data,
                         struct drm_file *file_priv)
 {
@@ -324,7 +303,7 @@ static int i915_getparam(struct drm_device *dev, void *data,
                value = 1;
                break;
        case I915_PARAM_HAS_SEMAPHORES:
-               value = i915_semaphore_is_enabled(dev_priv);
+               value = i915.semaphores;
                break;
        case I915_PARAM_HAS_PRIME_VMAP_FLUSH:
                value = 1;
@@ -999,6 +978,9 @@ static void intel_sanitize_options(struct drm_i915_private *dev_priv)
        i915.enable_ppgtt =
                intel_sanitize_enable_ppgtt(dev_priv, i915.enable_ppgtt);
        DRM_DEBUG_DRIVER("ppgtt mode: %i\n", i915.enable_ppgtt);
+
+       i915.semaphores = intel_sanitize_semaphores(dev_priv, i915.semaphores);
+       DRM_DEBUG_DRIVER("use GPU sempahores? %s\n", yesno(i915.semaphores));
 }
 
 /**
index 3ca1acec152264c6d2fc218e562985ce5bd60919..0f408ada1c659583814f9381d2c21d4f38aaf771 100644 (file)
@@ -2813,6 +2813,8 @@ extern int i915_resume_switcheroo(struct drm_device *dev);
 int intel_sanitize_enable_ppgtt(struct drm_i915_private *dev_priv,
                                int enable_ppgtt);
 
+bool intel_sanitize_semaphores(struct drm_i915_private *dev_priv, int value);
+
 /* i915_drv.c */
 void __printf(3, 4)
 __i915_printk(struct drm_i915_private *dev_priv, const char *level,
@@ -3641,7 +3643,6 @@ extern void intel_set_rps(struct drm_i915_private *dev_priv, u8 val);
 extern void intel_set_memory_cxsr(struct drm_i915_private *dev_priv,
                                  bool enable);
 
-extern bool i915_semaphore_is_enabled(struct drm_i915_private *dev_priv);
 int i915_reg_read_ioctl(struct drm_device *dev, void *data,
                        struct drm_file *file);
 
index 536acd527359fa6fd61f8dd4204c13b58314cdf1..40047eb4882617573c3f125faf3f8796e262ac3f 100644 (file)
@@ -2856,7 +2856,7 @@ __i915_gem_object_sync(struct drm_i915_gem_object *obj,
        if (i915_gem_request_completed(from_req))
                return 0;
 
-       if (!i915_semaphore_is_enabled(to_i915(obj->base.dev))) {
+       if (!i915.semaphores) {
                struct drm_i915_private *i915 = to_i915(obj->base.dev);
                ret = __i915_wait_request(from_req,
                                          i915->mm.interruptible,
@@ -4537,6 +4537,27 @@ out:
        return ret;
 }
 
+bool intel_sanitize_semaphores(struct drm_i915_private *dev_priv, int value)
+{
+       if (INTEL_INFO(dev_priv)->gen < 6)
+               return false;
+
+       /* TODO: make semaphores and Execlists play nicely together */
+       if (i915.enable_execlists)
+               return false;
+
+       if (value >= 0)
+               return value;
+
+#ifdef CONFIG_INTEL_IOMMU
+       /* Enable semaphores on SNB when IO remapping is off */
+       if (INTEL_INFO(dev_priv)->gen == 6 && intel_iommu_gfx_mapped)
+               return false;
+#endif
+
+       return true;
+}
+
 int i915_gem_init(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = to_i915(dev);
index 2600939fc2ee3f335c7746c4fc85daa64b05ce76..bd13d084e19c50af4850550f1aa5488e033a96a4 100644 (file)
@@ -556,7 +556,7 @@ mi_set_context(struct drm_i915_gem_request *req, u32 hw_flags)
        u32 flags = hw_flags | MI_MM_SPACE_GTT;
        const int num_rings =
                /* Use an extended w/a on ivb+ if signalling from other rings */
-               i915_semaphore_is_enabled(dev_priv) ?
+               i915.semaphores ?
                hweight32(INTEL_INFO(dev_priv)->ring_mask) - 1 :
                0;
        int len, ret;
index 6daaf4ecd2da501827a203c255dc4882d316e5fc..4d39c72846059d02bc88a3b23fc693a40813a18d 100644 (file)
@@ -863,7 +863,7 @@ static void gen8_record_semaphore_state(struct drm_i915_private *dev_priv,
        struct intel_engine_cs *to;
        enum intel_engine_id id;
 
-       if (!i915_semaphore_is_enabled(dev_priv))
+       if (!i915.semaphores)
                return;
 
        if (!error->semaphore_obj)
index b9638e19d3048ad940df3f3024f3c57e582a4f1c..b844e6984ae7fb18496e4ccf400cc83229f7121a 100644 (file)
@@ -2679,7 +2679,7 @@ static void intel_ring_init_semaphores(struct drm_i915_private *dev_priv,
        struct drm_i915_gem_object *obj;
        int ret, i;
 
-       if (!i915_semaphore_is_enabled(dev_priv))
+       if (!i915.semaphores)
                return;
 
        if (INTEL_GEN(dev_priv) >= 8 && !dev_priv->semaphore_obj) {
@@ -2700,7 +2700,7 @@ static void intel_ring_init_semaphores(struct drm_i915_private *dev_priv,
                }
        }
 
-       if (!i915_semaphore_is_enabled(dev_priv))
+       if (!i915.semaphores)
                return;
 
        if (INTEL_GEN(dev_priv) >= 8) {
@@ -2838,7 +2838,7 @@ int intel_init_render_ring_buffer(struct intel_engine_cs *engine)
                engine->init_context = intel_rcs_ctx_init;
                engine->add_request = gen8_render_add_request;
                engine->flush = gen8_render_ring_flush;
-               if (i915_semaphore_is_enabled(dev_priv))
+               if (i915.semaphores)
                        engine->semaphore.signal = gen8_rcs_signal;
        } else if (INTEL_GEN(dev_priv) >= 6) {
                engine->init_context = intel_rcs_ctx_init;