Commit d8be1357 authored by Maarten Lankhorst's avatar Maarten Lankhorst
Browse files

drm/i915: Add ww ctx to i915_gem_object_trylock



This is required for i915_gem_evict_vm, to be able to evict the entire VM,
including objects that are already locked to the current ww ctx.

Signed-off-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211216142749.1966107-12-maarten.lankhorst@linux.intel.com
parent be7612fd
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -210,9 +210,13 @@ static inline int i915_gem_object_lock_interruptible(struct drm_i915_gem_object
	return __i915_gem_object_lock(obj, ww, true);
}

static inline bool i915_gem_object_trylock(struct drm_i915_gem_object *obj)
static inline bool i915_gem_object_trylock(struct drm_i915_gem_object *obj,
					   struct i915_gem_ww_ctx *ww)
{
	if (!ww)
		return dma_resv_trylock(obj->base.resv);
	else
		return ww_mutex_trylock(&obj->base.resv->lock, &ww->ctx);
}

static inline void i915_gem_object_unlock(struct drm_i915_gem_object *obj)
+2 −2
Original line number Diff line number Diff line
@@ -216,7 +216,7 @@ i915_gem_shrink(struct i915_gem_ww_ctx *ww,

			/* May arrive from get_pages on another bo */
			if (!ww) {
				if (!i915_gem_object_trylock(obj))
				if (!i915_gem_object_trylock(obj, NULL))
					goto skip;
			} else {
				err = i915_gem_object_lock(obj, ww);
@@ -410,7 +410,7 @@ i915_gem_shrinker_vmap(struct notifier_block *nb, unsigned long event, void *ptr
		if (!vma->iomap || i915_vma_is_active(vma))
			continue;

		if (!i915_gem_object_trylock(obj))
		if (!i915_gem_object_trylock(obj, NULL))
			continue;

		if (__i915_vma_unbind(vma) == 0)
+1 −1
Original line number Diff line number Diff line
@@ -656,7 +656,7 @@ static int __i915_gem_object_create_stolen(struct intel_memory_region *mem,
	cache_level = HAS_LLC(mem->i915) ? I915_CACHE_LLC : I915_CACHE_NONE;
	i915_gem_object_set_cache_coherency(obj, cache_level);

	if (WARN_ON(!i915_gem_object_trylock(obj)))
	if (WARN_ON(!i915_gem_object_trylock(obj, NULL)))
		return -EBUSY;

	i915_gem_object_init_memory_region(obj, mem);
+1 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ static void dbg_poison_ce(struct intel_context *ce)
		int type = i915_coherent_map_type(ce->engine->i915, obj, true);
		void *map;

		if (!i915_gem_object_trylock(obj))
		if (!i915_gem_object_trylock(obj, NULL))
			return;

		map = i915_gem_object_pin_map(obj, type);
+1 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ static int mock_timeline_pin(struct intel_timeline *tl)
{
	int err;

	if (WARN_ON(!i915_gem_object_trylock(tl->hwsp_ggtt->obj)))
	if (WARN_ON(!i915_gem_object_trylock(tl->hwsp_ggtt->obj, NULL)))
		return -EBUSY;

	err = intel_timeline_pin_map(tl);
Loading