Commit d2cad535 authored by Chris Wilson's avatar Chris Wilson

drm/i915: Consolidate common error handling in intel_pin_and_map_ringbuffer_obj

After we pin the ringbuffer into the GGTT, all error paths need to unpin
it again. Move this common step into one block, and make the unable to
iomap error code consistent (i.e. treat it as out of memory to avoid
confusing it with a invalid argument).
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1460113874-17366-3-git-send-email-chris@chris-wilson.co.uk
parent 6d19245f
...@@ -2126,15 +2126,13 @@ int intel_pin_and_map_ringbuffer_obj(struct drm_device *dev, ...@@ -2126,15 +2126,13 @@ int intel_pin_and_map_ringbuffer_obj(struct drm_device *dev,
return ret; return ret;
ret = i915_gem_object_set_to_cpu_domain(obj, true); ret = i915_gem_object_set_to_cpu_domain(obj, true);
if (ret) { if (ret)
i915_gem_object_ggtt_unpin(obj); goto err_unpin;
return ret;
}
ringbuf->virtual_start = vmap_obj(obj); ringbuf->virtual_start = vmap_obj(obj);
if (ringbuf->virtual_start == NULL) { if (ringbuf->virtual_start == NULL) {
i915_gem_object_ggtt_unpin(obj); ret = -ENOMEM;
return -ENOMEM; goto err_unpin;
} }
} else { } else {
ret = i915_gem_obj_ggtt_pin(obj, PAGE_SIZE, PIN_MAPPABLE); ret = i915_gem_obj_ggtt_pin(obj, PAGE_SIZE, PIN_MAPPABLE);
...@@ -2142,10 +2140,8 @@ int intel_pin_and_map_ringbuffer_obj(struct drm_device *dev, ...@@ -2142,10 +2140,8 @@ int intel_pin_and_map_ringbuffer_obj(struct drm_device *dev,
return ret; return ret;
ret = i915_gem_object_set_to_gtt_domain(obj, true); ret = i915_gem_object_set_to_gtt_domain(obj, true);
if (ret) { if (ret)
i915_gem_object_ggtt_unpin(obj); goto err_unpin;
return ret;
}
/* Access through the GTT requires the device to be awake. */ /* Access through the GTT requires the device to be awake. */
assert_rpm_wakelock_held(dev_priv); assert_rpm_wakelock_held(dev_priv);
...@@ -2153,14 +2149,17 @@ int intel_pin_and_map_ringbuffer_obj(struct drm_device *dev, ...@@ -2153,14 +2149,17 @@ int intel_pin_and_map_ringbuffer_obj(struct drm_device *dev,
ringbuf->virtual_start = ioremap_wc(ggtt->mappable_base + ringbuf->virtual_start = ioremap_wc(ggtt->mappable_base +
i915_gem_obj_ggtt_offset(obj), ringbuf->size); i915_gem_obj_ggtt_offset(obj), ringbuf->size);
if (ringbuf->virtual_start == NULL) { if (ringbuf->virtual_start == NULL) {
i915_gem_object_ggtt_unpin(obj); ret = -ENOMEM;
return -EINVAL; goto err_unpin;
} }
} }
ringbuf->vma = i915_gem_obj_to_ggtt(obj); ringbuf->vma = i915_gem_obj_to_ggtt(obj);
return 0; return 0;
err_unpin:
i915_gem_object_ggtt_unpin(obj);
return ret;
} }
static void intel_destroy_ringbuffer_obj(struct intel_ringbuffer *ringbuf) static void intel_destroy_ringbuffer_obj(struct intel_ringbuffer *ringbuf)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment