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

Commit a01cb37a authored by Chris Wilson's avatar Chris Wilson
Browse files

drm/i915: Remove i915_vma_create from VMA API



With the introduce of i915_vma_instance() for obtaining the VMA
singleton for a (obj, vm, view) tuple, we can remove the
i915_vma_create() in favour of a single entry point. We do incur a
lookup onto an empty tree, but the i915_vma_create() were being called
infrequently and during initialisation, so the small overhead is
negligible.

v2: Drop the i915_ prefix from the now static vma_create() function

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/20170116152131.18089-4-chris@chris-wilson.co.uk
parent 4ea9527c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -269,7 +269,7 @@ __create_hw_context(struct drm_i915_private *dev_priv,
			goto err_out;
		}

		vma = i915_vma_create(obj, &dev_priv->ggtt.base, NULL);
		vma = i915_vma_instance(obj, &dev_priv->ggtt.base, NULL);
		if (IS_ERR(vma)) {
			i915_gem_object_put(obj);
			ret = PTR_ERR(vma);
+1 −1
Original line number Diff line number Diff line
@@ -200,7 +200,7 @@ int i915_gem_render_state_init(struct intel_engine_cs *engine)
		goto err_free;
	}

	so->vma = i915_vma_create(obj, &engine->i915->ggtt.base, NULL);
	so->vma = i915_vma_instance(obj, &engine->i915->ggtt.base, NULL);
	if (IS_ERR(so->vma)) {
		ret = PTR_ERR(so->vma);
		goto err_obj;
+1 −1
Original line number Diff line number Diff line
@@ -566,7 +566,7 @@ struct i915_vma *intel_guc_allocate_vma(struct intel_guc *guc, u32 size)
	if (IS_ERR(obj))
		return ERR_CAST(obj);

	vma = i915_vma_create(obj, &dev_priv->ggtt.base, NULL);
	vma = i915_vma_instance(obj, &dev_priv->ggtt.base, NULL);
	if (IS_ERR(vma))
		goto err;

+4 −31
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ i915_vma_retire(struct i915_gem_active *active,
}

static struct i915_vma *
__i915_vma_create(struct drm_i915_gem_object *obj,
vma_create(struct drm_i915_gem_object *obj,
	   struct i915_address_space *vm,
	   const struct i915_ggtt_view *view)
{
@@ -77,8 +77,6 @@ __i915_vma_create(struct drm_i915_gem_object *obj,
	struct rb_node *rb, **p;
	int i;

	GEM_BUG_ON(vm->closed);

	vma = kmem_cache_zalloc(to_i915(obj->base.dev)->vmas, GFP_KERNEL);
	if (vma == NULL)
		return ERR_PTR(-ENOMEM);
@@ -186,31 +184,6 @@ i915_vma_lookup(struct drm_i915_gem_object *obj,
	return NULL;
}

/**
 * i915_vma_create - creates a VMA
 * @obj: parent &struct drm_i915_gem_object to be mapped
 * @vm: address space in which the mapping is located
 * @view: additional mapping requirements
 *
 * i915_vma_create() allocates a new VMA of the @obj in the @vm with
 * @view characteristics.
 *
 * Must be called with struct_mutex held.
 *
 * Returns the vma if found, or an error pointer.
 */
struct i915_vma *
i915_vma_create(struct drm_i915_gem_object *obj,
		struct i915_address_space *vm,
		const struct i915_ggtt_view *view)
{
	lockdep_assert_held(&obj->base.dev->struct_mutex);
	GEM_BUG_ON(view && !i915_is_ggtt(vm));
	GEM_BUG_ON(i915_vma_lookup(obj, vm, view));

	return __i915_vma_create(obj, vm, view);
}

/**
 * i915_vma_instance - return the singleton instance of the VMA
 * @obj: parent &struct drm_i915_gem_object to be mapped
@@ -239,7 +212,7 @@ i915_vma_instance(struct drm_i915_gem_object *obj,

	vma = i915_vma_lookup(obj, vm, view);
	if (!vma)
		vma = i915_vma_create(obj, vm, view);
		vma = vma_create(obj, vm, view);

	GEM_BUG_ON(!IS_ERR(vma) && i915_vma_is_closed(vma));
	GEM_BUG_ON(!IS_ERR(vma) && i915_vma_compare(vma, vm, view));
+0 −5
Original line number Diff line number Diff line
@@ -111,11 +111,6 @@ struct i915_vma {
	struct drm_i915_gem_exec_object2 *exec_entry;
};

struct i915_vma *
i915_vma_create(struct drm_i915_gem_object *obj,
		struct i915_address_space *vm,
		const struct i915_ggtt_view *view);

struct i915_vma *
i915_vma_lookup(struct drm_i915_gem_object *obj,
		struct i915_address_space *vm,
Loading