drm/i915: Flatten engine init control flow
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 19 Nov 2014 23:33:08 +0000 (00:33 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 3 Dec 2014 08:35:29 +0000 (09:35 +0100)
Now that sanity prevails and we have the clean split between software
init and starting the engines we can drop all the "have we allocate
this struct already?" nonsense.

Execlist code could benefit quite a bit more still, but that's for
another patch.

Reviewed-by: Dave Gordon <david.s.gordon@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
drivers/gpu/drm/i915/i915_cmd_parser.c
drivers/gpu/drm/i915/intel_lrc.c
drivers/gpu/drm/i915/intel_ringbuffer.c

index 22c992a78ac6a86dd976bbe106c140fa61814b67..6e9eac4b175790a9d1e3cb19545fc8368a144a7f 100644 (file)
@@ -716,13 +716,13 @@ int i915_cmd_parser_init_ring(struct intel_engine_cs *ring)
        BUG_ON(!validate_cmds_sorted(ring, cmd_tables, cmd_table_count));
        BUG_ON(!validate_regs_sorted(ring));
 
-       if (hash_empty(ring->cmd_hash)) {
-               ret = init_hash_table(ring, cmd_tables, cmd_table_count);
-               if (ret) {
-                       DRM_ERROR("CMD: cmd_parser_init failed!\n");
-                       fini_hash_table(ring);
-                       return ret;
-               }
+       WARN_ON(!hash_empty(ring->cmd_hash));
+
+       ret = init_hash_table(ring, cmd_tables, cmd_table_count);
+       if (ret) {
+               DRM_ERROR("CMD: cmd_parser_init failed!\n");
+               fini_hash_table(ring);
+               return ret;
        }
 
        ring->needs_cmd_parser = true;
index 4ffb08cca98376d8895d8bd418f4ec10e01194f5..d6f82532ac1d6219a782d5607bda7bcb30ebec1b 100644 (file)
@@ -1833,8 +1833,7 @@ int intel_lr_context_deferred_create(struct intel_context *ctx,
        int ret;
 
        WARN_ON(ctx->legacy_hw_ctx.rcs_state != NULL);
-       if (ctx->engine[ring->id].state)
-               return 0;
+       WARN_ON(ctx->engine[ring->id].state);
 
        context_size = round_up(get_lr_context_size(ring), 4096);
 
index 590b7c38292f8d8cdf54dbf592c55cc15e5c65c6..79b4ca5dc65f291067554e6a40e0ec13ce69a9b8 100644 (file)
@@ -635,8 +635,7 @@ intel_init_pipe_control(struct intel_engine_cs *ring)
 {
        int ret;
 
-       if (ring->scratch.obj)
-               return 0;
+       WARN_ON(ring->scratch.obj);
 
        ring->scratch.obj = i915_gem_alloc_object(ring->dev, 4096);
        if (ring->scratch.obj == NULL) {
@@ -1799,15 +1798,15 @@ int intel_alloc_ringbuffer_obj(struct drm_device *dev,
 static int intel_init_ring_buffer(struct drm_device *dev,
                                  struct intel_engine_cs *ring)
 {
-       struct intel_ringbuffer *ringbuf = ring->buffer;
+       struct intel_ringbuffer *ringbuf;
        int ret;
 
-       if (ringbuf == NULL) {
-               ringbuf = kzalloc(sizeof(*ringbuf), GFP_KERNEL);
-               if (!ringbuf)
-                       return -ENOMEM;
-               ring->buffer = ringbuf;
-       }
+       WARN_ON(ring->buffer);
+
+       ringbuf = kzalloc(sizeof(*ringbuf), GFP_KERNEL);
+       if (!ringbuf)
+               return -ENOMEM;
+       ring->buffer = ringbuf;
 
        ring->dev = dev;
        INIT_LIST_HEAD(&ring->active_list);
@@ -1830,21 +1829,21 @@ static int intel_init_ring_buffer(struct drm_device *dev,
                        goto error;
        }
 
-       if (ringbuf->obj == NULL) {
-               ret = intel_alloc_ringbuffer_obj(dev, ringbuf);
-               if (ret) {
-                       DRM_ERROR("Failed to allocate ringbuffer %s: %d\n",
-                                       ring->name, ret);
-                       goto error;
-               }
+       WARN_ON(ringbuf->obj);
 
-               ret = intel_pin_and_map_ringbuffer_obj(dev, ringbuf);
-               if (ret) {
-                       DRM_ERROR("Failed to pin and map ringbuffer %s: %d\n",
-                                       ring->name, ret);
-                       intel_destroy_ringbuffer_obj(ringbuf);
-                       goto error;
-               }
+       ret = intel_alloc_ringbuffer_obj(dev, ringbuf);
+       if (ret) {
+               DRM_ERROR("Failed to allocate ringbuffer %s: %d\n",
+                               ring->name, ret);
+               goto error;
+       }
+
+       ret = intel_pin_and_map_ringbuffer_obj(dev, ringbuf);
+       if (ret) {
+               DRM_ERROR("Failed to pin and map ringbuffer %s: %d\n",
+                               ring->name, ret);
+               intel_destroy_ringbuffer_obj(ringbuf);
+               goto error;
        }
 
        /* Workaround an erratum on the i830 which causes a hang if