diff options
author | Dave Airlie <airlied@linux.ie> | 2009-01-14 23:03:07 -0500 |
---|---|---|
committer | Dave Airlie <airlied@linux.ie> | 2009-01-16 03:45:22 -0500 |
commit | 34b8686e12eaf9878aaab89e92222060c3e7cc48 (patch) | |
tree | 7e69761bdcb9865afd28a6e4d7b9ffcd77ce317d /drivers/gpu | |
parent | 71acb5eb8d95b371f4cdd88a47f3c83c870d1c8f (diff) |
drm/i915: lock correct mutex around object unreference.
This makes sure the mutex is held around the unreference.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/i915/intel_display.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 114a7a1a8740..31c3732b7a69 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c | |||
@@ -1016,8 +1016,8 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc, | |||
1016 | 1016 | ||
1017 | if (bo->size < width * height * 4) { | 1017 | if (bo->size < width * height * 4) { |
1018 | DRM_ERROR("buffer is to small\n"); | 1018 | DRM_ERROR("buffer is to small\n"); |
1019 | drm_gem_object_unreference(bo); | 1019 | ret = -ENOMEM; |
1020 | return -ENOMEM; | 1020 | goto fail; |
1021 | } | 1021 | } |
1022 | 1022 | ||
1023 | /* we only need to pin inside GTT if cursor is non-phy */ | 1023 | /* we only need to pin inside GTT if cursor is non-phy */ |
@@ -1025,16 +1025,14 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc, | |||
1025 | ret = i915_gem_object_pin(bo, PAGE_SIZE); | 1025 | ret = i915_gem_object_pin(bo, PAGE_SIZE); |
1026 | if (ret) { | 1026 | if (ret) { |
1027 | DRM_ERROR("failed to pin cursor bo\n"); | 1027 | DRM_ERROR("failed to pin cursor bo\n"); |
1028 | drm_gem_object_unreference(bo); | 1028 | goto fail; |
1029 | return ret; | ||
1030 | } | 1029 | } |
1031 | addr = obj_priv->gtt_offset; | 1030 | addr = obj_priv->gtt_offset; |
1032 | } else { | 1031 | } else { |
1033 | ret = i915_gem_attach_phys_object(dev, bo, (pipe == 0) ? I915_GEM_PHYS_CURSOR_0 : I915_GEM_PHYS_CURSOR_1); | 1032 | ret = i915_gem_attach_phys_object(dev, bo, (pipe == 0) ? I915_GEM_PHYS_CURSOR_0 : I915_GEM_PHYS_CURSOR_1); |
1034 | if (ret) { | 1033 | if (ret) { |
1035 | DRM_ERROR("failed to attach phys object\n"); | 1034 | DRM_ERROR("failed to attach phys object\n"); |
1036 | drm_gem_object_unreference(bo); | 1035 | goto fail; |
1037 | return ret; | ||
1038 | } | 1036 | } |
1039 | addr = obj_priv->phys_obj->handle->busaddr; | 1037 | addr = obj_priv->phys_obj->handle->busaddr; |
1040 | } | 1038 | } |
@@ -1054,13 +1052,20 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc, | |||
1054 | i915_gem_detach_phys_object(dev, intel_crtc->cursor_bo); | 1052 | i915_gem_detach_phys_object(dev, intel_crtc->cursor_bo); |
1055 | } else | 1053 | } else |
1056 | i915_gem_object_unpin(intel_crtc->cursor_bo); | 1054 | i915_gem_object_unpin(intel_crtc->cursor_bo); |
1055 | mutex_lock(&dev->struct_mutex); | ||
1057 | drm_gem_object_unreference(intel_crtc->cursor_bo); | 1056 | drm_gem_object_unreference(intel_crtc->cursor_bo); |
1057 | mutex_unlock(&dev->struct_mutex); | ||
1058 | } | 1058 | } |
1059 | 1059 | ||
1060 | intel_crtc->cursor_addr = addr; | 1060 | intel_crtc->cursor_addr = addr; |
1061 | intel_crtc->cursor_bo = bo; | 1061 | intel_crtc->cursor_bo = bo; |
1062 | 1062 | ||
1063 | return 0; | 1063 | return 0; |
1064 | fail: | ||
1065 | mutex_lock(&dev->struct_mutex); | ||
1066 | drm_gem_object_unreference(bo); | ||
1067 | mutex_unlock(&dev->struct_mutex); | ||
1068 | return ret; | ||
1064 | } | 1069 | } |
1065 | 1070 | ||
1066 | static int intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y) | 1071 | static int intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y) |