drm/i915: Use trylock instead of blocking lock for __i915_gem_free_objects.
authorMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Wed, 22 Dec 2021 15:56:22 +0000 (16:56 +0100)
committerMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Thu, 23 Dec 2021 11:30:27 +0000 (12:30 +0100)
commit6cb12fbda1c2e2fcb6d3adfe01f18eef6812e278
tree2421af963bdeee00ea0f3a5f9bd543d47a8b9376
parentc2ea703dcafccf18d7d77d8b68fb08c2d9842b7a
drm/i915: Use trylock instead of blocking lock for __i915_gem_free_objects.

Convert free_work into delayed_work, similar to ttm to allow converting the
blocking lock in __i915_gem_free_objects to a trylock.

Unlike ttm, the object should already be idle, as it's kept alive
by a reference through struct i915_vma->active, which is dropped
after all vma's are idle.

Because of this, we can use a no wait by default, or when the lock
is contested, we use ttm's 10 ms.

The trylock should only fail when the object is sharing it's resv with
other objects, and typically objects are not kept locked for a long
time, so we can safely retry on failure.

Fixes: be7612fd6665 ("drm/i915: Require object lock when freeing pages during destruction")
Testcase: igt/gem_exec_alignment/pi*
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211222155622.2960379-1-maarten.lankhorst@linux.intel.com
drivers/gpu/drm/i915/gem/i915_gem_object.c
drivers/gpu/drm/i915/i915_drv.h