drm/i915: Simplify intel_engines_init
authorTvrtko Ursulin <tvrtko.ursulin@intel.com>
Fri, 16 Jun 2017 13:03:38 +0000 (14:03 +0100)
committerTvrtko Ursulin <tvrtko.ursulin@intel.com>
Tue, 20 Jun 2017 11:42:12 +0000 (12:42 +0100)
We do not want to carry on over missing constructors and don't
need a duplicated engine mask checking which is already done
in the setup phase.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
drivers/gpu/drm/i915/intel_engine_cs.c

index a4487c5b7e37d209bb655cd629709b0ed03faa29..3b46c1f7b88b3894ff308eea34cf5a480121a128 100644 (file)
@@ -291,11 +291,9 @@ cleanup:
  */
 int intel_engines_init(struct drm_i915_private *dev_priv)
 {
-       struct intel_device_info *device_info = mkwrite_device_info(dev_priv);
        struct intel_engine_cs *engine;
        enum intel_engine_id id, err_id;
-       unsigned int mask = 0;
-       int err = 0;
+       int err;
 
        for_each_engine(engine, dev_priv, id) {
                const struct engine_class_info *class_info =
@@ -306,40 +304,30 @@ int intel_engines_init(struct drm_i915_private *dev_priv)
                        init = class_info->init_execlists;
                else
                        init = class_info->init_legacy;
-               if (!init) {
-                       kfree(engine);
-                       dev_priv->engine[id] = NULL;
-                       continue;
-               }
+
+               err = -EINVAL;
+               err_id = id;
+
+               if (GEM_WARN_ON(!init))
+                       goto cleanup;
 
                err = init(engine);
-               if (err) {
-                       err_id = id;
+               if (err)
                        goto cleanup;
-               }
 
                GEM_BUG_ON(!engine->submit_request);
-               mask |= ENGINE_MASK(id);
        }
 
-       /*
-        * Catch failures to update intel_engines table when the new engines
-        * are added to the driver by a warning and disabling the forgotten
-        * engines.
-        */
-       if (WARN_ON(mask != INTEL_INFO(dev_priv)->ring_mask))
-               device_info->ring_mask = mask;
-
-       device_info->num_rings = hweight32(mask);
-
        return 0;
 
 cleanup:
        for_each_engine(engine, dev_priv, id) {
-               if (id >= err_id)
+               if (id >= err_id) {
                        kfree(engine);
-               else
+                       dev_priv->engine[id] = NULL;
+               } else {
                        dev_priv->gt.cleanup_engine(engine);
+               }
        }
        return err;
 }