xe bo shrinker and exhaustive eviction
Subsystems (11)
Thomas Hellström
maintainerv2 cover xe bo shrinker and exhaustive eviction
CI testing of shrinker- and eviction patches
v2:
- Checkpatch error removal
Thomas Hellström (21):
drm/ttm: Allow TTM LRU list nodes of different types drm/ttm: Slightly clean up LRU list iteration
drm/ttm: Use LRU hitches
drm/ttm, drm/amdgpu, drm/xe: Consider hitch moves within bulk sublist
moves
drm/exec: Rework contended locking
drm/ttm: Provide a generic LRU walker helper
drm/ttm: Use restartable LRU and sleeping locks for swapping. drm/ttm: sleeping evict lock.
drm/ttm: Add a virtual base class for graphics memory backup drm/ttm/pool: Provide a helper to shrink pages.
drm/ttm: Use fault-injection to test error paths
drm/ttm, drm/xe: Add a shrinker for xe bos dma-buf/dma-resv: Introduce dma_resv_trylock_ctx() drm/exec: drm_exec_trylock()
drm/exec: Add a snapshot capability.
drm/exec: Introduce an evict mode
drm/ttm: Support drm_exec locking for eviction and swapping drm/ttm: Convert ttm vm to using drm_exec.
drm/xe: Use drm_exec for fault locking
drm/ttm: Use drm_exec_trylock for bo initialization drm/xe: Initial support for drm exec locking during validate.
drivers/gpu/drm/Kconfig | 10 + drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 6 +- drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c | 4 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 12 +- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 8 +- drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c | 4 +- drivers/gpu/drm/amd/amdgpu/amdgpu_umsch_mm.c | 8 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 4 + drivers/gpu/drm/drm_exec.c | 169 ++++++- drivers/gpu/drm/drm_gpuvm.c | 8 +- drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 4 +- drivers/gpu/drm/nouveau/nouveau_gem.c | 4 +- drivers/gpu/drm/nouveau/nouveau_uvmm.c | 2 +- drivers/gpu/drm/radeon/radeon_gem.c | 4 +- drivers/gpu/drm/tests/drm_exec_test.c | 12 +- drivers/gpu/drm/ttm/Makefile | 2 +- drivers/gpu/drm/ttm/ttm_backup_shmem.c | 137 ++++++ drivers/gpu/drm/ttm/ttm_bo.c | 468 +++++++++---------- drivers/gpu/drm/ttm/ttm_bo_util.c | 266 +++++++++++ drivers/gpu/drm/ttm/ttm_bo_vm.c | 101 ++-- drivers/gpu/drm/ttm/ttm_device.c | 29 +- drivers/gpu/drm/ttm/ttm_pool.c | 412 +++++++++++++++- drivers/gpu/drm/ttm/ttm_resource.c | 265 ++++++++--- drivers/gpu/drm/ttm/ttm_tt.c | 37 ++ drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c | 6 +- drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/display/xe_fb_pin.c | 2 +- drivers/gpu/drm/xe/tests/xe_bo.c | 124 ++++- drivers/gpu/drm/xe/tests/xe_bo_test.c | 1 + drivers/gpu/drm/xe/tests/xe_bo_test.h | 1 + drivers/gpu/drm/xe/tests/xe_dma_buf.c | 4 +- drivers/gpu/drm/xe/tests/xe_migrate.c | 2 +- drivers/gpu/drm/xe/xe_bo.c | 173 +++++-- drivers/gpu/drm/xe/xe_bo.h | 8 +- drivers/gpu/drm/xe/xe_device.c | 8 + drivers/gpu/drm/xe/xe_device_types.h | 2 + drivers/gpu/drm/xe/xe_dma_buf.c | 2 +- drivers/gpu/drm/xe/xe_ggtt.c | 2 +- drivers/gpu/drm/xe/xe_gt_pagefault.c | 6 +- drivers/gpu/drm/xe/xe_shrinker.c | 224 +++++++++ drivers/gpu/drm/xe/xe_shrinker.h | 18 + drivers/gpu/drm/xe/xe_vm.c | 18 +- include/drm/drm_exec.h | 35 +- include/drm/ttm/ttm_backup.h | 136 ++++++ include/drm/ttm/ttm_bo.h | 59 ++- include/drm/ttm/ttm_pool.h | 5 + include/drm/ttm/ttm_resource.h | 102 +++- include/drm/ttm/ttm_tt.h | 20 + include/linux/dma-resv.h | 23 +- 49 files changed, 2447 insertions(+), 511 deletions(-) create mode 100644 drivers/gpu/drm/ttm/ttm_backup_shmem.c create mode 100644 drivers/gpu/drm/xe/xe_shrinker.c create mode 100644 drivers/gpu/drm/xe/xe_shrinker.h create mode 100644 include/drm/ttm/ttm_backup.h
Signature · 1 line
2.44.0
Thomas Hellström
maintainerPATCH v2 1/21 drm/ttm: Allow TTM LRU list nodes of different types
To be able to handle list unlocking while traversing the LRU list, we want the iterators not only to point to the next position of the list traversal, but to insert themselves as list nodes at that point to work around the fact that the next node might otherwise disappear from the list while the iterator is pointing to it.
These list nodes need to be easily distinguishable from other list nodes so that others traversing the list can skip over them.
So declare a struct ttm_lru_item, with a struct list_head member and a type enum. This will slightly increase the size of a struct ttm_resource.
Changes in previous series:
- Update enum ttm_lru_item_type documentation.
--- drivers/gpu/drm/ttm/ttm_device.c | 4 +- drivers/gpu/drm/ttm/ttm_resource.c | 89 +++++++++++++++++++++++------- include/drm/ttm/ttm_resource.h | 54 +++++++++++++++++- 3 files changed, 125 insertions(+), 22 deletions(-)
drivers/gpu/drm/ttm/ttm_device.c +2 -2
@@ -274,14 +274,14 @@ static void ttm_device_clear_lru_dma_mappings(struct ttm_device *bdev,struct ttm_resource *res;spin_lock (&bdev->lru_lock); -while ((res =list_first_entry_or_null (list,typeof (*res), lru))) { +while ((res =ttm_lru_first_res_or_null (list))) {struct ttm_buffer_object *bo = res->bo;/* Take ref against racing releases once lru_lock is unlocked */ if (!ttm_bo_get_unless_zero (bo))continue ; -list_del_init (&res->lru); +list_del_init (&bo->resource->lru.link);spin_unlock (&bdev->lru_lock);if (bo->ttm)
drivers/gpu/drm/ttm/ttm_resource.c +70 -19
162 lines not on this page · raw message
include/drm/ttm/ttm_resource.h +53 -1
74 lines not on this page · raw message
Signature · 1 line
2.44.0
Thomas Hellström
maintainerPATCH v2 2/21 drm/ttm: Slightly clean up LRU list iteration
In reply to Thomas HellströmSimplify the ttm_resource_manager_next() interface to only take the cursor and reuse ttm_resource_manager_next() functionality from ttm_resource_manager_first().
--- drivers/gpu/drm/ttm/ttm_resource.c | 48 +++++++++++++----------------- include/drm/ttm/ttm_resource.h | 10 ++++--- 2 files changed, 27 insertions(+), 31 deletions(-)
drivers/gpu/drm/ttm/ttm_resource.c +21 -27
@@ -496,50 +496,44 @@ struct ttm_resource * ttm_resource_manager_first(struct ttm_resource_manager *man, struct ttm_resource_cursor *cursor) { - struct ttm_lru_item *lru; - lockdep_assert_held(&man->bdev->lru_lock); -for (cursor->priority =0 ; cursor->priority <TTM_MAX_BO_PRIORITY ; - ++cursor->priority) -list_for_each_entry (lru, &man->lru[cursor->priority], link) { -if (ttm_lru_item_is_res (lru)) -return ttm_lru_item_to_res (lru); - } - -return NULL ; + cursor->priority =0 ; + cursor->man = man; + cursor->cur = &man->lru[cursor->priority]; +return ttm_resource_manager_next (cursor); }/** * ttm_resource_manager_next * -* @man: resource manager to iterate over * @cursor: cursor to record the position -* @res: the current resource pointer * -* Returns the next resource from the resource manager. +* Return: the next resource from the resource manager. */ struct ttm_resource * -ttm_resource_manager_next (struct ttm_resource_manager *man, -struct ttm_resource_cursor *cursor, -struct ttm_resource *res) +ttm_resource_manager_next (struct ttm_resource_cursor *cursor) { -struct ttm_lru_item *lru = &res->lru; +struct ttm_resource_manager *man = cursor->man; +struct ttm_lru_item *lru;lockdep_assert_held (&man->bdev->lru_lock); -list_for_each_entry_continue (lru, &man->lru[cursor->priority], link) { -if (ttm_lru_item_is_res (lru)) -return ttm_lru_item_to_res (lru); - } - -for (++cursor->priority; cursor->priority <TTM_MAX_BO_PRIORITY ; - ++cursor->priority) -list_for_each_entry (lru, &man->lru[cursor->priority], link) { -if (ttm_lru_item_is_res (lru)) -ttm_lru_item_to_res (lru); +for (;;) { + lru =list_entry (cursor->cur,typeof (*lru), link); +list_for_each_entry_continue (lru, &man->lru[cursor->priority], link) { +if (ttm_lru_item_is_res (lru)) { + cursor->cur = &lru->link; +return ttm_lru_item_to_res (lru); + } } +if (++cursor->priority >=TTM_MAX_BO_PRIORITY ) +break ; + + cursor->cur = &man->lru[cursor->priority]; + } +return NULL ; }
include/drm/ttm/ttm_resource.h +6 -4
@@ -272,11 +272,15 @@ ttm_lru_item_to_res(struct ttm_lru_item *item)/** * struct ttm_resource_cursor * +* @man: The resource manager currently being iterated over. +* @cur: The list head the cursor currently points to. * @priority: the current priority * * Cursor to iterate over the resources in a manager. */ struct ttm_resource_cursor { +struct ttm_resource_manager *man; +struct list_head *cur;unsigned int priority; };
@@ -438,9 +442,7 @@ struct ttm_resource * ttm_resource_manager_first(struct ttm_resource_manager *man, struct ttm_resource_cursor *cursor);struct ttm_resource * -ttm_resource_manager_next (struct ttm_resource_manager *man, -struct ttm_resource_cursor *cursor, -struct ttm_resource *res); +ttm_resource_manager_next (struct ttm_resource_cursor *cursor);struct ttm_resource *ttm_lru_first_res_or_null (struct list_head *head);
@@ -455,7 +457,7 @@ ttm_lru_first_res_or_null(struct list_head *head);*/ #define ttm_resource_manager_for_each_res (man, cursor, res) \ for (res = ttm_resource_manager_first(man, cursor); res; \ - res = ttm_resource_manager_next(man, cursor, res)) + res = ttm_resource_manager_next(cursor))struct ttm_kmap_iter * ttm_kmap_iter_iomap_init(struct ttm_kmap_iter_iomap *iter_io,
Signature · 1 line
2.44.0
Thomas Hellström
maintainerPATCH v2 3/21 drm/ttm: Use LRU hitches
In reply to Thomas HellströmHave iterators insert themselves into the list they are iterating over using hitch list nodes. Since only the iterator owner can remove these list nodes from the list, it's safe to unlock the list and when continuing, use them as a starting point. Due to the way LRU bumping works in TTM, newly added items will not be missed, and bumped items will be iterated over a second time before reaching the end of the list.
The exception is list with bulk move sublists. When bumping a sublist, a hitch that is part of that sublist will also be moved and we might miss items if restarting from it. This will be addressed in a later patch.
Changes in previous series:
- Updated ttm_resource_cursor_fini() documentation. v2:
- Don't reorder ttm_resource_manager_first() and _next(). (Christian König).
- Use list_add instead of list_move
(Christian König)
v3:
- Split into two patches, one cleanup, one new functionality (Christian König)
- use ttm_resource_cursor_fini_locked() instead of open-coding (Matthew Brost)
--- drivers/gpu/drm/ttm/ttm_bo.c | 1 + drivers/gpu/drm/ttm/ttm_device.c | 9 +++-- drivers/gpu/drm/ttm/ttm_resource.c | 56 +++++++++++++++++++++++++----- include/drm/ttm/ttm_resource.h | 9 +++-- 4 files changed, 62 insertions(+), 13 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +1 -0
@@ -621,6 +621,7 @@ int ttm_mem_evict_first(struct ttm_device *bdev,if (locked)dma_resv_unlock (res->bo->base.resv); } +ttm_resource_cursor_fini_locked (&cursor);if (!bo) {if (busy_bo && !ttm_bo_get_unless_zero (busy_bo))
drivers/gpu/drm/ttm/ttm_device.c +7 -2
@@ -170,12 +170,17 @@ int ttm_device_swapout(struct ttm_device *bdev, struct ttm_operation_ctx *ctx, num_pages =PFN_UP (bo->base.size); ret =ttm_bo_swapout (bo, ctx, gfp_flags);/* ttm_bo_swapout has dropped the lru_lock */ -if (!ret) +if (!ret) { +ttm_resource_cursor_fini (&cursor);return num_pages; -if (ret != -EBUSY ) + } +if (ret != -EBUSY ) { +ttm_resource_cursor_fini (&cursor);return ret; + } } } +ttm_resource_cursor_fini_locked (&cursor);spin_unlock (&bdev->lru_lock);return 0 ; }
drivers/gpu/drm/ttm/ttm_resource.c +47 -9
97 lines not on this page · raw message
include/drm/ttm/ttm_resource.h +7 -2
@@ -273,17 +273,22 @@ ttm_lru_item_to_res(struct ttm_lru_item *item)* struct ttm_resource_cursor * * @man: The resource manager currently being iterated over. -* @cur: The list head the cursor currently points to. +* @hitch: A hitch list node inserted before the next resource +* to iterate over. * @priority: the current priority * * Cursor to iterate over the resources in a manager. */ struct ttm_resource_cursor {struct ttm_resource_manager *man; -struct list_head *cur; +struct ttm_lru_item hitch;unsigned int priority; }; +void ttm_resource_cursor_fini_locked (struct ttm_resource_cursor *cursor); + +void ttm_resource_cursor_fini (struct ttm_resource_cursor *cursor); +/** * struct ttm_lru_bulk_move_pos *
Signature · 1 line
2.44.0
Thomas Hellström
maintainerPATCH v2 4/21 drm/ttm, drm/amdgpu, drm/xe: Consider hitch moves within bulk sublist moves
In reply to Thomas HellströmTo address the problem with hitches moving when bulk move sublists are lru-bumped, register the list cursors with the ttm_lru_bulk_move structure when traversing its list, and when lru-bumping the list, move the cursor hitch to the tail. This also means it's mandatory for drivers to call ttm_lru_bulk_move_init() and ttm_lru_bulk_move_fini() when initializing and finalizing the bulk move structure, so add those calls to the amdgpu- and xe driver.
Compared to v1 this is slightly more code but less fragile and hopefully easier to understand.
Changes in previous series:
- Completely rework the functionality
- Avoid a NULL pointer dereference assigning manager->mem_type
- Remove some leftover code causing build problems v2:
- For hitch bulk tail moves, store the mem_type in the cursor instead of with the manager.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 4 ++ drivers/gpu/drm/ttm/ttm_resource.c | 90 ++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_vm.c | 4 ++ include/drm/ttm/ttm_resource.h | 59 +++++++++++------ 4 files changed, 136 insertions(+), 21 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4 -0
@@ -2422,6 +2422,8 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,if (r)return r; +ttm_lru_bulk_move_init (&vm->lru_bulk_move); + vm->is_compute_context = false; vm->use_cpu_for_update = !!(adev->vm_manager.vm_update_mode &
@@ -2486,6 +2488,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, error_free_delayed:dma_fence_put (vm->last_tlb_flush);dma_fence_put (vm->last_unlocked); +ttm_lru_bulk_move_fini (&adev->mman.bdev, &vm->lru_bulk_move);amdgpu_vm_fini_entities (vm);return r;
@@ -2642,6 +2645,7 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm) } } +ttm_lru_bulk_move_fini (&adev->mman.bdev, &vm->lru_bulk_move); }/**
drivers/gpu/drm/ttm/ttm_resource.c +90 -0
147 lines not on this page · raw message
drivers/gpu/drm/xe/xe_vm.c +4 -0
@@ -1339,6 +1339,8 @@ struct xe_vm *xe_vm_create(struct xe_device *xe, u32 flags)INIT_WORK (&vm->destroy_work, vm_destroy_work_func); +ttm_lru_bulk_move_init (&vm->lru_bulk_move); +INIT_LIST_HEAD (&vm->preempt.exec_queues); vm->preempt.min_run_period_ms =10 ;/* FIXME: Wire up to uAPI */
@@ -1456,6 +1458,7 @@ struct xe_vm *xe_vm_create(struct xe_device *xe, u32 flags)mutex_destroy (&vm->snap_mutex);for_each_tile (tile, xe, id)xe_range_fence_tree_fini (&vm->rftree[id]); +ttm_lru_bulk_move_fini (&xe->ttm, &vm->lru_bulk_move);kfree (vm);if (!(flags &XE_VM_FLAG_MIGRATION ))xe_pm_runtime_put (xe);
@@ -1599,6 +1602,7 @@ static void vm_destroy_work_func(struct work_struct *w)XE_WARN_ON (vm->pt_root[id]);trace_xe_vm_free (vm); +ttm_lru_bulk_move_fini (&xe->ttm, &vm->lru_bulk_move);kfree (vm); }
include/drm/ttm/ttm_resource.h +38 -21
92 lines not on this page · raw message
Signature · 1 line
2.44.0
Thomas Hellström
maintainerPATCH v2 5/21 drm/exec: Rework contended locking
In reply to Thomas Hellström--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 6 ++--- drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 8 +++---- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 8 +++---- drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_umsch_mm.c | 8 +++---- drivers/gpu/drm/drm_exec.c | 23 ++++++++++++++------ drivers/gpu/drm/drm_gpuvm.c | 8 +++---- drivers/gpu/drm/nouveau/nouveau_uvmm.c | 2 +- drivers/gpu/drm/tests/drm_exec_test.c | 12 +++++----- drivers/gpu/drm/xe/xe_gt_pagefault.c | 4 ++-- drivers/gpu/drm/xe/xe_vm.c | 10 ++++----- include/drm/drm_exec.h | 19 +++++++++++----- 13 files changed, 67 insertions(+), 49 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +3 -3
@@ -897,7 +897,7 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p, drm_exec_until_all_locked(&p->exec) { r =amdgpu_vm_lock_pd (&fpriv->vm, &p->exec,1 + p->gang_size); -drm_exec_retry_on_contention (&p->exec); + r =drm_exec_retry_on_contention (&p->exec, r);if (unlikely (r)) goto out_free_user_pages;
@@ -905,7 +905,7 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,/* One fence for TTM and one for each CS job */ r =drm_exec_prepare_obj (&p->exec, &e->bo->tbo.base,1 + p->gang_size); -drm_exec_retry_on_contention (&p->exec); + r =drm_exec_retry_on_contention (&p->exec, r);if (unlikely (r)) goto out_free_user_pages;
@@ -915,7 +915,7 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,if (p->uf_bo) { r =drm_exec_prepare_obj (&p->exec, &p->uf_bo->tbo.base,1 + p->gang_size); -drm_exec_retry_on_contention (&p->exec); + r =drm_exec_retry_on_contention (&p->exec, r);if (unlikely (r)) goto out_free_user_pages; }
drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c +2 -2
@@ -74,7 +74,7 @@ int amdgpu_map_static_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm, r =amdgpu_vm_lock_pd (vm, &exec,0 );if (likely (!r)) r =drm_exec_lock_obj (&exec, &bo->tbo.base); -drm_exec_retry_on_contention (&exec); + r =drm_exec_retry_on_contention (&exec, r);if (unlikely (r)) {DRM_ERROR ("failed to reserve CSA,PD BOs: err=%d\n" , r); goto error;
@@ -114,7 +114,7 @@ int amdgpu_unmap_static_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm, r =amdgpu_vm_lock_pd (vm, &exec,0 );if (likely (!r)) r =drm_exec_lock_obj (&exec, &bo->tbo.base); -drm_exec_retry_on_contention (&exec); + r =drm_exec_retry_on_contention (&exec, r);if (unlikely (r)) {DRM_ERROR ("failed to reserve CSA,PD BOs: err=%d\n" , r); goto error;
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +4 -4
@@ -239,12 +239,12 @@ static void amdgpu_gem_object_close(struct drm_gem_object *obj,drm_exec_init (&exec,DRM_EXEC_IGNORE_DUPLICATES ,0 ); drm_exec_until_all_locked(&exec) { r =drm_exec_prepare_obj (&exec, &bo->tbo.base,1 ); -drm_exec_retry_on_contention (&exec); + r =drm_exec_retry_on_contention (&exec, r);if (unlikely (r)) goto out_unlock; r =amdgpu_vm_lock_pd (vm, &exec,0 ); -drm_exec_retry_on_contention (&exec); + r =drm_exec_retry_on_contention (&exec, r);if (unlikely (r)) goto out_unlock; }
@@ -776,13 +776,13 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data, drm_exec_until_all_locked(&exec) {if (gobj) { r =drm_exec_lock_obj (&exec, gobj); -drm_exec_retry_on_contention (&exec); + r =drm_exec_retry_on_contention (&exec, r);if (unlikely (r)) goto error; } r =amdgpu_vm_lock_pd (&fpriv->vm, &exec,2 ); -drm_exec_retry_on_contention (&exec); + r =drm_exec_retry_on_contention (&exec, r);if (unlikely (r)) goto error; }
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +4 -4
@@ -1221,12 +1221,12 @@ int amdgpu_mes_ctx_map_meta_data(struct amdgpu_device *adev, drm_exec_until_all_locked(&exec) { r =drm_exec_lock_obj (&exec, &ctx_data->meta_data_obj->tbo.base); -drm_exec_retry_on_contention (&exec); + r =drm_exec_retry_on_contention (&exec, r);if (unlikely (r)) goto error_fini_exec; r =amdgpu_vm_lock_pd (vm, &exec,0 ); -drm_exec_retry_on_contention (&exec); + r =drm_exec_retry_on_contention (&exec, r);if (unlikely (r)) goto error_fini_exec; }
@@ -1292,12 +1292,12 @@ int amdgpu_mes_ctx_unmap_meta_data(struct amdgpu_device *adev, drm_exec_until_all_locked(&exec) { r =drm_exec_lock_obj (&exec, &ctx_data->meta_data_obj->tbo.base); -drm_exec_retry_on_contention (&exec); + r =drm_exec_retry_on_contention (&exec, r);if (unlikely (r)) goto out_unlock; r =amdgpu_vm_lock_pd (vm, &exec,0 ); -drm_exec_retry_on_contention (&exec); + r =drm_exec_retry_on_contention (&exec, r);if (unlikely (r)) goto out_unlock; }
drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c +2 -2
@@ -77,7 +77,7 @@ int amdgpu_seq64_map(struct amdgpu_device *adev, struct amdgpu_vm *vm, r =amdgpu_vm_lock_pd (vm, &exec,0 );if (likely (!r)) r =drm_exec_lock_obj (&exec, &bo->tbo.base); -drm_exec_retry_on_contention (&exec); + r =drm_exec_retry_on_contention (&exec, r);if (unlikely (r)) goto error; }
@@ -138,7 +138,7 @@ void amdgpu_seq64_unmap(struct amdgpu_device *adev, struct amdgpu_fpriv *fpriv) r =amdgpu_vm_lock_pd (vm, &exec,0 );if (likely (!r)) r =drm_exec_lock_obj (&exec, &bo->tbo.base); -drm_exec_retry_on_contention (&exec); + r =drm_exec_retry_on_contention (&exec, r);if (unlikely (r)) goto error; }
drivers/gpu/drm/amd/amdgpu/amdgpu_umsch_mm.c +4 -4
@@ -89,12 +89,12 @@ static int map_ring_data(struct amdgpu_device *adev, struct amdgpu_vm *vm,drm_exec_init (&exec,0 ,0 ); drm_exec_until_all_locked(&exec) { r =drm_exec_lock_obj (&exec, &bo->tbo.base); -drm_exec_retry_on_contention (&exec); + r =drm_exec_retry_on_contention (&exec, r);if (unlikely (r)) goto error_fini_exec; r =amdgpu_vm_lock_pd (vm, &exec,0 ); -drm_exec_retry_on_contention (&exec); + r =drm_exec_retry_on_contention (&exec, r);if (unlikely (r)) goto error_fini_exec; }
@@ -152,12 +152,12 @@ static int unmap_ring_data(struct amdgpu_device *adev, struct amdgpu_vm *vm,drm_exec_init (&exec,0 ,0 ); drm_exec_until_all_locked(&exec) { r =drm_exec_lock_obj (&exec, &bo->tbo.base); -drm_exec_retry_on_contention (&exec); + r =drm_exec_retry_on_contention (&exec, r);if (unlikely (r)) goto out_unlock; r =amdgpu_vm_lock_pd (vm, &exec,0 ); -drm_exec_retry_on_contention (&exec); + r =drm_exec_retry_on_contention (&exec, r);if (unlikely (r)) goto out_unlock; }
drivers/gpu/drm/drm_exec.c +16 -7
@@ -48,7 +48,8 @@*/ /* Dummy value used to initially enter the retry loop */ -#define DRM_EXEC_DUMMY ((void *)~0) +#define DRM_EXEC_DUMMY ERR_PTR(-ESTALE) +#define DRM_EXEC_CONTENDED ERR_PTR(-EDEADLK)/* Unlock all objects and drop references */ static void drm_exec_unlock_all (struct drm_exec *exec)
@@ -131,8 +132,7 @@ bool drm_exec_cleanup(struct drm_exec *exec)return true; } -drm_exec_unlock_all (exec); - exec->num_objects =0 ; + exec->contended =NULL ;return true; }EXPORT_SYMBOL (drm_exec_cleanup);
@@ -194,6 +194,19 @@ static int drm_exec_lock_contended(struct drm_exec *exec)return ret; } +int drm_exec_handle_contended (struct drm_exec *exec) +{ +int ret; + +drm_exec_unlock_all (exec); + exec->num_objects =0 ; + ret =drm_exec_lock_contended (exec); + exec->contended =DRM_EXEC_CONTENDED ; + +return ret; +} +EXPORT_SYMBOL (drm_exec_handle_contended); +/** * drm_exec_lock_obj - lock a GEM object for use * @exec: the drm_exec object with the state
@@ -209,10 +222,6 @@ int drm_exec_lock_obj(struct drm_exec *exec, struct drm_gem_object *obj) {int ret; - ret =drm_exec_lock_contended (exec); -if (unlikely (ret)) -return ret; -if (exec->prelocked == obj) {drm_gem_object_put (exec->prelocked); exec->prelocked =NULL ;
drivers/gpu/drm/drm_gpuvm.c +4 -4
@@ -1254,18 +1254,18 @@ drm_gpuvm_exec_lock(struct drm_gpuvm_exec *vm_exec)drm_exec_until_all_locked (exec) { ret =drm_gpuvm_prepare_vm (gpuvm, exec, num_fences); -drm_exec_retry_on_contention (exec); + ret =drm_exec_retry_on_contention (exec, ret);if (ret) goto err; ret =drm_gpuvm_prepare_objects (gpuvm, exec, num_fences); -drm_exec_retry_on_contention (exec); + ret =drm_exec_retry_on_contention (exec, ret);if (ret) goto err;if (vm_exec->extra.fn) { ret = vm_exec->extra.fn (vm_exec); -drm_exec_retry_on_contention (exec); + ret =drm_exec_retry_on_contention (exec, ret);if (ret) goto err; }
@@ -1346,7 +1346,7 @@ drm_gpuvm_exec_lock_range(struct drm_gpuvm_exec *vm_exec,drm_exec_until_all_locked (exec) { ret =drm_gpuvm_prepare_range (gpuvm, exec, addr, range, vm_exec->num_fences); -drm_exec_retry_on_contention (exec); + ret =drm_exec_retry_on_contention (exec, ret);if (ret) goto err; }
drivers/gpu/drm/nouveau/nouveau_uvmm.c +1 -1
@@ -1350,7 +1350,7 @@ nouveau_uvmm_bind_job_submit(struct nouveau_job *job,drm_exec_init (exec, vme->flags,0 );drm_exec_until_all_locked (exec) { ret =bind_lock_validate (job, exec, vme->num_fences); -drm_exec_retry_on_contention (exec); + ret =drm_exec_retry_on_contention (exec, ret);if (ret) { op =list_last_op (&bind_job->ops); goto unwind;
drivers/gpu/drm/tests/drm_exec_test.c +6 -6
@@ -63,7 +63,7 @@ static void test_lock(struct kunit *test)drm_exec_init (&exec,DRM_EXEC_INTERRUPTIBLE_WAIT ,0 ); drm_exec_until_all_locked(&exec) { ret =drm_exec_lock_obj (&exec, &gobj); -drm_exec_retry_on_contention (&exec); + ret =drm_exec_retry_on_contention (&exec, ret);KUNIT_EXPECT_EQ (test, ret,0 );if (ret)break ;
@@ -83,14 +83,14 @@ static void test_lock_unlock(struct kunit *test)drm_exec_init (&exec,DRM_EXEC_INTERRUPTIBLE_WAIT ,0 ); drm_exec_until_all_locked(&exec) { ret =drm_exec_lock_obj (&exec, &gobj); -drm_exec_retry_on_contention (&exec); + ret =drm_exec_retry_on_contention (&exec, ret);KUNIT_EXPECT_EQ (test, ret,0 );if (ret)break ;drm_exec_unlock_obj (&exec, &gobj); ret =drm_exec_lock_obj (&exec, &gobj); -drm_exec_retry_on_contention (&exec); + ret =drm_exec_retry_on_contention (&exec, ret);KUNIT_EXPECT_EQ (test, ret,0 );if (ret)break ;
@@ -110,13 +110,13 @@ static void test_duplicates(struct kunit *test)drm_exec_init (&exec,DRM_EXEC_IGNORE_DUPLICATES ,0 ); drm_exec_until_all_locked(&exec) { ret =drm_exec_lock_obj (&exec, &gobj); -drm_exec_retry_on_contention (&exec); + ret =drm_exec_retry_on_contention (&exec, ret);KUNIT_EXPECT_EQ (test, ret,0 );if (ret)break ; ret =drm_exec_lock_obj (&exec, &gobj); -drm_exec_retry_on_contention (&exec); + ret =drm_exec_retry_on_contention (&exec, ret);KUNIT_EXPECT_EQ (test, ret,0 );if (ret)break ;
@@ -137,7 +137,7 @@ static void test_prepare(struct kunit *test)drm_exec_init (&exec,DRM_EXEC_INTERRUPTIBLE_WAIT ,0 ); drm_exec_until_all_locked(&exec) { ret =drm_exec_prepare_obj (&exec, &gobj,1 ); -drm_exec_retry_on_contention (&exec); + ret =drm_exec_retry_on_contention (&exec, ret);KUNIT_EXPECT_EQ (test, ret,0 );if (ret)break ;
drivers/gpu/drm/xe/xe_gt_pagefault.c +2 -2
@@ -200,7 +200,7 @@ static int handle_pagefault(struct xe_gt *gt, struct pagefault *pf)drm_exec_init (&exec,0 ,0 ); drm_exec_until_all_locked(&exec) { ret =xe_pf_begin (&exec, vma, atomic, tile->id); -drm_exec_retry_on_contention (&exec); + ret =drm_exec_retry_on_contention (&exec, ret);if (ret) goto unlock_dma_resv;
@@ -543,7 +543,7 @@ static int handle_acc(struct xe_gt *gt, struct acc *acc)drm_exec_init (&exec,0 ,0 ); drm_exec_until_all_locked(&exec) { ret =xe_pf_begin (&exec, vma, true, tile->id); -drm_exec_retry_on_contention (&exec); + ret =drm_exec_retry_on_contention (&exec, ret);if (ret)break ; }
drivers/gpu/drm/xe/xe_vm.c +5 -5
@@ -501,7 +501,7 @@ static void preempt_rebind_work_func(struct work_struct *w)bool done = false; err =xe_preempt_work_begin (&exec, vm, &done); -drm_exec_retry_on_contention (&exec); + err =drm_exec_retry_on_contention (&exec, err);if (err || done) {drm_exec_fini (&exec);if (err &&xe_vm_validate_should_retry (&exec, err, &end))
@@ -1052,7 +1052,7 @@ static void xe_vma_destroy_unlocked(struct xe_vma *vma)drm_exec_init (&exec,0 ,0 ); drm_exec_until_all_locked(&exec) { err =xe_vm_lock_vma (&exec, vma); -drm_exec_retry_on_contention (&exec); + err =drm_exec_retry_on_contention (&exec, err);if (XE_WARN_ON (err))break ; }
@@ -2148,11 +2148,11 @@ static struct xe_vma *new_vma(struct xe_vm *vm, struct drm_gpuva_op_map *op, err =0 ;if (!bo->vm) { err =drm_exec_lock_obj (&exec,xe_vm_obj (vm)); -drm_exec_retry_on_contention (&exec); + err =drm_exec_retry_on_contention (&exec, err); }if (!err) { err =drm_exec_lock_obj (&exec, &bo->ttm.base); -drm_exec_retry_on_contention (&exec); + err =drm_exec_retry_on_contention (&exec, err); }if (err) {drm_exec_fini (&exec);
@@ -2884,7 +2884,7 @@ static int vm_bind_ioctl_ops_execute(struct xe_vm *vm, DRM_EXEC_IGNORE_DUPLICATES, 0); drm_exec_until_all_locked(&exec) { err =vm_bind_ioctl_ops_lock_and_prep (&exec, vm, vops); -drm_exec_retry_on_contention (&exec); + err =drm_exec_retry_on_contention (&exec, err);if (err) goto unlock;
include/drm/drm_exec.h +14 -5
@@ -51,6 +51,8 @@ struct drm_exec {struct drm_gem_object *prelocked; }; +int drm_exec_handle_contended (struct drm_exec *exec); +/** * drm_exec_obj() - Return the object for a give drm_exec index * @exec: Pointer to the drm_exec context
@@ -117,11 +119,18 @@ __PASTE(__drm_exec_, __LINE__): \* Control flow helper to continue when a contention was detected and we need to * clean up and re-start the loop to prepare all GEM objects. */ -#define drm_exec_retry_on_contention (exec) \ - do { \ - if (unlikely(drm_exec_is_contended(exec))) \ - goto *__drm_exec_retry_ptr; \ - } while (0) +#define drm_exec_retry_on_contention (exec, _ret) \ + ({ \ + int __ret = (_ret); \ + \ + if (unlikely(drm_exec_is_contended(exec))) { \ + WARN_ON(__ret != -EDEADLK); \ + __ret = drm_exec_handle_contended(exec); \ + if (!__ret) \ + goto *__drm_exec_retry_ptr; \ + } \ + __ret; \ + })/** * drm_exec_is_contended - check for contention
Signature · 1 line
2.44.0
Thomas Hellström
maintainerPATCH v2 6/21 drm/ttm: Provide a generic LRU walker helper
In reply to Thomas HellströmProvide a generic LRU walker in TTM, in the spirit of drm_gem_lru_scan() but building on the restartable TTM LRU functionality.
The LRU walker optionally supports locking objects as part of a drm_exec locking transaction, and can thus be used for both exhaustive eviction and shrinking. And, in fact, direct shrinking in the case where we fail to populate system memory objects and want to retry by shrinking purgeable or evictable local objects, which a shrinker is not capable of doing.
--- drivers/gpu/drm/ttm/ttm_bo_util.c | 162 ++++++++++++++++++++++++++++++ include/drm/ttm/ttm_bo.h | 32 ++++++ 2 files changed, 194 insertions(+)
drivers/gpu/drm/ttm/ttm_bo_util.c +162 -0
@@ -768,3 +768,165 @@ int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo)ttm_tt_destroy (bo->bdev, ttm);return ret; } + +static bool ttm_lru_walk_trylock (struct ttm_lru_walk *walk, +struct ttm_buffer_object *bo, +bool *needs_unlock) +{ +struct ttm_operation_ctx *ctx = walk->ctx; + + *needs_unlock = false; + +if (dma_resv_trylock (bo->base.resv)) { + *needs_unlock = true; +return true; + } + +if (bo->base.resv == ctx->resv && ctx->allow_res_evict) { +dma_resv_assert_held (bo->base.resv); +return true; + } + +return false; +} + +static int ttm_lru_walk_ticketlock (struct ttm_lru_walk *walk, +struct ttm_buffer_object *bo, +bool *needs_unlock) +{ +struct dma_resv *resv = bo->base.resv; +int ret; + +if (walk->ctx->interruptible) + ret =dma_resv_lock_interruptible (resv, walk->ticket); +else + ret =dma_resv_lock (resv, walk->ticket); + +if (ret == -EDEADLK ) + ret = -ENOSPC ; + +if (!ret) { + *needs_unlock = true; +/* Only a single ticketlock per loop */ + walk->ticket =NULL ; + } + +return ret; +} + +static void ttm_lru_walk_unlock (struct ttm_buffer_object *bo,bool locked) +{ +if (locked) +dma_resv_unlock (bo->base.resv); +} + +/** +* ttm_lru_walk_for_evict() - Perform a LRU list walk, with actions taken on +* valid items. +* @walk: describe the walks and actions taken +* @bdev: The TTM device. +* @man: The struct ttm_resource manager whose LRU lists we're walking. +* @target: The end condition for the walk. +* +* The LRU lists of @man are walk, and for each struct ttm_resource encountered, +* the corresponding ttm_buffer_object is locked and taken a reference on, and +* the LRU lock is dropped. the LRU lock may be dropped before locking and, in +* that case, it's verified that the item actually remains on the LRU list after +* the lock, and that the buffer object hasn't changed. +* +* With a locked object, the actions indicated by @walk->process_bo are +* performed, and after that, the bo is unlocked, the refcount dropped and the +* next struct ttm_resource is processed. Here we rely on TTM's restartable +* LRU list implementation. +* +* Typically @walk->process_bo() would return the number of pages evicted, and +* that when the total exceeds @target, or when the LRU list has been walked +* in full, iteration is terminated. It's also terminated on error. +* +* Buffer object dma_resv locking: +* This locking is performed using the combined interpretation of @walk->exec and +* @walk->ctx according to the following. +* 1) Sleeping locks: Sleeping locks are used exclusively if @walk->exec is true. +* The buffer object are not unlocked. That is the caller's responsibility. +* 2) Assuming bo is already locked: This assumption is made iff @walk->exec is false, +* @walk->ctx->allow_res_evict is true and bo->base.resv == @walk->ctx->resv. +* This is for cases where it is desired to evict bos sharing a reservation lock +* that is already held by the process. Thes bo locks are not unlocked during +* the walk. +* 3) Trylocking. Trylocking is done in all other cases. If trylocking fails, the +* iteration skips the current item and continues. Trylocks are always unlocked +* by the walk. +* +* Note that the way dma_resv individualization is done, locking needs to be done +* either with the LRU lock held (trylocking only) or with a reference on the +* object. +* +* Return: (Typically) The number of pages evicted or negative error code on error. +*/ +long ttm_lru_walk_for_evict (struct ttm_lru_walk *walk,struct ttm_device *bdev, +struct ttm_resource_manager *man,long target) +{ +struct ttm_resource_cursor cursor; +struct ttm_resource *res; +long sofar =0 ; +long lret; + +spin_lock (&bdev->lru_lock); +ttm_resource_manager_for_each_res (man, &cursor, res) { +struct ttm_buffer_object *bo = res->bo; +bool bo_needs_unlock = false; +bool bo_locked = false; +int mem_type; + +if (!bo || bo->resource != res) +continue ; + +if (ttm_lru_walk_trylock (walk, bo, &bo_needs_unlock)) + bo_locked = true; +else if ((!walk->ticket) || walk->ctx->no_wait_gpu || + walk->trylock_only) +continue ; + +if (!ttm_bo_get_unless_zero (bo)) { +ttm_lru_walk_unlock (bo, bo_needs_unlock); +continue ; + } + + mem_type = res->mem_type; +spin_unlock (&bdev->lru_lock); + + lret =0 ; +if (!bo_locked && walk->ticket) + lret =ttm_lru_walk_ticketlock (walk, bo, &bo_needs_unlock); + +/* +* Note that in between the release of the lru lock and the +* ticketlock, the bo may have switched resource, +* and also memory type, since the resource may have been +* freed and allocated again with a different memory type. +* In that case, just skip it. +*/ +if (!lret && bo->resource == res && res->mem_type == mem_type) + lret = walk->ops->process_bo (walk, bo); + +ttm_lru_walk_unlock (bo, bo_needs_unlock); +ttm_bo_put (bo); +if (lret == -EBUSY ) + lret =0 ; +if (lret <0 ) { + sofar = lret; + goto out; + } + + sofar += lret; +if (sofar >= target) + goto out; + +cond_resched (); +spin_lock (&bdev->lru_lock); + } +spin_unlock (&bdev->lru_lock); +out: +ttm_resource_cursor_fini (&cursor); +return sofar; +}
include/drm/ttm/ttm_bo.h +32 -0
@@ -190,6 +190,38 @@ struct ttm_operation_ctx {uint64_t bytes_moved; }; +struct ttm_lru_walk ; + +/** struct ttm_lru_walk_ops - Operations for a LRU walk. */ +struct ttm_lru_walk_ops { +/** +* process_bo - Process this bo. +* @walk: struct ttm_lru_walk describing the walk. +* @bo: A locked and referenced buffer object. +* +* Return: Negative error code on error, Number of processed pages on +* success. 0 also indicates success. +*/ +long (*process_bo)(struct ttm_lru_walk *walk,struct ttm_buffer_object *bo); +}; + +/** +* struct ttm_lru_walk - Structure describing a LRU walk. +* @ops: Pointer to the ops structure. +* @ctx: Pointer to the struct ttm_operation_ctx. +* @ticket: The struct ww_acquire_ctx if any. +* @tryock_only: Only use trylock for locking. +*/ +struct ttm_lru_walk { +const struct ttm_lru_walk_ops *ops; +struct ttm_operation_ctx *ctx; +struct ww_acquire_ctx *ticket; +bool trylock_only; +}; + +long ttm_lru_walk_for_evict (struct ttm_lru_walk *walk,struct ttm_device *bdev, +struct ttm_resource_manager *man,long target); +/** * ttm_bo_get - reference a struct ttm_buffer_object *
Signature · 1 line
2.44.0
Thomas Hellström
maintainerPATCH v2 7/21 drm/ttm: Use restartable LRU and sleeping locks for swapping.
In reply to Thomas Hellström--- drivers/gpu/drm/ttm/ttm_bo.c | 86 ++++++++++++++++++++------------ drivers/gpu/drm/ttm/ttm_device.c | 29 ++--------- include/drm/ttm/ttm_bo.h | 5 +- 3 files changed, 63 insertions(+), 57 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +55 -31
@@ -1118,11 +1118,18 @@ int ttm_bo_wait_ctx(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx) }EXPORT_SYMBOL (ttm_bo_wait_ctx); -int ttm_bo_swapout (struct ttm_buffer_object *bo,struct ttm_operation_ctx *ctx, -gfp_t gfp_flags) +struct ttm_bo_swapout_walk { +struct ttm_lru_walk walk; +gfp_t gfp_flags; +}; + +static long +ttm_bo_swapout_cb (struct ttm_lru_walk *walk,struct ttm_buffer_object *bo) { -struct ttm_place place; -bool locked; +struct ttm_place place = {.mem_type = bo->resource->mem_type}; +struct ttm_bo_swapout_walk *swapout_walk = +container_of (walk,typeof (*swapout_walk), walk); +struct ttm_operation_ctx *ctx = walk->ctx;long ret;/*
@@ -1131,28 +1138,29 @@ int ttm_bo_swapout(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx,* The driver may use the fact that we're moving from SYSTEM * as an indication that we're about to swap out. */ -memset (&place,0 ,sizeof (place)); - place.mem_type = bo->resource->mem_type; -if (!ttm_bo_evict_swapout_allowable (bo, ctx, &place, &locked,NULL )) -return -EBUSY ; +if (!bo->bdev->funcs->eviction_valuable (bo, &place)) { + ret = -EBUSY ; + goto out; + }if (!bo->ttm || !ttm_tt_is_populated (bo->ttm) || bo->ttm->page_flags &TTM_TT_FLAG_EXTERNAL || - bo->ttm->page_flags &TTM_TT_FLAG_SWAPPED || - !ttm_bo_get_unless_zero (bo)) { -if (locked) -dma_resv_unlock (bo->base.resv); -return -EBUSY ; + bo->ttm->page_flags &TTM_TT_FLAG_SWAPPED ) { + ret = -EBUSY ; + goto out; }if (bo->deleted) { - ret =ttm_bo_cleanup_refs (bo, false, false, locked); -ttm_bo_put (bo); -return ret == -EBUSY ? -ENOSPC : ret; - } +pgoff_t num_pages = bo->ttm->num_pages; -/* TODO: Cleanup the locking */ -spin_unlock (&bo->bdev->lru_lock); + ret =ttm_bo_wait_ctx (bo, ctx); +if (ret) + goto out; + +ttm_bo_cleanup_memtype_use (bo); + ret = num_pages; + goto out; + }/* * Move to system cached
@@ -1164,11 +1172,11 @@ int ttm_bo_swapout(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx,memset (&hop,0 ,sizeof (hop)); place.mem_type =TTM_PL_SYSTEM ; ret =ttm_resource_alloc (bo, &place, &evict_mem); -if (unlikely (ret)) +if (ret) goto out; ret =ttm_bo_handle_move_mem (bo, evict_mem, true, ctx, &hop); -if (unlikely (ret !=0 )) { +if (ret) {WARN (ret == -EMULTIHOP ,"Unexpected multihop in swaput - likely driver bug.\n" );ttm_resource_free (bo, &evict_mem); goto out;
@@ -1179,7 +1187,7 @@ int ttm_bo_swapout(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx,* Make sure BO is idle. */ ret =ttm_bo_wait_ctx (bo, ctx); -if (unlikely (ret !=0 )) +if (ret) goto out;ttm_bo_unmap_virtual (bo);
@@ -1192,17 +1200,33 @@ int ttm_bo_swapout(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx, bo->bdev->funcs->swap_notify (bo);if (ttm_tt_is_populated (bo->ttm)) - ret =ttm_tt_swapout (bo->bdev, bo->ttm, gfp_flags); + ret =ttm_tt_swapout (bo->bdev, bo->ttm, swapout_walk->gfp_flags); out: +/* Consider some error codes fatal. Others may continue the walk. */ +if (ret == -ENOMEM || ret == -EINTR || ret == -ERESTARTSYS || + ret == -EAGAIN || ret >0 ) +return ret; -/* -* Unreserve without putting on LRU to avoid swapping out an -* already swapped buffer. -*/ -if (locked) -dma_resv_unlock (bo->base.resv); -ttm_bo_put (bo); -return ret == -EBUSY ? -ENOSPC : ret; +return 0 ; +} + +const struct ttm_lru_walk_ops ttm_swap_ops = { + .process_bo = ttm_bo_swapout_cb, +}; + +long ttm_bo_swapout (struct ttm_device *bdev,struct ttm_operation_ctx *ctx, +struct ttm_resource_manager *man,gfp_t gfp_flags, +pgoff_t target) +{ +struct ttm_bo_swapout_walk swapout_walk = { + .walk = { + .ops = &ttm_swap_ops, + .ctx = ctx, + }, + .gfp_flags = gfp_flags, + }; + +return ttm_lru_walk_for_evict (&swapout_walk.walk, bdev, man, target); }void ttm_bo_tt_destroy (struct ttm_buffer_object *bo)
drivers/gpu/drm/ttm/ttm_device.c +5 -24
@@ -148,11 +148,9 @@ int ttm_global_swapout(struct ttm_operation_ctx *ctx, gfp_t gfp_flags)int ttm_device_swapout (struct ttm_device *bdev,struct ttm_operation_ctx *ctx,gfp_t gfp_flags) { -struct ttm_resource_cursor cursor;struct ttm_resource_manager *man; -struct ttm_resource *res;unsigned i; -int ret; +long lret;spin_lock (&bdev->lru_lock);for (i =TTM_PL_SYSTEM ; i <TTM_NUM_MEM_TYPES ; ++i) {
@@ -160,28 +158,11 @@ int ttm_device_swapout(struct ttm_device *bdev, struct ttm_operation_ctx *ctx,if (!man || !man->use_tt)continue ; -ttm_resource_manager_for_each_res (man, &cursor, res) { -struct ttm_buffer_object *bo = res->bo; -uint32_t num_pages; - -if (!bo || bo->resource != res) -continue ; - - num_pages =PFN_UP (bo->base.size); - ret =ttm_bo_swapout (bo, ctx, gfp_flags); -/* ttm_bo_swapout has dropped the lru_lock */ -if (!ret) { -ttm_resource_cursor_fini (&cursor); -return num_pages; - } -if (ret != -EBUSY ) { -ttm_resource_cursor_fini (&cursor); -return ret; - } - } + lret =ttm_bo_swapout (bdev, ctx, man, gfp_flags,1 ); +/* Can be both positive (num_pages) and negative (error) */ +if (lret) +return lret; } -ttm_resource_cursor_fini_locked (&cursor); -spin_unlock (&bdev->lru_lock);return 0 ; }EXPORT_SYMBOL (ttm_device_swapout);
include/drm/ttm/ttm_bo.h +3 -2
@@ -410,8 +410,9 @@ void ttm_bo_kunmap(struct ttm_bo_kmap_obj *map);int ttm_bo_vmap (struct ttm_buffer_object *bo,struct iosys_map *map);void ttm_bo_vunmap (struct ttm_buffer_object *bo,struct iosys_map *map);int ttm_bo_mmap_obj (struct vm_area_struct *vma,struct ttm_buffer_object *bo); -int ttm_bo_swapout (struct ttm_buffer_object *bo,struct ttm_operation_ctx *ctx, -gfp_t gfp_flags); +long ttm_bo_swapout (struct ttm_device *bdev,struct ttm_operation_ctx *ctx, +struct ttm_resource_manager *man,gfp_t gfp_flags, +pgoff_t target);void ttm_bo_pin (struct ttm_buffer_object *bo);void ttm_bo_unpin (struct ttm_buffer_object *bo); int ttm_mem_evict_first(struct ttm_device *bdev,
Signature · 1 line
2.44.0
Thomas Hellström
maintainerPATCH v2 8/21 drm/ttm: sleeping evict lock.
In reply to Thomas Hellström--- drivers/gpu/drm/ttm/ttm_bo.c | 338 +++++++++++------------------ drivers/gpu/drm/ttm/ttm_device.c | 1 - drivers/gpu/drm/ttm/ttm_resource.c | 20 +- include/drm/ttm/ttm_bo.h | 8 +- 4 files changed, 129 insertions(+), 238 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +123 -215
@@ -224,80 +224,6 @@ static void ttm_bo_flush_all_fences(struct ttm_buffer_object *bo)dma_resv_iter_end (&cursor); } -/** -* ttm_bo_cleanup_refs -* If bo idle, remove from lru lists, and unref. -* If not idle, block if possible. -* -* Must be called with lru_lock and reservation held, this function -* will drop the lru lock and optionally the reservation lock before returning. -* -* @bo: The buffer object to clean-up -* @interruptible: Any sleeps should occur interruptibly. -* @no_wait_gpu: Never wait for gpu. Return -EBUSY instead. -* @unlock_resv: Unlock the reservation lock as well. -*/ - -static int ttm_bo_cleanup_refs (struct ttm_buffer_object *bo, -bool interruptible,bool no_wait_gpu, -bool unlock_resv) -{ -struct dma_resv *resv = &bo->base._resv; -int ret; - -if (dma_resv_test_signaled (resv,DMA_RESV_USAGE_BOOKKEEP )) - ret =0 ; -else - ret = -EBUSY ; - -if (ret && !no_wait_gpu) { -long lret; - -if (unlock_resv) -dma_resv_unlock (bo->base.resv); -spin_unlock (&bo->bdev->lru_lock); - - lret =dma_resv_wait_timeout (resv,DMA_RESV_USAGE_BOOKKEEP , - interruptible, -30 *HZ ); - -if (lret <0 ) -return lret; -else if (lret ==0 ) -return -EBUSY ; - -spin_lock (&bo->bdev->lru_lock); -if (unlock_resv && !dma_resv_trylock (bo->base.resv)) { -/* -* We raced, and lost, someone else holds the reservation now, -* and is probably busy in ttm_bo_cleanup_memtype_use. -* -* Even if it's not the case, because we finished waiting any -* delayed destruction would succeed, so just return success -* here. -*/ -spin_unlock (&bo->bdev->lru_lock); -return 0 ; - } - ret =0 ; - } - -if (ret) { -if (unlock_resv) -dma_resv_unlock (bo->base.resv); -spin_unlock (&bo->bdev->lru_lock); -return ret; - } - -spin_unlock (&bo->bdev->lru_lock); -ttm_bo_cleanup_memtype_use (bo); - -if (unlock_resv) -dma_resv_unlock (bo->base.resv); - -return 0 ; -} -/* * Block for the dma_resv object to become idle, lock the buffer and clean up * the resource and tt object.
@@ -505,151 +431,131 @@ bool ttm_bo_eviction_valuable(struct ttm_buffer_object *bo, }EXPORT_SYMBOL (ttm_bo_eviction_valuable); -/* -* Check the target bo is allowable to be evicted or swapout, including cases: -* -* a. if share same reservation object with ctx->resv, have assumption -* reservation objects should already be locked, so not lock again and -* return true directly when either the opreation allow_reserved_eviction -* or the target bo already is in delayed free list; -* -* b. Otherwise, trylock it. -*/ -static bool ttm_bo_evict_swapout_allowable (struct ttm_buffer_object *bo, -struct ttm_operation_ctx *ctx, -const struct ttm_place *place, -bool *locked,bool *busy) +int ttm_bo_evict_first (struct ttm_device *bdev,struct ttm_resource_manager *man, +struct ttm_operation_ctx *ctx) { -bool ret = false; +struct ttm_resource_cursor cursor; +struct ttm_resource *res; +struct ttm_buffer_object *bo; +int ret =0 ; -if (bo->pin_count) { - *locked = false; -if (busy) - *busy = false; -return false; +spin_lock (&bdev->lru_lock); + res =ttm_resource_manager_first (man, &cursor); +if (!res) { + ret = -ENOENT ; + goto out_no_ref; } + bo = res->bo; +if (!ttm_bo_get_unless_zero (bo)) + goto out_no_ref; +spin_unlock (&bdev->lru_lock); +dma_resv_lock (bo->base.resv,NULL ); +if (bo->resource != res) + goto out_bad_res; -if (bo->base.resv == ctx->resv) { -dma_resv_assert_held (bo->base.resv); -if (ctx->allow_res_evict) - ret = true; - *locked = false; -if (busy) - *busy = false; +if (bo->deleted) { + ret =ttm_bo_wait_ctx (bo, ctx); +if (ret) +ttm_bo_cleanup_memtype_use (bo); }else { - ret =dma_resv_trylock (bo->base.resv); - *locked = ret; -if (busy) - *busy = !ret; - } - -if (ret && place && (bo->resource->mem_type != place->mem_type || - !bo->bdev->funcs->eviction_valuable (bo, place))) { - ret = false; -if (*locked) { -dma_resv_unlock (bo->base.resv); - *locked = false; - } + ret =ttm_bo_evict (bo, ctx); } - +out_bad_res: +dma_resv_unlock (bo->base.resv); +ttm_bo_put (bo); +ttm_resource_cursor_fini (&cursor);return ret; -} - -/** -* ttm_mem_evict_wait_busy - wait for a busy BO to become available -* -* @busy_bo: BO which couldn't be locked with trylock -* @ctx: operation context -* @ticket: acquire ticket -* -* Try to lock a busy buffer object to avoid failing eviction. -*/ -static int ttm_mem_evict_wait_busy (struct ttm_buffer_object *busy_bo, -struct ttm_operation_ctx *ctx, -struct ww_acquire_ctx *ticket) -{ -int r; - -if (!busy_bo || !ticket) -return -EBUSY ; -if (ctx->interruptible) - r =dma_resv_lock_interruptible (busy_bo->base.resv, - ticket); -else - r =dma_resv_lock (busy_bo->base.resv, ticket); - -/* -* TODO: It would be better to keep the BO locked until allocation is at -* least tried one more time, but that would mean a much larger rework -* of TTM. -*/ -if (!r) -dma_resv_unlock (busy_bo->base.resv); - -return r == -EDEADLK ? -EBUSY : r; +out_no_ref: +ttm_resource_cursor_fini_locked (&cursor); +spin_unlock (&bdev->lru_lock); +return -ENOENT ; } -int ttm_mem_evict_first (struct ttm_device *bdev, -struct ttm_resource_manager *man, -const struct ttm_place *place, -struct ttm_operation_ctx *ctx, -struct ww_acquire_ctx *ticket) +struct ttm_bo_evict_walk { +struct ttm_lru_walk walk; +const struct ttm_place *place; +struct ttm_buffer_object *evictor; +struct ttm_resource **res; +unsigned long evicted; +}; + +static long ttm_bo_evict_cb (struct ttm_lru_walk *walk,struct ttm_buffer_object *bo) { -struct ttm_buffer_object *bo =NULL , *busy_bo =NULL ; -struct ttm_resource_cursor cursor; -struct ttm_resource *res; -bool locked = false; -int ret; +struct ttm_bo_evict_walk *evict_walk = +container_of (walk,typeof (*evict_walk), walk); +long lret; -spin_lock (&bdev->lru_lock); -ttm_resource_manager_for_each_res (man, &cursor, res) { -bool busy; - -if (!ttm_bo_evict_swapout_allowable (res->bo, ctx, place, - &locked, &busy)) { -if (busy && !busy_bo && ticket != -dma_resv_locking_ctx (res->bo->base.resv)) - busy_bo = res->bo; -continue ; - } +if (!bo->bdev->funcs->eviction_valuable (bo, evict_walk->place)) +return 0 ; -if (ttm_bo_get_unless_zero (res->bo)) { - bo = res->bo; -break ; - } -if (locked) -dma_resv_unlock (res->bo->base.resv); +if (bo->deleted) { + lret =ttm_bo_wait_ctx (bo, walk->ctx); +if (!lret) +ttm_bo_cleanup_memtype_use (bo); + }else { + lret =ttm_bo_evict (bo, walk->ctx); } -ttm_resource_cursor_fini_locked (&cursor); -if (!bo) { -if (busy_bo && !ttm_bo_get_unless_zero (busy_bo)) - busy_bo =NULL ; -spin_unlock (&bdev->lru_lock); - ret =ttm_mem_evict_wait_busy (busy_bo, ctx, ticket); -if (busy_bo) -ttm_bo_put (busy_bo); -return ret; - } +if (lret) + goto out; -if (bo->deleted) { - ret =ttm_bo_cleanup_refs (bo, ctx->interruptible, - ctx->no_wait_gpu, locked); -ttm_bo_put (bo); -return ret; - } + evict_walk->evicted++; +if (evict_walk->res) + lret =ttm_resource_alloc (evict_walk->evictor, evict_walk->place, + evict_walk->res); +if (lret ==0 ) +return 1 ; +out: +/* Errors that should terminate the walk. */ +if (lret == -ENOMEM || lret == -EINTR || lret == -ERESTARTSYS || + lret == -EAGAIN ) +return lret; -spin_unlock (&bdev->lru_lock); +return 0 ; +} - ret =ttm_bo_evict (bo, ctx); -if (locked) -ttm_bo_unreserve (bo); -else -ttm_bo_move_to_lru_tail_unlocked (bo); +static const struct ttm_lru_walk_ops ttm_evict_walk_ops = { + .process_bo = ttm_bo_evict_cb, +}; -ttm_bo_put (bo); -return ret; +static int ttm_bo_evict_alloc (struct ttm_device *bdev, +struct ttm_resource_manager *man, +const struct ttm_place *place, +struct ttm_buffer_object *evictor, +struct ttm_operation_ctx *ctx, +struct ww_acquire_ctx *ticket, +struct ttm_resource **res) +{ +struct ttm_bo_evict_walk evict_walk = { + .walk = { + .ops = &ttm_evict_walk_ops, + .ctx = ctx, + .ticket = ticket, + }, + .place = place, + .evictor = evictor, + .res = res, + }; +long lret; + + evict_walk.walk.trylock_only = true; + lret =ttm_lru_walk_for_evict (&evict_walk.walk, bdev, man,1 ); +if (lret || !ticket) + goto out; + +/* If ticket-locking, repeat while we make progress. */ + evict_walk.walk.trylock_only = false; +do { + evict_walk.evicted =0 ; + lret =ttm_lru_walk_for_evict (&evict_walk.walk, bdev, man,1 ); + }while (!lret && evict_walk.evicted); +out: +if (lret <0 ) +return lret; +if (lret ==0 ) +return -EBUSY ; +return 0 ; }/**
@@ -760,6 +666,7 @@ static int ttm_bo_alloc_resource(struct ttm_buffer_object *bo,for (i =0 ; i < placement->num_placement; ++i) {const struct ttm_place *place = &placement->placement[i];struct ttm_resource_manager *man; +bool may_evict; man =ttm_manager_type (bdev, place->mem_type);if (!man || !ttm_resource_manager_used (man))
@@ -769,22 +676,21 @@ static int ttm_bo_alloc_resource(struct ttm_buffer_object *bo, TTM_PL_FLAG_FALLBACK))continue ; -do { - ret =ttm_resource_alloc (bo, place, res); -if (unlikely (ret && ret != -ENOSPC )) + may_evict = (force_space && place->mem_type !=TTM_PL_SYSTEM ); + ret =ttm_resource_alloc (bo, place, res); +if (ret) { +if (ret != -ENOSPC )return ret; -if (likely (!ret) || !force_space) -break ; - - ret =ttm_mem_evict_first (bdev, man, place, ctx, - ticket); -if (unlikely (ret == -EBUSY )) -break ; -if (unlikely (ret)) +if (!may_evict) +continue ; + + ret =ttm_bo_evict_alloc (bdev, man, place, bo, ctx, + ticket, res); +if (ret == -EBUSY ) +continue ; +if (ret)return ret; - }while (1 ); -if (ret) -continue ; + } ret =ttm_bo_add_move_fence (bo, man, ctx->no_wait_gpu);if (unlikely (ret)) {
@@ -796,7 +702,6 @@ static int ttm_bo_alloc_resource(struct ttm_buffer_object *bo, }return 0 ; } -return -ENOSPC ; }
@@ -822,6 +727,9 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,do { ret =ttm_bo_alloc_resource (bo, placement, ctx, force_space, res); +if (ret) +pr_err ("mem space failure %pe, force_space %d\n" , +ERR_PTR (ret), force_space); force_space = !force_space; }while (ret == -ENOSPC && force_space);
drivers/gpu/drm/ttm/ttm_device.c +0 -1
@@ -152,7 +152,6 @@ int ttm_device_swapout(struct ttm_device *bdev, struct ttm_operation_ctx *ctx,unsigned i;long lret; -spin_lock (&bdev->lru_lock);for (i =TTM_PL_SYSTEM ; i <TTM_NUM_MEM_TYPES ; ++i) { man =ttm_manager_type (bdev, i);if (!man || !man->use_tt)
drivers/gpu/drm/ttm/ttm_resource.c +3 -17
@@ -509,24 +509,10 @@ int ttm_resource_manager_evict_all(struct ttm_device *bdev, };struct dma_fence *fence;int ret; -unsigned i; - -/* -* Can't use standard list traversal since we're unlocking. -*/ -spin_lock (&bdev->lru_lock); -for (i =0 ; i <TTM_MAX_BO_PRIORITY ; ++i) { -while (!list_empty (&man->lru[i])) { -spin_unlock (&bdev->lru_lock); - ret =ttm_mem_evict_first (bdev, man,NULL , &ctx, -NULL ); -if (ret) -return ret; -spin_lock (&bdev->lru_lock); - } - } -spin_unlock (&bdev->lru_lock); +do { + ret =ttm_bo_evict_first (bdev, man, &ctx); + }while (!ret);spin_lock (&man->move_lock); fence =dma_fence_get (man->move);
include/drm/ttm/ttm_bo.h +3 -5
@@ -415,11 +415,9 @@ long ttm_bo_swapout(struct ttm_device *bdev, struct ttm_operation_ctx *ctx, pgoff_t target);void ttm_bo_pin (struct ttm_buffer_object *bo);void ttm_bo_unpin (struct ttm_buffer_object *bo); -int ttm_mem_evict_first (struct ttm_device *bdev, -struct ttm_resource_manager *man, -const struct ttm_place *place, -struct ttm_operation_ctx *ctx, -struct ww_acquire_ctx *ticket); +int ttm_bo_evict_first (struct ttm_device *bdev, +struct ttm_resource_manager *man, +struct ttm_operation_ctx *ctx);vm_fault_t ttm_bo_vm_reserve (struct ttm_buffer_object *bo,struct vm_fault *vmf); vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
Signature · 1 line
2.44.0
Thomas Hellström
maintainerPATCH v2 9/21 drm/ttm: Add a virtual base class for graphics memory backup
In reply to Thomas HellströmInitially intended for experimenting with different backup solutions (shmem vs direct swap cache insertion), abstract the backup destination using a virtual base class.
Also provide a sample implementation for shmem.
While when settling on a preferred backup solution, one could perhaps skip the abstraction, this functionality may actually come in handy for configurable dedicated graphics memory backup to fast nvme files or similar, whithout affecting swap-space. Could indeed be useful for VRAM backup on S4 and other cases.
--- drivers/gpu/drm/ttm/Makefile | 2 +- drivers/gpu/drm/ttm/ttm_backup_shmem.c | 137 +++++++++++++++++++++++++ include/drm/ttm/ttm_backup.h | 136 ++++++++++++++++++++++++ 3 files changed, 274 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/ttm/ttm_backup_shmem.c create mode 100644 include/drm/ttm/ttm_backup.h
drivers/gpu/drm/ttm/Makefile +1 -1
@@ -4,7 +4,7 @@ ttm-y := ttm_tt.o ttm_bo.o ttm_bo_util.o ttm_bo_vm.o ttm_module.o \ ttm_execbuf_util.o ttm_range_manager.o ttm_resource.o ttm_pool.o \ - ttm_device.o ttm_sys_manager.o + ttm_device.o ttm_sys_manager.o ttm_backup_shmem.o ttm-$(CONFIG_AGP) += ttm_agp_backend.o obj-$(CONFIG_DRM_TTM) += ttm.o
drivers/gpu/drm/ttm/ttm_backup_shmem.c new file +137 -0
137 lines not on this page · raw message
include/drm/ttm/ttm_backup.h new file +136 -0
136 lines not on this page · raw message
Signature · 1 line
2.44.0
Thomas Hellström
maintainerPATCH v2 10/21 drm/ttm/pool: Provide a helper to shrink pages.
In reply to Thomas HellströmProvide a helper to shrink ttm_tt page-vectors on a per-page basis. A ttm_backup backend could then in theory get away with allocating a single temporary page for each struct ttm_tt.
This is accomplished by splitting larger pages before trying to back them up.
In the future we could allow ttm_backup to handle backing up large pages as well, but currently there's no benefit in doing that, since the shmem backup backend would have to split those anyway to avoid allocating too much temporary memory, and if the backend instead inserts pages into the swap-cache, those are split on reclaim by the core.
Due to potential backup- and recover errors, allow partially swapped out struct ttm_tt's, although mark them as swapped out stopping them from being swapped out a second time. More details in the ttm_pool.c DOC section.
v2:
- A couple of cleanups and error fixes in ttm_pool_back_up_tt.
- s/back_up/backup/
- Add a writeback parameter to the exported interface.
--- drivers/gpu/drm/ttm/ttm_pool.c | 397 +++++++++++++++++++++++++++++++-- drivers/gpu/drm/ttm/ttm_tt.c | 37 +++ include/drm/ttm/ttm_pool.h | 5 + include/drm/ttm/ttm_tt.h | 20 ++ 4 files changed, 446 insertions(+), 13 deletions(-)
drivers/gpu/drm/ttm/ttm_pool.c +384 -13
@@ -41,6 +41,7 @@#include <asm/set_memory.h> #endif +#include <drm/ttm/ttm_backup.h> #include <drm/ttm/ttm_pool.h> #include <drm/ttm/ttm_tt.h> #include <drm/ttm/ttm_bo.h>
@@ -58,6 +59,32 @@ struct ttm_pool_dma {unsigned long vaddr; }; +/** +* struct ttm_pool_tt_restore - State representing restore from backup +* @alloced_pages: Total number of already allocated pages for the ttm_tt. +* @restored_pages: Number of (sub) pages restored from swap for this +* chunk of 1 << @order pages. +* @first_page: The ttm page ptr representing for @old_pages[0]. +* @caching_divide: Page pointer where subsequent pages are cached. +* @old_pages: Backup copy of page pointers that were replaced by the new +* page allocation. +* @pool: The pool used for page allocation while restoring. +* @order: The order of the last page allocated while restoring. +* +* Recovery from backup might fail when we've recovered less than the +* full ttm_tt. In order not to loose any data (yet), keep information +* around that allows us to restart a failed ttm backup recovery. +*/ +struct ttm_pool_tt_restore { +pgoff_t alloced_pages; +pgoff_t restored_pages; +struct page **first_page; +struct page **caching_divide; +struct ttm_pool *pool; +unsigned int order; +struct page *old_pages[]; +}; +static unsigned long page_pool_size;MODULE_PARM_DESC (page_pool_size,"Number of pages in the WC/UC/DMA pool" );
@@ -354,11 +381,102 @@ static unsigned int ttm_pool_page_order(struct ttm_pool *pool, struct page *p)return p->private; } +/* +* To be able to insert single pages into backup directly, +* we need to split multi-order page allocations and make them look +* like single-page allocations. +*/ +static void ttm_pool_split_for_swap (struct ttm_pool *pool,struct page *p) +{ +unsigned int order =ttm_pool_page_order (pool, p); +pgoff_t nr; + +if (!order) +return ; + +split_page (p, order); + nr =1UL << order; +while (nr--) + (p++)->private =0 ; +} + +/** +* DOC: Partial backup and restoration of a struct ttm_tt. +* +* Swapout using ttm_backup::ops::backup_page() and swapin using +* ttm_backup::ops::copy_backed_up_page() may fail. +* The former most likely due to lack of swap-space or memory, the latter due +* to lack of memory or because of signal interruption during waits. +* +* Backupfailure is easily handled by using a ttm_tt pages vector that holds +* both swap entries and page pointers. This has to be taken into account when +* restoring such a ttm_tt from backup, and when freeing it while backed up. +* When restoring, for simplicity, new pages are actually allocated from the +* pool and the contents of any old pages are copied in and then the old pages +* are released. +* +* For restoration failures, the struct ttm_pool_tt_restore holds sufficient state +* to be able to resume an interrupted restore, and that structure is freed once +* the restoration is complete. If the struct ttm_tt is destroyed while there +* is a valid struct ttm_pool_tt_restore attached, that is also properly taken +* care of. +*/ + +static bool ttm_pool_restore_valid (const struct ttm_pool_tt_restore *restore) +{ +return restore && restore->restored_pages < (1 << restore->order); +} + +static int ttm_pool_restore_tt (struct ttm_pool_tt_restore *restore, +struct ttm_backup *backup, +struct ttm_operation_ctx *ctx) +{ +unsigned int i, nr =1 << restore->order; +int ret =0 ; + +if (!ttm_pool_restore_valid (restore)) +return 0 ; + +for (i = restore->restored_pages; i < nr; ++i) { +struct page *p = restore->old_pages[i]; + +if (ttm_backup_page_ptr_is_handle (p)) { +unsigned long handle =ttm_backup_page_ptr_to_handle (p); + +if (handle ==0 ) +continue ; + + ret = backup->ops->copy_backed_up_page + (backup, restore->first_page[i], + handle, ctx->interruptible); +if (ret) +break ; + + backup->ops->drop (backup, handle); + }else if (p) { +/* +* We could probably avoid splitting the old page +* using clever logic, but ATM we don't care. +*/ +ttm_pool_split_for_swap (restore->pool, p); +copy_highpage (restore->first_page[i], p); +__free_pages (p,0 ); + } + + restore->restored_pages++; + restore->old_pages[i] =NULL ; +cond_resched (); + } + +return ret; +} +/* Called when we got a page, either from a pool or newly allocated */ static int ttm_pool_page_allocated (struct ttm_pool *pool,unsigned int order,struct page *p,dma_addr_t **dma_addr,unsigned long *num_pages, -struct page ***pages) +struct page ***pages, +struct ttm_pool_tt_restore *restore) {unsigned int i;int r;
@@ -369,6 +487,16 @@ static int ttm_pool_page_allocated(struct ttm_pool *pool, unsigned int order,return r; } +if (restore) { +memcpy (restore->old_pages, *pages, + (1 << order) *sizeof (*restore->old_pages)); +memset (*pages,0 , (1 << order) *sizeof (**pages)); + restore->order = order; + restore->restored_pages =0 ; + restore->first_page = *pages; + restore->alloced_pages +=1UL << order; + } + *num_pages -=1 << order;for (i =1 << order; i; --i, ++(*pages), ++p) **pages = p;
@@ -394,22 +522,39 @@ static void ttm_pool_free_range(struct ttm_pool *pool, struct ttm_tt *tt, pgoff_t start_page, pgoff_t end_page) {struct page **pages = &tt->pages[start_page]; +struct ttm_backup *backup = tt->backup;unsigned int order;pgoff_t i, nr;for (i = start_page; i < end_page; i += nr, pages += nr) {struct ttm_pool_type *pt =NULL ; +struct page *p = *pages; + +if (ttm_backup_page_ptr_is_handle (p)) { +unsigned long handle =ttm_backup_page_ptr_to_handle (p); + + nr =1 ; +if (handle !=0 ) + backup->ops->drop (backup, handle); +continue ; + } + +if (pool) { + order =ttm_pool_page_order (pool, p); + nr = (1UL << order); +if (tt->dma_address) +ttm_pool_unmap (pool, tt->dma_address[i], nr); - order =ttm_pool_page_order (pool, *pages); - nr = (1UL << order); -if (tt->dma_address) -ttm_pool_unmap (pool, tt->dma_address[i], nr); + pt =ttm_pool_select_type (pool, caching, order); + }else { + order = p->private; + nr = (1UL << order); + } - pt =ttm_pool_select_type (pool, caching, order);if (pt) -ttm_pool_type_give (pt, *pages); +ttm_pool_type_give (pt, p);else -ttm_pool_free_page (pool, caching, order, *pages); +ttm_pool_free_page (pool, caching, order, p); } }
@@ -453,9 +598,37 @@ int ttm_pool_alloc(struct ttm_pool *pool, struct ttm_tt *tt,else gfp_flags |=GFP_HIGHUSER ; - for (order = min_t(unsigned int, MAX_PAGE_ORDER, __fls(num_pages)); - num_pages; - order = min_t(unsigned int, order, __fls(num_pages))) { + order = min_t(unsigned int, MAX_PAGE_ORDER, __fls(num_pages)); + +if (tt->page_flags &TTM_TT_FLAG_PRIV_BACKED_UP ) { +if (!tt->restore) { +gfp_t gfp =GFP_KERNEL | __GFP_NOWARN; + +if (ctx->gfp_retry_mayfail) + gfp |= __GFP_RETRY_MAYFAIL; + + tt->restore = +kvzalloc (struct_size (tt->restore, old_pages, + (size_t )1 << order), gfp); +/* RFC: Possibly loop on -ENOMEM and reduce order. */ +if (!tt->restore) +return -ENOMEM ; + }else if (ttm_pool_restore_valid (tt->restore)) { +struct ttm_pool_tt_restore *restore = tt->restore; + + num_pages -= restore->alloced_pages; + order = min_t(unsigned int, order, __fls(num_pages)); + pages += restore->alloced_pages; + r =ttm_pool_restore_tt (restore, tt->backup, ctx); +if (r) +return r; + caching = restore->caching_divide; + } + + tt->restore->pool = pool; + } + + for (; num_pages; order = min_t(unsigned int, order, __fls(num_pages))) {struct ttm_pool_type *pt; page_caching = tt->caching;
@@ -472,11 +645,19 @@ int ttm_pool_alloc(struct ttm_pool *pool, struct ttm_tt *tt, r =ttm_pool_page_allocated (pool, order, p, &dma_addr, &num_pages, - &pages); + &pages, + tt->restore);if (r) goto error_free_page; caching = pages; +if (ttm_pool_restore_valid (tt->restore)) { + r =ttm_pool_restore_tt (tt->restore, tt->backup, + ctx); +if (r) + goto error_free_all; + } +if (num_pages < (1 << order))break ;
@@ -496,9 +677,17 @@ int ttm_pool_alloc(struct ttm_pool *pool, struct ttm_tt *tt, caching = pages; } r =ttm_pool_page_allocated (pool, order, p, &dma_addr, - &num_pages, &pages); + &num_pages, &pages, + tt->restore);if (r) goto error_free_page; + +if (ttm_pool_restore_valid (tt->restore)) { + r =ttm_pool_restore_tt (tt->restore, tt->backup, ctx); +if (r) + goto error_free_all; + } +if (PageHighMem (p)) caching = pages; }
@@ -517,12 +706,26 @@ int ttm_pool_alloc(struct ttm_pool *pool, struct ttm_tt *tt,if (r) goto error_free_all; +if (tt->restore) { +kvfree (tt->restore); + tt->restore =NULL ; + } + +if (tt->page_flags &TTM_TT_FLAG_PRIV_BACKED_UP ) + tt->page_flags &= ~(TTM_TT_FLAG_PRIV_BACKED_UP | +TTM_TT_FLAG_SWAPPED ); +return 0 ; error_free_page:ttm_pool_free_page (pool, page_caching, order, p); error_free_all: +if (tt->page_flags &TTM_TT_FLAG_PRIV_BACKED_UP ) { + tt->restore->caching_divide = caching; +return r; + } + num_pages = tt->num_pages - num_pages; caching_divide = caching - tt->pages;ttm_pool_free_range (pool, tt, tt->caching,0 , caching_divide);
@@ -549,6 +752,174 @@ void ttm_pool_free(struct ttm_pool *pool, struct ttm_tt *tt) }EXPORT_SYMBOL (ttm_pool_free); +/** +* ttm_pool_release_backed_up() - Release content of a swapped-out struct ttm_tt +* @tt: The struct ttm_tt. +* +* Release handles with associated content or any remaining pages of +* a backed-up struct ttm_tt. +*/ +void ttm_pool_release_backed_up (struct ttm_tt *tt) +{ +struct ttm_backup *backup = tt->backup; +struct ttm_pool_tt_restore *restore; +pgoff_t i, start_page =0 ; +unsigned long handle; + +if (!(tt->page_flags &TTM_TT_FLAG_PRIV_BACKED_UP )) +return ; + + restore = tt->restore; + +if (ttm_pool_restore_valid (restore)) { +pgoff_t nr =1UL << restore->order; + +for (i = restore->restored_pages; i < nr; ++i) { +struct page *p = restore->old_pages[i]; + +if (ttm_backup_page_ptr_is_handle (p)) { + handle =ttm_backup_page_ptr_to_handle (p); +if (handle ==0 ) +continue ; + + backup->ops->drop (backup, handle); + }else if (p) { +ttm_pool_split_for_swap (restore->pool, p); +__free_pages (p,0 ); + } + } + } + +if (restore) { +pgoff_t mid = restore->caching_divide - tt->pages; + + start_page = restore->alloced_pages; +/* Pages that might be dma-mapped and non-cached */ +ttm_pool_free_range (restore->pool, tt, tt->caching, +0 , mid); +/* Pages that might be dma-mapped but cached */ +ttm_pool_free_range (restore->pool, tt, ttm_cached, + mid, restore->alloced_pages); + } + +/* Shrunken pages. Cached and not dma-mapped. */ +ttm_pool_free_range (NULL , tt, ttm_cached, start_page, tt->num_pages); + +if (restore) { +kvfree (restore); + tt->restore =NULL ; + } + + tt->page_flags &= ~(TTM_TT_FLAG_PRIV_BACKED_UP |TTM_TT_FLAG_SWAPPED ); +} + +/** +* ttm_pool_backup_tt() - Back up or purge a struct ttm_tt +* @pool: The pool used when allocating the struct ttm_tt. +* @ttm: The struct ttm_tt. +* @purge: Don't back up but release pages directly to system. +* @writeback: If !@purge, Try to write out directly to the +* underlying persistent media. +* +* Back up or purge a struct ttm_tt. If @purge is true, then +* all pages will be freed directly to the system rather than to the pool +* they were allocated from, making the function behave similarly to +* ttm_pool_free(). If @purge is false the pages will be backed up instead, +* exchanged for handles. +* A subsequent call to ttm_pool_alloc() will then read back the content and +* a subsequent call to ttm_pool_release_shrunken() will drop it. +* If backup of a page fails for whatever reason, @ttm will still be +* partially backed up, retaining those pages for which backup fails. +* +* Return: Number of pages actually backed up or freed, or negative +* error code on error. +*/ +long ttm_pool_backup_tt (struct ttm_pool *pool,struct ttm_tt *ttm,bool purge, +bool writeback) +{ +struct ttm_backup *backup = ttm->backup; +struct page *page; +unsigned long handle; +gfp_t alloc_gfp; +gfp_t gfp; +int ret =0 ; +pgoff_t shrunken =0 ; +pgoff_t i, num_pages; + +if ((!get_nr_swap_pages () && !purge) || + pool->use_dma_alloc || + (ttm->page_flags &TTM_TT_FLAG_PRIV_BACKED_UP )) +return -EBUSY ; + +#ifdef CONFIG_X86 +/* Anything returned to the system needs to be cached. */ +if (ttm->caching != ttm_cached) +set_pages_array_wb (ttm->pages, ttm->num_pages); +#endif + +if (ttm->dma_address || purge) { +for (i =0 ; i < ttm->num_pages; i += num_pages) { +unsigned int order; + + page = ttm->pages[i]; +if (unlikely (!page)) { + num_pages =1 ; +continue ; + } + + order =ttm_pool_page_order (pool, page); + num_pages =1UL << order; +if (ttm->dma_address) +ttm_pool_unmap (pool, ttm->dma_address[i], + num_pages); +if (purge) { + shrunken += num_pages; + page->private =0 ; +__free_pages (page, order); +memset (ttm->pages + i,0 , + num_pages *sizeof (*ttm->pages)); + } + } + } + +if (purge) +return shrunken; + +if (pool->use_dma32) + gfp =GFP_DMA32 ; +else + gfp =GFP_HIGHUSER ; + + alloc_gfp =GFP_KERNEL | __GFP_HIGH | __GFP_NOWARN | __GFP_RETRY_MAYFAIL; + +for (i =0 ; i < ttm->num_pages; ++i) { + page = ttm->pages[i]; +if (unlikely (!page)) +continue ; + +ttm_pool_split_for_swap (pool, page); + + handle = backup->ops->backup_page (backup, page, writeback, i, + gfp, alloc_gfp); +if (handle) { + ttm->pages[i] =ttm_backup_handle_to_page_ptr (handle); +put_page (page); + shrunken++; + }else { +/* We allow partially shrunken tts */ + ret = -ENOMEM ; +break ; + } +cond_resched (); + } + +if (shrunken) + ttm->page_flags |= (TTM_TT_FLAG_PRIV_BACKED_UP | +TTM_TT_FLAG_SWAPPED ); + +return shrunken ? shrunken : ret; +} +/** * ttm_pool_init - Initialize a pool *
drivers/gpu/drm/ttm/ttm_tt.c +37 -0
@@ -40,6 +40,7 @@#include <drm/drm_cache.h> #include <drm/drm_device.h> #include <drm/drm_util.h> +#include <drm/ttm/ttm_backup.h> #include <drm/ttm/ttm_bo.h> #include <drm/ttm/ttm_tt.h>
@@ -158,6 +159,7 @@ static void ttm_tt_init_fields(struct ttm_tt *ttm, ttm->swap_storage =NULL ; ttm->sg = bo->sg; ttm->caching = caching; + ttm->restore =NULL ; } int ttm_tt_init(struct ttm_tt *ttm, struct ttm_buffer_object *bo,
@@ -182,6 +184,12 @@ void ttm_tt_fini(struct ttm_tt *ttm)fput (ttm->swap_storage); ttm->swap_storage =NULL ; +ttm_pool_release_backed_up (ttm); +if (ttm->backup) { + ttm->backup->ops->fini (ttm->backup); + ttm->backup =NULL ; + } +if (ttm->pages)kvfree (ttm->pages);else
@@ -252,6 +260,35 @@ int ttm_tt_swapin(struct ttm_tt *ttm)return ret; } +/** +* ttm_tt_backup() - Helper to back up a struct ttm_tt. +* @bdev: The TTM device. +* @tt: The struct ttm_tt. +* @purge: Don't back up but release pages directly to system, +* bypassing any pooling. +* @writeback: If !@purge, try to write out directly to the +* underlying persistent media. +* +* Helper for a TTM driver to use from the bo_shrink() method to shrink +* a struct ttm_tt, after it has done the necessary unbinding. This function +* will update the page accounting and call ttm_pool_shrink_tt to free pages +* or move them to the swap cache. +* +* Return: Number of pages freed or swapped out, or negative error code on +* error. +*/ +long ttm_tt_backup (struct ttm_device *bdev,struct ttm_tt *tt,bool purge, +bool writeback) +{ +long ret =ttm_pool_backup_tt (&bdev->pool, tt, purge, writeback); + +if (ret >0 ) + tt->page_flags &= ~TTM_TT_FLAG_PRIV_POPULATED ; + +return ret; +} +EXPORT_SYMBOL (ttm_tt_backup); +/** * ttm_tt_swapout - swap out tt object *
include/drm/ttm/ttm_pool.h +5 -0
@@ -89,6 +89,11 @@ void ttm_pool_fini(struct ttm_pool *pool);int ttm_pool_debugfs (struct ttm_pool *pool,struct seq_file *m); +void ttm_pool_release_backed_up (struct ttm_tt *tt); + +long ttm_pool_backup_tt (struct ttm_pool *pool,struct ttm_tt *ttm, +bool purge,bool writeback); +int ttm_pool_mgr_init (unsigned long num_pages);void ttm_pool_mgr_fini (void );
include/drm/ttm/ttm_tt.h +20 -0
@@ -32,11 +32,13 @@#include <drm/ttm/ttm_caching.h> #include <drm/ttm/ttm_kmap_iter.h> +struct ttm_backup ;struct ttm_device ;struct ttm_tt ;struct ttm_resource ;struct ttm_buffer_object ;struct ttm_operation_ctx ; +struct ttm_pool_tt_restore ;/** * struct ttm_tt - This is a structure holding the pages, caching- and aperture
@@ -85,6 +87,9 @@ struct ttm_tt {* fault handling abuses the DMA api a bit and dma_map_attrs can't be * used to assure pgprot always matches. * +* TTM_TT_FLAG_PRIV_BACKED_UP: TTM internal only. This is set if the +* struct ttm_tt has been (possibly partially) backed up. +* * TTM_TT_FLAG_PRIV_POPULATED: TTM internal only. DO NOT USE. This is * set by TTM after ttm_tt_populate() has successfully returned, and is * then unset when TTM calls ttm_tt_unpopulate().
@@ -96,6 +101,7 @@ struct ttm_tt {#define TTM_TT_FLAG_DECRYPTED BIT(4)#define TTM_TT_FLAG_PRIV_POPULATED BIT(5) +#define TTM_TT_FLAG_PRIV_BACKED_UP BIT(6)uint32_t page_flags;/** @num_pages: Number of pages in the page array. */ uint32_t num_pages;
@@ -105,11 +111,21 @@ struct ttm_tt {dma_addr_t *dma_address;/** @swap_storage: Pointer to shmem struct file for swap storage. */ struct file *swap_storage; +/** +* @backup: Pointer to backup struct for backed up tts. +* RFC: Could possibly be unified with @swap_storage. +*/ +struct ttm_backup *backup;/** * @caching: The current caching state of the pages, see enum * ttm_caching. */ enum ttm_caching caching; +/** +* @restore: Partial restoration from backup state. +* RFC: Incorporate in struct ttm_backup? +*/ +struct ttm_pool_tt_restore *restore; };/**
@@ -230,6 +246,10 @@ void ttm_tt_mgr_init(unsigned long num_pages, unsigned long num_dma32_pages);struct ttm_kmap_iter *ttm_kmap_iter_tt_init (struct ttm_kmap_iter_tt *iter_tt,struct ttm_tt *tt);unsigned long ttm_tt_pages_limit (void ); + +long ttm_tt_backup (struct ttm_device *bdev,struct ttm_tt *tt,bool purge, +bool writeback); +#if IS_ENABLED (CONFIG_AGP )#include <linux/agp_backend.h>
Signature · 1 line
2.44.0
Thomas Hellström
maintainerPATCH v2 11/21 drm/ttm: Use fault-injection to test error paths
In reply to Thomas HellströmUse fault-injection to test partial TTM swapout and interrupted swapin. Return -EINTR for swapin to test the callers ability to handle and restart the swapin, and on swapout perform a partial swapout to test that the swapin and release_shrunken functionality.
--- drivers/gpu/drm/Kconfig | 10 ++++++++++ drivers/gpu/drm/ttm/ttm_pool.c | 17 ++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-)
drivers/gpu/drm/Kconfig +10 -0
@@ -258,6 +258,16 @@ config DRM_GPUVM GPU-VM representation providing helpers to manage a GPUs virtual address space +config DRM_TTM_BACKUP_FAULT_INJECT + bool "Enable fault injection during TTM backup" + depends on DRM_TTM + default n + help + Inject recoverable failures during TTM backup and recovery of + backed-up objects. For DRM driver developers only. + + If in doubt, choose N. + config DRM_BUDDY tristate depends on DRM
drivers/gpu/drm/ttm/ttm_pool.c +16 -1
@@ -431,6 +431,7 @@ static int ttm_pool_restore_tt(struct ttm_pool_tt_restore *restore, struct ttm_backup *backup, struct ttm_operation_ctx *ctx) { +static unsigned long __maybe_unused swappedin;unsigned int i, nr =1 << restore->order;int ret =0 ;
@@ -446,6 +447,13 @@ static int ttm_pool_restore_tt(struct ttm_pool_tt_restore *restore,if (handle ==0 )continue ; +if (IS_ENABLED (CONFIG_DRM_TTM_BACKUP_FAULT_INJECT ) && + ctx->interruptible && + ++swappedin %100 ==0 ) { + ret = -EINTR ; +break ; + } + ret = backup->ops->copy_backed_up_page (backup, restore->first_page[i], handle, ctx->interruptible);
@@ -892,7 +900,14 @@ long ttm_pool_backup_tt(struct ttm_pool *pool, struct ttm_tt *ttm, bool purge, alloc_gfp =GFP_KERNEL | __GFP_HIGH | __GFP_NOWARN | __GFP_RETRY_MAYFAIL; -for (i =0 ; i < ttm->num_pages; ++i) { + num_pages = ttm->num_pages; + +/* Pretend doing fault injection by shrinking only half of the pages. */ + +if (IS_ENABLED (CONFIG_DRM_TTM_BACKUP_FAULT_INJECT )) + num_pages =DIV_ROUND_UP (num_pages,2 ); + +for (i =0 ; i < num_pages; ++i) { page = ttm->pages[i];if (unlikely (!page))continue ;
Signature · 1 line
2.44.0
Thomas Hellström
maintainerPATCH v2 12/21 drm/ttm, drm/xe: Add a shrinker for xe bos
In reply to Thomas HellströmRather than relying on the TTM watermark accounting add a shrinker for xe_bos in TT or system memory.
Leverage the newly added TTM per-page shrinking and shmem backup support.
Although xe doesn't fully support WONTNEED (purgeable) bos yet, introduce and add shrinker support for purgeable ttm_tts.
v2:
- Cleanups bugfixes and a KUNIT shrinker test.
- Add writeback support, and activate if kswapd.
--- drivers/gpu/drm/ttm/ttm_bo_util.c | 75 +++++++++ drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/tests/xe_bo.c | 118 ++++++++++++++ drivers/gpu/drm/xe/tests/xe_bo_test.c | 1 + drivers/gpu/drm/xe/tests/xe_bo_test.h | 1 + drivers/gpu/drm/xe/xe_bo.c | 128 +++++++++++++-- drivers/gpu/drm/xe/xe_bo.h | 4 + drivers/gpu/drm/xe/xe_device.c | 8 + drivers/gpu/drm/xe/xe_device_types.h | 2 + drivers/gpu/drm/xe/xe_shrinker.c | 224 ++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_shrinker.h | 18 +++ include/drm/ttm/ttm_bo.h | 3 + 12 files changed, 567 insertions(+), 16 deletions(-) create mode 100644 drivers/gpu/drm/xe/xe_shrinker.c create mode 100644 drivers/gpu/drm/xe/xe_shrinker.h
drivers/gpu/drm/ttm/ttm_bo_util.c +75 -0
@@ -930,3 +930,78 @@ long ttm_lru_walk_for_evict(struct ttm_lru_walk *walk, struct ttm_device *bdev,ttm_resource_cursor_fini (&cursor);return sofar; } +EXPORT_SYMBOL (ttm_lru_walk_for_evict); + +/** +* ttm_bo_try_shrink - LRU walk helper to shrink a ttm buffer object. +* @walk: The struct xe_ttm_lru_walk that describes the walk. +* @bo: The buffer object. +* @purge: Whether to attempt to purge the bo content since it's no +* longer needed. +* @writeback: If !@purge, attempt to write out to persistent storage. +* +* The function uses the ttm_tt_back_up functionality to back up or +* purge a struct ttm_tt. If the bo is not in system, it's first +* moved there. +* +* Return: The number of pages shrunken or purged, or +* negative error code on failure. +*/ +long ttm_bo_try_shrink (struct ttm_lru_walk *walk,struct ttm_buffer_object *bo, +bool purge,bool writeback) +{ +static const struct ttm_place sys_placement_flags = { + .fpfn =0 , + .lpfn =0 , + .mem_type =TTM_PL_SYSTEM , + .flags =0 , + }; +static struct ttm_placement sys_placement = { + .num_placement =1 , + .placement = &sys_placement_flags, + }; +struct ttm_operation_ctx *ctx = walk->ctx; +struct ttm_tt *tt = bo->ttm; +long lret; + +dma_resv_assert_held (bo->base.resv); + +if (!tt || !ttm_tt_is_populated (tt)) +return 0 ; + +if (bo->resource->mem_type !=TTM_PL_SYSTEM ) { +int ret =ttm_bo_validate (bo, &sys_placement, ctx); + +if (ret) { +if (ret == -EINTR || ret == -EDEADLK || + ret == -ERESTARTSYS ) +return ret; +return 0 ; + } + } + +if (ctx->no_wait_gpu && + !dma_resv_test_signaled (bo->base.resv, +DMA_RESV_USAGE_BOOKKEEP )) +return 0 ; + + lret =dma_resv_wait_timeout (bo->base.resv, +DMA_RESV_USAGE_BOOKKEEP , + ctx->interruptible, +MAX_SCHEDULE_TIMEOUT ); +if (lret <0 ) { +if (lret == -ERESTARTSYS ) +return lret; +return 0 ; + } + +if (bo->deleted) + lret =ttm_tt_backup (bo->bdev, tt, true, writeback); +else + lret =ttm_tt_backup (bo->bdev, tt, purge, writeback); +if (lret <0 && lret != -EINTR ) +return 0 ; + +return lret; +} +EXPORT_SYMBOL (ttm_bo_try_shrink);
drivers/gpu/drm/xe/Makefile +1 -0
@@ -130,6 +130,7 @@ xe-y += xe_bb.o \ xe_ring_ops.o \ xe_sa.o \ xe_sched_job.o \ + xe_shrinker.o \ xe_step.o \ xe_sync.o \ xe_tile.o \
drivers/gpu/drm/xe/tests/xe_bo.c +118 -0
127 lines not on this page · raw message
drivers/gpu/drm/xe/tests/xe_bo_test.c +1 -0
@@ -10,6 +10,7 @@static struct kunit_case xe_bo_tests[] = {KUNIT_CASE (xe_ccs_migrate_kunit),KUNIT_CASE (xe_bo_evict_kunit), +KUNIT_CASE_SLOW (xe_bo_shrink_kunit), {} };
drivers/gpu/drm/xe/tests/xe_bo_test.h +1 -0
@@ -10,5 +10,6 @@ struct kunit;void xe_ccs_migrate_kunit (struct kunit *test);void xe_bo_evict_kunit (struct kunit *test); +void xe_bo_shrink_kunit (struct kunit *test);#endif
drivers/gpu/drm/xe/xe_bo.c +112 -16
255 lines not on this page · raw message
drivers/gpu/drm/xe/xe_bo.h +4 -0
@@ -63,6 +63,7 @@#define XE_BO_PROPS_INVALID (-1)struct sg_table ; +struct xe_ttm_lru_walk ;struct xe_bo *xe_bo_alloc (void );void xe_bo_free (struct xe_bo *bo);
@@ -315,6 +316,9 @@ static inline unsigned int xe_sg_segment_size(struct device *dev)#define i915_gem_object_flush_if_display (obj) ((void)(obj)) +long xe_bo_shrink (struct ttm_lru_walk *walk,struct ttm_buffer_object *bo, +bool purge,bool writeback); +#if IS_ENABLED (CONFIG_DRM_XE_KUNIT_TEST )/** * xe_bo_is_mem_type - Whether the bo currently resides in the given
drivers/gpu/drm/xe/xe_device.c +8 -0
@@ -42,6 +42,7 @@#include "xe_pcode.h" #include "xe_pm.h" #include "xe_query.h" +#include "xe_shrinker.h" #include "xe_sriov.h" #include "xe_tile.h" #include "xe_ttm_stolen_mgr.h"
@@ -239,6 +240,9 @@ static void xe_device_destroy(struct drm_device *dev, void *dummy)if (xe->unordered_wq)destroy_workqueue (xe->unordered_wq); +if (!IS_ERR_OR_NULL (xe->mem.shrinker)) +xe_shrinker_destroy (xe->mem.shrinker); +ttm_device_fini (&xe->ttm); }
@@ -268,6 +272,10 @@ struct xe_device *xe_device_create(struct pci_dev *pdev,if (err) goto err; + xe->mem.shrinker =xe_shrinker_create (xe); +if (IS_ERR (xe->mem.shrinker)) +return ERR_CAST (xe->mem.shrinker); + xe->info.devid = pdev->device; xe->info.revid = pdev->revision; xe->info.force_execlist = xe_modparam.force_execlist;
drivers/gpu/drm/xe/xe_device_types.h +2 -0
@@ -319,6 +319,8 @@ struct xe_device {struct xe_mem_region vram;/** @mem.sys_mgr: system TTM manager */ struct ttm_resource_manager sys_mgr; +/** @mem.sys_mgr: system memory shrinker. */ +struct xe_shrinker *shrinker; } mem;/** @sriov: device level virtualization data */
drivers/gpu/drm/xe/xe_shrinker.c new file +224 -0
224 lines not on this page · raw message
drivers/gpu/drm/xe/xe_shrinker.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2024 Intel Corporation +*/ + +#ifndef _XE_SHRINKER_H_ +#define _XE_SHRINKER_H_ + +struct xe_shrinker ; +struct xe_device ; + +void xe_shrinker_mod_pages (struct xe_shrinker *shrinker,long shrinkable,long purgeable); + +struct xe_shrinker *xe_shrinker_create (struct xe_device *xe); + +void xe_shrinker_destroy (struct xe_shrinker *shrinker); + +#endif
include/drm/ttm/ttm_bo.h +3 -0
@@ -222,6 +222,9 @@ struct ttm_lru_walk {long ttm_lru_walk_for_evict (struct ttm_lru_walk *walk,struct ttm_device *bdev,struct ttm_resource_manager *man,long target); +long ttm_bo_try_shrink (struct ttm_lru_walk *walk,struct ttm_buffer_object *bo, +bool purge,bool writeback); +/** * ttm_bo_get - reference a struct ttm_buffer_object *
Signature · 1 line
2.44.0
Thomas Hellström
maintainerPATCH v2 13/21 dma-buf/dma-resv: Introduce dma_resv_trylock_ctx()
In reply to Thomas HellströmFor the drm_exec_trylock() functionality, there is a need to be able to trylock a dma-resv object as part of a drm_exec transaction. Therefore expose a variant of dma_resv_trylock that also takes a struct ww_acquire_ctx parameter.
--- include/linux/dma-resv.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
include/linux/dma-resv.h +22 -1
@@ -405,6 +405,27 @@ static inline int dma_resv_lock_slow_interruptible(struct dma_resv *obj,return ww_mutex_lock_slow_interruptible (&obj->lock, ctx); } +/** +* dma_resv_trylock_ctx - trylock the reservation object +* @obj: the reservation object +* @ctx: The ww acquire context or NULL. +* +* Tries to lock the reservation object for exclusive access and modification. +* Note, that the lock is only against other writers, readers will run +* concurrently with a writer under RCU. The seqlock is used to notify readers +* if they overlap with a writer. The context parameter ensures that other +* ww transactions can perform deadlock backoff if necessary, and that +* subsequent attempts to dma_resv_lock() @obj for @ctx will return +* -EALREADY. +* +* Return: true if the lock was acquired, false otherwise. +*/ +static inline bool __must_check +dma_resv_trylock_ctx (struct dma_resv *obj,struct ww_acquire_ctx *ctx) +{ +return ww_mutex_trylock (&obj->lock, ctx); +} +/** * dma_resv_trylock - trylock the reservation object * @obj: the reservation object
@@ -421,7 +442,7 @@ static inline int dma_resv_lock_slow_interruptible(struct dma_resv *obj,*/ static inline bool __must_check dma_resv_trylock (struct dma_resv *obj) { -return ww_mutex_trylock (&obj->lock,NULL ); +return dma_resv_trylock_ctx (obj,NULL ); }/**
Signature · 1 line
2.44.0
Thomas Hellström
maintainerPATCH v2 14/21 drm/exec: drm_exec_trylock()
In reply to Thomas Hellström--- drivers/gpu/drm/drm_exec.c | 38 ++++++++++++++++++++++++++++++++++++++ include/drm/drm_exec.h | 1 + 2 files changed, 39 insertions(+)
drivers/gpu/drm/drm_exec.c +38 -0
@@ -207,6 +207,44 @@ int drm_exec_handle_contended(struct drm_exec *exec) }EXPORT_SYMBOL (drm_exec_handle_contended); +/** +* drm_exec_trylock_obj - trylock a GEM object for use +* @exec: the drm_exec object with the state +* @obj: the GEM object to lock +* +* Lock a GEM object for use and grab a reference to it. +* +* Returns: -EALREADY when object is already locked (can be suppressed by +* setting the DRM_EXEC_IGNORE_DUPLICATES flag), -ENOMEM when memory +* allocation failed and zero for success. +*/ +int drm_exec_trylock_obj (struct drm_exec *exec,struct drm_gem_object *obj) +{ +int ret; + +might_alloc (GFP_KERNEL ); + +if (exec->prelocked == obj) { +drm_gem_object_put (exec->prelocked); + exec->prelocked =NULL ; +return 0 ; + } + +if (!dma_resv_trylock_ctx (obj->resv, &exec->ticket)) { +if (dma_resv_locking_ctx (obj->resv) == &exec->ticket) +return (exec->flags &DRM_EXEC_IGNORE_DUPLICATES ) ?0 : -EALREADY ; +else +return -EBUSY ; + } + + ret =drm_exec_obj_locked (exec, obj); +if (ret) +dma_resv_unlock (obj->resv); + +return ret; +} +EXPORT_SYMBOL (drm_exec_trylock_obj); +/** * drm_exec_lock_obj - lock a GEM object for use * @exec: the drm_exec object with the state
include/drm/drm_exec.h +1 -0
@@ -148,6 +148,7 @@ void drm_exec_init(struct drm_exec *exec, u32 flags, unsigned nr);void drm_exec_fini (struct drm_exec *exec);bool drm_exec_cleanup (struct drm_exec *exec);int drm_exec_lock_obj (struct drm_exec *exec,struct drm_gem_object *obj); +int drm_exec_trylock_obj (struct drm_exec *exec,struct drm_gem_object *obj);void drm_exec_unlock_obj (struct drm_exec *exec,struct drm_gem_object *obj);int drm_exec_prepare_obj (struct drm_exec *exec,struct drm_gem_object *obj,unsigned int num_fences);
Signature · 1 line
2.44.0
Thomas Hellström
maintainerPATCH v2 15/21 drm/exec: Add a snapshot capability.
In reply to Thomas Hellström--- drivers/gpu/drm/drm_exec.c | 38 +++++++++++++++++++++++++++++++++++++- include/drm/drm_exec.h | 11 ++++++++++- 2 files changed, 47 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_exec.c +37 -1
@@ -57,6 +57,7 @@ static void drm_exec_unlock_all(struct drm_exec *exec)struct drm_gem_object *obj;unsigned long index; +WARN_ON (exec->snap);drm_exec_for_each_locked_object_reverse (exec, index, obj) {dma_resv_unlock (obj->resv);drm_gem_object_put (obj);
@@ -289,7 +290,6 @@ int drm_exec_lock_obj(struct drm_exec *exec, struct drm_gem_object *obj) goto error_unlock;return 0 ; - error_unlock:dma_resv_unlock (obj->resv);return ret;
@@ -383,5 +383,41 @@ int drm_exec_prepare_array(struct drm_exec *exec, }EXPORT_SYMBOL (drm_exec_prepare_array); +void drm_exec_restore (struct drm_exec *exec,struct drm_exec_snapshot *snap) +{ +struct drm_gem_object *obj; +unsigned int index; + + exec->snap = snap->saved_snap; + +drm_exec_for_each_locked_object_reverse (exec, index, obj) { +if (index +1 == snap->num_locked) +break ; + +dma_resv_unlock (obj->resv); +drm_gem_object_put (obj); + exec->objects[index] =NULL ; + } + + exec->num_objects = snap->num_locked; + +if (!exec->prelocked) + exec->prelocked = snap->prelocked; +else +drm_gem_object_put (snap->prelocked); +} +EXPORT_SYMBOL (drm_exec_restore); + +void drm_exec_snapshot (struct drm_exec *exec,struct drm_exec_snapshot *snap) +{ + snap->num_locked = exec->num_objects; + snap->prelocked = exec->prelocked; +if (snap->prelocked) +drm_gem_object_get (snap->prelocked); + snap->saved_snap = exec->snap; + exec->snap = snap; +} +EXPORT_SYMBOL (drm_exec_snapshot); +MODULE_DESCRIPTION ("DRM execution context" );MODULE_LICENSE ("Dual MIT/GPL" );
include/drm/drm_exec.h +10 -1
@@ -19,7 +19,6 @@ struct drm_exec {* @flags: Flags to control locking behavior */ u32 flags; -/** * @ticket: WW ticket used for acquiring locks */
@@ -49,6 +48,13 @@ struct drm_exec {* @prelocked: already locked GEM object due to contention */ struct drm_gem_object *prelocked; +struct drm_exec_snapshot *snap; +}; + +struct drm_exec_snapshot { +struct drm_exec_snapshot *saved_snap; +struct drm_gem_object *prelocked; +unsigned long num_locked; };int drm_exec_handle_contended (struct drm_exec *exec);
@@ -156,5 +162,8 @@ int drm_exec_prepare_array(struct drm_exec *exec,struct drm_gem_object **objects, unsigned int num_objects, unsigned int num_fences); +void drm_exec_snapshot (struct drm_exec *exec,struct drm_exec_snapshot *snap); +void drm_exec_restore (struct drm_exec *exec,struct drm_exec_snapshot *snap); +#endif
Signature · 1 line
2.44.0
Thomas Hellström
maintainerPATCH v2 16/21 drm/exec: Introduce an evict mode
In reply to Thomas HellströmLocking for eviction is in some way different from locking for submission:
1) We can't lock objects that are already locked for submission, hence DRM_EXEC_IGNORE_DUPLICATES must be unset.
2) We must be able to re-lock objects locked for eviction, either for submission or for yet another eviction, in particular objects sharing a single resv must be considered.
3) There is no point to keep a contending object after the transaction restart. We don't know whether we actuall want to use it again.
So introduce a drm_exec evict mode, and for now instead of explicitly setting it using a function call or implement separate locking functions that use evict mode, assume evict mode if there is a snapshot registered. This can easily be changed later.
To keep track of resvs locked for eviction, use a pointer set implemented by an xarray. This is probably not the most efficient data structure but used as an easy-to-implement first approach. If the set is empty (evict mode never used), the performance- and memory usage impact will be very small.
--- drivers/gpu/drm/drm_exec.c | 78 ++++++++++++++++++++++++++++++++++---- include/drm/drm_exec.h | 4 ++ 2 files changed, 75 insertions(+), 7 deletions(-)
drivers/gpu/drm/drm_exec.c +71 -7
@@ -65,6 +65,10 @@ static void drm_exec_unlock_all(struct drm_exec *exec)drm_gem_object_put (exec->prelocked); exec->prelocked =NULL ; + +/* garbage collect */ +xa_destroy (&exec->resv_set); +xa_init (&exec->resv_set); }/**
@@ -91,6 +95,8 @@ void drm_exec_init(struct drm_exec *exec, u32 flags, unsigned nr) exec->num_objects =0 ; exec->contended =DRM_EXEC_DUMMY ; exec->prelocked =NULL ; + exec->drop_contended = false; +xa_init (&exec->resv_set); }EXPORT_SYMBOL (drm_exec_init);
@@ -109,6 +115,7 @@ void drm_exec_fini(struct drm_exec *exec)drm_gem_object_put (exec->contended);ww_acquire_fini (&exec->ticket); } +xa_destroy (&exec->resv_set); }EXPORT_SYMBOL (drm_exec_fini);
@@ -138,6 +145,30 @@ bool drm_exec_cleanup(struct drm_exec *exec) }EXPORT_SYMBOL (drm_exec_cleanup); +static unsigned long drm_exec_resv_to_key (const struct dma_resv *resv) +{ + return (unsigned long)resv / __alignof__(typeof(*resv)); +} + +static void +drm_exec_resv_set_erase (struct drm_exec *exec,unsigned long key) +{ +if (xa_load (&exec->resv_set, key)) +xa_erase (&exec->resv_set, key); +} + +static bool drm_exec_in_evict_mode (struct drm_exec *exec) +{ +return !!exec->snap; +} + +static void drm_exec_set_evict_mode (struct drm_exec *exec, +struct drm_exec_snapshot *snap) +{ + exec->snap = snap; + exec->flags &= ~DRM_EXEC_IGNORE_DUPLICATES ; +} +/* Track the locked object in the array */ static int drm_exec_obj_locked (struct drm_exec *exec,struct drm_gem_object *obj)
@@ -157,6 +188,15 @@ static int drm_exec_obj_locked(struct drm_exec *exec,drm_gem_object_get (obj); exec->objects[exec->num_objects++] = obj; +/* +* Errors here are not fatal, It means the object we locked +* for eviction can't be locked again. If that is problematic +* we may need to reconsider this. +*/ +if (drm_exec_in_evict_mode (exec)) + (void )xa_store (&exec->resv_set,drm_exec_resv_to_key (obj->resv), + obj->resv,GFP_KERNEL | __GFP_RETRY_MAYFAIL | + __GFP_NOWARN);return 0 ; }
@@ -180,6 +220,9 @@ static int drm_exec_lock_contended(struct drm_exec *exec)dma_resv_lock_slow (obj->resv, &exec->ticket); } +if (exec->drop_contended) + goto error_unlock; + ret =drm_exec_obj_locked (exec, obj);if (unlikely (ret)) goto error_unlock;
@@ -232,10 +275,19 @@ int drm_exec_trylock_obj(struct drm_exec *exec, struct drm_gem_object *obj) }if (!dma_resv_trylock_ctx (obj->resv, &exec->ticket)) { -if (dma_resv_locking_ctx (obj->resv) == &exec->ticket) -return (exec->flags &DRM_EXEC_IGNORE_DUPLICATES ) ?0 : -EALREADY ; -else +if (dma_resv_locking_ctx (obj->resv) == &exec->ticket) { +unsigned long key =drm_exec_resv_to_key (obj->resv); + +if (exec->flags &DRM_EXEC_IGNORE_DUPLICATES || +xa_load (&exec->resv_set, key)) { +if (!drm_exec_in_evict_mode (exec)) +drm_exec_resv_set_erase (exec, key); +return 0 ; + } +return -EALREADY ; + }else {return -EBUSY ; + } } ret =drm_exec_obj_locked (exec, obj);
@@ -275,12 +327,20 @@ int drm_exec_lock_obj(struct drm_exec *exec, struct drm_gem_object *obj)if (unlikely (ret == -EDEADLK )) {drm_gem_object_get (obj); exec->contended = obj; + exec->drop_contended =drm_exec_in_evict_mode (exec);return -EDEADLK ; } -if (unlikely (ret == -EALREADY ) && - exec->flags &DRM_EXEC_IGNORE_DUPLICATES ) -return 0 ; +if (unlikely (ret == -EALREADY )) { +unsigned long key =drm_exec_resv_to_key (obj->resv); + +if (exec->flags &DRM_EXEC_IGNORE_DUPLICATES || +xa_load (&exec->resv_set, key)) { +if (!drm_exec_in_evict_mode (exec)) +drm_exec_resv_set_erase (exec, key); +return 0 ; + } + }if (unlikely (ret))return ret;
@@ -311,6 +371,7 @@ void drm_exec_unlock_obj(struct drm_exec *exec, struct drm_gem_object *obj)for (i = exec->num_objects; i--;) {if (exec->objects[i] == obj) { +drm_exec_resv_set_erase (exec,drm_exec_resv_to_key (obj->resv));dma_resv_unlock (obj->resv);for (++i; i < exec->num_objects; ++i) exec->objects[i -1 ] = exec->objects[i];
@@ -394,12 +455,14 @@ void drm_exec_restore(struct drm_exec *exec, struct drm_exec_snapshot *snap)if (index +1 == snap->num_locked)break ; +xa_erase (&exec->resv_set,drm_exec_resv_to_key (obj->resv));dma_resv_unlock (obj->resv);drm_gem_object_put (obj); exec->objects[index] =NULL ; } exec->num_objects = snap->num_locked; + exec->flags = snap->flags;if (!exec->prelocked) exec->prelocked = snap->prelocked;
@@ -414,8 +477,9 @@ void drm_exec_snapshot(struct drm_exec *exec, struct drm_exec_snapshot *snap) snap->prelocked = exec->prelocked;if (snap->prelocked)drm_gem_object_get (snap->prelocked); + snap->flags = exec->flags; snap->saved_snap = exec->snap; - exec->snap = snap; +drm_exec_set_evict_mode (exec, snap); }EXPORT_SYMBOL (drm_exec_snapshot);
include/drm/drm_exec.h +4 -0
@@ -5,6 +5,7 @@#include <linux/compiler.h> #include <linux/ww_mutex.h> +#include <linux/xarray.h> #define DRM_EXEC_INTERRUPTIBLE_WAIT BIT(0)#define DRM_EXEC_IGNORE_DUPLICATES BIT(1)
@@ -49,12 +50,15 @@ struct drm_exec {*/ struct drm_gem_object *prelocked;struct drm_exec_snapshot *snap; +struct xarray resv_set; +bool drop_contended; };struct drm_exec_snapshot {struct drm_exec_snapshot *saved_snap;struct drm_gem_object *prelocked;unsigned long num_locked; +u32 flags; };int drm_exec_handle_contended (struct drm_exec *exec);
Signature · 1 line
2.44.0
Thomas Hellström
maintainerPATCH v2 17/21 drm/ttm: Support drm_exec locking for eviction and swapping
In reply to Thomas Hellström--- drivers/gpu/drm/ttm/ttm_bo.c | 40 +++++++++++++++++++------- drivers/gpu/drm/ttm/ttm_bo_util.c | 47 +++++++++++++++++++++++++------ include/drm/ttm/ttm_bo.h | 5 ++++ 3 files changed, 73 insertions(+), 19 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +30 -10
@@ -31,6 +31,8 @@#define pr_fmt (fmt) "[TTM] " fmt +#include <drm/drm_exec.h> +#include <drm/ttm/ttm_bo.h> #include <drm/ttm/ttm_placement.h> #include <drm/ttm/ttm_tt.h>
@@ -539,10 +541,12 @@ static int ttm_bo_evict_alloc(struct ttm_device *bdev, };long lret; - evict_walk.walk.trylock_only = true; - lret =ttm_lru_walk_for_evict (&evict_walk.walk, bdev, man,1 ); -if (lret || !ticket) - goto out; +if (!ctx->exec || !IS_ENABLED (CONFIG_DEBUG_WW_MUTEX_SLOWPATH )) { + evict_walk.walk.trylock_only = true; + lret =ttm_lru_walk_for_evict (&evict_walk.walk, bdev, man,1 ); +if (lret || !(ticket || ctx->exec)) + goto out; + }/* If ticket-locking, repeat while we make progress. */ evict_walk.walk.trylock_only = false;
@@ -756,6 +760,7 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,struct ttm_placement *placement, struct ttm_operation_ctx *ctx) { + struct drm_exec_snapshot snap;struct ttm_resource *res;struct ttm_place hop;bool force_space;
@@ -769,17 +774,24 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,if (!placement->num_placement)return ttm_bo_pipeline_gutting (bo); +if (ctx->exec) +drm_exec_snapshot (ctx->exec, &snap); + force_space = false; do { /* Check whether we need to move buffer. */ if (bo->resource && ttm_resource_compatible(bo->resource, placement, - force_space)) - return 0; + force_space)) { + ret = 0; + goto out; + } /* Moving of pinned BOs is forbidden */ - if (bo->pin_count) - return -EINVAL; + if (bo->pin_count) { + ret = -EINVAL; + goto out; + } /* * Determine where to move the buffer.
@@ -796,7 +808,7 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,if (ret == -ENOSPC )continue ;if (ret) -return ret; + goto out; bounce: ret =ttm_bo_handle_move_mem (bo, res, false, ctx, &hop);
@@ -808,11 +820,14 @@ int ttm_bo_validate(struct ttm_buffer_object *bo, }if (ret) {ttm_resource_free (bo, &res); -return ret; + goto out; } }while (ret && force_space); +if (ctx->exec) +drm_exec_restore (ctx->exec, &snap); +/* For backward compatibility with userspace */ if (ret == -ENOSPC )return -ENOMEM ;
@@ -826,6 +841,11 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,return ret; }return 0 ; +out: +if (ctx->exec) +drm_exec_restore (ctx->exec, &snap); + +return ret; }EXPORT_SYMBOL (ttm_bo_validate);
drivers/gpu/drm/ttm/ttm_bo_util.c +38 -9
86 lines not on this page · raw message
include/drm/ttm/ttm_bo.h +5 -0
@@ -164,6 +164,8 @@ struct ttm_bo_kmap_obj {struct ttm_buffer_object *bo; }; +struct drm_exec ; +/** * struct ttm_operation_ctx *
@@ -175,6 +177,8 @@ struct ttm_bo_kmap_obj {* @force_alloc: Don't check the memory account during suspend or CPU page * faults. Should only be used by TTM internally. * @resv: Reservation object to allow reserved evictions with. +* @exec: If part of a drm_exec transaction, pointer to the struct drm_exec. +* Null otherwise. * @bytes_moved: Statistics on how many bytes have been moved. * * Context for TTM operations like changing buffer placement or general memory
@@ -187,6 +191,7 @@ struct ttm_operation_ctx {bool allow_res_evict;bool force_alloc;struct dma_resv *resv; +struct drm_exec *exec;uint64_t bytes_moved; };
Signature · 1 line
2.44.0
Thomas Hellström
maintainerPATCH v2 18/21 drm/ttm: Convert ttm vm to using drm_exec.
In reply to Thomas Hellström--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 4 +- drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 4 +- drivers/gpu/drm/nouveau/nouveau_gem.c | 4 +- drivers/gpu/drm/radeon/radeon_gem.c | 4 +- drivers/gpu/drm/ttm/ttm_bo_vm.c | 101 ++++++++++++++------- drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c | 6 +- drivers/gpu/drm/xe/xe_bo.c | 5 +- include/drm/ttm/ttm_bo.h | 6 +- 8 files changed, 85 insertions(+), 49 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2 -2
@@ -52,7 +52,7 @@ static vm_fault_t amdgpu_gem_fault(struct vm_fault *vmf)vm_fault_t ret;int idx; - ret =ttm_bo_vm_reserve (bo, vmf); + ret =ttm_bo_vm_reserve (bo, vmf,NULL );if (ret)return ret;
@@ -64,7 +64,7 @@ static vm_fault_t amdgpu_gem_fault(struct vm_fault *vmf) } ret =ttm_bo_vm_fault_reserved (vmf, vmf->vma->vm_page_prot, -TTM_BO_VM_NUM_PREFAULT ); +TTM_BO_VM_NUM_PREFAULT ,NULL );drm_dev_exit (idx); }else {
drivers/gpu/drm/i915/gem/i915_gem_ttm.c +2 -2
@@ -1046,7 +1046,7 @@ static vm_fault_t vm_fault_ttm(struct vm_fault *vmf) area->vm_flags & VM_WRITE))return VM_FAULT_SIGBUS ; - ret =ttm_bo_vm_reserve (bo, vmf); + ret =ttm_bo_vm_reserve (bo, vmf,NULL );if (ret)return ret;
@@ -1108,7 +1108,7 @@ static vm_fault_t vm_fault_ttm(struct vm_fault *vmf)if (drm_dev_enter (dev, &idx)) { ret =ttm_bo_vm_fault_reserved (vmf, vmf->vma->vm_page_prot, -TTM_BO_VM_NUM_PREFAULT ); +TTM_BO_VM_NUM_PREFAULT ,NULL );drm_dev_exit (idx); }else { ret =ttm_bo_vm_dummy_page (vmf, vmf->vma->vm_page_prot);
drivers/gpu/drm/nouveau/nouveau_gem.c +2 -2
@@ -46,7 +46,7 @@ static vm_fault_t nouveau_ttm_fault(struct vm_fault *vmf)pgprot_t prot;vm_fault_t ret; - ret =ttm_bo_vm_reserve (bo, vmf); + ret =ttm_bo_vm_reserve (bo, vmf,NULL );if (ret)return ret;
@@ -56,7 +56,7 @@ static vm_fault_t nouveau_ttm_fault(struct vm_fault *vmf)nouveau_bo_del_io_reserve_lru (bo); prot =vm_get_page_prot (vma->vm_flags); - ret =ttm_bo_vm_fault_reserved (vmf, prot,TTM_BO_VM_NUM_PREFAULT ); + ret =ttm_bo_vm_fault_reserved (vmf, prot,TTM_BO_VM_NUM_PREFAULT ,NULL );nouveau_bo_add_io_reserve_lru (bo);if (ret ==VM_FAULT_RETRY && !(vmf->flags &FAULT_FLAG_RETRY_NOWAIT ))return ret;
drivers/gpu/drm/radeon/radeon_gem.c +2 -2
@@ -54,7 +54,7 @@ static vm_fault_t radeon_gem_fault(struct vm_fault *vmf)down_read (&rdev->pm.mclk_lock); - ret =ttm_bo_vm_reserve (bo, vmf); + ret =ttm_bo_vm_reserve (bo, vmf,NULL );if (ret) goto unlock_mclk;
@@ -63,7 +63,7 @@ static vm_fault_t radeon_gem_fault(struct vm_fault *vmf) goto unlock_resv; ret =ttm_bo_vm_fault_reserved (vmf, vmf->vma->vm_page_prot, -TTM_BO_VM_NUM_PREFAULT ); +TTM_BO_VM_NUM_PREFAULT ,NULL );if (ret ==VM_FAULT_RETRY && !(vmf->flags &FAULT_FLAG_RETRY_NOWAIT )) goto unlock_mclk;
drivers/gpu/drm/ttm/ttm_bo_vm.c +67 -34
183 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c +3 -3
@@ -388,7 +388,7 @@ vm_fault_t vmw_bo_vm_mkwrite(struct vm_fault *vmf)*/ save_flags = vmf->flags; vmf->flags &= ~FAULT_FLAG_ALLOW_RETRY ; - ret =ttm_bo_vm_reserve (bo, vmf); + ret =ttm_bo_vm_reserve (bo, vmf,NULL ); vmf->flags = save_flags;if (ret)return ret;
@@ -423,7 +423,7 @@ vm_fault_t vmw_bo_vm_fault(struct vm_fault *vmf)pgprot_t prot;vm_fault_t ret; - ret =ttm_bo_vm_reserve (bo, vmf); + ret =ttm_bo_vm_reserve (bo, vmf,NULL );if (ret)return ret;
@@ -457,7 +457,7 @@ vm_fault_t vmw_bo_vm_fault(struct vm_fault *vmf)else prot =vm_get_page_prot (vma->vm_flags); - ret =ttm_bo_vm_fault_reserved (vmf, prot, num_prefault); + ret =ttm_bo_vm_fault_reserved (vmf, prot, num_prefault,NULL );if (ret ==VM_FAULT_RETRY && !(vmf->flags &FAULT_FLAG_RETRY_NOWAIT ))return ret;
drivers/gpu/drm/xe/xe_bo.c +3 -2
@@ -1223,7 +1223,7 @@ static vm_fault_t xe_gem_fault(struct vm_fault *vmf)if (needs_rpm)xe_pm_runtime_get (xe); - ret =ttm_bo_vm_reserve (tbo, vmf); + ret =ttm_bo_vm_reserve (tbo, vmf,NULL );if (ret) goto out;
@@ -1231,7 +1231,8 @@ static vm_fault_t xe_gem_fault(struct vm_fault *vmf)trace_xe_bo_cpu_fault (bo); ret =ttm_bo_vm_fault_reserved (vmf, vmf->vma->vm_page_prot, -TTM_BO_VM_NUM_PREFAULT ); +TTM_BO_VM_NUM_PREFAULT , +NULL );drm_dev_exit (idx); }else { ret =ttm_bo_vm_dummy_page (vmf, vmf->vma->vm_page_prot);
include/drm/ttm/ttm_bo.h +4 -2
@@ -427,10 +427,12 @@ int ttm_bo_evict_first(struct ttm_device *bdev,struct ttm_resource_manager *man, struct ttm_operation_ctx *ctx);vm_fault_t ttm_bo_vm_reserve (struct ttm_buffer_object *bo, -struct vm_fault *vmf); +struct vm_fault *vmf, +struct drm_exec *exec);vm_fault_t ttm_bo_vm_fault_reserved (struct vm_fault *vmf,pgprot_t prot, -pgoff_t num_prefault); +pgoff_t num_prefault, +struct drm_exec *exec);vm_fault_t ttm_bo_vm_fault (struct vm_fault *vmf);void ttm_bo_vm_open (struct vm_area_struct *vma);void ttm_bo_vm_close (struct vm_area_struct *vma);
Signature · 1 line
2.44.0
Thomas Hellström
maintainerPATCH v2 19/21 drm/xe: Use drm_exec for fault locking
In reply to Thomas Hellström--- drivers/gpu/drm/xe/xe_bo.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-)
drivers/gpu/drm/xe/xe_bo.c +23 -15
@@ -1217,29 +1217,37 @@ static vm_fault_t xe_gem_fault(struct vm_fault *vmf)struct xe_device *xe =to_xe_device (ddev);struct xe_bo *bo =ttm_to_xe_bo (tbo);bool needs_rpm = bo->flags &XE_BO_FLAG_VRAM_MASK ; +struct drm_exec exec;vm_fault_t ret; -int idx; +int idx, err;if (needs_rpm)xe_pm_runtime_get (xe); - ret =ttm_bo_vm_reserve (tbo, vmf,NULL ); -if (ret) - goto out; +drm_exec_init (&exec,DRM_EXEC_INTERRUPTIBLE_WAIT ,16 ); + drm_exec_until_all_locked(&exec) { + ret =ttm_bo_vm_reserve (tbo, vmf, &exec); + err =drm_exec_retry_on_contention (&exec,0 ); +if (err) + ret =VM_FAULT_NOPAGE ; +if (ret) + goto out; -if (drm_dev_enter (ddev, &idx)) { -trace_xe_bo_cpu_fault (bo); +if (drm_dev_enter (ddev, &idx)) { +trace_xe_bo_cpu_fault (bo); - ret =ttm_bo_vm_fault_reserved (vmf, vmf->vma->vm_page_prot, -TTM_BO_VM_NUM_PREFAULT , -NULL ); -drm_dev_exit (idx); - }else { - ret =ttm_bo_vm_dummy_page (vmf, vmf->vma->vm_page_prot); + ret =ttm_bo_vm_fault_reserved (vmf, vmf->vma->vm_page_prot, +TTM_BO_VM_NUM_PREFAULT , + &exec); +drm_dev_exit (idx); + err =drm_exec_retry_on_contention (&exec,0 ); +if (err) + ret =VM_FAULT_NOPAGE ; + }else { + ret =ttm_bo_vm_dummy_page (vmf, vmf->vma->vm_page_prot); + } } -if (ret ==VM_FAULT_RETRY && !(vmf->flags &FAULT_FLAG_RETRY_NOWAIT )) - goto out;/* * ttm_bo_vm_reserve() already has dma_resv_lock. */
@@ -1250,8 +1258,8 @@ static vm_fault_t xe_gem_fault(struct vm_fault *vmf)mutex_unlock (&xe->mem_access.vram_userfault.lock); } -dma_resv_unlock (tbo->base.resv); out: +drm_exec_fini (&exec);if (needs_rpm)xe_pm_runtime_put (xe);
Signature · 1 line
2.44.0
Thomas Hellström
maintainerPATCH v2 20/21 drm/ttm: Use drm_exec_trylock for bo initialization
In reply to Thomas HellströmBuffer object initialization may be part of a drm_exec transaction. Rather than using dma_resv_trylock, use drm_exec_trylock_obj().
--- drivers/gpu/drm/ttm/ttm_bo.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +10 -3
@@ -919,7 +919,10 @@ int ttm_bo_init_reserved(struct ttm_device *bdev, struct ttm_buffer_object *bo,* since otherwise lockdep will be angered in radeon. */ if (!resv) -WARN_ON (!dma_resv_trylock (bo->base.resv)); +if (ctx->exec) +WARN_ON (drm_exec_trylock_obj (ctx->exec, &bo->base)); +else +WARN_ON (!dma_resv_trylock (bo->base.resv));else dma_resv_assert_held (resv);
@@ -930,8 +933,12 @@ int ttm_bo_init_reserved(struct ttm_device *bdev, struct ttm_buffer_object *bo,return 0 ; err_unlock: -if (!resv) -dma_resv_unlock (bo->base.resv); +if (!resv) { +if (ctx->exec) +drm_exec_unlock_obj (ctx->exec, &bo->base); +else +dma_resv_unlock (bo->base.resv); + } err_put:ttm_bo_put (bo);
Signature · 1 line
2.44.0
Thomas Hellström
maintainerPATCH v2 21/21 drm/xe: Initial support for drm exec locking during validate.
In reply to Thomas Hellström--- drivers/gpu/drm/xe/display/xe_fb_pin.c | 2 +- drivers/gpu/drm/xe/tests/xe_bo.c | 6 +++--- drivers/gpu/drm/xe/tests/xe_dma_buf.c | 4 ++-- drivers/gpu/drm/xe/tests/xe_migrate.c | 2 +- drivers/gpu/drm/xe/xe_bo.c | 8 +++++--- drivers/gpu/drm/xe/xe_bo.h | 4 +++- drivers/gpu/drm/xe/xe_dma_buf.c | 2 +- drivers/gpu/drm/xe/xe_ggtt.c | 2 +- drivers/gpu/drm/xe/xe_gt_pagefault.c | 2 +- drivers/gpu/drm/xe/xe_vm.c | 4 ++-- 10 files changed, 20 insertions(+), 16 deletions(-)
drivers/gpu/drm/xe/display/xe_fb_pin.c +1 -1
@@ -289,7 +289,7 @@ static struct i915_vma *__xe_pin_fb_vma(const struct intel_framebuffer *fb,if (IS_DGFX (xe)) ret =xe_bo_migrate (bo,XE_PL_VRAM0 );else - ret =xe_bo_validate (bo,NULL , true); + ret =xe_bo_validate (bo,NULL , true,NULL );if (!ret)ttm_bo_pin (&bo->ttm);ttm_bo_unreserve (&bo->ttm);
drivers/gpu/drm/xe/tests/xe_bo.c +3 -3
@@ -30,7 +30,7 @@ static int ccs_test_migrate(struct xe_tile *tile, struct xe_bo *bo,u32 offset;/* Move bo to VRAM if not already there. */ - ret =xe_bo_validate (bo,NULL , false); + ret =xe_bo_validate (bo,NULL , false,NULL );if (ret) {KUNIT_FAIL (test,"Failed to validate bo.\n" );return ret;
@@ -276,7 +276,7 @@ static int evict_test_run_tile(struct xe_device *xe, struct xe_tile *tile, strucif (i) {down_read (&vm->lock);xe_vm_lock (vm, false); - err =xe_bo_validate (bo, bo->vm, false); + err =xe_bo_validate (bo, bo->vm, false,NULL );xe_vm_unlock (vm);up_read (&vm->lock);if (err) {
@@ -285,7 +285,7 @@ static int evict_test_run_tile(struct xe_device *xe, struct xe_tile *tile, struc goto cleanup_all; }xe_bo_lock (external, false); - err =xe_bo_validate (external,NULL , false); + err =xe_bo_validate (external,NULL , false,NULL );xe_bo_unlock (external);if (err) { KUNIT_FAIL(test, "external bo valid err=%pe\n",
drivers/gpu/drm/xe/tests/xe_dma_buf.c +2 -2
@@ -81,7 +81,7 @@ static void check_residency(struct kunit *test, struct xe_bo *exported, }/* Re-validate the importer. This should move also exporter in. */ - ret =xe_bo_validate (imported,NULL , false); + ret =xe_bo_validate (imported,NULL , false,NULL );if (ret) {if (ret != -EINTR && ret != -ERESTARTSYS ) KUNIT_FAIL(test, "Validating importer failed with err=%d.\n",
@@ -157,7 +157,7 @@ static void xe_test_dmabuf_import_same_driver(struct xe_device *xe)/* Is everything where we expect it to be? */ xe_bo_lock (import_bo, false); - err =xe_bo_validate (import_bo,NULL , false); + err =xe_bo_validate (import_bo,NULL , false,NULL );/* Pinning in VRAM is not allowed. */ if (!is_dynamic(params) &&
drivers/gpu/drm/xe/tests/xe_migrate.c +1 -1
@@ -90,7 +90,7 @@ static void test_copy(struct xe_migrate *m, struct xe_bo *bo,return ; } - err =xe_bo_validate (remote,NULL , false); + err =xe_bo_validate (remote,NULL , false,NULL );if (err) {KUNIT_FAIL (test,"Failed to validate system bo for %s: %i\n" , str, err);
drivers/gpu/drm/xe/xe_bo.c +5 -3
@@ -1755,7 +1755,7 @@ int xe_bo_pin_external(struct xe_bo *bo)xe_assert (xe,xe_bo_is_user (bo));if (!xe_bo_is_pinned (bo)) { - err =xe_bo_validate (bo,NULL , false); + err =xe_bo_validate (bo,NULL , false,NULL );if (err)return err;
@@ -1801,7 +1801,7 @@ int xe_bo_pin(struct xe_bo *bo)/* We only expect at most 1 pin */ xe_assert (xe, !xe_bo_is_pinned (bo)); - err =xe_bo_validate (bo,NULL , false); + err =xe_bo_validate (bo,NULL , false,NULL );if (err)return err;
@@ -1917,11 +1917,13 @@ void xe_bo_unpin(struct xe_bo *bo)* Return: 0 on success, negative error code on failure. May return * -EINTR or -ERESTARTSYS if internal waits are interrupted by a signal. */ -int xe_bo_validate (struct xe_bo *bo,struct xe_vm *vm,bool allow_res_evict) +int xe_bo_validate (struct xe_bo *bo,struct xe_vm *vm,bool allow_res_evict, +struct drm_exec *exec) {struct ttm_operation_ctx ctx = { .interruptible = true, .no_wait_gpu = false, + .exec = exec, };if (vm) {
drivers/gpu/drm/xe/xe_bo.h +3 -1
@@ -62,6 +62,7 @@#define XE_BO_PROPS_INVALID (-1) +struct drm_exec ;struct sg_table ;struct xe_ttm_lru_walk ;
@@ -164,7 +165,8 @@ int xe_bo_pin_external(struct xe_bo *bo);int xe_bo_pin (struct xe_bo *bo);void xe_bo_unpin_external (struct xe_bo *bo);void xe_bo_unpin (struct xe_bo *bo); -int xe_bo_validate (struct xe_bo *bo,struct xe_vm *vm,bool allow_res_evict); +int xe_bo_validate (struct xe_bo *bo,struct xe_vm *vm,bool allow_res_evict, +struct drm_exec *exec);static inline bool xe_bo_is_pinned (struct xe_bo *bo) {
drivers/gpu/drm/xe/xe_dma_buf.c +1 -1
@@ -102,7 +102,7 @@ static struct sg_table *xe_dma_buf_map(struct dma_buf_attachment *attach,if (!attach->peer2peer) r =xe_bo_migrate (bo,XE_PL_TT );else - r =xe_bo_validate (bo,NULL , false); + r =xe_bo_validate (bo,NULL , false,NULL );if (r)return ERR_PTR (r); }
drivers/gpu/drm/xe/xe_ggtt.c +1 -1
@@ -400,7 +400,7 @@ static int __xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,return 0 ; } - err =xe_bo_validate (bo,NULL , false); + err =xe_bo_validate (bo,NULL , false,NULL );if (err)return err;
drivers/gpu/drm/xe/xe_gt_pagefault.c +1 -1
@@ -117,7 +117,7 @@ static int xe_pf_begin(struct drm_exec *exec, struct xe_vma *vma,return err; }else if (bo) {/* Create backing store if needed */ - err =xe_bo_validate (bo, vm, true); + err =xe_bo_validate (bo, vm, true,NULL );if (err)return err; }
drivers/gpu/drm/xe/xe_vm.c +2 -2
@@ -380,7 +380,7 @@ static int xe_gpuvm_validate(struct drm_gpuvm_bo *vm_bo, struct drm_exec *exec)list_move_tail (&gpuva_to_vma (gpuva)->combined_links.rebind, &vm->rebind_list); - ret =xe_bo_validate (gem_to_xe_bo (vm_bo->obj), vm, false); + ret =xe_bo_validate (gem_to_xe_bo (vm_bo->obj), vm, false, exec);if (ret)return ret;
@@ -2698,7 +2698,7 @@ static int vma_lock_and_validate(struct drm_exec *exec, struct xe_vma *vma,if (!bo->vm) err =drm_exec_lock_obj (exec, &bo->ttm.base);if (!err && validate) - err =xe_bo_validate (bo,xe_vma_vm (vma), true); + err =xe_bo_validate (bo,xe_vma_vm (vma), true, exec); }return err;
Signature · 1 line
2.44.0
Patchwork
CI✓ CI.Patch_applied: success for xe bo shrinker and exhaustive eviction (rev3)
In reply to Thomas Hellström== Series Details ==
== Series Details ==
Series: xe bo shrinker and exhaustive eviction (rev3)
URL : https://patchwork.freedesktop.org/series/133643/
State : success
== Summary ==
=== Applying kernel patches on branch 'drm-tip' with base: ===
Base commit: 220fb645d6cd drm-tip: 2024y-05m-16d-02h-50m-18s UTC integration manifest === git am output follows ===
Applying: drm/ttm: Allow TTM LRU list nodes of different types
Applying: drm/ttm: Slightly clean up LRU list iteration
Applying: drm/ttm: Use LRU hitches
Applying: drm/ttm, drm/amdgpu, drm/xe: Consider hitch moves within bulk sublist moves
Applying: drm/exec: Rework contended locking
Applying: drm/ttm: Provide a generic LRU walker helper
Applying: drm/ttm: Use restartable LRU and sleeping locks for swapping.
Applying: drm/ttm: sleeping evict lock.
Applying: drm/ttm: Add a virtual base class for graphics memory backup
Applying: drm/ttm/pool: Provide a helper to shrink pages.
Applying: drm/ttm: Use fault-injection to test error paths
Applying: drm/ttm, drm/xe: Add a shrinker for xe bos
Applying: dma-buf/dma-resv: Introduce dma_resv_trylock_ctx()
Applying: drm/exec: drm_exec_trylock()
Applying: drm/exec: Add a snapshot capability.
Applying: drm/exec: Introduce an evict mode
Applying: drm/ttm: Support drm_exec locking for eviction and swapping
Applying: drm/ttm: Convert ttm vm to using drm_exec.
Applying: drm/xe: Use drm_exec for fault locking
Applying: drm/ttm: Use drm_exec_trylock for bo initialization
Applying: drm/xe: Initial support for drm exec locking during validate.
Patchwork
CI✗ CI.checkpatch: warning for xe bo shrinker and exhaustive eviction (rev3)
In reply to Thomas Hellström== Series Details ==
== Series Details ==
Series: xe bo shrinker and exhaustive eviction (rev3)
URL : https://patchwork.freedesktop.org/series/133643/
State : warning
== Summary ==
+ KERNEL=/kernel
+ git clone https://gitlab.freedesktop.org/drm/maintainer-tools mt Cloning into 'mt'...
warning: redirecting to https://gitlab.freedesktop.org/drm/maintainer-tools.git/
+ git -C mt rev-list -n1 origin/master 57b97a66dd129aea93991dc66cd10477f7a05cf8
+ cd /kernel
+ git config --global --add safe.directory /kernel
+ git log -n1
commit 1e1640bbe371a93de3073dda07ecb665dea1c51f
Author: Thomas Hellström <[email protected]> Date: Thu May 16 08:44:09 2024 +0200
drm/xe: Initial support for drm exec locking during validate.
+ /mt/dim checkpatch 220fb645d6cd4ce4155b5ccfdf52b35d6a7942c3 drm-intel 27acc2083fb8 drm/ttm: Allow TTM LRU list nodes of different types 70d8a80369b4 drm/ttm: Slightly clean up LRU list iteration186ae11b6763 drm/ttm: Use LRU hitchesed6090e548fe drm/ttm, drm/amdgpu, drm/xe: Consider hitch moves within bulk sublist moves ce01a671e3ae drm/exec: Rework contended locking
-:10: WARNING:COMMIT_MESSAGE: Missing commit description - Add an appropriate one
-:436: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'exec' - possible side-effects? #436: FILE: include/drm/drm_exec.h:122:
+#define drm_exec_retry_on_contention(exec, _ret) \
+ ({ \
+ int __ret = (_ret); \
+ \
+ if (unlikely(drm_exec_is_contended(exec))) { \
+ WARN_ON(__ret != -EDEADLK); \
+ __ret = drm_exec_handle_contended(exec); \
+ if (!__ret) \
+ goto *__drm_exec_retry_ptr; \
+ } \
+ __ret; \
+ })
-:436: WARNING:MACRO_WITH_FLOW_CONTROL: Macros with flow control statements should be avoided #436: FILE: include/drm/drm_exec.h:122:
+#define drm_exec_retry_on_contention(exec, _ret) \
+ ({ \
+ int __ret = (_ret); \
+ \
+ if (unlikely(drm_exec_is_contended(exec))) { \
+ WARN_ON(__ret != -EDEADLK); \
+ __ret = drm_exec_handle_contended(exec); \
+ if (!__ret) \
+ goto *__drm_exec_retry_ptr; \
+ } \
+ __ret; \
+ })
total: 0 errors, 2 warnings, 1 checks, 356 lines checked 35802f8f7e9b drm/ttm: Provide a generic LRU walker helper 5c9c507aa2d8 drm/ttm: Use restartable LRU and sleeping locks for swapping. -:10: WARNING:COMMIT_MESSAGE: Missing commit description - Add an appropriate one
total: 0 errors, 1 warnings, 0 checks, 184 lines checked 155e1484f104 drm/ttm: sleeping evict lock.
-:10: WARNING:COMMIT_MESSAGE: Missing commit description - Add an appropriate one
total: 0 errors, 1 warnings, 0 checks, 443 lines checked720f4f49d967 drm/ttm: Add a virtual base class for graphics memory backup Traceback (most recent call last):
File "scripts/spdxcheck.py", line 6, in <module>
from ply import lex, yacc
ModuleNotFoundError: No module named 'ply'
Traceback (most recent call last):
File "scripts/spdxcheck.py", line 6, in <module>
from ply import lex, yacc
ModuleNotFoundError: No module named 'ply'
-:41: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #41:
new file mode 100644
total: 0 errors, 1 warnings, 0 checks, 281 lines checked40fdaccdad4b drm/ttm/pool: Provide a helper to shrink pages.4d4e39087c79 drm/ttm: Use fault-injection to test error paths
-:27: WARNING:CONFIG_DESCRIPTION: please write a help paragraph that fully describes the config symbol #27: FILE: drivers/gpu/drm/Kconfig:261:
+config DRM_TTM_BACKUP_FAULT_INJECT
+ bool "Enable fault injection during TTM backup"
+ depends on DRM_TTM
+ default n
+ help
+ Inject recoverable failures during TTM backup and recovery of
+ backed-up objects. For DRM driver developers only.
+
+ If in doubt, choose N.
+
total: 0 errors, 1 warnings, 0 checks, 51 lines checked479722a36387 drm/ttm, drm/xe: Add a shrinker for xe bos
Traceback (most recent call last):
File "scripts/spdxcheck.py", line 6, in <module>
from ply import lex, yacc
ModuleNotFoundError: No module named 'ply'
Traceback (most recent call last):
File "scripts/spdxcheck.py", line 6, in <module>
from ply import lex, yacc
ModuleNotFoundError: No module named 'ply'
-:616: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #616:
new file mode 100644
total: 0 errors, 1 warnings, 0 checks, 781 lines checked b5961624445a dma-buf/dma-resv: Introduce dma_resv_trylock_ctx() b95dc6018fe5 drm/exec: drm_exec_trylock()
-:10: WARNING:COMMIT_MESSAGE: Missing commit description - Add an appropriate one
total: 0 errors, 1 warnings, 0 checks, 51 lines checked63daf836316f drm/exec: Add a snapshot capability.
-:10: WARNING:COMMIT_MESSAGE: Missing commit description - Add an appropriate one
total: 0 errors, 1 warnings, 0 checks, 83 lines checked7871891b04f3 drm/exec: Introduce an evict mode213ef833c1bd drm/ttm: Support drm_exec locking for eviction and swapping -:10: WARNING:COMMIT_MESSAGE: Missing commit description - Add an appropriate one
total: 0 errors, 1 warnings, 0 checks, 202 lines checked edec8c35c136 drm/ttm: Convert ttm vm to using drm_exec.
-:10: WARNING:COMMIT_MESSAGE: Missing commit description - Add an appropriate one
total: 0 errors, 1 warnings, 0 checks, 302 lines checked 27e80221cf4e drm/xe: Use drm_exec for fault locking
-:10: WARNING:COMMIT_MESSAGE: Missing commit description - Add an appropriate one
total: 0 errors, 1 warnings, 0 checks, 60 lines checkedd7f4b43b1d8b drm/ttm: Use drm_exec_trylock for bo initialization 1e1640bbe371 drm/xe: Initial support for drm exec locking during validate. -:10: WARNING:COMMIT_MESSAGE: Missing commit description - Add an appropriate one
total: 0 errors, 1 warnings, 0 checks, 142 lines checked
Patchwork
CI✓ CI.KUnit: success for xe bo shrinker and exhaustive eviction (rev3)
In reply to Thomas Hellström== Series Details ==
== Series Details ==
Series: xe bo shrinker and exhaustive eviction (rev3)
URL : https://patchwork.freedesktop.org/series/133643/
State : success
== Summary ==
+ trap cleanup EXIT
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/xe/.kunitconfig [06:50:23] Configuring KUnit Kernel ...
Generating .config ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
[06:50:27] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make ARCH=um O=.kunit --jobs=48
../arch/x86/um/user-offsets.c:17:6: warning: no previous prototype for ‘foo’ [-Wmissing-prototypes]
17 | void foo(void)
| ^~~
In file included from ../arch/um/kernel/asm-offsets.c:1:
../arch/x86/um/shared/sysdep/kernel-offsets.h:9:6: warning: no previous prototype for ‘foo’ [-Wmissing-prototypes]
9 | void foo(void)
| ^~~
../arch/x86/um/bugs_64.c:9:6: warning: no previous prototype for ‘arch_check_bugs’ [-Wmissing-prototypes]
9 | void arch_check_bugs(void)
| ^~~~~~~~~~~~~~~
../arch/x86/um/bugs_64.c:13:6: warning: no previous prototype for ‘arch_examine_signal’ [-Wmissing-prototypes]
13 | void arch_examine_signal(int sig, struct uml_pt_regs *regs)
| ^~~~~~~~~~~~~~~~~~~
../arch/x86/um/fault.c:18:5: warning: no previous prototype for ‘arch_fixup’ [-Wmissing-prototypes]
18 | int arch_fixup(unsigned long address, struct uml_pt_regs *regs)
| ^~~~~~~~~~
../arch/x86/um/os-Linux/mcontext.c:7:6: warning: no previous prototype for ‘get_regs_from_mc’ [-Wmissing-prototypes]
7 | void get_regs_from_mc(struct uml_pt_regs *regs, mcontext_t *mc)
| ^~~~~~~~~~~~~~~~
../arch/x86/um/os-Linux/registers.c:146:15: warning: no previous prototype for ‘get_thread_reg’ [-Wmissing-prototypes]
146 | unsigned long get_thread_reg(int reg, jmp_buf *buf)
| ^~~~~~~~~~~~~~
../arch/x86/um/vdso/um_vdso.c:16:5: warning: no previous prototype for ‘__vdso_clock_gettime’ [-Wmissing-prototypes]
16 | int __vdso_clock_gettime(clockid_t clock, struct __kernel_old_timespec *ts)
| ^~~~~~~~~~~~~~~~~~~~
../arch/x86/um/vdso/um_vdso.c:30:5: warning: no previous prototype for ‘__vdso_gettimeofday’ [-Wmissing-prototypes]
30 | int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz)
| ^~~~~~~~~~~~~~~~~~~
../arch/x86/um/vdso/um_vdso.c:44:21: warning: no previous prototype for ‘__vdso_time’ [-Wmissing-prototypes]
44 | __kernel_old_time_t __vdso_time(__kernel_old_time_t *t)
| ^~~~~~~~~~~
../arch/x86/um/vdso/um_vdso.c:57:1: warning: no previous prototype for ‘__vdso_getcpu’ [-Wmissing-prototypes]
57 | __vdso_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *unused)
| ^~~~~~~~~~~~~
../arch/um/os-Linux/skas/process.c:107:6: warning: no previous prototype for ‘wait_stub_done’ [-Wmissing-prototypes]
107 | void wait_stub_done(int pid)
| ^~~~~~~~~~~~~~
../arch/um/os-Linux/skas/process.c:683:6: warning: no previous prototype for ‘__switch_mm’ [-Wmissing-prototypes]
683 | void __switch_mm(struct mm_id *mm_idp)
| ^~~~~~~~~~~
../arch/um/kernel/skas/process.c:36:12: warning: no previous prototype for ‘start_uml’ [-Wmissing-prototypes]
36 | int __init start_uml(void)
| ^~~~~~~~~
../arch/um/kernel/skas/mmu.c:17:5: warning: no previous prototype for ‘init_new_context’ [-Wmissing-prototypes]
17 | int init_new_context(struct task_struct *task, struct mm_struct *mm)
| ^~~~~~~~~~~~~~~~
../arch/um/kernel/skas/mmu.c:60:6: warning: no previous prototype for ‘destroy_context’ [-Wmissing-prototypes]
60 | void destroy_context(struct mm_struct *mm)
| ^~~~~~~~~~~~~~~
../arch/um/os-Linux/main.c:187:7: warning: no previous prototype for ‘__wrap_malloc’ [-Wmissing-prototypes]
187 | void *__wrap_malloc(int size)
| ^~~~~~~~~~~~~
../arch/um/os-Linux/main.c:208:7: warning: no previous prototype for ‘__wrap_calloc’ [-Wmissing-prototypes]
208 | void *__wrap_calloc(int n, int size)
| ^~~~~~~~~~~~~
../arch/um/os-Linux/main.c:222:6: warning: no previous prototype for ‘__wrap_free’ [-Wmissing-prototypes]
222 | void __wrap_free(void *ptr)
| ^~~~~~~~~~~
../arch/um/os-Linux/mem.c:28:6: warning: no previous prototype for ‘kasan_map_memory’ [-Wmissing-prototypes]
28 | void kasan_map_memory(void *start, size_t len)
| ^~~~~~~~~~~~~~~~
../arch/um/os-Linux/mem.c:212:13: warning: no previous prototype for ‘check_tmpexec’ [-Wmissing-prototypes]
212 | void __init check_tmpexec(void)
| ^~~~~~~~~~~~~
../arch/x86/um/ptrace_64.c:111:5: warning: no previous prototype for ‘poke_user’ [-Wmissing-prototypes]
111 | int poke_user(struct task_struct *child, long addr, long data)
| ^~~~~~~~~
../arch/x86/um/ptrace_64.c:171:5: warning: no previous prototype for ‘peek_user’ [-Wmissing-prototypes]
171 | int peek_user(struct task_struct *child, long addr, long data)
| ^~~~~~~~~
../arch/x86/um/signal.c:560:6: warning: no previous prototype for ‘sys_rt_sigreturn’ [-Wmissing-prototypes]
560 | long sys_rt_sigreturn(void)
| ^~~~~~~~~~~~~~~~
../arch/um/os-Linux/signal.c:75:6: warning: no previous prototype for ‘sig_handler’ [-Wmissing-prototypes]
75 | void sig_handler(int sig, struct siginfo *si, mcontext_t *mc)
| ^~~~~~~~~~~
../arch/um/os-Linux/signal.c:111:6: warning: no previous prototype for ‘timer_alarm_handler’ [-Wmissing-prototypes]
111 | void timer_alarm_handler(int sig, struct siginfo *unused_si, mcontext_t *mc)
| ^~~~~~~~~~~~~~~~~~~
../arch/um/os-Linux/start_up.c:301:12: warning: no previous prototype for ‘parse_iomem’ [-Wmissing-prototypes]
301 | int __init parse_iomem(char *str, int *add)
| ^~~~~~~~~~~
../arch/um/kernel/mem.c:202:8: warning: no previous prototype for ‘pgd_alloc’ [-Wmissing-prototypes]
202 | pgd_t *pgd_alloc(struct mm_struct *mm)
| ^~~~~~~~~
../arch/um/kernel/mem.c:215:7: warning: no previous prototype for ‘uml_kmalloc’ [-Wmissing-prototypes]
215 | void *uml_kmalloc(int size, int flags)
| ^~~~~~~~~~~
../arch/um/kernel/process.c:51:5: warning: no previous prototype for ‘pid_to_processor_id’ [-Wmissing-prototypes]
51 | int pid_to_processor_id(int pid)
| ^~~~~~~~~~~~~~~~~~~
../arch/um/kernel/process.c:87:7: warning: no previous prototype for ‘__switch_to’ [-Wmissing-prototypes]
87 | void *__switch_to(struct task_struct *from, struct task_struct *to)
| ^~~~~~~~~~~
../arch/um/kernel/process.c:140:6: warning: no previous prototype for ‘fork_handler’ [-Wmissing-prototypes]
140 | void fork_handler(void)
| ^~~~~~~~~~~~
../arch/um/kernel/process.c:217:6: warning: no previous prototype for ‘arch_cpu_idle’ [-Wmissing-prototypes]
217 | void arch_cpu_idle(void)
| ^~~~~~~~~~~~~
../arch/um/kernel/process.c:253:5: warning: no previous prototype for ‘copy_to_user_proc’ [-Wmissing-prototypes]
253 | int copy_to_user_proc(void __user *to, void *from, int size)
| ^~~~~~~~~~~~~~~~~
../arch/um/kernel/process.c:263:5: warning: no previous prototype for ‘clear_user_proc’ [-Wmissing-prototypes]
263 | int clear_user_proc(void __user *buf, int size)
| ^~~~~~~~~~~~~~~
../arch/um/kernel/process.c:271:6: warning: no previous prototype for ‘set_using_sysemu’ [-Wmissing-prototypes]
271 | void set_using_sysemu(int value)
| ^~~~~~~~~~~~~~~~
../arch/um/kernel/process.c:278:5: warning: no previous prototype for ‘get_using_sysemu’ [-Wmissing-prototypes]
278 | int get_using_sysemu(void)
| ^~~~~~~~~~~~~~~~
../arch/um/kernel/process.c:316:12: warning: no previous prototype for ‘make_proc_sysemu’ [-Wmissing-prototypes]
316 | int __init make_proc_sysemu(void)
| ^~~~~~~~~~~~~~~~
../arch/um/kernel/process.c:348:15: warning: no previous prototype for ‘arch_align_stack’ [-Wmissing-prototypes]
348 | unsigned long arch_align_stack(unsigned long sp)
| ^~~~~~~~~~~~~~~~
../arch/x86/um/syscalls_64.c:48:6: warning: no previous prototype for ‘arch_switch_to’ [-Wmissing-prototypes]
48 | void arch_switch_to(struct task_struct *to)
| ^~~~~~~~~~~~~~
../arch/um/kernel/reboot.c:45:6: warning: no previous prototype for ‘machine_restart’ [-Wmissing-prototypes]
45 | void machine_restart(char * __unused)
| ^~~~~~~~~~~~~~~
../arch/um/kernel/reboot.c:51:6: warning: no previous prototype for ‘machine_power_off’ [-Wmissing-prototypes]
51 | void machine_power_off(void)
| ^~~~~~~~~~~~~~~~~
../arch/um/kernel/reboot.c:57:6: warning: no previous prototype for ‘machine_halt’ [-Wmissing-prototypes]
57 | void machine_halt(void)
| ^~~~~~~~~~~~
../arch/um/kernel/kmsg_dump.c:60:12: warning: no previous prototype for ‘kmsg_dumper_stdout_init’ [-Wmissing-prototypes]
60 | int __init kmsg_dumper_stdout_init(void)
| ^~~~~~~~~~~~~~~~~~~~~~~
../arch/um/kernel/tlb.c:579:6: warning: no previous prototype for ‘flush_tlb_mm_range’ [-Wmissing-prototypes]
579 | void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start,
| ^~~~~~~~~~~~~~~~~~
../arch/um/kernel/tlb.c:594:6: warning: no previous prototype for ‘force_flush_all’ [-Wmissing-prototypes]
594 | void force_flush_all(void)
| ^~~~~~~~~~~~~~~
../arch/um/kernel/um_arch.c:408:19: warning: no previous prototype for ‘read_initrd’ [-Wmissing-prototypes]
408 | int __init __weak read_initrd(void)
| ^~~~~~~~~~~
../arch/um/kernel/um_arch.c:461:7: warning: no previous prototype for ‘text_poke’ [-Wmissing-prototypes]
461 | void *text_poke(void *addr, const void *opcode, size_t len)
| ^~~~~~~~~
../arch/um/kernel/um_arch.c:473:6: warning: no previous prototype for ‘text_poke_sync’ [-Wmissing-prototypes]
473 | void text_poke_sync(void)
| ^~~~~~~~~~~~~~
../lib/iomap.c:156:5: warning: no previous prototype for ‘ioread64_lo_hi’ [-Wmissing-prototypes]
156 | u64 ioread64_lo_hi(const void __iomem *addr)
| ^~~~~~~~~~~~~~
../lib/iomap.c:163:5: warning: no previous prototype for ‘ioread64_hi_lo’ [-Wmissing-prototypes]
163 | u64 ioread64_hi_lo(const void __iomem *addr)
| ^~~~~~~~~~~~~~
../lib/iomap.c:170:5: warning: no previous prototype for ‘ioread64be_lo_hi’ [-Wmissing-prototypes]
170 | u64 ioread64be_lo_hi(const void __iomem *addr)
| ^~~~~~~~~~~~~~~~
../lib/iomap.c:178:5: warning: no previous prototype for ‘ioread64be_hi_lo’ [-Wmissing-prototypes]
178 | u64 ioread64be_hi_lo(const void __iomem *addr)
| ^~~~~~~~~~~~~~~~
../lib/iomap.c:264:6: warning: no previous prototype for ‘iowrite64_lo_hi’ [-Wmissing-prototypes]
264 | void iowrite64_lo_hi(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~
../lib/iomap.c:272:6: warning: no previous prototype for ‘iowrite64_hi_lo’ [-Wmissing-prototypes]
272 | void iowrite64_hi_lo(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~
../lib/iomap.c:280:6: warning: no previous prototype for ‘iowrite64be_lo_hi’ [-Wmissing-prototypes]
280 | void iowrite64be_lo_hi(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~~~
../lib/iomap.c:288:6: warning: no previous prototype for ‘iowrite64be_hi_lo’ [-Wmissing-prototypes]
288 | void iowrite64be_hi_lo(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~~~
stty: 'standard input': Inappropriate ioctl for device[06:50:52] Starting KUnit Kernel (1/1)...
[06:50:52] ============================================================ Running tests with:
$ .kunit/linux kunit.enable=1 mem=1G console=tty kunit_shutdown=halt [06:50:52] =================== guc_dbm (7 subtests) =================== [06:50:52] [PASSED] test_empty [06:50:52] [PASSED] test_default [06:50:52] ======================== test_size ======================== [06:50:52] [PASSED] 4 [06:50:52] [PASSED] 8 [06:50:52] [PASSED] 32 [06:50:52] [PASSED] 256 [06:50:52] ==================== [PASSED] test_size ==================== [06:50:52] ======================= test_reuse ======================== [06:50:52] [PASSED] 4 [06:50:52] [PASSED] 8 [06:50:52] [PASSED] 32 [06:50:52] [PASSED] 256 [06:50:52] =================== [PASSED] test_reuse ==================== [06:50:52] =================== test_range_overlap ==================== [06:50:52] [PASSED] 4 [06:50:52] [PASSED] 8 [06:50:52] [PASSED] 32 [06:50:52] [PASSED] 256 [06:50:52] =============== [PASSED] test_range_overlap ================ [06:50:52] =================== test_range_compact ==================== [06:50:52] [PASSED] 4 [06:50:52] [PASSED] 8 [06:50:52] [PASSED] 32 [06:50:52] [PASSED] 256 [06:50:52] =============== [PASSED] test_range_compact ================ [06:50:52] ==================== test_range_spare ===================== [06:50:52] [PASSED] 4 [06:50:52] [PASSED] 8 [06:50:52] [PASSED] 32 [06:50:52] [PASSED] 256 [06:50:52] ================ [PASSED] test_range_spare ================= [06:50:52] ===================== [PASSED] guc_dbm ===================== [06:50:52] =================== guc_idm (6 subtests) =================== [06:50:52] [PASSED] bad_init [06:50:52] [PASSED] no_init [06:50:52] [PASSED] init_fini [06:50:52] [PASSED] check_used [06:50:52] [PASSED] check_quota [06:50:52] [PASSED] check_all [06:50:52] ===================== [PASSED] guc_idm ===================== [06:50:52] ================== no_relay (3 subtests) =================== [06:50:52] [PASSED] xe_drops_guc2pf_if_not_ready [06:50:52] [PASSED] xe_drops_guc2vf_if_not_ready [06:50:52] [PASSED] xe_rejects_send_if_not_ready [06:50:52] ==================== [PASSED] no_relay ===================== [06:50:52] ================== pf_relay (14 subtests) ================== [06:50:52] [PASSED] pf_rejects_guc2pf_too_short [06:50:52] [PASSED] pf_rejects_guc2pf_too_long [06:50:52] [PASSED] pf_rejects_guc2pf_no_payload [06:50:52] [PASSED] pf_fails_no_payload [06:50:52] [PASSED] pf_fails_bad_origin [06:50:52] [PASSED] pf_fails_bad_type [06:50:52] [PASSED] pf_txn_reports_error [06:50:52] [PASSED] pf_txn_sends_pf2guc [06:50:52] [PASSED] pf_sends_pf2guc [06:50:52] [SKIPPED] pf_loopback_nop [06:50:52] [SKIPPED] pf_loopback_echo [06:50:52] [SKIPPED] pf_loopback_fail [06:50:52] [SKIPPED] pf_loopback_busy [06:50:52] [SKIPPED] pf_loopback_retry [06:50:52] ==================== [PASSED] pf_relay ===================== [06:50:52] ================== vf_relay (3 subtests) =================== [06:50:52] [PASSED] vf_rejects_guc2vf_too_short [06:50:52] [PASSED] vf_rejects_guc2vf_too_long [06:50:52] [PASSED] vf_rejects_guc2vf_no_payload [06:50:52] ==================== [PASSED] vf_relay ===================== [06:50:52] ================= pf_service (11 subtests) ================= [06:50:52] [PASSED] pf_negotiate_any [06:50:52] [PASSED] pf_negotiate_base_match [06:50:52] [PASSED] pf_negotiate_base_newer [06:50:52] [PASSED] pf_negotiate_base_next [06:50:52] [SKIPPED] pf_negotiate_base_older [06:50:52] [PASSED] pf_negotiate_base_prev [06:50:52] [PASSED] pf_negotiate_latest_match [06:50:52] [PASSED] pf_negotiate_latest_newer [06:50:52] [PASSED] pf_negotiate_latest_next [06:50:52] [SKIPPED] pf_negotiate_latest_older [06:50:52] [SKIPPED] pf_negotiate_latest_prev [06:50:52] =================== [PASSED] pf_service ==================== [06:50:52] ===================== lmtt (1 subtest) ===================== [06:50:52] ======================== test_ops ========================= [06:50:52] [PASSED] 2-level [06:50:52] [PASSED] multi-level [06:50:52] ==================== [PASSED] test_ops ===================== [06:50:52] ====================== [PASSED] lmtt ======================= [06:50:52] ==================== xe_bo (3 subtests) ==================== [06:50:52] [SKIPPED] xe_ccs_migrate_kunit [06:50:52] [SKIPPED] xe_bo_evict_kunit [06:50:52] [SKIPPED] xe_bo_shrink_kunit [06:50:52] ===================== [SKIPPED] xe_bo ====================== [06:50:52] ================== xe_dma_buf (1 subtest) ================== [06:50:52] [SKIPPED] xe_dma_buf_kunit [06:50:52] =================== [SKIPPED] xe_dma_buf =================== [06:50:52] ================== xe_migrate (1 subtest) ================== [06:50:52] [SKIPPED] xe_migrate_sanity_kunit [06:50:52] =================== [SKIPPED] xe_migrate =================== [06:50:52] =================== xe_mocs (2 subtests) =================== [06:50:52] [SKIPPED] xe_live_mocs_kernel_kunit [06:50:52] [SKIPPED] xe_live_mocs_reset_kunit [06:50:52] ==================== [SKIPPED] xe_mocs ===================== [06:50:52] ==================== args (11 subtests) ==================== [06:50:52] [PASSED] count_args_test [06:50:52] [PASSED] call_args_example [06:50:52] [PASSED] call_args_test [06:50:52] [PASSED] drop_first_arg_example [06:50:52] [PASSED] drop_first_arg_test [06:50:52] [PASSED] first_arg_example [06:50:52] [PASSED] first_arg_test [06:50:52] [PASSED] last_arg_example [06:50:52] [PASSED] last_arg_test [06:50:52] [PASSED] pick_arg_example [06:50:52] [PASSED] sep_comma_example [06:50:52] ====================== [PASSED] args ======================= [06:50:52] =================== xe_pci (2 subtests) ==================== [06:50:52] [PASSED] xe_gmdid_graphics_ip [06:50:52] [PASSED] xe_gmdid_media_ip [06:50:52] ===================== [PASSED] xe_pci ====================== [06:50:52] ==================== xe_rtp (1 subtest) ==================== [06:50:52] ================== xe_rtp_process_tests =================== [06:50:52] [PASSED] coalesce-same-reg [06:50:52] [PASSED] no-match-no-add [06:50:52] [PASSED] no-match-no-add-multiple-rules [06:50:52] [PASSED] two-regs-two-entries [06:50:52] [PASSED] clr-one-set-other [06:50:52] [PASSED] set-field [06:50:52] [PASSED] conflict-duplicate [06:50:52] [PASSED] conflict-not-disjoint [06:50:52] [PASSED] conflict-reg-type [06:50:52] ============== [PASSED] xe_rtp_process_tests =============== [06:50:52] ===================== [PASSED] xe_rtp ====================== [06:50:52] ==================== xe_wa (1 subtest) ===================== [06:50:52] ======================== xe_wa_gt ========================= [06:50:52] [PASSED] TIGERLAKE (B0) [06:50:52] [PASSED] DG1 (A0) [06:50:52] [PASSED] DG1 (B0) [06:50:52] [PASSED] ALDERLAKE_S (A0) [06:50:52] [PASSED] ALDERLAKE_S (B0) [06:50:52] [PASSED] ALDERLAKE_S (C0) [06:50:52] [PASSED] ALDERLAKE_S (D0) [06:50:52] [PASSED] ALDERLAKE_P (A0) [06:50:52] [PASSED] ALDERLAKE_P (B0) [06:50:52] [PASSED] ALDERLAKE_P (C0) [06:50:52] [PASSED] ALDERLAKE_S_RPLS (D0) [06:50:52] [PASSED] ALDERLAKE_P_RPLU (E0) [06:50:52] [PASSED] DG2_G10 (C0) [06:50:52] [PASSED] DG2_G11 (B1) [06:50:52] [PASSED] DG2_G12 (A1) [06:50:52] [PASSED] METEORLAKE (g:A0, m:A0) [06:50:52] [PASSED] METEORLAKE (g:A0, m:A0) [06:50:52] [PASSED] METEORLAKE (g:A0, m:A0) [06:50:52] [PASSED] LUNARLAKE (g:A0, m:A0) [06:50:52] [PASSED] LUNARLAKE (g:B0, m:A0) [06:50:52] ==================== [PASSED] xe_wa_gt ===================== [06:50:52] ====================== [PASSED] xe_wa ====================== [06:50:52] ============================================================ [06:50:52] Testing complete. Ran 110 tests: passed: 95, skipped: 15 [06:50:52] Elapsed time: 29.672s total, 4.252s configuring, 25.199s building, 0.175s running
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/tests/.kunitconfig [06:50:52] Configuring KUnit Kernel ...
Regenerating .config ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
[06:50:54] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make ARCH=um O=.kunit --jobs=48
In file included from ../arch/um/kernel/asm-offsets.c:1:
../arch/x86/um/shared/sysdep/kernel-offsets.h:9:6: warning: no previous prototype for ‘foo’ [-Wmissing-prototypes]
9 | void foo(void)
| ^~~
../arch/x86/um/ptrace_64.c:111:5: warning: no previous prototype for ‘poke_user’ [-Wmissing-prototypes]
111 | int poke_user(struct task_struct *child, long addr, long data)
| ^~~~~~~~~
../arch/x86/um/ptrace_64.c:171:5: warning: no previous prototype for ‘peek_user’ [-Wmissing-prototypes]
171 | int peek_user(struct task_struct *child, long addr, long data)
| ^~~~~~~~~
../arch/x86/um/signal.c:560:6: warning: no previous prototype for ‘sys_rt_sigreturn’ [-Wmissing-prototypes]
560 | long sys_rt_sigreturn(void)
| ^~~~~~~~~~~~~~~~
../arch/um/kernel/mem.c:202:8: warning: no previous prototype for ‘pgd_alloc’ [-Wmissing-prototypes]
202 | pgd_t *pgd_alloc(struct mm_struct *mm)
| ^~~~~~~~~
../arch/um/kernel/mem.c:215:7: warning: no previous prototype for ‘uml_kmalloc’ [-Wmissing-prototypes]
215 | void *uml_kmalloc(int size, int flags)
| ^~~~~~~~~~~
../arch/um/kernel/process.c:51:5: warning: no previous prototype for ‘pid_to_processor_id’ [-Wmissing-prototypes]
51 | int pid_to_processor_id(int pid)
| ^~~~~~~~~~~~~~~~~~~
../arch/um/kernel/process.c:87:7: warning: no previous prototype for ‘__switch_to’ [-Wmissing-prototypes]
87 | void *__switch_to(struct task_struct *from, struct task_struct *to)
| ^~~~~~~~~~~
../arch/um/kernel/process.c:140:6: warning: no previous prototype for ‘fork_handler’ [-Wmissing-prototypes]
140 | void fork_handler(void)
| ^~~~~~~~~~~~
../arch/um/kernel/process.c:217:6: warning: no previous prototype for ‘arch_cpu_idle’ [-Wmissing-prototypes]
217 | void arch_cpu_idle(void)
| ^~~~~~~~~~~~~
../arch/um/kernel/process.c:253:5: warning: no previous prototype for ‘copy_to_user_proc’ [-Wmissing-prototypes]
253 | int copy_to_user_proc(void __user *to, void *from, int size)
| ^~~~~~~~~~~~~~~~~
../arch/um/kernel/process.c:263:5: warning: no previous prototype for ‘clear_user_proc’ [-Wmissing-prototypes]
263 | int clear_user_proc(void __user *buf, int size)
| ^~~~~~~~~~~~~~~
../arch/um/kernel/process.c:271:6: warning: no previous prototype for ‘set_using_sysemu’ [-Wmissing-prototypes]
271 | void set_using_sysemu(int value)
| ^~~~~~~~~~~~~~~~
../arch/um/kernel/process.c:278:5: warning: no previous prototype for ‘get_using_sysemu’ [-Wmissing-prototypes]
278 | int get_using_sysemu(void)
| ^~~~~~~~~~~~~~~~
../arch/um/kernel/process.c:316:12: warning: no previous prototype for ‘make_proc_sysemu’ [-Wmissing-prototypes]
316 | int __init make_proc_sysemu(void)
| ^~~~~~~~~~~~~~~~
../arch/um/kernel/process.c:348:15: warning: no previous prototype for ‘arch_align_stack’ [-Wmissing-prototypes]
348 | unsigned long arch_align_stack(unsigned long sp)
| ^~~~~~~~~~~~~~~~
../arch/um/kernel/reboot.c:45:6: warning: no previous prototype for ‘machine_restart’ [-Wmissing-prototypes]
45 | void machine_restart(char * __unused)
| ^~~~~~~~~~~~~~~
../arch/um/kernel/reboot.c:51:6: warning: no previous prototype for ‘machine_power_off’ [-Wmissing-prototypes]
51 | void machine_power_off(void)
| ^~~~~~~~~~~~~~~~~
../arch/um/kernel/reboot.c:57:6: warning: no previous prototype for ‘machine_halt’ [-Wmissing-prototypes]
57 | void machine_halt(void)
| ^~~~~~~~~~~~
../arch/x86/um/syscalls_64.c:48:6: warning: no previous prototype for ‘arch_switch_to’ [-Wmissing-prototypes]
48 | void arch_switch_to(struct task_struct *to)
| ^~~~~~~~~~~~~~
../arch/um/kernel/tlb.c:579:6: warning: no previous prototype for ‘flush_tlb_mm_range’ [-Wmissing-prototypes]
579 | void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start,
| ^~~~~~~~~~~~~~~~~~
../arch/um/kernel/tlb.c:594:6: warning: no previous prototype for ‘force_flush_all’ [-Wmissing-prototypes]
594 | void force_flush_all(void)
| ^~~~~~~~~~~~~~~
../arch/um/kernel/um_arch.c:408:19: warning: no previous prototype for ‘read_initrd’ [-Wmissing-prototypes]
408 | int __init __weak read_initrd(void)
| ^~~~~~~~~~~
../arch/um/kernel/um_arch.c:461:7: warning: no previous prototype for ‘text_poke’ [-Wmissing-prototypes]
461 | void *text_poke(void *addr, const void *opcode, size_t len)
| ^~~~~~~~~
../arch/um/kernel/um_arch.c:473:6: warning: no previous prototype for ‘text_poke_sync’ [-Wmissing-prototypes]
473 | void text_poke_sync(void)
| ^~~~~~~~~~~~~~
../arch/um/kernel/kmsg_dump.c:60:12: warning: no previous prototype for ‘kmsg_dumper_stdout_init’ [-Wmissing-prototypes]
60 | int __init kmsg_dumper_stdout_init(void)
| ^~~~~~~~~~~~~~~~~~~~~~~
../arch/um/kernel/skas/mmu.c:17:5: warning: no previous prototype for ‘init_new_context’ [-Wmissing-prototypes]
17 | int init_new_context(struct task_struct *task, struct mm_struct *mm)
| ^~~~~~~~~~~~~~~~
../arch/um/kernel/skas/mmu.c:60:6: warning: no previous prototype for ‘destroy_context’ [-Wmissing-prototypes]
60 | void destroy_context(struct mm_struct *mm)
| ^~~~~~~~~~~~~~~
../arch/um/kernel/skas/process.c:36:12: warning: no previous prototype for ‘start_uml’ [-Wmissing-prototypes]
36 | int __init start_uml(void)
| ^~~~~~~~~
../lib/iomap.c:156:5: warning: no previous prototype for ‘ioread64_lo_hi’ [-Wmissing-prototypes]
156 | u64 ioread64_lo_hi(const void __iomem *addr)
| ^~~~~~~~~~~~~~
../lib/iomap.c:163:5: warning: no previous prototype for ‘ioread64_hi_lo’ [-Wmissing-prototypes]
163 | u64 ioread64_hi_lo(const void __iomem *addr)
| ^~~~~~~~~~~~~~
../lib/iomap.c:170:5: warning: no previous prototype for ‘ioread64be_lo_hi’ [-Wmissing-prototypes]
170 | u64 ioread64be_lo_hi(const void __iomem *addr)
| ^~~~~~~~~~~~~~~~
../lib/iomap.c:178:5: warning: no previous prototype for ‘ioread64be_hi_lo’ [-Wmissing-prototypes]
178 | u64 ioread64be_hi_lo(const void __iomem *addr)
| ^~~~~~~~~~~~~~~~
../lib/iomap.c:264:6: warning: no previous prototype for ‘iowrite64_lo_hi’ [-Wmissing-prototypes]
264 | void iowrite64_lo_hi(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~
../lib/iomap.c:272:6: warning: no previous prototype for ‘iowrite64_hi_lo’ [-Wmissing-prototypes]
272 | void iowrite64_hi_lo(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~
../lib/iomap.c:280:6: warning: no previous prototype for ‘iowrite64be_lo_hi’ [-Wmissing-prototypes]
280 | void iowrite64be_lo_hi(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~~~
../lib/iomap.c:288:6: warning: no previous prototype for ‘iowrite64be_hi_lo’ [-Wmissing-prototypes]
288 | void iowrite64be_hi_lo(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~~~[06:51:16] Starting KUnit Kernel (1/1)...
[06:51:16] ============================================================ Running tests with:
$ .kunit/linux kunit.enable=1 mem=1G console=tty kunit_shutdown=halt [06:51:16] ============ drm_test_pick_cmdline (2 subtests) ============ [06:51:16] [PASSED] drm_test_pick_cmdline_res_1920_1080_60 [06:51:16] =============== drm_test_pick_cmdline_named =============== [06:51:16] [PASSED] NTSC [06:51:16] [PASSED] NTSC-J [06:51:16] [PASSED] PAL [06:51:16] [PASSED] PAL-M [06:51:16] =========== [PASSED] drm_test_pick_cmdline_named =========== [06:51:16] ============== [PASSED] drm_test_pick_cmdline ============== [06:51:16] ================== drm_buddy (7 subtests) ================== [06:51:16] [PASSED] drm_test_buddy_alloc_limit [06:51:16] [PASSED] drm_test_buddy_alloc_optimistic [06:51:16] [PASSED] drm_test_buddy_alloc_pessimistic [06:51:16] [PASSED] drm_test_buddy_alloc_pathological [06:51:16] [PASSED] drm_test_buddy_alloc_contiguous [06:51:16] [PASSED] drm_test_buddy_alloc_clear [06:51:16] [PASSED] drm_test_buddy_alloc_range_bias [06:51:16] ==================== [PASSED] drm_buddy ==================== [06:51:16] ============= drm_cmdline_parser (40 subtests) ============= [06:51:16] [PASSED] drm_test_cmdline_force_d_only [06:51:16] [PASSED] drm_test_cmdline_force_D_only_dvi [06:51:16] [PASSED] drm_test_cmdline_force_D_only_hdmi [06:51:16] [PASSED] drm_test_cmdline_force_D_only_not_digital [06:51:16] [PASSED] drm_test_cmdline_force_e_only [06:51:16] [PASSED] drm_test_cmdline_res [06:51:16] [PASSED] drm_test_cmdline_res_vesa [06:51:16] [PASSED] drm_test_cmdline_res_vesa_rblank [06:51:16] [PASSED] drm_test_cmdline_res_rblank [06:51:16] [PASSED] drm_test_cmdline_res_bpp [06:51:16] [PASSED] drm_test_cmdline_res_refresh [06:51:16] [PASSED] drm_test_cmdline_res_bpp_refresh [06:51:16] [PASSED] drm_test_cmdline_res_bpp_refresh_interlaced [06:51:16] [PASSED] drm_test_cmdline_res_bpp_refresh_margins [06:51:16] [PASSED] drm_test_cmdline_res_bpp_refresh_force_off [06:51:16] [PASSED] drm_test_cmdline_res_bpp_refresh_force_on [06:51:16] [PASSED] drm_test_cmdline_res_bpp_refresh_force_on_analog [06:51:16] [PASSED] drm_test_cmdline_res_bpp_refresh_force_on_digital [06:51:16] [PASSED] drm_test_cmdline_res_bpp_refresh_interlaced_margins_force_on [06:51:16] [PASSED] drm_test_cmdline_res_margins_force_on [06:51:16] [PASSED] drm_test_cmdline_res_vesa_margins [06:51:16] [PASSED] drm_test_cmdline_name [06:51:16] [PASSED] drm_test_cmdline_name_bpp [06:51:16] [PASSED] drm_test_cmdline_name_option [06:51:16] [PASSED] drm_test_cmdline_name_bpp_option [06:51:16] [PASSED] drm_test_cmdline_rotate_0 [06:51:16] [PASSED] drm_test_cmdline_rotate_90 [06:51:16] [PASSED] drm_test_cmdline_rotate_180 [06:51:16] [PASSED] drm_test_cmdline_rotate_270 [06:51:16] [PASSED] drm_test_cmdline_hmirror [06:51:16] [PASSED] drm_test_cmdline_vmirror [06:51:16] [PASSED] drm_test_cmdline_margin_options [06:51:16] [PASSED] drm_test_cmdline_multiple_options [06:51:16] [PASSED] drm_test_cmdline_bpp_extra_and_option [06:51:16] [PASSED] drm_test_cmdline_extra_and_option [06:51:16] [PASSED] drm_test_cmdline_freestanding_options [06:51:16] [PASSED] drm_test_cmdline_freestanding_force_e_and_options [06:51:16] [PASSED] drm_test_cmdline_panel_orientation [06:51:16] ================ drm_test_cmdline_invalid ================= [06:51:16] [PASSED] margin_only [06:51:16] [PASSED] interlace_only [06:51:16] [PASSED] res_missing_x [06:51:16] [PASSED] res_missing_y [06:51:16] [PASSED] res_bad_y [06:51:16] [PASSED] res_missing_y_bpp [06:51:16] [PASSED] res_bad_bpp [06:51:16] [PASSED] res_bad_refresh [06:51:16] [PASSED] res_bpp_refresh_force_on_off [06:51:16] [PASSED] res_invalid_mode [06:51:16] [PASSED] res_bpp_wrong_place_mode [06:51:16] [PASSED] name_bpp_refresh [06:51:16] [PASSED] name_refresh [06:51:16] [PASSED] name_refresh_wrong_mode [06:51:16] [PASSED] name_refresh_invalid_mode [06:51:16] [PASSED] rotate_multiple [06:51:16] [PASSED] rotate_invalid_val [06:51:16] [PASSED] rotate_truncated [06:51:16] [PASSED] invalid_option [06:51:16] [PASSED] invalid_tv_option [06:51:16] [PASSED] truncated_tv_option [06:51:16] ============ [PASSED] drm_test_cmdline_invalid ============= [06:51:16] =============== drm_test_cmdline_tv_options =============== [06:51:16] [PASSED] NTSC [06:51:16] [PASSED] NTSC_443 [06:51:16] [PASSED] NTSC_J [06:51:16] [PASSED] PAL [06:51:16] [PASSED] PAL_M [06:51:16] [PASSED] PAL_N [06:51:16] [PASSED] SECAM [06:51:16] =========== [PASSED] drm_test_cmdline_tv_options =========== [06:51:16] =============== [PASSED] drm_cmdline_parser ================ [06:51:16] ============= drmm_connector_init (3 subtests) ============= [06:51:16] [PASSED] drm_test_drmm_connector_init [06:51:16] [PASSED] drm_test_drmm_connector_init_null_ddc [06:51:16] ========= drm_test_drmm_connector_init_type_valid ========= [06:51:16] [PASSED] Unknown [06:51:16] [PASSED] VGA [06:51:16] [PASSED] DVI-I [06:51:16] [PASSED] DVI-D [06:51:16] [PASSED] DVI-A [06:51:16] [PASSED] Composite [06:51:16] [PASSED] SVIDEO [06:51:16] [PASSED] LVDS [06:51:16] [PASSED] Component [06:51:16] [PASSED] DIN [06:51:16] [PASSED] DP [06:51:16] [PASSED] HDMI-A [06:51:16] [PASSED] HDMI-B [06:51:16] [PASSED] TV [06:51:16] [PASSED] eDP [06:51:16] [PASSED] Virtual [06:51:16] [PASSED] DSI [06:51:16] [PASSED] DPI [06:51:16] [PASSED] Writeback [06:51:16] [PASSED] SPI [06:51:16] [PASSED] USB [06:51:16] ===== [PASSED] drm_test_drmm_connector_init_type_valid ===== [06:51:16] =============== [PASSED] drmm_connector_init =============== [06:51:16] ========== drm_get_tv_mode_from_name (2 subtests) ========== [06:51:16] ========== drm_test_get_tv_mode_from_name_valid =========== [06:51:16] [PASSED] NTSC [06:51:16] [PASSED] NTSC-443 [06:51:16] [PASSED] NTSC-J [06:51:16] [PASSED] PAL [06:51:16] [PASSED] PAL-M [06:51:16] [PASSED] PAL-N [06:51:16] [PASSED] SECAM [06:51:16] ====== [PASSED] drm_test_get_tv_mode_from_name_valid ======= [06:51:16] [PASSED] drm_test_get_tv_mode_from_name_truncated [06:51:16] ============ [PASSED] drm_get_tv_mode_from_name ============ [06:51:16] ============= drm_damage_helper (21 subtests) ============== [06:51:16] [PASSED] drm_test_damage_iter_no_damage [06:51:16] [PASSED] drm_test_damage_iter_no_damage_fractional_src [06:51:16] [PASSED] drm_test_damage_iter_no_damage_src_moved [06:51:16] [PASSED] drm_test_damage_iter_no_damage_fractional_src_moved [06:51:16] [PASSED] drm_test_damage_iter_no_damage_not_visible [06:51:16] [PASSED] drm_test_damage_iter_no_damage_no_crtc [06:51:16] [PASSED] drm_test_damage_iter_no_damage_no_fb [06:51:16] [PASSED] drm_test_damage_iter_simple_damage [06:51:16] [PASSED] drm_test_damage_iter_single_damage [06:51:16] [PASSED] drm_test_damage_iter_single_damage_intersect_src [06:51:16] [PASSED] drm_test_damage_iter_single_damage_outside_src [06:51:16] [PASSED] drm_test_damage_iter_single_damage_fractional_src [06:51:16] [PASSED] drm_test_damage_iter_single_damage_intersect_fractional_src [06:51:16] [PASSED] drm_test_damage_iter_single_damage_outside_fractional_src [06:51:16] [PASSED] drm_test_damage_iter_single_damage_src_moved [06:51:16] [PASSED] drm_test_damage_iter_single_damage_fractional_src_moved [06:51:16] [PASSED] drm_test_damage_iter_damage [06:51:16] [PASSED] drm_test_damage_iter_damage_one_intersect [06:51:16] [PASSED] drm_test_damage_iter_damage_one_outside [06:51:16] [PASSED] drm_test_damage_iter_damage_src_moved [06:51:16] [PASSED] drm_test_damage_iter_damage_not_visible [06:51:16] ================ [PASSED] drm_damage_helper ================ [06:51:16] ============== drm_dp_mst_helper (3 subtests) ============== [06:51:16] ============== drm_test_dp_mst_calc_pbn_mode ============== [06:51:16] [PASSED] Clock 154000 BPP 30 DSC disabled [06:51:16] [PASSED] Clock 234000 BPP 30 DSC disabled [06:51:16] [PASSED] Clock 297000 BPP 24 DSC disabled [06:51:16] [PASSED] Clock 332880 BPP 24 DSC enabled [06:51:16] [PASSED] Clock 324540 BPP 24 DSC enabled [06:51:16] ========== [PASSED] drm_test_dp_mst_calc_pbn_mode ========== [06:51:16] ============== drm_test_dp_mst_calc_pbn_div =============== [06:51:16] [PASSED] Link rate 2000000 lane count 4 [06:51:16] [PASSED] Link rate 2000000 lane count 2 [06:51:16] [PASSED] Link rate 2000000 lane count 1 [06:51:16] [PASSED] Link rate 1350000 lane count 4 [06:51:16] [PASSED] Link rate 1350000 lane count 2 [06:51:16] [PASSED] Link rate 1350000 lane count 1 [06:51:16] [PASSED] Link rate 1000000 lane count 4 [06:51:16] [PASSED] Link rate 1000000 lane count 2 [06:51:16] [PASSED] Link rate 1000000 lane count 1 [06:51:16] [PASSED] Link rate 810000 lane count 4 [06:51:16] [PASSED] Link rate 810000 lane count 2 [06:51:16] [PASSED] Link rate 810000 lane count 1 [06:51:16] [PASSED] Link rate 540000 lane count 4 [06:51:16] [PASSED] Link rate 540000 lane count 2 [06:51:16] [PASSED] Link rate 540000 lane count 1 [06:51:16] [PASSED] Link rate 270000 lane count 4 [06:51:16] [PASSED] Link rate 270000 lane count 2 [06:51:16] [PASSED] Link rate 270000 lane count 1 [06:51:16] [PASSED] Link rate 162000 lane count 4 [06:51:16] [PASSED] Link rate 162000 lane count 2 [06:51:16] [PASSED] Link rate 162000 lane count 1 [06:51:16] ========== [PASSED] drm_test_dp_mst_calc_pbn_div =========== [06:51:16] ========= drm_test_dp_mst_sideband_msg_req_decode ========= [06:51:16] [PASSED] DP_ENUM_PATH_RESOURCES with port number [06:51:16] [PASSED] DP_POWER_UP_PHY with port number [06:51:16] [PASSED] DP_POWER_DOWN_PHY with port number [06:51:16] [PASSED] DP_ALLOCATE_PAYLOAD with SDP stream sinks [06:51:16] [PASSED] DP_ALLOCATE_PAYLOAD with port number [06:51:16] [PASSED] DP_ALLOCATE_PAYLOAD with VCPI [06:51:16] [PASSED] DP_ALLOCATE_PAYLOAD with PBN [06:51:16] [PASSED] DP_QUERY_PAYLOAD with port number [06:51:16] [PASSED] DP_QUERY_PAYLOAD with VCPI [06:51:16] [PASSED] DP_REMOTE_DPCD_READ with port number [06:51:16] [PASSED] DP_REMOTE_DPCD_READ with DPCD address [06:51:16] [PASSED] DP_REMOTE_DPCD_READ with max number of bytes [06:51:16] [PASSED] DP_REMOTE_DPCD_WRITE with port number [06:51:16] [PASSED] DP_REMOTE_DPCD_WRITE with DPCD address [06:51:16] [PASSED] DP_REMOTE_DPCD_WRITE with data array [06:51:16] [PASSED] DP_REMOTE_I2C_READ with port number [06:51:16] [PASSED] DP_REMOTE_I2C_READ with I2C device ID [06:51:16] [PASSED] DP_REMOTE_I2C_READ with transactions array [06:51:16] [PASSED] DP_REMOTE_I2C_WRITE with port number [06:51:16] [PASSED] DP_REMOTE_I2C_WRITE with I2C device ID [06:51:16] [PASSED] DP_REMOTE_I2C_WRITE with data array [06:51:16] [PASSED] DP_QUERY_STREAM_ENC_STATUS with stream ID [06:51:16] [PASSED] DP_QUERY_STREAM_ENC_STATUS with client ID [06:51:16] [PASSED] DP_QUERY_STREAM_ENC_STATUS with stream event [06:51:16] [PASSED] DP_QUERY_STREAM_ENC_STATUS with valid stream event [06:51:16] [PASSED] DP_QUERY_STREAM_ENC_STATUS with stream behavior [06:51:16] [PASSED] DP_QUERY_STREAM_ENC_STATUS with a valid stream behavior [06:51:16] ===== [PASSED] drm_test_dp_mst_sideband_msg_req_decode ===== [06:51:16] ================ [PASSED] drm_dp_mst_helper ================ [06:51:16] ================== drm_exec (7 subtests) =================== [06:51:16] [PASSED] sanitycheck [06:51:16] [PASSED] test_lock [06:51:16] [PASSED] test_lock_unlock [06:51:16] [PASSED] test_duplicates [06:51:16] [PASSED] test_prepare [06:51:16] [PASSED] test_prepare_array [06:51:16] [PASSED] test_multiple_loops [06:51:16] ==================== [PASSED] drm_exec ===================== [06:51:16] =========== drm_format_helper_test (17 subtests) =========== [06:51:16] ============== drm_test_fb_xrgb8888_to_gray8 ============== [06:51:16] [PASSED] single_pixel_source_buffer [06:51:16] [PASSED] single_pixel_clip_rectangle [06:51:16] [PASSED] well_known_colors [06:51:16] [PASSED] destination_pitch [06:51:16] ========== [PASSED] drm_test_fb_xrgb8888_to_gray8 ========== [06:51:16] ============= drm_test_fb_xrgb8888_to_rgb332 ============== [06:51:16] [PASSED] single_pixel_source_buffer [06:51:16] [PASSED] single_pixel_clip_rectangle [06:51:16] [PASSED] well_known_colors [06:51:16] [PASSED] destination_pitch [06:51:16] ========= [PASSED] drm_test_fb_xrgb8888_to_rgb332 ========== [06:51:16] ============= drm_test_fb_xrgb8888_to_rgb565 ============== [06:51:16] [PASSED] single_pixel_source_buffer [06:51:16] [PASSED] single_pixel_clip_rectangle [06:51:16] [PASSED] well_known_colors [06:51:16] [PASSED] destination_pitch [06:51:16] ========= [PASSED] drm_test_fb_xrgb8888_to_rgb565 ========== [06:51:16] ============ drm_test_fb_xrgb8888_to_xrgb1555 ============= [06:51:16] [PASSED] single_pixel_source_buffer [06:51:16] [PASSED] single_pixel_clip_rectangle [06:51:16] [PASSED] well_known_colors [06:51:16] [PASSED] destination_pitch [06:51:16] ======== [PASSED] drm_test_fb_xrgb8888_to_xrgb1555 ========= [06:51:16] ============ drm_test_fb_xrgb8888_to_argb1555 ============= [06:51:16] [PASSED] single_pixel_source_buffer [06:51:16] [PASSED] single_pixel_clip_rectangle [06:51:16] [PASSED] well_known_colors [06:51:16] [PASSED] destination_pitch [06:51:16] ======== [PASSED] drm_test_fb_xrgb8888_to_argb1555 ========= [06:51:16] ============ drm_test_fb_xrgb8888_to_rgba5551 ============= [06:51:16] [PASSED] single_pixel_source_buffer [06:51:16] [PASSED] single_pixel_clip_rectangle [06:51:16] [PASSED] well_known_colors [06:51:16] [PASSED] destination_pitch [06:51:16] ======== [PASSED] drm_test_fb_xrgb8888_to_rgba5551 ========= [06:51:16] ============= drm_test_fb_xrgb8888_to_rgb888 ============== [06:51:16] [PASSED] single_pixel_source_buffer [06:51:16] [PASSED] single_pixel_clip_rectangle [06:51:16] [PASSED] well_known_colors [06:51:16] [PASSED] destination_pitch [06:51:16] ========= [PASSED] drm_test_fb_xrgb8888_to_rgb888 ========== [06:51:16] ============ drm_test_fb_xrgb8888_to_argb8888 ============= [06:51:16] [PASSED] single_pixel_source_buffer [06:51:16] [PASSED] single_pixel_clip_rectangle [06:51:16] [PASSED] well_known_colors [06:51:16] [PASSED] destination_pitch [06:51:16] ======== [PASSED] drm_test_fb_xrgb8888_to_argb8888 ========= [06:51:16] =========== drm_test_fb_xrgb8888_to_xrgb2101010 =========== [06:51:16] [PASSED] single_pixel_source_buffer [06:51:16] [PASSED] single_pixel_clip_rectangle [06:51:16] [PASSED] well_known_colors [06:51:16] [PASSED] destination_pitch [06:51:16] ======= [PASSED] drm_test_fb_xrgb8888_to_xrgb2101010 ======= [06:51:16] =========== drm_test_fb_xrgb8888_to_argb2101010 =========== [06:51:16] [PASSED] single_pixel_source_buffer [06:51:16] [PASSED] single_pixel_clip_rectangle [06:51:16] [PASSED] well_known_colors [06:51:16] [PASSED] destination_pitch [06:51:16] ======= [PASSED] drm_test_fb_xrgb8888_to_argb2101010 ======= [06:51:16] ============== drm_test_fb_xrgb8888_to_mono =============== [06:51:16] [PASSED] single_pixel_source_buffer [06:51:16] [PASSED] single_pixel_clip_rectangle [06:51:16] [PASSED] well_known_colors [06:51:16] [PASSED] destination_pitch [06:51:16] ========== [PASSED] drm_test_fb_xrgb8888_to_mono =========== [06:51:16] ==================== drm_test_fb_swab ===================== [06:51:16] [PASSED] single_pixel_source_buffer [06:51:16] [PASSED] single_pixel_clip_rectangle [06:51:16] [PASSED] well_known_colors [06:51:16] [PASSED] destination_pitch [06:51:16] ================ [PASSED] drm_test_fb_swab ================= [06:51:16] ============ drm_test_fb_xrgb8888_to_xbgr8888 ============= [06:51:16] [PASSED] single_pixel_source_buffer [06:51:16] [PASSED] single_pixel_clip_rectangle [06:51:16] [PASSED] well_known_colors [06:51:16] [PASSED] destination_pitch [06:51:16] ======== [PASSED] drm_test_fb_xrgb8888_to_xbgr8888 ========= [06:51:16] ============ drm_test_fb_xrgb8888_to_abgr8888 ============= [06:51:16] [PASSED] single_pixel_source_buffer [06:51:16] [PASSED] single_pixel_clip_rectangle [06:51:16] [PASSED] well_known_colors [06:51:16] [PASSED] destination_pitch [06:51:16] ======== [PASSED] drm_test_fb_xrgb8888_to_abgr8888 ========= [06:51:16] ================= drm_test_fb_clip_offset ================= [06:51:16] [PASSED] pass through [06:51:16] [PASSED] horizontal offset [06:51:16] [PASSED] vertical offset [06:51:16] [PASSED] horizontal and vertical offset [06:51:16] [PASSED] horizontal offset (custom pitch) [06:51:16] [PASSED] vertical offset (custom pitch) [06:51:16] [PASSED] horizontal and vertical offset (custom pitch) [06:51:16] ============= [PASSED] drm_test_fb_clip_offset ============= [06:51:16] ============== drm_test_fb_build_fourcc_list ============== [06:51:16] [PASSED] no native formats [06:51:16] [PASSED] XRGB8888 as native format [06:51:16] [PASSED] remove duplicates [06:51:16] [PASSED] convert alpha formats [06:51:16] [PASSED] random formats [06:51:16] ========== [PASSED] drm_test_fb_build_fourcc_list ========== [06:51:16] =================== drm_test_fb_memcpy ==================== [06:51:16] [PASSED] single_pixel_source_buffer: XR24 little-endian (0x34325258) [06:51:16] [PASSED] single_pixel_source_buffer: XRA8 little-endian (0x38415258) [06:51:16] [PASSED] single_pixel_source_buffer: YU24 little-endian (0x34325559) [06:51:16] [PASSED] single_pixel_clip_rectangle: XB24 little-endian (0x34324258) [06:51:16] [PASSED] single_pixel_clip_rectangle: XRA8 little-endian (0x38415258) [06:51:16] [PASSED] single_pixel_clip_rectangle: YU24 little-endian (0x34325559) [06:51:16] [PASSED] well_known_colors: XB24 little-endian (0x34324258) [06:51:16] [PASSED] well_known_colors: XRA8 little-endian (0x38415258) [06:51:16] [PASSED] well_known_colors: YU24 little-endian (0x34325559) [06:51:16] [PASSED] destination_pitch: XB24 little-endian (0x34324258) [06:51:16] [PASSED] destination_pitch: XRA8 little-endian (0x38415258) [06:51:16] [PASSED] destination_pitch: YU24 little-endian (0x34325559) [06:51:16] =============== [PASSED] drm_test_fb_memcpy ================ [06:51:16] ============= [PASSED] drm_format_helper_test ============== [06:51:16] ================= drm_format (18 subtests) ================= [06:51:16] [PASSED] drm_test_format_block_width_invalid [06:51:16] [PASSED] drm_test_format_block_width_one_plane [06:51:16] [PASSED] drm_test_format_block_width_two_plane [06:51:16] [PASSED] drm_test_format_block_width_three_plane [06:51:16] [PASSED] drm_test_format_block_width_tiled [06:51:16] [PASSED] drm_test_format_block_height_invalid [06:51:16] [PASSED] drm_test_format_block_height_one_plane [06:51:16] [PASSED] drm_test_format_block_height_two_plane [06:51:16] [PASSED] drm_test_format_block_height_three_plane [06:51:16] [PASSED] drm_test_format_block_height_tiled [06:51:16] [PASSED] drm_test_format_min_pitch_invalid [06:51:16] [PASSED] drm_test_format_min_pitch_one_plane_8bpp [06:51:16] [PASSED] drm_test_format_min_pitch_one_plane_16bpp [06:51:16] [PASSED] drm_test_format_min_pitch_one_plane_24bpp [06:51:16] [PASSED] drm_test_format_min_pitch_one_plane_32bpp [06:51:16] [PASSED] drm_test_format_min_pitch_two_plane [06:51:16] [PASSED] drm_test_format_min_pitch_three_plane_8bpp [06:51:16] [PASSED] drm_test_format_min_pitch_tiled [06:51:16] =================== [PASSED] drm_format ==================== [06:51:16] =============== drm_framebuffer (1 subtest) ================ [06:51:16] =============== drm_test_framebuffer_create =============== [06:51:16] [PASSED] ABGR8888 normal sizes [06:51:16] [PASSED] ABGR8888 max sizes [06:51:16] [PASSED] ABGR8888 pitch greater than min required [06:51:16] [PASSED] ABGR8888 pitch less than min required [06:51:16] [PASSED] ABGR8888 Invalid width [06:51:16] [PASSED] ABGR8888 Invalid buffer handle [06:51:16] [PASSED] No pixel format [06:51:16] [PASSED] ABGR8888 Width 0 [06:51:16] [PASSED] ABGR8888 Height 0 [06:51:16] [PASSED] ABGR8888 Out of bound height * pitch combination [06:51:16] [PASSED] ABGR8888 Large buffer offset [06:51:16] [PASSED] ABGR8888 Set DRM_MODE_FB_MODIFIERS without modifiers [06:51:16] [PASSED] ABGR8888 Valid buffer modifier [06:51:16] [PASSED] ABGR8888 Invalid buffer modifier(DRM_FORMAT_MOD_SAMSUNG_64_32_TILE) [06:51:16] [PASSED] ABGR8888 Extra pitches without DRM_MODE_FB_MODIFIERS [06:51:16] [PASSED] ABGR8888 Extra pitches with DRM_MODE_FB_MODIFIERS [06:51:16] [PASSED] NV12 Normal sizes [06:51:16] [PASSED] NV12 Max sizes [06:51:16] [PASSED] NV12 Invalid pitch [06:51:16] [PASSED] NV12 Invalid modifier/missing DRM_MODE_FB_MODIFIERS flag [06:51:16] [PASSED] NV12 different modifier per-plane [06:51:16] [PASSED] NV12 with DRM_FORMAT_MOD_SAMSUNG_64_32_TILE [06:51:16] [PASSED] NV12 Valid modifiers without DRM_MODE_FB_MODIFIERS [06:51:16] [PASSED] NV12 Modifier for inexistent plane [06:51:16] [PASSED] NV12 Handle for inexistent plane [06:51:16] [PASSED] NV12 Handle for inexistent plane without DRM_MODE_FB_MODIFIERS [06:51:16] [PASSED] YVU420 DRM_MODE_FB_MODIFIERS set without modifier [06:51:16] [PASSED] YVU420 Normal sizes [06:51:16] [PASSED] YVU420 Max sizes [06:51:16] [PASSED] YVU420 Invalid pitch [06:51:16] [PASSED] YVU420 Different pitches [06:51:16] [PASSED] YVU420 Different buffer offsets/pitches [06:51:16] [PASSED] YVU420 Modifier set just for plane 0, without DRM_MODE_FB_MODIFIERS [06:51:16] [PASSED] YVU420 Modifier set just for planes 0, 1, without DRM_MODE_FB_MODIFIERS [06:51:16] [PASSED] YVU420 Modifier set just for plane 0, 1, with DRM_MODE_FB_MODIFIERS [06:51:16] [PASSED] YVU420 Valid modifier [06:51:16] [PASSED] YVU420 Different modifiers per plane [06:51:16] [PASSED] YVU420 Modifier for inexistent plane [06:51:16] [PASSED] X0L2 Normal sizes [06:51:16] [PASSED] X0L2 Max sizes [06:51:16] [PASSED] X0L2 Invalid pitch [06:51:16] [PASSED] X0L2 Pitch greater than minimum required [06:51:16] [PASSED] X0L2 Handle for inexistent plane [06:51:16] [PASSED] X0L2 Offset for inexistent plane, without DRM_MODE_FB_MODIFIERS set [06:51:16] [PASSED] X0L2 Modifier without DRM_MODE_FB_MODIFIERS set [06:51:16] [PASSED] X0L2 Valid modifier [06:51:16] [PASSED] X0L2 Modifier for inexistent plane [06:51:16] =========== [PASSED] drm_test_framebuffer_create =========== [06:51:16] ================= [PASSED] drm_framebuffer ================= [06:51:16] ================ drm_gem_shmem (8 subtests) ================ [06:51:16] [PASSED] drm_gem_shmem_test_obj_create [06:51:16] [PASSED] drm_gem_shmem_test_obj_create_private [06:51:16] [PASSED] drm_gem_shmem_test_pin_pages [06:51:16] [PASSED] drm_gem_shmem_test_vmap [06:51:16] [PASSED] drm_gem_shmem_test_get_pages_sgt [06:51:16] [PASSED] drm_gem_shmem_test_get_sg_table [06:51:16] [PASSED] drm_gem_shmem_test_madvise [06:51:16] [PASSED] drm_gem_shmem_test_purge [06:51:16] ================== [PASSED] drm_gem_shmem ================== [06:51:16] ================= drm_managed (2 subtests) ================= [06:51:16] [PASSED] drm_test_managed_release_action [06:51:16] [PASSED] drm_test_managed_run_action [06:51:16] =================== [PASSED] drm_managed =================== [06:51:16] =================== drm_mm (6 subtests) ==================== [06:51:16] [PASSED] drm_test_mm_init [06:51:16] [PASSED] drm_test_mm_debug [06:51:16] [PASSED] drm_test_mm_align32 [06:51:16] [PASSED] drm_test_mm_align64 [06:51:16] [PASSED] drm_test_mm_lowest [06:51:16] [PASSED] drm_test_mm_highest [06:51:16] ===================== [PASSED] drm_mm ====================== [06:51:16] ============= drm_modes_analog_tv (4 subtests) ============= [06:51:16] [PASSED] drm_test_modes_analog_tv_ntsc_480i [06:51:16] [PASSED] drm_test_modes_analog_tv_ntsc_480i_inlined [06:51:16] [PASSED] drm_test_modes_analog_tv_pal_576i [06:51:16] [PASSED] drm_test_modes_analog_tv_pal_576i_inlined [06:51:16] =============== [PASSED] drm_modes_analog_tv =============== [06:51:16] ============== drm_plane_helper (2 subtests) =============== [06:51:16] =============== drm_test_check_plane_state ================ [06:51:16] [PASSED] clipping_simple [06:51:16] [PASSED] clipping_rotate_reflect [06:51:16] [PASSED] positioning_simple [06:51:16] [PASSED] upscaling [06:51:16] [PASSED] downscaling [06:51:16] [PASSED] rounding1 [06:51:16] [PASSED] rounding2 [06:51:16] [PASSED] rounding3 [06:51:16] [PASSED] rounding4 [06:51:16] =========== [PASSED] drm_test_check_plane_state ============ [06:51:16] =========== drm_test_check_invalid_plane_state ============ [06:51:16] [PASSED] positioning_invalid [06:51:16] [PASSED] upscaling_invalid [06:51:16] [PASSED] downscaling_invalid [06:51:16] ======= [PASSED] drm_test_check_invalid_plane_state ======== [06:51:16] ================ [PASSED] drm_plane_helper ================= [06:51:16] ====== drm_connector_helper_tv_get_modes (1 subtest) ======= [06:51:16] ====== drm_test_connector_helper_tv_get_modes_check ======= [06:51:16] [PASSED] None [06:51:16] [PASSED] PAL [06:51:16] [PASSED] NTSC [06:51:16] [PASSED] Both, NTSC Default [06:51:16] [PASSED] Both, PAL Default [06:51:16] [PASSED] Both, NTSC Default, with PAL on command-line [06:51:16] [PASSED] Both, PAL Default, with NTSC on command-line [06:51:16] == [PASSED] drm_test_connector_helper_tv_get_modes_check === [06:51:16] ======== [PASSED] drm_connector_helper_tv_get_modes ======== [06:51:16] ================== drm_rect (9 subtests) =================== [06:51:16] [PASSED] drm_test_rect_clip_scaled_div_by_zero [06:51:16] [PASSED] drm_test_rect_clip_scaled_not_clipped [06:51:16] [PASSED] drm_test_rect_clip_scaled_clipped stty: 'standard input': Inappropriate ioctl for device [06:51:16] [PASSED] drm_test_rect_clip_scaled_signed_vs_unsigned [06:51:16] ================= drm_test_rect_intersect ================= [06:51:16] [PASSED] top-left x bottom-right: 2x2+1+1 x 2x2+0+0 [06:51:16] [PASSED] top-right x bottom-left: 2x2+0+0 x 2x2+1-1 [06:51:16] [PASSED] bottom-left x top-right: 2x2+1-1 x 2x2+0+0 [06:51:16] [PASSED] bottom-right x top-left: 2x2+0+0 x 2x2+1+1 [06:51:16] [PASSED] right x left: 2x1+0+0 x 3x1+1+0 [06:51:16] [PASSED] left x right: 3x1+1+0 x 2x1+0+0 [06:51:16] [PASSED] up x bottom: 1x2+0+0 x 1x3+0-1 [06:51:16] [PASSED] bottom x up: 1x3+0-1 x 1x2+0+0 [06:51:16] [PASSED] touching corner: 1x1+0+0 x 2x2+1+1 [06:51:16] [PASSED] touching side: 1x1+0+0 x 1x1+1+0 [06:51:16] [PASSED] equal rects: 2x2+0+0 x 2x2+0+0 [06:51:16] [PASSED] inside another: 2x2+0+0 x 1x1+1+1 [06:51:16] [PASSED] far away: 1x1+0+0 x 1x1+3+6 [06:51:16] [PASSED] points intersecting: 0x0+5+10 x 0x0+5+10 [06:51:16] [PASSED] points not intersecting: 0x0+0+0 x 0x0+5+10 [06:51:16] ============= [PASSED] drm_test_rect_intersect ============= [06:51:16] ================ drm_test_rect_calc_hscale ================ [06:51:16] [PASSED] normal use [06:51:16] [PASSED] out of max range [06:51:16] [PASSED] out of min range [06:51:16] [PASSED] zero dst [06:51:16] [PASSED] negative src [06:51:16] [PASSED] negative dst [06:51:16] ============ [PASSED] drm_test_rect_calc_hscale ============ [06:51:16] ================ drm_test_rect_calc_vscale ================ [06:51:16] [PASSED] normal use [06:51:16] [PASSED] out of max range [06:51:16] [PASSED] out of min range [06:51:16] [PASSED] zero dst [06:51:16] [PASSED] negative src [06:51:16] [PASSED] negative dst [06:51:16] ============ [PASSED] drm_test_rect_calc_vscale ============ [06:51:16] ================== drm_test_rect_rotate =================== [06:51:16] [PASSED] reflect-x [06:51:16] [PASSED] reflect-y [06:51:16] [PASSED] rotate-0 [06:51:16] [PASSED] rotate-90 [06:51:16] [PASSED] rotate-180 [06:51:16] [PASSED] rotate-270 [06:51:16] ============== [PASSED] drm_test_rect_rotate =============== [06:51:16] ================ drm_test_rect_rotate_inv ================= [06:51:16] [PASSED] reflect-x [06:51:16] [PASSED] reflect-y [06:51:16] [PASSED] rotate-0 [06:51:16] [PASSED] rotate-90 [06:51:16] [PASSED] rotate-180 [06:51:16] [PASSED] rotate-270 [06:51:16] ============ [PASSED] drm_test_rect_rotate_inv ============= [06:51:16] ==================== [PASSED] drm_rect ===================== [06:51:16] ============================================================ [06:51:16] Testing complete. Ran 417 tests: passed: 417 [06:51:16] Elapsed time: 23.838s total, 1.715s configuring, 21.945s building, 0.149s running
+ cleanup
++ stat -c %u:%g /kernel
+ chown -R 1003:1003 /kernel