drm/i915: Cleanup after failed initialization of ringbuffers
authorChris Wilson <chris@chris-wilson.co.uk>
Thu, 27 May 2010 12:18:22 +0000 (13:18 +0100)
committerEric Anholt <eric@anholt.net>
Fri, 28 May 2010 18:01:02 +0000 (11:01 -0700)
The callers expect us to cleanup any partially initialised structures
before reporting the error.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Eric Anholt <eric@anholt.net>
drivers/gpu/drm/i915/i915_gem.c

index f84c8e982dcb398c810eb915bcd5c352686419a0..42866c01540dc5e2bae4cec6d7dae85520c1c2fd 100644 (file)
@@ -4632,23 +4632,40 @@ i915_gem_init_ringbuffer(struct drm_device *dev)
 {
        drm_i915_private_t *dev_priv = dev->dev_private;
        int ret;
+
        dev_priv->render_ring = render_ring;
+
        if (!I915_NEED_GFX_HWS(dev)) {
                dev_priv->render_ring.status_page.page_addr
                        = dev_priv->status_page_dmah->vaddr;
                memset(dev_priv->render_ring.status_page.page_addr,
                                0, PAGE_SIZE);
        }
+
        if (HAS_PIPE_CONTROL(dev)) {
                ret = i915_gem_init_pipe_control(dev);
                if (ret)
                        return ret;
        }
+
        ret = intel_init_ring_buffer(dev, &dev_priv->render_ring);
-       if (!ret && HAS_BSD(dev)) {
+       if (ret)
+               goto cleanup_pipe_control;
+
+       if (HAS_BSD(dev)) {
                dev_priv->bsd_ring = bsd_ring;
                ret = intel_init_ring_buffer(dev, &dev_priv->bsd_ring);
+               if (ret)
+                       goto cleanup_render_ring;
        }
+
+       return 0;
+
+cleanup_render_ring:
+       intel_cleanup_ring_buffer(dev, &dev_priv->render_ring);
+cleanup_pipe_control:
+       if (HAS_PIPE_CONTROL(dev))
+               i915_gem_cleanup_pipe_control(dev);
        return ret;
 }