Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fe3db79b authored by Chris Wilson's avatar Chris Wilson Committed by Joonas Lahtinen
Browse files

drm/i915: Propagate error from drm_gem_object_init()



Propagate the real error from drm_gem_object_init(). Note this also
fixes some confusion in the error return from i915_gem_alloc_object...

v2:
(Matthew Auld)
  - updated new users of gem_alloc_object from latest drm-nightly
  - replaced occurrences of IS_ERR_OR_NULL() with IS_ERR()
v3:
(Joonas Lahtinen)
  - fix double "From:" in commit message
  - add goto teardown path
v4:
(Matthew Auld)
  - rebase with i915_gem_alloc_object name change

Signed-off-by: default avatarMatthew Auld <matthew.auld@intel.com>
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1461587533-8841-1-git-send-email-matthew.auld@intel.com


[Joonas: Removed spurious " = NULL" from _init() function]
Signed-off-by: default avatarJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
parent bcbdb6d0
Loading
Loading
Loading
Loading
+13 −8
Original line number Diff line number Diff line
@@ -382,8 +382,8 @@ i915_gem_create(struct drm_file *file,

	/* Allocate the new object */
	obj = i915_gem_object_create(dev, size);
	if (obj == NULL)
		return -ENOMEM;
	if (IS_ERR(obj))
		return PTR_ERR(obj);

	ret = drm_gem_handle_create(file, &obj->base, &handle);
	/* drop reference from allocate - handle holds it now */
@@ -4501,15 +4501,15 @@ struct drm_i915_gem_object *i915_gem_object_create(struct drm_device *dev,
	struct drm_i915_gem_object *obj;
	struct address_space *mapping;
	gfp_t mask;
	int ret;

	obj = i915_gem_object_alloc(dev);
	if (obj == NULL)
		return NULL;
		return ERR_PTR(-ENOMEM);

	if (drm_gem_object_init(dev, &obj->base, size) != 0) {
		i915_gem_object_free(obj);
		return NULL;
	}
	ret = drm_gem_object_init(dev, &obj->base, size);
	if (ret)
		goto fail;

	mask = GFP_HIGHUSER | __GFP_RECLAIMABLE;
	if (IS_CRESTLINE(dev) || IS_BROADWATER(dev)) {
@@ -4546,6 +4546,11 @@ struct drm_i915_gem_object *i915_gem_object_create(struct drm_device *dev,
	trace_i915_gem_object_create(obj);

	return obj;

fail:
	i915_gem_object_free(obj);

	return ERR_PTR(ret);
}

static bool discard_backing_storage(struct drm_i915_gem_object *obj)
@@ -5351,7 +5356,7 @@ i915_gem_object_create_from_data(struct drm_device *dev,
	int ret;

	obj = i915_gem_object_create(dev, round_up(size, PAGE_SIZE));
	if (IS_ERR_OR_NULL(obj))
	if (IS_ERR(obj))
		return obj;

	ret = i915_gem_object_set_to_cpu_domain(obj, true);
+2 −2
Original line number Diff line number Diff line
@@ -135,8 +135,8 @@ i915_gem_batch_pool_get(struct i915_gem_batch_pool *pool,
		int ret;

		obj = i915_gem_object_create(pool->dev, size);
		if (obj == NULL)
			return ERR_PTR(-ENOMEM);
		if (IS_ERR(obj))
			return obj;

		ret = i915_gem_object_get_pages(obj);
		if (ret)
+2 −2
Original line number Diff line number Diff line
@@ -179,8 +179,8 @@ i915_gem_alloc_context_obj(struct drm_device *dev, size_t size)
	int ret;

	obj = i915_gem_object_create(dev, size);
	if (obj == NULL)
		return ERR_PTR(-ENOMEM);
	if (IS_ERR(obj))
		return obj;

	/*
	 * Try to make the context utilize L3 as well as LLC.
+2 −2
Original line number Diff line number Diff line
@@ -58,8 +58,8 @@ static int render_state_init(struct render_state *so, struct drm_device *dev)
		return -EINVAL;

	so->obj = i915_gem_object_create(dev, 4096);
	if (so->obj == NULL)
		return -ENOMEM;
	if (IS_ERR(so->obj))
		return PTR_ERR(so->obj);

	ret = i915_gem_obj_ggtt_pin(so->obj, 4096, 0);
	if (ret)
+1 −1
Original line number Diff line number Diff line
@@ -588,7 +588,7 @@ static struct drm_i915_gem_object *gem_allocate_guc_obj(struct drm_device *dev,
	struct drm_i915_gem_object *obj;

	obj = i915_gem_object_create(dev, size);
	if (!obj)
	if (IS_ERR(obj))
		return NULL;

	if (i915_gem_object_get_pages(obj)) {
Loading