Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/ttm, drm/xe: Modify the struct ttm_bo_lru_walk_cursor initialization

Instead of the struct ttm_operation_ctx, Pass a struct ttm_lru_walk_arg
to enable us to easily extend the walk functionality, and to
implement ttm_lru_walk_for_evict() using the guarded LRU iteration.

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-3-thomas.hellstrom@linux.intel.com

+15 -14
+5 -5
drivers/gpu/drm/ttm/ttm_bo_util.c
··· 958 958 * ttm_bo_lru_cursor_init() - Initialize a struct ttm_bo_lru_cursor 959 959 * @curs: The ttm_bo_lru_cursor to initialize. 960 960 * @man: The ttm resource_manager whose LRU lists to iterate over. 961 - * @ctx: The ttm_operation_ctx to govern the locking. 961 + * @arg: The ttm_lru_walk_arg to govern the walk. 962 962 * 963 963 * Initialize a struct ttm_bo_lru_cursor. Currently only trylocking 964 964 * or prelocked buffer objects are available as detailed by 965 - * @ctx::resv and @ctx::allow_res_evict. Ticketlocking is not 965 + * @arg->ctx.resv and @arg->ctx.allow_res_evict. Ticketlocking is not 966 966 * supported. 967 967 * 968 968 * Return: Pointer to @curs. The function does not fail. ··· 970 970 struct ttm_bo_lru_cursor * 971 971 ttm_bo_lru_cursor_init(struct ttm_bo_lru_cursor *curs, 972 972 struct ttm_resource_manager *man, 973 - struct ttm_operation_ctx *ctx) 973 + struct ttm_lru_walk_arg *arg) 974 974 { 975 975 memset(curs, 0, sizeof(*curs)); 976 976 ttm_resource_cursor_init(&curs->res_curs, man); 977 - curs->arg.ctx = ctx; 977 + curs->arg = arg; 978 978 979 979 return curs; 980 980 } ··· 985 985 { 986 986 struct ttm_buffer_object *bo = res->bo; 987 987 988 - if (!ttm_lru_walk_trylock(&curs->arg, bo, &curs->needs_unlock)) 988 + if (!ttm_lru_walk_trylock(curs->arg, bo, &curs->needs_unlock)) 989 989 return NULL; 990 990 991 991 if (!ttm_bo_get_unless_zero(bo)) {
+2 -1
drivers/gpu/drm/xe/xe_shrinker.c
··· 65 65 struct ttm_resource_manager *man = ttm_manager_type(&xe->ttm, mem_type); 66 66 struct ttm_bo_lru_cursor curs; 67 67 struct ttm_buffer_object *ttm_bo; 68 + struct ttm_lru_walk_arg arg = {.ctx = ctx}; 68 69 69 70 if (!man || !man->use_tt) 70 71 continue; 71 72 72 - ttm_bo_lru_for_each_reserved_guarded(&curs, man, ctx, ttm_bo) { 73 + ttm_bo_lru_for_each_reserved_guarded(&curs, man, &arg, ttm_bo) { 73 74 if (!ttm_bo_shrink_suitable(ttm_bo, ctx)) 74 75 continue; 75 76
+8 -8
include/drm/ttm/ttm_bo.h
··· 484 484 * unlock before the next iteration or after loop exit. 485 485 */ 486 486 bool needs_unlock; 487 - /** @arg: Common BO LRU walk arguments. */ 488 - struct ttm_lru_walk_arg arg; 487 + /** @arg: Pointer to common BO LRU walk arguments. */ 488 + struct ttm_lru_walk_arg *arg; 489 489 }; 490 490 491 491 void ttm_bo_lru_cursor_fini(struct ttm_bo_lru_cursor *curs); ··· 493 493 struct ttm_bo_lru_cursor * 494 494 ttm_bo_lru_cursor_init(struct ttm_bo_lru_cursor *curs, 495 495 struct ttm_resource_manager *man, 496 - struct ttm_operation_ctx *ctx); 496 + struct ttm_lru_walk_arg *arg); 497 497 498 498 struct ttm_buffer_object *ttm_bo_lru_cursor_first(struct ttm_bo_lru_cursor *curs); 499 499 ··· 504 504 */ 505 505 DEFINE_CLASS(ttm_bo_lru_cursor, struct ttm_bo_lru_cursor *, 506 506 if (_T) {ttm_bo_lru_cursor_fini(_T); }, 507 - ttm_bo_lru_cursor_init(curs, man, ctx), 507 + ttm_bo_lru_cursor_init(curs, man, arg), 508 508 struct ttm_bo_lru_cursor *curs, struct ttm_resource_manager *man, 509 - struct ttm_operation_ctx *ctx); 509 + struct ttm_lru_walk_arg *arg); 510 510 static inline void * 511 511 class_ttm_bo_lru_cursor_lock_ptr(class_ttm_bo_lru_cursor_t *_T) 512 512 { return *_T; } ··· 517 517 * resources on LRU lists. 518 518 * @_cursor: struct ttm_bo_lru_cursor to use for the iteration. 519 519 * @_man: The resource manager whose LRU lists to iterate over. 520 - * @_ctx: The struct ttm_operation_context to govern the @_bo locking. 520 + * @_arg: The struct ttm_lru_walk_arg to govern the LRU walk. 521 521 * @_bo: The struct ttm_buffer_object pointer pointing to the buffer object 522 522 * for the current iteration. 523 523 * ··· 530 530 * example a return or break statement. Exiting the loop will also unlock 531 531 * (if needed) and unreference @_bo. 532 532 */ 533 - #define ttm_bo_lru_for_each_reserved_guarded(_cursor, _man, _ctx, _bo) \ 534 - scoped_guard(ttm_bo_lru_cursor, _cursor, _man, _ctx) \ 533 + #define ttm_bo_lru_for_each_reserved_guarded(_cursor, _man, _arg, _bo) \ 534 + scoped_guard(ttm_bo_lru_cursor, _cursor, _man, _arg) \ 535 535 for ((_bo) = ttm_bo_lru_cursor_first(_cursor); (_bo); \ 536 536 (_bo) = ttm_bo_lru_cursor_next(_cursor)) 537 537