diff options
| author | Thomas Hellström <thomas.hellstrom@linux.intel.com> | 2025-06-23 17:53:13 +0200 |
|---|---|---|
| committer | Thomas Hellström <thomas.hellstrom@linux.intel.com> | 2025-06-26 17:20:00 +0200 |
| commit | bb8aa27eff6f3376242da37c2d02b9dcc66934b1 (patch) | |
| tree | b4f208dc05e9ba978be73fac01f39d9bcebe922c /include | |
| parent | e1e85eb0a977f1eb1d17d4627aceaa8eeac37159 (diff) | |
drm/ttm, drm_xe, Implement ttm_lru_walk_for_evict() using the guarded LRU iteration
To avoid duplicating the tricky bo locking implementation,
Implement ttm_lru_walk_for_evict() using the guarded bo LRU iteration.
To facilitate this, support ticketlocking from the guarded bo LRU
iteration.
v2:
- Clean up some static function interfaces (Christian König)
- Fix Handling -EALREADY from ticketlocking in the loop by
skipping to the next item. (Intel CI)
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Link: https://lore.kernel.org/r/20250623155313.4901-4-thomas.hellstrom@linux.intel.com
Diffstat (limited to 'include')
| -rw-r--r-- | include/drm/ttm/ttm_bo.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/include/drm/ttm/ttm_bo.h b/include/drm/ttm/ttm_bo.h index ab9a6b343a53..894ff7ccd68e 100644 --- a/include/drm/ttm/ttm_bo.h +++ b/include/drm/ttm/ttm_bo.h @@ -529,10 +529,15 @@ class_ttm_bo_lru_cursor_lock_ptr(class_ttm_bo_lru_cursor_t *_T) * up at looping termination, even if terminated prematurely by, for * example a return or break statement. Exiting the loop will also unlock * (if needed) and unreference @_bo. + * + * Return: If locking of a bo returns an error, then iteration is terminated + * and @_bo is set to a corresponding error pointer. It's illegal to + * dereference @_bo after loop exit. */ #define ttm_bo_lru_for_each_reserved_guarded(_cursor, _man, _arg, _bo) \ scoped_guard(ttm_bo_lru_cursor, _cursor, _man, _arg) \ - for ((_bo) = ttm_bo_lru_cursor_first(_cursor); (_bo); \ - (_bo) = ttm_bo_lru_cursor_next(_cursor)) + for ((_bo) = ttm_bo_lru_cursor_first(_cursor); \ + !IS_ERR_OR_NULL(_bo); \ + (_bo) = ttm_bo_lru_cursor_next(_cursor)) #endif |
