Skip to content

Commit d8be135

Browse files
committed
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: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Reviewed-by: Matthew Auld <matthew.auld@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20211216142749.1966107-12-maarten.lankhorst@linux.intel.com
1 parent be7612f commit d8be135

6 files changed

Lines changed: 12 additions & 8 deletions

File tree

drivers/gpu/drm/i915/gem/i915_gem_object.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,13 @@ static inline int i915_gem_object_lock_interruptible(struct drm_i915_gem_object
210210
return __i915_gem_object_lock(obj, ww, true);
211211
}
212212

213-
static inline bool i915_gem_object_trylock(struct drm_i915_gem_object *obj)
213+
static inline bool i915_gem_object_trylock(struct drm_i915_gem_object *obj,
214+
struct i915_gem_ww_ctx *ww)
214215
{
215-
return dma_resv_trylock(obj->base.resv);
216+
if (!ww)
217+
return dma_resv_trylock(obj->base.resv);
218+
else
219+
return ww_mutex_trylock(&obj->base.resv->lock, &ww->ctx);
216220
}
217221

218222
static inline void i915_gem_object_unlock(struct drm_i915_gem_object *obj)

drivers/gpu/drm/i915/gem/i915_gem_shrinker.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ i915_gem_shrink(struct i915_gem_ww_ctx *ww,
216216

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

413-
if (!i915_gem_object_trylock(obj))
413+
if (!i915_gem_object_trylock(obj, NULL))
414414
continue;
415415

416416
if (__i915_vma_unbind(vma) == 0)

drivers/gpu/drm/i915/gem/i915_gem_stolen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ static int __i915_gem_object_create_stolen(struct intel_memory_region *mem,
656656
cache_level = HAS_LLC(mem->i915) ? I915_CACHE_LLC : I915_CACHE_NONE;
657657
i915_gem_object_set_cache_coherency(obj, cache_level);
658658

659-
if (WARN_ON(!i915_gem_object_trylock(obj)))
659+
if (WARN_ON(!i915_gem_object_trylock(obj, NULL)))
660660
return -EBUSY;
661661

662662
i915_gem_object_init_memory_region(obj, mem);

drivers/gpu/drm/i915/gt/intel_engine_pm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static void dbg_poison_ce(struct intel_context *ce)
2626
int type = i915_coherent_map_type(ce->engine->i915, obj, true);
2727
void *map;
2828

29-
if (!i915_gem_object_trylock(obj))
29+
if (!i915_gem_object_trylock(obj, NULL))
3030
return;
3131

3232
map = i915_gem_object_pin_map(obj, type);

drivers/gpu/drm/i915/gt/mock_engine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ static int mock_timeline_pin(struct intel_timeline *tl)
1717
{
1818
int err;
1919

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

2323
err = intel_timeline_pin_map(tl);

drivers/gpu/drm/i915/gt/selftest_migrate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ create_init_lmem_internal(struct intel_gt *gt, size_t sz, bool try_lmem)
465465
return obj;
466466
}
467467

468-
i915_gem_object_trylock(obj);
468+
i915_gem_object_trylock(obj, NULL);
469469
err = i915_gem_object_pin_pages(obj);
470470
if (err) {
471471
i915_gem_object_unlock(obj);

0 commit comments

Comments
 (0)