drm/i915: Define an engine class enum for the uABI
[sfrench/cifs-2.6.git] / drivers / gpu / drm / i915 / intel_engine_cs.c
index 6895a90af008369fb1aeecd863ca90ef04782dbf..bded9c40dbd53313024d629e23d37f16a87cf757 100644 (file)
@@ -50,6 +50,8 @@ struct engine_class_info {
        const char *name;
        int (*init_legacy)(struct intel_engine_cs *engine);
        int (*init_execlists)(struct intel_engine_cs *engine);
+
+       u8 uabi_class;
 };
 
 static const struct engine_class_info intel_engine_classes[] = {
@@ -57,21 +59,25 @@ static const struct engine_class_info intel_engine_classes[] = {
                .name = "rcs",
                .init_execlists = logical_render_ring_init,
                .init_legacy = intel_init_render_ring_buffer,
+               .uabi_class = I915_ENGINE_CLASS_RENDER,
        },
        [COPY_ENGINE_CLASS] = {
                .name = "bcs",
                .init_execlists = logical_xcs_ring_init,
                .init_legacy = intel_init_blt_ring_buffer,
+               .uabi_class = I915_ENGINE_CLASS_COPY,
        },
        [VIDEO_DECODE_CLASS] = {
                .name = "vcs",
                .init_execlists = logical_xcs_ring_init,
                .init_legacy = intel_init_bsd_ring_buffer,
+               .uabi_class = I915_ENGINE_CLASS_VIDEO,
        },
        [VIDEO_ENHANCEMENT_CLASS] = {
                .name = "vecs",
                .init_execlists = logical_xcs_ring_init,
                .init_legacy = intel_init_vebox_ring_buffer,
+               .uabi_class = I915_ENGINE_CLASS_VIDEO_ENHANCE,
        },
 };
 
@@ -213,13 +219,15 @@ intel_engine_setup(struct drm_i915_private *dev_priv,
        WARN_ON(snprintf(engine->name, sizeof(engine->name), "%s%u",
                         class_info->name, info->instance) >=
                sizeof(engine->name));
-       engine->uabi_id = info->uabi_id;
        engine->hw_id = engine->guc_id = info->hw_id;
        engine->mmio_base = info->mmio_base;
        engine->irq_shift = info->irq_shift;
        engine->class = info->class;
        engine->instance = info->instance;
 
+       engine->uabi_id = info->uabi_id;
+       engine->uabi_class = class_info->uabi_class;
+
        engine->context_size = __intel_engine_context_size(dev_priv,
                                                           engine->class);
        if (WARN_ON(engine->context_size > BIT(20)))
@@ -1320,6 +1328,9 @@ static int cnl_init_workarounds(struct intel_engine_cs *engine)
        WA_SET_FIELD_MASKED(GEN8_CS_CHICKEN1, GEN9_PREEMPT_GPGPU_LEVEL_MASK,
                            GEN9_PREEMPT_GPGPU_COMMAND_LEVEL);
 
+       /* ReadHitWriteOnlyDisable: cnl */
+       WA_SET_BIT_MASKED(SLICE_UNIT_LEVEL_CLKGATE, RCCUNIT_CLKGATE_DIS);
+
        /* WaEnablePreemptionGranularityControlByUMD:cnl */
        I915_WRITE(GEN7_FF_SLICE_CS_CHICKEN1,
                   _MASKED_BIT_ENABLE(GEN9_FFSC_PERCTX_PREEMPT_CTRL));
@@ -1614,25 +1625,27 @@ void intel_engines_park(struct drm_i915_private *i915)
        enum intel_engine_id id;
 
        for_each_engine(engine, i915, id) {
+               /* Flush the residual irq tasklets first. */
+               intel_engine_disarm_breadcrumbs(engine);
+               tasklet_kill(&engine->execlists.irq_tasklet);
+
                /*
                 * We are committed now to parking the engines, make sure there
                 * will be no more interrupts arriving later and the engines
                 * are truly idle.
                 */
-               if (!intel_engine_is_idle(engine)) {
+               if (wait_for(intel_engine_is_idle(engine), 10)) {
                        struct drm_printer p = drm_debug_printer(__func__);
 
-                       DRM_ERROR("%s is not idle before parking\n",
-                                 engine->name);
+                       dev_err(i915->drm.dev,
+                               "%s is not idle before parking\n",
+                               engine->name);
                        intel_engine_dump(engine, &p);
                }
 
                if (engine->park)
                        engine->park(engine);
 
-               intel_engine_disarm_breadcrumbs(engine);
-               tasklet_kill(&engine->execlists.irq_tasklet);
-
                i915_gem_batch_pool_fini(&engine->batch_pool);
                engine->execlists.no_priolist = false;
        }
@@ -1834,6 +1847,7 @@ void intel_engine_dump(struct intel_engine_cs *engine, struct drm_printer *m)
        }
        spin_unlock_irq(&b->rb_lock);
 
+       drm_printf(m, "Idle? %s\n", yesno(intel_engine_is_idle(engine)));
        drm_printf(m, "\n");
 }