diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-08-07 06:01:34 -0400 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2010-08-09 14:24:35 -0400 |
commit | dd785e35cb3c430c2290d351e67715864f7e5db5 (patch) | |
tree | 45b4b4e1b360e49afe53f171109453b89ee92649 | |
parent | debcaddcbd92387137b87f2c1c640571753915e0 (diff) |
drm/i915/ringbuffer: Set ring->gem_buffer = NULL on init unwind
The cleanup path for early abort failed to nullify the gem_buffer. The
likely consequence of this is zero, since a failure here should mean
aborting the module load.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Eric Anholt <eric@anholt.net>
-rw-r--r-- | drivers/gpu/drm/i915/intel_ringbuffer.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c index 3a0242557220..7823b9648176 100644 --- a/drivers/gpu/drm/i915/intel_ringbuffer.c +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c | |||
@@ -608,9 +608,10 @@ err: | |||
608 | int intel_init_ring_buffer(struct drm_device *dev, | 608 | int intel_init_ring_buffer(struct drm_device *dev, |
609 | struct intel_ring_buffer *ring) | 609 | struct intel_ring_buffer *ring) |
610 | { | 610 | { |
611 | int ret; | ||
612 | struct drm_i915_gem_object *obj_priv; | 611 | struct drm_i915_gem_object *obj_priv; |
613 | struct drm_gem_object *obj; | 612 | struct drm_gem_object *obj; |
613 | int ret; | ||
614 | |||
614 | ring->dev = dev; | 615 | ring->dev = dev; |
615 | 616 | ||
616 | if (I915_NEED_GFX_HWS(dev)) { | 617 | if (I915_NEED_GFX_HWS(dev)) { |
@@ -623,16 +624,14 @@ int intel_init_ring_buffer(struct drm_device *dev, | |||
623 | if (obj == NULL) { | 624 | if (obj == NULL) { |
624 | DRM_ERROR("Failed to allocate ringbuffer\n"); | 625 | DRM_ERROR("Failed to allocate ringbuffer\n"); |
625 | ret = -ENOMEM; | 626 | ret = -ENOMEM; |
626 | goto cleanup; | 627 | goto err_hws; |
627 | } | 628 | } |
628 | 629 | ||
629 | ring->gem_object = obj; | 630 | ring->gem_object = obj; |
630 | 631 | ||
631 | ret = i915_gem_object_pin(obj, ring->alignment); | 632 | ret = i915_gem_object_pin(obj, ring->alignment); |
632 | if (ret != 0) { | 633 | if (ret) |
633 | drm_gem_object_unreference(obj); | 634 | goto err_unref; |
634 | goto cleanup; | ||
635 | } | ||
636 | 635 | ||
637 | obj_priv = to_intel_bo(obj); | 636 | obj_priv = to_intel_bo(obj); |
638 | ring->map.size = ring->size; | 637 | ring->map.size = ring->size; |
@@ -644,18 +643,14 @@ int intel_init_ring_buffer(struct drm_device *dev, | |||
644 | drm_core_ioremap_wc(&ring->map, dev); | 643 | drm_core_ioremap_wc(&ring->map, dev); |
645 | if (ring->map.handle == NULL) { | 644 | if (ring->map.handle == NULL) { |
646 | DRM_ERROR("Failed to map ringbuffer.\n"); | 645 | DRM_ERROR("Failed to map ringbuffer.\n"); |
647 | i915_gem_object_unpin(obj); | ||
648 | drm_gem_object_unreference(obj); | ||
649 | ret = -EINVAL; | 646 | ret = -EINVAL; |
650 | goto cleanup; | 647 | goto err_unpin; |
651 | } | 648 | } |
652 | 649 | ||
653 | ring->virtual_start = ring->map.handle; | 650 | ring->virtual_start = ring->map.handle; |
654 | ret = ring->init(dev, ring); | 651 | ret = ring->init(dev, ring); |
655 | if (ret != 0) { | 652 | if (ret) |
656 | intel_cleanup_ring_buffer(dev, ring); | 653 | goto err_unmap; |
657 | return ret; | ||
658 | } | ||
659 | 654 | ||
660 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) | 655 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
661 | i915_kernel_lost_context(dev); | 656 | i915_kernel_lost_context(dev); |
@@ -669,7 +664,15 @@ int intel_init_ring_buffer(struct drm_device *dev, | |||
669 | INIT_LIST_HEAD(&ring->active_list); | 664 | INIT_LIST_HEAD(&ring->active_list); |
670 | INIT_LIST_HEAD(&ring->request_list); | 665 | INIT_LIST_HEAD(&ring->request_list); |
671 | return ret; | 666 | return ret; |
672 | cleanup: | 667 | |
668 | err_unmap: | ||
669 | drm_core_ioremapfree(&ring->map, dev); | ||
670 | err_unpin: | ||
671 | i915_gem_object_unpin(obj); | ||
672 | err_unref: | ||
673 | drm_gem_object_unreference(obj); | ||
674 | ring->gem_object = NULL; | ||
675 | err_hws: | ||
673 | cleanup_status_page(dev, ring); | 676 | cleanup_status_page(dev, ring); |
674 | return ret; | 677 | return ret; |
675 | } | 678 | } |