Commit d8be1357 authored by Maarten Lankhorst's avatar Maarten Lankhorst

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
...@@ -210,9 +210,13 @@ static inline int i915_gem_object_lock_interruptible(struct drm_i915_gem_object ...@@ -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); 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)
{ {
return dma_resv_trylock(obj->base.resv); 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) static inline void i915_gem_object_unlock(struct drm_i915_gem_object *obj)
......
...@@ -216,7 +216,7 @@ i915_gem_shrink(struct i915_gem_ww_ctx *ww, ...@@ -216,7 +216,7 @@ i915_gem_shrink(struct i915_gem_ww_ctx *ww,
/* May arrive from get_pages on another bo */ /* May arrive from get_pages on another bo */
if (!ww) { if (!ww) {
if (!i915_gem_object_trylock(obj)) if (!i915_gem_object_trylock(obj, NULL))
goto skip; goto skip;
} else { } else {
err = i915_gem_object_lock(obj, ww); err = i915_gem_object_lock(obj, ww);
...@@ -410,7 +410,7 @@ i915_gem_shrinker_vmap(struct notifier_block *nb, unsigned long event, void *ptr ...@@ -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)) if (!vma->iomap || i915_vma_is_active(vma))
continue; continue;
if (!i915_gem_object_trylock(obj)) if (!i915_gem_object_trylock(obj, NULL))
continue; continue;
if (__i915_vma_unbind(vma) == 0) if (__i915_vma_unbind(vma) == 0)
......
...@@ -656,7 +656,7 @@ static int __i915_gem_object_create_stolen(struct intel_memory_region *mem, ...@@ -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; cache_level = HAS_LLC(mem->i915) ? I915_CACHE_LLC : I915_CACHE_NONE;
i915_gem_object_set_cache_coherency(obj, cache_level); 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; return -EBUSY;
i915_gem_object_init_memory_region(obj, mem); i915_gem_object_init_memory_region(obj, mem);
......
...@@ -26,7 +26,7 @@ static void dbg_poison_ce(struct intel_context *ce) ...@@ -26,7 +26,7 @@ static void dbg_poison_ce(struct intel_context *ce)
int type = i915_coherent_map_type(ce->engine->i915, obj, true); int type = i915_coherent_map_type(ce->engine->i915, obj, true);
void *map; void *map;
if (!i915_gem_object_trylock(obj)) if (!i915_gem_object_trylock(obj, NULL))
return; return;
map = i915_gem_object_pin_map(obj, type); map = i915_gem_object_pin_map(obj, type);
......
...@@ -17,7 +17,7 @@ static int mock_timeline_pin(struct intel_timeline *tl) ...@@ -17,7 +17,7 @@ static int mock_timeline_pin(struct intel_timeline *tl)
{ {
int err; 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; return -EBUSY;
err = intel_timeline_pin_map(tl); err = intel_timeline_pin_map(tl);
......
...@@ -465,7 +465,7 @@ create_init_lmem_internal(struct intel_gt *gt, size_t sz, bool try_lmem) ...@@ -465,7 +465,7 @@ create_init_lmem_internal(struct intel_gt *gt, size_t sz, bool try_lmem)
return obj; return obj;
} }
i915_gem_object_trylock(obj); i915_gem_object_trylock(obj, NULL);
err = i915_gem_object_pin_pages(obj); err = i915_gem_object_pin_pages(obj);
if (err) { if (err) {
i915_gem_object_unlock(obj); i915_gem_object_unlock(obj);
......
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