Skip to contentSkip to conversation

TTM shrinker helpers and xe buffer object shrinker

PATCH Superseded Thomas Hellström 4 participants 20 messages Jun 14, 2024 – Jun 17, 2024

Subsystems (5)

v4 of 17 Superseded Latest is v17 →

lore
Share & tools
lore

Thomas Hellström

author maintainer
#0 lore raw

v4 cover TTM shrinker helpers and xe buffer object shrinker

This series implements TTM shrinker / eviction helpers and an xe bo shrinker. It builds on two previous series, *and obsoletes these*. First

https://www.mail-archive.com/[email protected]/msg484425.html

Second the previous TTM shrinker series

https://lore.kernel.org/linux-mm/[email protected]/T/

Where the comment about layering
https://lore.kernel.org/linux-mm/[email protected]/T/#ma918844aa8a6efe8768fdcda0c6590d5c93850c9

now addressed, and this version also implements shmem objects for backup rather than direct swap-cache insertions, which was used in the previuos series. It turns out that with per-page backup / shrinking, shmem objects appears to work just as well as direct swap-cache insertions with the added benefit that was introduced in the previous TTM shrinker series to avoid running out of swap entries isn't really needed.

Patch 1-4 implements restartable LRU list iteration.

Patch 5 implements a LRU walker + resv locking helper

Patch 6 moves TTM swapping over to the walker.

Patch 7 moves TTM eviction over to the walker.

Patch 8 could in theory be skipped but introduces a possibility to easily add or test multiple backup backends, like the direct swap-cache insertion or even files into fast dedicated nvme storage for for example.

Patch 9 introduces helpers in the ttm_pool code for page-by-page shrinking and recovery. It avoids having to temporarily allocate a huge amount of memory to be able to shrink a buffer object. It also introduces the possibility to immediately write-back pages if needed, since that tends to be a bit delayed when left to kswapd.

Patch 10 Adds a simple error injection to the above code to help increase test coverage.

Patch 11 Implements an xe bo shrinker and a common helper in TTM for shrinking.

Patch 12-21 are really a separate POC series, for introducing drm_exec locking in TTM. The patch touches both drm_exec and dma-buf and is for now marked as an RFC:

Patch 12 Increases (removes) the XE_PL_TT watermark.

v2:
- Squash obsolete revision history in the patch commit messages.
- Fix a couple of review comments by Christian
- Don't store the mem_type in the TTM managers but in the resource cursor.
- Rename introduced TTM *back_up* function names to *backup*
- Add ttm pool recovery fault injection.
- Shrinker xe kunit test
- Various bugfixes

v3:
- Address some review comments from Matthew Brost and Christian König.
- Use the restartable LRU walk for TTM swapping and eviction.
- Provide a POC drm_exec locking implementation for exhaustive eviction. (Christian König).

v4:
- Remove the RFC exhaustive eviction part. While the path to exhaustive eviction is pretty clear and demonstrated in v3, there is still some drm_exec work that needs to be agreed and implemented.
- Add shrinker power management. On some hw we need to wake when shrinking.
- Fix the lru walker helper for -EALREADY errors.
- Add drm/xe: Increase the XE_PL_TT watermark.

Cc Somalapuram Amaranath <[email protected]>
Cc Christian König <[email protected]>
Cc Matthew Brost <[email protected]>

Thomas Hellström (12):
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/ttm: Provide a generic LRU walker helper
drm/ttm: Use the LRU walker helper for swapping
drm/ttm: Use the LRU walker for eviction
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
drm/xe: Increase the XE_PL_TT watermark

 drivers/gpu/drm/Kconfig                |  10 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c |   4 +
 drivers/gpu/drm/ttm/Makefile           |   2 +-
 drivers/gpu/drm/ttm/ttm_backup_shmem.c | 137 ++++++++
 drivers/gpu/drm/ttm/ttm_bo.c           | 463 ++++++++++++-------------
 drivers/gpu/drm/ttm/ttm_bo_util.c      | 212 +++++++++++
 drivers/gpu/drm/ttm/ttm_device.c       |  29 +-
 drivers/gpu/drm/ttm/ttm_pool.c         | 412 +++++++++++++++++++++-
 drivers/gpu/drm/ttm/ttm_resource.c     | 264 +++++++++++---
 drivers/gpu/drm/ttm/ttm_tt.c           |  37 ++
 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             | 139 +++++++-
 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       | 287 +++++++++++++++
 drivers/gpu/drm/xe/xe_shrinker.h       |  18 +
 drivers/gpu/drm/xe/xe_ttm_sys_mgr.c    |   3 +-
 drivers/gpu/drm/xe/xe_vm.c             |   4 +
 include/drm/ttm/ttm_backup.h           | 136 ++++++++
 include/drm/ttm/ttm_bo.h               |  48 ++-
 include/drm/ttm/ttm_pool.h             |   5 +
 include/drm/ttm/ttm_resource.h         |  99 +++++-
 include/drm/ttm/ttm_tt.h               |  20 ++
 27 files changed, 2089 insertions(+), 375 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
author maintainer
#1 lore raw

PATCH v4 1/12 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.
v3:
- Introduce ttm_lru_first_res_or_null()
(Christian König, Thomas Hellström)

---
 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
index 434cf0258000..09411978a13a 100644
@@ -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
author maintainer
#4 lore raw

PATCH v4 3/12 drm/ttm: Use LRU hitches

In reply to Thomas Hellström

Have 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)

Cc Christian König <[email protected]>
Cc Somalapuram Amaranath <[email protected]>
Cc Matthew Brost <[email protected]>
---
 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
index 6396dece0db1..43eda720657f 100644
@@ -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
index 09411978a13a..f9e9b1ec8c8a 100644
@@ -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
index 7d81fd5b5b83..8fac781f641e 100644
@@ -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
author maintainer
#5 lore raw

PATCH v4 4/12 drm/ttm, drm/amdgpu, drm/xe: Consider hitch moves within bulk sublist moves

In reply to Thomas Hellström

To 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.
v3:
- Remove leftover mem_type member from change in v2.

Cc Christian König <[email protected]>
Cc Somalapuram Amaranath <[email protected]>
Cc Matthew Brost <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c |  4 ++
 drivers/gpu/drm/ttm/ttm_resource.c     | 89 ++++++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_vm.c             |  4 ++
 include/drm/ttm/ttm_resource.h         | 56 ++++++++++------
 4 files changed, 132 insertions(+), 21 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4 -0
index 3abfa66d72a2..97743993d711 100644
@@ -2420,6 +2420,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 &
@@ -2484,6 +2486,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;
@@ -2640,6 +2643,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 +89 -0

140 lines not on this page · raw message

drivers/gpu/drm/xe/xe_vm.c +4 -0
index ffda487653d8..483a88837aed 100644
@@ -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 */
 
@@ -1462,6 +1464,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_LR_MODE)
 		xe_pm_runtime_put(xe);
@@ -1605,6 +1608,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 +35 -21

83 lines not on this page · raw message

Signature · 1 line
2.44.0
author maintainer
#8 lore raw

PATCH v4 7/12 drm/ttm: Use the LRU walker for eviction

In reply to Thomas Hellström

Use the LRU walker for eviction. This helps
removing a lot of code with weird locking
semantics.

The functionality is slightly changed so that when trylocked buffer objects are exhausted, we continue to interleave walks with ticket-locks while there is still progress made. The list walks are not restarted in-between evictions.

Also provide a separate ttm_bo_evict_first() function for its single user. The context of that user allows sleeping dma_resv locks.

Cc Christian König <[email protected]>
Cc Somalapuram Amaranath <[email protected]>
Cc Matthew Brost <[email protected]>
---
 drivers/gpu/drm/ttm/ttm_bo.c       | 350 ++++++++++++-----------------
 drivers/gpu/drm/ttm/ttm_resource.c |  20 +-
 include/drm/ttm/ttm_bo.h           |   8 +-
 3 files changed, 145 insertions(+), 233 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +139 -211
index 63a91b77f7da..316afe19a325 100644
@@ -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,154 @@ 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;
+/**
+ * ttm_bo_evict_first() - Evict the first bo on the manager's LRU list.
+ * @bdev: The ttm device.
+ * @man: The manager whose bo to evict.
+ * @ctx: The TTM operation ctx governing the eviction.
  *
- * b. Otherwise, trylock it.
+ * Return: 0 if successful or the resource disappeared. Negative error code on error.
  */
-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_buffer_object *bo;
+	struct ttm_resource *res;
+	unsigned int mem_type;
+	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;
+	mem_type = res->mem_type;
+	spin_unlock(&bdev->lru_lock);
+	ret = ttm_bo_reserve(bo, ctx->interruptible, ctx->no_wait_gpu, NULL);
+	if (ret)
+		goto out_no_lock;
+	if (bo->resource != res || res->mem_type != mem_type)
+		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);
+out_no_lock:
+	ttm_bo_put(bo);
+	ttm_resource_cursor_fini(&cursor);
 	return ret;
+
+out_no_ref:
+	ttm_resource_cursor_fini_locked(&cursor);
+	spin_unlock(&bdev->lru_lock);
+	return -ENOENT;
 }
 
 /**
- * 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.
+ * struct ttm_bo_evict_walk - Parameters for the evict walk.
  */
-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;
-}
+struct ttm_bo_evict_walk {
+	/** @walk: The walk base parameters. */
+	struct ttm_lru_walk walk;
+	/** @place: The place passed to the resource allocation. */
+	const struct ttm_place *place;
+	/** @evictor: The buffer object we're trying to make room for. */
+	struct ttm_buffer_object *evictor;
+	/** @res: The allocated resource if any. */
+	struct ttm_resource **res;
+	/** @evicted: The number of evicted pages. */
+	unsigned long evicted;
+};
 
-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)
+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 making progress. */
+	evict_walk.walk.trylock_only = false;
+	do {
+		/* The walk may clear the evict_walk.walk.ticket field */
+		evict_walk.walk.ticket = ticket;
+		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 +689,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 +699,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 +725,6 @@ static int ttm_bo_alloc_resource(struct ttm_buffer_object *bo,
 		}
 		return 0;
 	}
-
 	return -ENOSPC;
 }
 
drivers/gpu/drm/ttm/ttm_resource.c +3 -17
index a03090683e79..6d0c66fc36e3 100644
@@ -508,24 +508,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
index 472a55b69afb..148f49f625e4 100644
@@ -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
author maintainer
#9 lore raw

PATCH v4 8/12 drm/ttm: Add a virtual base class for graphics memory backup

In reply to Thomas Hellström

Initially 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.

Cc Christian König <[email protected]>
Cc Somalapuram Amaranath <[email protected]>
Cc Matthew Brost <[email protected]>
---
 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
index dad298127226..5e980dd90e41 100644
@@ -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
author maintainer
#3 lore raw

PATCH v4 2/12 drm/ttm: Slightly clean up LRU list iteration

In reply to Thomas Hellström

To make the transition to using lru hitches easier, simplify 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
index db9a7a3717c4..8bfbddddc0e8 100644
@@ -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
index 1511d91e290d..7d81fd5b5b83 100644
@@ -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
author maintainer
#13 lore raw

PATCH v4 10/12 drm/ttm: Use fault-injection to test error paths

In reply to Thomas Hellström

Use 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.

Cc Christian König <[email protected]>
Cc Somalapuram Amaranath <[email protected]>
Cc Matthew Brost <[email protected]>
---
 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
index 981f43d4ca8c..5f010ec31002 100644
@@ -272,6 +272,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
index 38e50cf81b0a..d32a1f2e5e50 100644
@@ -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
author maintainer
#7 lore raw

PATCH v4 6/12 drm/ttm: Use the LRU walker helper for swapping

In reply to Thomas Hellström

Rework the TTM swapping to use the LRU walker helper. This helps fixing up the ttm_bo_swapout() interface to be consistent about not requiring any locking.

For now mimic the current behaviour of using trylock only. We could be using ticket-locks here but defer that until it's deemed necessary. The TTM swapout functionality is a bit weird anyway since it alternates between memory types without exhausting TTM_PL_SYSTEM first.

Cc Christian König <[email protected]>
Cc Somalapuram Amaranath <[email protected]>
Cc Matthew Brost <[email protected]>
---
 drivers/gpu/drm/ttm/ttm_bo.c     | 112 +++++++++++++++++++++----------
 drivers/gpu/drm/ttm/ttm_device.c |  30 ++-------
 include/drm/ttm/ttm_bo.h         |   5 +-
 3 files changed, 83 insertions(+), 64 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +75 -37
index 43eda720657f..63a91b77f7da 100644
@@ -1118,11 +1118,23 @@ 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 - Parameters for the swapout walk
+ */
+struct ttm_bo_swapout_walk {
+	/** @walk: The walk base parameters. */
+	struct ttm_lru_walk walk;
+	/** @gfp_flags: The gfp flags to use for ttm_tt_swapout() */
+	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 +1143,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,12 +1177,13 @@ 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)) {
-			WARN(ret == -EMULTIHOP, "Unexpected multihop in swaput - likely driver bug.\n");
+		if (ret) {
+			WARN(ret == -EMULTIHOP,
+			     "Unexpected multihop in swapout - likely driver bug.\n");
 			ttm_resource_free(bo, &evict_mem);
 			goto out;
 		}
@@ -1179,30 +1193,54 @@ 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);
-
-	/*
-	 * Swap out. Buffer will be swapped in again as soon as
-	 * anyone tries to access a ttm page.
-	 */
 	if (bo->bdev->funcs->swap_notify)
 		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,
+};
+
+/**
+ * ttm_bo_swapout() - Swap out buffer objects on the LRU list to shmem.
+ * @bdev: The ttm device.
+ * @ctx: The ttm_operation_ctx governing the swapout operation.
+ * @man: The resource manager whose resources / buffer objects are
+ * goint to be swapped out.
+ * @gfp_flags: The gfp flags used for shmem page allocations.
+ * @target: The desired number of pages to swap out.
+ *
+ * Return: The number of pages actually swapped out, or negative error code
+ * on error.
+ */
+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,
+			.trylock_only = true,
+		},
+		.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 -25
index f9e9b1ec8c8a..ee575d8a54c0 100644
@@ -148,40 +148,20 @@ 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) {
 		man = ttm_manager_type(bdev, i);
 		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
index 8b032298d66e..472a55b69afb 100644
@@ -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
author maintainer
#14 lore raw

PATCH v4 11/12 drm/ttm, drm/xe: Add a shrinker for xe bos

In reply to Thomas Hellström

Rather 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.
v3:
- Move the try_shrink() helper to core TTM.
- Minor cleanups.
v4:
- Add runtime pm for the shrinker. Shrinking may require an active device for CCS metadata copying.

Cc Christian König <[email protected]>
Cc Somalapuram Amaranath <[email protected]>
Cc Matthew Brost <[email protected]>
---
 drivers/gpu/drm/ttm/ttm_bo_util.c     |  67 ++++++
 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            | 139 +++++++++++--
 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      | 287 ++++++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_shrinker.h      |  18 ++
 include/drm/ttm/ttm_bo.h              |   3 +
 12 files changed, 633 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 +67 -0
index 45fcaf6f8644..44711f422459 100644
@@ -913,3 +913,70 @@ 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;
+		}
+	}
+
+	lret = ttm_bo_wait_ctx(bo, ctx);
+	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
index 1905a80e61e3..46304592d94d 100644
@@ -107,6 +107,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
index a324cde77db8..317fa923e287 100644
@@ -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
index 0113ab45066a..7f44d14a45c5 100644
@@ -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 +123 -16

266 lines not on this page · raw message

drivers/gpu/drm/xe/xe_bo.h +4 -0
index 6de894c728f5..220e71086e65 100644
@@ -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
index 94dbfe5cf19c..2c2f54c6e722 100644
@@ -46,6 +46,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
index f1c09824b145..0f281008f71c 100644
@@ -324,6 +324,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 +287 -0

287 lines not on this page · raw message

drivers/gpu/drm/xe/xe_shrinker.h new file +18 -0
new file mode 100644
index 000000000000..28a038f4fcbf
@@ -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
index 148f49f625e4..deaedfb060ed 100644
@@ -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
author maintainer
#6 lore raw

PATCH v4 5/12 drm/ttm: Provide a generic LRU walker helper

In reply to Thomas Hellström

Provide 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 ww mutex locking transaction, to mimic to some extent the current functionality in ttm. However any -EDEADLK return is converted to -ENOMEM, so that the driver will need to back off and possibly retry without being able to keep the ticket.

v3:
- Move the helper to core ttm.
- Remove the drm_exec usage from it for now, it will be reintroduced later in the series.
v4:
- Handle the -EALREADY case if ticketlocking.

Cc Christian König <[email protected]>
Cc Somalapuram Amaranath <[email protected]>
Cc Matthew Brost <[email protected]>
---
 drivers/gpu/drm/ttm/ttm_bo_util.c | 145 ++++++++++++++++++++++++++++++
 include/drm/ttm/ttm_bo.h          |  32 +++++++
 2 files changed, 177 insertions(+)
drivers/gpu/drm/ttm/ttm_bo_util.c +145 -0
index 0b3f4267130c..45fcaf6f8644 100644
@@ -768,3 +768,148 @@ 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) {
+		*needs_unlock = true;
+		/* Only a single ticketlock per loop. */
+		walk->ticket = NULL;
+	} else if (ret == -EDEADLK) {
+		/* Caller needs to exit the ww transaction. */
+		ret = -ENOSPC;
+	}
+
+	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 didn't switch resource in between.
+ *
+ * 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, the walker relies on
+ * TTM's restartable LRU list implementation.
+ *
+ * Typically @walk->process_bo() would return the number of pages evicted,
+ * swapped or shrunken, so 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. Note that the definition of @target is done by the caller, it
+ * could have a different meaning than the number of pages.
+ *
+ * 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: The progress made towards target 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 == -EALREADY)
+			lret = 0;
+		sofar = (lret < 0) ? lret : sofar + lret;
+		if (sofar < 0 || 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
index 6ccf96c91f3a..8b032298d66e 100644
@@ -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.
+ */
+struct ttm_lru_walk {
+	/** @ops: Pointer to the ops structure. */
+	const struct ttm_lru_walk_ops *ops;
+	/** @ctx: Pointer to the struct ttm_operation_ctx. */
+	struct ttm_operation_ctx *ctx;
+	/** @ticket: The struct ww_acquire_ctx if any. */
+	struct ww_acquire_ctx *ticket;
+	/** @tryock_only: Only use trylock for locking. */
+	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
author maintainer
#16 lore raw

PATCH v4 12/12 drm/xe: Increase the XE_PL_TT watermark

In reply to Thomas Hellström

The XE_PL_TT watermark was set to 50% of system memory. The idea behind that was unclear since the net effect is that TT memory will be evicted to TTM_PL_SYSTEM memory if that watermark is exceeded, requiring PPGTT rebinds and dma remapping. But there is no similar watermark for TTM_PL_SYSTEM memory.

The TTM functionality that tries to swap out system memory to shmem objects if a 50% limit of total system memory is reached is orthogonal to this, and with the shrinker added, it's no longer in effect.

Replace the 50% TTM_PL_TT limit with a 100% limit, in effect allowing all graphics memory to be bound to the device unless it has been swapped out by the shrinker.

---
 drivers/gpu/drm/xe/xe_ttm_sys_mgr.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_ttm_sys_mgr.c +1 -2
index 9844a8edbfe1..d38b91872da3 100644
@@ -108,9 +108,8 @@ int xe_ttm_sys_mgr_init(struct xe_device *xe)
 	u64 gtt_size;
 
 	si_meminfo(&si);
+	/* Potentially restrict amount of TT memory here. */
 	gtt_size = (u64)si.totalram * si.mem_unit;
-	/* TTM limits allocation of all TTM devices by 50% of system memory */
-	gtt_size /= 2;
 
 	man->use_tt = true;
 	man->func = &xe_ttm_sys_mgr_func;
Signature · 1 line
2.44.0
author maintainer
#11 lore raw

PATCH v4 9/12 drm/ttm/pool: Provide a helper to shrink pages

In reply to Thomas Hellström

Provide 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.

Cc Christian König <[email protected]>
Cc Somalapuram Amaranath <[email protected]>
Cc Matthew Brost <[email protected]>
---
 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
index 6e1fd6985ffc..38e50cf81b0a 100644
@@ -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
index 7b00ddf0ce49..bc994b8e7e73 100644
@@ -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
index 160d954a261e..4e4db369952b 100644
@@ -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
index 2b9d856ff388..6b990f1e7dd0 100644
@@ -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
#17 lore raw

✓ CI.Patch_applied: success for TTM shrinker helpers and xe buffer object shrinker (rev4)

In reply to Thomas Hellström
== Series Details ==

== Series Details ==

Series: TTM shrinker helpers and xe buffer object shrinker (rev4)
URL : https://patchwork.freedesktop.org/series/131815/
State : success

== Summary ==

=== Applying kernel patches on branch 'drm-tip' with base: ===
Base commit: 00e9498b4534 drm-tip: 2024y-06m-14d-10h-57m-36s 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/ttm: Provide a generic LRU walker helper
Applying: drm/ttm: Use the LRU walker helper for swapping
Applying: drm/ttm: Use the LRU walker for eviction
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: drm/xe: Increase the XE_PL_TT watermark

#18 lore raw

✗ CI.checkpatch: warning for TTM shrinker helpers and xe buffer object shrinker (rev4)

In reply to Thomas Hellström
== Series Details ==

== Series Details ==

Series: TTM shrinker helpers and xe buffer object shrinker (rev4)
URL : https://patchwork.freedesktop.org/series/131815/
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 51ce9f6cd981d42d7467409d7dbc559a450abc1e
+ cd /kernel
+ git config --global --add safe.directory /kernel
+ git log -n1
commit f583ee12b6d35087cbffd89abcc39e764b1d8132

Author: Thomas Hellström <[email protected]>
Date:   Fri Jun 14 12:25:48 2024 +0200

drm/xe: Increase the XE_PL_TT watermark

The XE_PL_TT watermark was set to 50% of system memory. The idea behind that was unclear since the net effect is that TT memory will be evicted to TTM_PL_SYSTEM memory if that watermark is exceeded, requiring PPGTT rebinds and dma remapping. But there is no similar watermark for TTM_PL_SYSTEM memory.

The TTM functionality that tries to swap out system memory to shmem objects if a 50% limit of total system memory is reached is orthogonal to this, and with the shrinker added, it's no longer in effect.

Replace the 50% TTM_PL_TT limit with a 100% limit, in effect allowing all graphics memory to be bound to the device unless it has been swapped out by the shrinker.

+ /mt/dim checkpatch 00e9498b453447a5afe527bd0e174587b12f66d2 drm-intel a3ee82a8348f drm/ttm: Allow TTM LRU list nodes of different types
0cedff4b359a drm/ttm: Slightly clean up LRU list iteration
f6e7ad09ebf1 drm/ttm: Use LRU hitches
7d44a714680a drm/ttm, drm/amdgpu, drm/xe: Consider hitch moves within bulk sublist moves aa8130cad174 drm/ttm: Provide a generic LRU walker helper
185f3627f74b drm/ttm: Use the LRU walker helper for swapping
cf1779304448 drm/ttm: Use the LRU walker for eviction
b0f8b3643f8a 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'
-:42: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #42:
new file mode 100644

total: 0 errors, 1 warnings, 0 checks, 281 lines checked
1caca67e1781 drm/ttm/pool: Provide a helper to shrink pages
310192c37b72 drm/ttm: Use fault-injection to test error paths
-:28: WARNING:CONFIG_DESCRIPTION: please write a help paragraph that fully describes the config symbol #28: FILE: drivers/gpu/drm/Kconfig:275:
+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 checked
3befb29c0c24 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'
-:629: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #629:
new file mode 100644

total: 0 errors, 1 warnings, 0 checks, 847 lines checked f583ee12b6d3 drm/xe: Increase the XE_PL_TT watermark

#19 lore raw

✗ CI.KUnit: failure for TTM shrinker helpers and xe buffer object shrinker (rev4)

In reply to Thomas Hellström
== Series Details ==

== Series Details ==

Series: TTM shrinker helpers and xe buffer object shrinker (rev4)
URL : https://patchwork.freedesktop.org/series/131815/
State : failure

== Summary ==

+ trap cleanup EXIT
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/xe/.kunitconfig [12:00:46] Configuring KUnit Kernel ...
Generating .config ...
Populating config with:

$ make ARCH=um O=.kunit olddefconfig
[12:00:50] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make ARCH=um O=.kunit --jobs=48
../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)
      |      ^~~~~~~~~~~~~~~~~

[12:01:16] Starting KUnit Kernel (1/1)...
[12:01:16] ============================================================ Running tests with:

$ .kunit/linux kunit.enable=1 mem=1G console=tty kunit_shutdown=halt
[12:01:16] =================== guc_dbm (7 subtests) ===================
[12:01:16] [PASSED] test_empty
[12:01:16] [PASSED] test_default
[12:01:16] ======================== test_size  ========================
[12:01:16] [PASSED] 4
[12:01:16] [PASSED] 8
[12:01:16] [PASSED] 32
[12:01:16] [PASSED] 256
[12:01:16] ==================== [PASSED] test_size ====================
[12:01:16] ======================= test_reuse  ========================
[12:01:16] [PASSED] 4
[12:01:16] [PASSED] 8
[12:01:16] [PASSED] 32
[12:01:16] [PASSED] 256
[12:01:16] =================== [PASSED] test_reuse ====================
[12:01:16] =================== test_range_overlap  ====================
[12:01:16] [PASSED] 4
[12:01:16] [PASSED] 8
[12:01:16] [PASSED] 32
[12:01:16] [PASSED] 256
[12:01:16] =============== [PASSED] test_range_overlap ================
[12:01:16] =================== test_range_compact  ====================
[12:01:16] [PASSED] 4
[12:01:16] [PASSED] 8
[12:01:16] [PASSED] 32
[12:01:16] [PASSED] 256
[12:01:16] =============== [PASSED] test_range_compact ================
[12:01:16] ==================== test_range_spare  =====================
[12:01:16] [PASSED] 4
[12:01:16] [PASSED] 8
[12:01:16] [PASSED] 32
[12:01:16] [PASSED] 256
[12:01:16] ================ [PASSED] test_range_spare =================
[12:01:16] ===================== [PASSED] guc_dbm =====================
[12:01:16] =================== guc_idm (6 subtests) ===================
[12:01:16] [PASSED] bad_init
[12:01:16] [PASSED] no_init
[12:01:16] [PASSED] init_fini
[12:01:16] [PASSED] check_used
[12:01:16] [PASSED] check_quota
[12:01:16] [PASSED] check_all
[12:01:16] ===================== [PASSED] guc_idm =====================
[12:01:16] ================== no_relay (3 subtests) ===================
[12:01:16] [PASSED] xe_drops_guc2pf_if_not_ready
[12:01:16] [PASSED] xe_drops_guc2vf_if_not_ready
[12:01:16] [PASSED] xe_rejects_send_if_not_ready
[12:01:16] ==================== [PASSED] no_relay =====================
[12:01:16] ================== pf_relay (14 subtests) ==================
[12:01:16] [PASSED] pf_rejects_guc2pf_too_short
[12:01:16] [PASSED] pf_rejects_guc2pf_too_long
[12:01:16] [PASSED] pf_rejects_guc2pf_no_payload
[12:01:16] [PASSED] pf_fails_no_payload
[12:01:16] [PASSED] pf_fails_bad_origin
[12:01:16] [PASSED] pf_fails_bad_type
[12:01:16] [PASSED] pf_txn_reports_error
[12:01:16] [PASSED] pf_txn_sends_pf2guc
[12:01:16] [PASSED] pf_sends_pf2guc
[12:01:16] [SKIPPED] pf_loopback_nop
[12:01:16] [SKIPPED] pf_loopback_echo
[12:01:16] [SKIPPED] pf_loopback_fail
[12:01:16] [SKIPPED] pf_loopback_busy
[12:01:16] [SKIPPED] pf_loopback_retry
[12:01:16] ==================== [PASSED] pf_relay =====================
[12:01:16] ================== vf_relay (3 subtests) ===================
[12:01:16] [PASSED] vf_rejects_guc2vf_too_short
[12:01:16] [PASSED] vf_rejects_guc2vf_too_long
[12:01:16] [PASSED] vf_rejects_guc2vf_no_payload
[12:01:16] ==================== [PASSED] vf_relay =====================
[12:01:16] ================= pf_service (11 subtests) =================
[12:01:16] [PASSED] pf_negotiate_any
[12:01:16] [PASSED] pf_negotiate_base_match
[12:01:16] [PASSED] pf_negotiate_base_newer
[12:01:16] [PASSED] pf_negotiate_base_next
[12:01:16] [SKIPPED] pf_negotiate_base_older
[12:01:16] [PASSED] pf_negotiate_base_prev
[12:01:16] [PASSED] pf_negotiate_latest_match
[12:01:16] [PASSED] pf_negotiate_latest_newer
[12:01:16] [PASSED] pf_negotiate_latest_next
[12:01:16] [SKIPPED] pf_negotiate_latest_older
[12:01:16] [SKIPPED] pf_negotiate_latest_prev
[12:01:16] =================== [PASSED] pf_service ====================
[12:01:16] ===================== lmtt (1 subtest) =====================
[12:01:16] ======================== test_ops  =========================
[12:01:16] [PASSED] 2-level
[12:01:16] [PASSED] multi-level
[12:01:16] ==================== [PASSED] test_ops =====================
[12:01:16] ====================== [PASSED] lmtt =======================
[12:01:16] ==================== xe_bo (3 subtests) ====================
[12:01:16] [SKIPPED] xe_ccs_migrate_kunit
[12:01:16] [SKIPPED] xe_bo_evict_kunit
[12:01:16] [SKIPPED] xe_bo_shrink_kunit
[12:01:16] ===================== [SKIPPED] xe_bo ======================
[12:01:16] ================== xe_dma_buf (1 subtest) ==================
[12:01:16] [SKIPPED] xe_dma_buf_kunit
[12:01:16] =================== [SKIPPED] xe_dma_buf ===================
[12:01:16] ================== xe_migrate (1 subtest) ==================
[12:01:16] [SKIPPED] xe_migrate_sanity_kunit
[12:01:16] =================== [SKIPPED] xe_migrate ===================
[12:01:16] =================== xe_mocs (2 subtests) ===================
[12:01:16] [SKIPPED] xe_live_mocs_kernel_kunit
[12:01:16] [SKIPPED] xe_live_mocs_reset_kunit
[12:01:16] ==================== [SKIPPED] xe_mocs =====================
[12:01:16] ==================== args (11 subtests) ====================
[12:01:16] [PASSED] count_args_test
[12:01:16] [PASSED] call_args_example
[12:01:16] [PASSED] call_args_test
[12:01:16] [PASSED] drop_first_arg_example
[12:01:16] [PASSED] drop_first_arg_test
[12:01:16] [PASSED] first_arg_example
[12:01:16] [PASSED] first_arg_test
[12:01:16] [PASSED] last_arg_example
[12:01:16] [PASSED] last_arg_test
[12:01:16] [PASSED] pick_arg_example
[12:01:16] [PASSED] sep_comma_example
[12:01:16] ====================== [PASSED] args =======================
[12:01:16] =================== xe_pci (2 subtests) ====================
[12:01:16] [PASSED] xe_gmdid_graphics_ip
[12:01:16] [PASSED] xe_gmdid_media_ip
[12:01:16] ===================== [PASSED] xe_pci ======================
[12:01:16] ==================== xe_rtp (1 subtest) ====================
[12:01:16] ================== xe_rtp_process_tests  ===================
[12:01:16] [PASSED] coalesce-same-reg
[12:01:16] [PASSED] no-match-no-add
[12:01:16] [PASSED] no-match-no-add-multiple-rules
[12:01:16] [PASSED] two-regs-two-entries
[12:01:16] [PASSED] clr-one-set-other
[12:01:16] [PASSED] set-field
[12:01:16] [PASSED] conflict-duplicate
[12:01:16] [PASSED] conflict-not-disjoint
[12:01:16] [PASSED] conflict-reg-type
[12:01:16] ============== [PASSED] xe_rtp_process_tests ===============
stty: 'standard input': Inappropriate ioctl for device
[12:01:16] ===================== [PASSED] xe_rtp ======================
[12:01:16] ==================== xe_wa (1 subtest) =====================
[12:01:16] ======================== xe_wa_gt  =========================
[12:01:16] [PASSED] TIGERLAKE (B0)
[12:01:16] [PASSED] DG1 (A0)
[12:01:16] [PASSED] DG1 (B0)
[12:01:16] [PASSED] ALDERLAKE_S (A0)
[12:01:16] [PASSED] ALDERLAKE_S (B0)
[12:01:16] [PASSED] ALDERLAKE_S (C0)
[12:01:16] [PASSED] ALDERLAKE_S (D0)
[12:01:16] [PASSED] ALDERLAKE_P (A0)
[12:01:16] [PASSED] ALDERLAKE_P (B0)
[12:01:16] [PASSED] ALDERLAKE_P (C0)
[12:01:16] [PASSED] ALDERLAKE_S_RPLS (D0)
[12:01:16] [PASSED] ALDERLAKE_P_RPLU (E0)
[12:01:16] [PASSED] DG2_G10 (C0)
[12:01:16] [PASSED] DG2_G11 (B1)
[12:01:16] [PASSED] DG2_G12 (A1)
[12:01:16] [PASSED] METEORLAKE (g:A0, m:A0)
[12:01:16] [PASSED] METEORLAKE (g:A0, m:A0)
[12:01:16] [PASSED] METEORLAKE (g:A0, m:A0)
[12:01:16] [PASSED] LUNARLAKE (g:A0, m:A0)
[12:01:16] [PASSED] LUNARLAKE (g:B0, m:A0)
[12:01:16] ==================== [PASSED] xe_wa_gt =====================
[12:01:16] ====================== [PASSED] xe_wa ======================
[12:01:16] ============================================================
[12:01:16] Testing complete. Ran 110 tests: passed: 95, skipped: 15
[12:01:16] Elapsed time: 29.745s total, 4.258s configuring, 25.216s building, 0.217s running

+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/tests/.kunitconfig [12:01:16] Configuring KUnit Kernel ...
Regenerating .config ...
Populating config with:

$ make ARCH=um O=.kunit olddefconfig
[12:01:18] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make ARCH=um O=.kunit --jobs=48
../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)
      |      ^~~~~~~~~~~~~~~~~

[12:01:40] Starting KUnit Kernel (1/1)...
[12:01:40] ============================================================ Running tests with:

$ .kunit/linux kunit.enable=1 mem=1G console=tty kunit_shutdown=halt
[12:01:40] ============ drm_test_pick_cmdline (2 subtests) ============
[12:01:40] [PASSED] drm_test_pick_cmdline_res_1920_1080_60
[12:01:40] =============== drm_test_pick_cmdline_named  ===============
[12:01:40] [PASSED] NTSC
[12:01:40] [PASSED] NTSC-J
[12:01:40] [PASSED] PAL
[12:01:40] [PASSED] PAL-M
[12:01:40] =========== [PASSED] drm_test_pick_cmdline_named ===========
[12:01:40] ============== [PASSED] drm_test_pick_cmdline ==============
[12:01:40] ================== drm_buddy (7 subtests) ==================
[12:01:40] [PASSED] drm_test_buddy_alloc_limit
[12:01:40] [PASSED] drm_test_buddy_alloc_optimistic
[12:01:40] [PASSED] drm_test_buddy_alloc_pessimistic
[12:01:40] [PASSED] drm_test_buddy_alloc_pathological
[12:01:40] [PASSED] drm_test_buddy_alloc_contiguous
[12:01:40] [PASSED] drm_test_buddy_alloc_clear
[12:01:40] [PASSED] drm_test_buddy_alloc_range_bias
[12:01:40] ==================== [PASSED] drm_buddy ====================
[12:01:40] ============= drm_cmdline_parser (40 subtests) =============
[12:01:40] [PASSED] drm_test_cmdline_force_d_only
[12:01:40] [PASSED] drm_test_cmdline_force_D_only_dvi
[12:01:40] [PASSED] drm_test_cmdline_force_D_only_hdmi
[12:01:40] [PASSED] drm_test_cmdline_force_D_only_not_digital
[12:01:40] [PASSED] drm_test_cmdline_force_e_only
[12:01:40] [PASSED] drm_test_cmdline_res
[12:01:40] [PASSED] drm_test_cmdline_res_vesa
[12:01:40] [PASSED] drm_test_cmdline_res_vesa_rblank
[12:01:40] [PASSED] drm_test_cmdline_res_rblank
[12:01:40] [PASSED] drm_test_cmdline_res_bpp
[12:01:40] [PASSED] drm_test_cmdline_res_refresh
[12:01:40] [PASSED] drm_test_cmdline_res_bpp_refresh
[12:01:40] [PASSED] drm_test_cmdline_res_bpp_refresh_interlaced
[12:01:40] [PASSED] drm_test_cmdline_res_bpp_refresh_margins
[12:01:40] [PASSED] drm_test_cmdline_res_bpp_refresh_force_off
[12:01:40] [PASSED] drm_test_cmdline_res_bpp_refresh_force_on
[12:01:40] [PASSED] drm_test_cmdline_res_bpp_refresh_force_on_analog
[12:01:40] [PASSED] drm_test_cmdline_res_bpp_refresh_force_on_digital
[12:01:40] [PASSED] drm_test_cmdline_res_bpp_refresh_interlaced_margins_force_on
[12:01:40] [PASSED] drm_test_cmdline_res_margins_force_on
[12:01:40] [PASSED] drm_test_cmdline_res_vesa_margins
[12:01:40] [PASSED] drm_test_cmdline_name
[12:01:40] [PASSED] drm_test_cmdline_name_bpp
[12:01:40] [PASSED] drm_test_cmdline_name_option
[12:01:40] [PASSED] drm_test_cmdline_name_bpp_option
[12:01:40] [PASSED] drm_test_cmdline_rotate_0
[12:01:40] [PASSED] drm_test_cmdline_rotate_90
[12:01:40] [PASSED] drm_test_cmdline_rotate_180
[12:01:40] [PASSED] drm_test_cmdline_rotate_270
[12:01:40] [PASSED] drm_test_cmdline_hmirror
[12:01:40] [PASSED] drm_test_cmdline_vmirror
[12:01:40] [PASSED] drm_test_cmdline_margin_options
[12:01:40] [PASSED] drm_test_cmdline_multiple_options
[12:01:40] [PASSED] drm_test_cmdline_bpp_extra_and_option
[12:01:40] [PASSED] drm_test_cmdline_extra_and_option
[12:01:40] [PASSED] drm_test_cmdline_freestanding_options
[12:01:40] [PASSED] drm_test_cmdline_freestanding_force_e_and_options
[12:01:40] [PASSED] drm_test_cmdline_panel_orientation
[12:01:40] ================ drm_test_cmdline_invalid  =================
[12:01:40] [PASSED] margin_only
[12:01:40] [PASSED] interlace_only
[12:01:40] [PASSED] res_missing_x
[12:01:40] [PASSED] res_missing_y
[12:01:40] [PASSED] res_bad_y
[12:01:40] [PASSED] res_missing_y_bpp
[12:01:40] [PASSED] res_bad_bpp
[12:01:40] [PASSED] res_bad_refresh
[12:01:40] [PASSED] res_bpp_refresh_force_on_off
[12:01:40] [PASSED] res_invalid_mode
[12:01:40] [PASSED] res_bpp_wrong_place_mode
[12:01:40] [PASSED] name_bpp_refresh
[12:01:40] [PASSED] name_refresh
[12:01:40] [PASSED] name_refresh_wrong_mode
[12:01:40] [PASSED] name_refresh_invalid_mode
[12:01:40] [PASSED] rotate_multiple
[12:01:40] [PASSED] rotate_invalid_val
[12:01:40] [PASSED] rotate_truncated
[12:01:40] [PASSED] invalid_option
[12:01:40] [PASSED] invalid_tv_option
[12:01:40] [PASSED] truncated_tv_option
[12:01:40] ============ [PASSED] drm_test_cmdline_invalid =============
[12:01:40] =============== drm_test_cmdline_tv_options  ===============
[12:01:40] [PASSED] NTSC
[12:01:40] [PASSED] NTSC_443
[12:01:40] [PASSED] NTSC_J
[12:01:40] [PASSED] PAL
[12:01:40] [PASSED] PAL_M
[12:01:40] [PASSED] PAL_N
[12:01:40] [PASSED] SECAM
[12:01:40] =========== [PASSED] drm_test_cmdline_tv_options ===========
[12:01:40] =============== [PASSED] drm_cmdline_parser ================
[12:01:40] ========== drmm_connector_hdmi_init (19 subtests) ==========
[12:01:40] [PASSED] drm_test_connector_hdmi_init_valid
[12:01:40] [PASSED] drm_test_connector_hdmi_init_bpc_8
[12:01:40] [PASSED] drm_test_connector_hdmi_init_bpc_10
[12:01:40] [PASSED] drm_test_connector_hdmi_init_bpc_12
[12:01:40] [PASSED] drm_test_connector_hdmi_init_bpc_invalid
[12:01:40] [PASSED] drm_test_connector_hdmi_init_bpc_null
[12:01:40] [PASSED] drm_test_connector_hdmi_init_formats_empty
[12:01:40] [PASSED] drm_test_connector_hdmi_init_formats_no_rgb
[12:01:40] [PASSED] drm_test_connector_hdmi_init_null_ddc
[12:01:40] [PASSED] drm_test_connector_hdmi_init_null_product
[12:01:40] [PASSED] drm_test_connector_hdmi_init_null_vendor
[12:01:40] [PASSED] drm_test_connector_hdmi_init_product_length_exact
[12:01:40] [PASSED] drm_test_connector_hdmi_init_product_length_too_long
[12:01:40] [PASSED] drm_test_connector_hdmi_init_product_valid
[12:01:40] [PASSED] drm_test_connector_hdmi_init_vendor_length_exact
[12:01:40] [PASSED] drm_test_connector_hdmi_init_vendor_length_too_long
[12:01:40] [PASSED] drm_test_connector_hdmi_init_vendor_valid
[12:01:40] ========= drm_test_connector_hdmi_init_type_valid  =========
[12:01:40] [PASSED] HDMI-A
[12:01:40] [PASSED] HDMI-B
[12:01:40] ===== [PASSED] drm_test_connector_hdmi_init_type_valid =====
[12:01:40] ======== drm_test_connector_hdmi_init_type_invalid  ========
[12:01:40] [PASSED] Unknown
[12:01:40] [PASSED] VGA
[12:01:40] [PASSED] DVI-I
[12:01:40] [PASSED] DVI-D
[12:01:40] [PASSED] DVI-A
[12:01:40] [PASSED] Composite
[12:01:40] [PASSED] SVIDEO
[12:01:40] [PASSED] LVDS
[12:01:40] [PASSED] Component
[12:01:40] [PASSED] DIN
[12:01:40] [PASSED] DP
[12:01:40] [PASSED] TV
[12:01:40] [PASSED] eDP
[12:01:40] [PASSED] Virtual
[12:01:40] [PASSED] DSI
[12:01:40] [PASSED] DPI
[12:01:40] [PASSED] Writeback
[12:01:40] [PASSED] SPI
[12:01:40] [PASSED] USB
[12:01:40] ==== [PASSED] drm_test_connector_hdmi_init_type_invalid ====
[12:01:40] ============ [PASSED] drmm_connector_hdmi_init =============
[12:01:40] ============= drmm_connector_init (3 subtests) =============
[12:01:40] [PASSED] drm_test_drmm_connector_init
[12:01:40] [PASSED] drm_test_drmm_connector_init_null_ddc
[12:01:40] ========= drm_test_drmm_connector_init_type_valid  =========
[12:01:40] [PASSED] Unknown
[12:01:40] [PASSED] VGA
[12:01:40] [PASSED] DVI-I
[12:01:40] [PASSED] DVI-D
[12:01:40] [PASSED] DVI-A
[12:01:40] [PASSED] Composite
[12:01:40] [PASSED] SVIDEO
[12:01:40] [PASSED] LVDS
[12:01:40] [PASSED] Component
[12:01:40] [PASSED] DIN
[12:01:40] [PASSED] DP
[12:01:40] [PASSED] HDMI-A
[12:01:40] [PASSED] HDMI-B
[12:01:40] [PASSED] TV
[12:01:40] [PASSED] eDP
[12:01:40] [PASSED] Virtual
[12:01:40] [PASSED] DSI
[12:01:40] [PASSED] DPI
[12:01:40] [PASSED] Writeback
[12:01:40] [PASSED] SPI
[12:01:40] [PASSED] USB
[12:01:40] ===== [PASSED] drm_test_drmm_connector_init_type_valid =====
[12:01:40] =============== [PASSED] drmm_connector_init ===============
[12:01:40] = drm_connector_attach_broadcast_rgb_property (2 subtests) =
[12:01:40] [PASSED] drm_test_drm_connector_attach_broadcast_rgb_property
[12:01:40] [PASSED] drm_test_drm_connector_attach_broadcast_rgb_property_hdmi_connector
[12:01:40] === [PASSED] drm_connector_attach_broadcast_rgb_property ===
[12:01:40] ========== drm_get_tv_mode_from_name (2 subtests) ==========
[12:01:40] ========== drm_test_get_tv_mode_from_name_valid  ===========
[12:01:40] [PASSED] NTSC
[12:01:40] [PASSED] NTSC-443
[12:01:40] [PASSED] NTSC-J
[12:01:40] [PASSED] PAL
[12:01:40] [PASSED] PAL-M
[12:01:40] [PASSED] PAL-N
[12:01:40] [PASSED] SECAM
[12:01:40] ====== [PASSED] drm_test_get_tv_mode_from_name_valid =======
[12:01:40] [PASSED] drm_test_get_tv_mode_from_name_truncated
[12:01:40] ============ [PASSED] drm_get_tv_mode_from_name ============
[12:01:40] = drm_test_connector_hdmi_compute_mode_clock (12 subtests) =
[12:01:40] [PASSED] drm_test_drm_hdmi_compute_mode_clock_rgb
[12:01:40] [PASSED] drm_test_drm_hdmi_compute_mode_clock_rgb_10bpc
[12:01:40] [PASSED] drm_test_drm_hdmi_compute_mode_clock_rgb_10bpc_vic_1
[12:01:40] [PASSED] drm_test_drm_hdmi_compute_mode_clock_rgb_12bpc
[12:01:40] [PASSED] drm_test_drm_hdmi_compute_mode_clock_rgb_12bpc_vic_1
[12:01:40] [PASSED] drm_test_drm_hdmi_compute_mode_clock_rgb_double
[12:01:40] = drm_test_connector_hdmi_compute_mode_clock_yuv420_valid  =
[12:01:40] [PASSED] VIC 96
[12:01:40] [PASSED] VIC 97
[12:01:40] [PASSED] VIC 101
[12:01:40] [PASSED] VIC 102
[12:01:40] [PASSED] VIC 106
[12:01:40] [PASSED] VIC 107
[12:01:40] === [PASSED] drm_test_connector_hdmi_compute_mode_clock_yuv420_valid ===
[12:01:40] [PASSED] drm_test_connector_hdmi_compute_mode_clock_yuv420_10_bpc
[12:01:40] [PASSED] drm_test_connector_hdmi_compute_mode_clock_yuv420_12_bpc
[12:01:40] [PASSED] drm_test_connector_hdmi_compute_mode_clock_yuv422_8_bpc
[12:01:40] [PASSED] drm_test_connector_hdmi_compute_mode_clock_yuv422_10_bpc
[12:01:40] [PASSED] drm_test_connector_hdmi_compute_mode_clock_yuv422_12_bpc
[12:01:40] === [PASSED] drm_test_connector_hdmi_compute_mode_clock ====
[12:01:40] == drm_hdmi_connector_get_broadcast_rgb_name (2 subtests) ==
[12:01:40] === drm_test_drm_hdmi_connector_get_broadcast_rgb_name  ====
[12:01:40] [PASSED] Automatic
[12:01:40] [PASSED] Full
[12:01:40] [PASSED] Limited 16:235
[12:01:40] === [PASSED] drm_test_drm_hdmi_connector_get_broadcast_rgb_name ===
[12:01:40] [PASSED] drm_test_drm_hdmi_connector_get_broadcast_rgb_name_invalid
[12:01:40] ==== [PASSED] drm_hdmi_connector_get_broadcast_rgb_name ====
[12:01:40] == drm_hdmi_connector_get_output_format_name (2 subtests) ==
[12:01:40] === drm_test_drm_hdmi_connector_get_output_format_name  ====
[12:01:40] [PASSED] RGB
[12:01:40] [PASSED] YUV 4:2:0
[12:01:40] [PASSED] YUV 4:2:2
[12:01:40] [PASSED] YUV 4:4:4
[12:01:40] === [PASSED] drm_test_drm_hdmi_connector_get_output_format_name ===
[12:01:40] [PASSED] drm_test_drm_hdmi_connector_get_output_format_name_invalid
[12:01:40] ==== [PASSED] drm_hdmi_connector_get_output_format_name ====
[12:01:40] ============= drm_damage_helper (21 subtests) ==============
[12:01:40] [PASSED] drm_test_damage_iter_no_damage
[12:01:40] [PASSED] drm_test_damage_iter_no_damage_fractional_src
[12:01:40] [PASSED] drm_test_damage_iter_no_damage_src_moved
[12:01:40] [PASSED] drm_test_damage_iter_no_damage_fractional_src_moved
[12:01:40] [PASSED] drm_test_damage_iter_no_damage_not_visible
[12:01:40] [PASSED] drm_test_damage_iter_no_damage_no_crtc
[12:01:40] [PASSED] drm_test_damage_iter_no_damage_no_fb
[12:01:40] [PASSED] drm_test_damage_iter_simple_damage
[12:01:40] [PASSED] drm_test_damage_iter_single_damage
[12:01:40] [PASSED] drm_test_damage_iter_single_damage_intersect_src
[12:01:40] [PASSED] drm_test_damage_iter_single_damage_outside_src
[12:01:40] [PASSED] drm_test_damage_iter_single_damage_fractional_src
[12:01:40] [PASSED] drm_test_damage_iter_single_damage_intersect_fractional_src
[12:01:40] [PASSED] drm_test_damage_iter_single_damage_outside_fractional_src
[12:01:40] [PASSED] drm_test_damage_iter_single_damage_src_moved
[12:01:40] [PASSED] drm_test_damage_iter_single_damage_fractional_src_moved
[12:01:40] [PASSED] drm_test_damage_iter_damage
[12:01:40] [PASSED] drm_test_damage_iter_damage_one_intersect
[12:01:40] [PASSED] drm_test_damage_iter_damage_one_outside
[12:01:40] [PASSED] drm_test_damage_iter_damage_src_moved
[12:01:40] [PASSED] drm_test_damage_iter_damage_not_visible
[12:01:40] ================ [PASSED] drm_damage_helper ================
[12:01:40] ============== drm_dp_mst_helper (3 subtests) ==============
[12:01:40] ============== drm_test_dp_mst_calc_pbn_mode  ==============
[12:01:40] [PASSED] Clock 154000 BPP 30 DSC disabled
[12:01:40] [PASSED] Clock 234000 BPP 30 DSC disabled
[12:01:40] [PASSED] Clock 297000 BPP 24 DSC disabled
[12:01:40] [PASSED] Clock 332880 BPP 24 DSC enabled
[12:01:40] [PASSED] Clock 324540 BPP 24 DSC enabled
[12:01:40] ========== [PASSED] drm_test_dp_mst_calc_pbn_mode ==========
[12:01:40] ============== drm_test_dp_mst_calc_pbn_div  ===============
[12:01:40] [PASSED] Link rate 2000000 lane count 4
[12:01:40] [PASSED] Link rate 2000000 lane count 2
[12:01:40] [PASSED] Link rate 2000000 lane count 1
[12:01:40] [PASSED] Link rate 1350000 lane count 4
[12:01:40] [PASSED] Link rate 1350000 lane count 2
[12:01:40] [PASSED] Link rate 1350000 lane count 1
[12:01:40] [PASSED] Link rate 1000000 lane count 4
[12:01:40] [PASSED] Link rate 1000000 lane count 2
[12:01:40] [PASSED] Link rate 1000000 lane count 1
[12:01:40] [PASSED] Link rate 810000 lane count 4
[12:01:40] [PASSED] Link rate 810000 lane count 2
[12:01:40] [PASSED] Link rate 810000 lane count 1
[12:01:40] [PASSED] Link rate 540000 lane count 4
[12:01:40] [PASSED] Link rate 540000 lane count 2
[12:01:40] [PASSED] Link rate 540000 lane count 1
[12:01:40] [PASSED] Link rate 270000 lane count 4
[12:01:40] [PASSED] Link rate 270000 lane count 2
[12:01:40] [PASSED] Link rate 270000 lane count 1
[12:01:40] [PASSED] Link rate 162000 lane count 4
[12:01:40] [PASSED] Link rate 162000 lane count 2
[12:01:40] [PASSED] Link rate 162000 lane count 1
[12:01:40] ========== [PASSED] drm_test_dp_mst_calc_pbn_div ===========
[12:01:40] ========= drm_test_dp_mst_sideband_msg_req_decode  =========
[12:01:40] [PASSED] DP_ENUM_PATH_RESOURCES with port number
[12:01:40] [PASSED] DP_POWER_UP_PHY with port number
[12:01:40] [PASSED] DP_POWER_DOWN_PHY with port number
[12:01:40] [PASSED] DP_ALLOCATE_PAYLOAD with SDP stream sinks
[12:01:40] [PASSED] DP_ALLOCATE_PAYLOAD with port number
[12:01:40] [PASSED] DP_ALLOCATE_PAYLOAD with VCPI
[12:01:40] [PASSED] DP_ALLOCATE_PAYLOAD with PBN
[12:01:40] [PASSED] DP_QUERY_PAYLOAD with port number
[12:01:40] [PASSED] DP_QUERY_PAYLOAD with VCPI
[12:01:40] [PASSED] DP_REMOTE_DPCD_READ with port number
[12:01:40] [PASSED] DP_REMOTE_DPCD_READ with DPCD address
[12:01:40] [PASSED] DP_REMOTE_DPCD_READ with max number of bytes
[12:01:40] [PASSED] DP_REMOTE_DPCD_WRITE with port number
[12:01:40] [PASSED] DP_REMOTE_DPCD_WRITE with DPCD address
[12:01:40] [PASSED] DP_REMOTE_DPCD_WRITE with data array
[12:01:40] [PASSED] DP_REMOTE_I2C_READ with port number
[12:01:40] [PASSED] DP_REMOTE_I2C_READ with I2C device ID
[12:01:40] [PASSED] DP_REMOTE_I2C_READ with transactions array
[12:01:40] [PASSED] DP_REMOTE_I2C_WRITE with port number
[12:01:40] [PASSED] DP_REMOTE_I2C_WRITE with I2C device ID
[12:01:40] [PASSED] DP_REMOTE_I2C_WRITE with data array
[12:01:40] [PASSED] DP_QUERY_STREAM_ENC_STATUS with stream ID
[12:01:40] [PASSED] DP_QUERY_STREAM_ENC_STATUS with client ID
[12:01:40] [PASSED] DP_QUERY_STREAM_ENC_STATUS with stream event
[12:01:40] [PASSED] DP_QUERY_STREAM_ENC_STATUS with valid stream event
[12:01:40] [PASSED] DP_QUERY_STREAM_ENC_STATUS with stream behavior
[12:01:40] [PASSED] DP_QUERY_STREAM_ENC_STATUS with a valid stream behavior
[12:01:40] ===== [PASSED] drm_test_dp_mst_sideband_msg_req_decode =====
[12:01:40] ================ [PASSED] drm_dp_mst_helper ================
[12:01:40] ================== drm_exec (7 subtests) ===================
[12:01:40] [PASSED] sanitycheck
[12:01:40] [PASSED] test_lock
[12:01:40] [PASSED] test_lock_unlock
[12:01:40] [PASSED] test_duplicates
[12:01:40] [PASSED] test_prepare
[12:01:40] [PASSED] test_prepare_array
[12:01:40] [PASSED] test_multiple_loops
[12:01:40] ==================== [PASSED] drm_exec =====================
[12:01:40] =========== drm_format_helper_test (17 subtests) ===========
[12:01:40] ============== drm_test_fb_xrgb8888_to_gray8  ==============
[12:01:40] [PASSED] single_pixel_source_buffer
[12:01:40] [PASSED] single_pixel_clip_rectangle
[12:01:40] [PASSED] well_known_colors
[12:01:40] [PASSED] destination_pitch
[12:01:40] ========== [PASSED] drm_test_fb_xrgb8888_to_gray8 ==========
[12:01:40] ============= drm_test_fb_xrgb8888_to_rgb332  ==============
[12:01:40] [PASSED] single_pixel_source_buffer
[12:01:40] [PASSED] single_pixel_clip_rectangle
[12:01:40] [PASSED] well_known_colors
[12:01:40] [PASSED] destination_pitch
[12:01:40] ========= [PASSED] drm_test_fb_xrgb8888_to_rgb332 ==========
[12:01:40] ============= drm_test_fb_xrgb8888_to_rgb565  ==============
[12:01:40] [PASSED] single_pixel_source_buffer
[12:01:40] [PASSED] single_pixel_clip_rectangle
[12:01:40] [PASSED] well_known_colors
[12:01:40] [PASSED] destination_pitch
[12:01:40] ========= [PASSED] drm_test_fb_xrgb8888_to_rgb565 ==========
[12:01:40] ============ drm_test_fb_xrgb8888_to_xrgb1555  =============
[12:01:40] [PASSED] single_pixel_source_buffer
[12:01:40] [PASSED] single_pixel_clip_rectangle
[12:01:40] [PASSED] well_known_colors
[12:01:40] [PASSED] destination_pitch
[12:01:40] ======== [PASSED] drm_test_fb_xrgb8888_to_xrgb1555 =========
[12:01:40] ============ drm_test_fb_xrgb8888_to_argb1555  =============
[12:01:40] [PASSED] single_pixel_source_buffer
[12:01:40] [PASSED] single_pixel_clip_rectangle
[12:01:40] [PASSED] well_known_colors
[12:01:40] [PASSED] destination_pitch
[12:01:40] ======== [PASSED] drm_test_fb_xrgb8888_to_argb1555 =========
[12:01:40] ============ drm_test_fb_xrgb8888_to_rgba5551  =============
[12:01:40] [PASSED] single_pixel_source_buffer
[12:01:40] [PASSED] single_pixel_clip_rectangle
[12:01:40] [PASSED] well_known_colors
[12:01:40] [PASSED] destination_pitch
[12:01:40] ======== [PASSED] drm_test_fb_xrgb8888_to_rgba5551 =========
[12:01:40] ============= drm_test_fb_xrgb8888_to_rgb888  ==============
[12:01:40] [PASSED] single_pixel_source_buffer
[12:01:40] [PASSED] single_pixel_clip_rectangle
[12:01:40] [PASSED] well_known_colors
[12:01:40] [PASSED] destination_pitch
[12:01:40] ========= [PASSED] drm_test_fb_xrgb8888_to_rgb888 ==========
[12:01:40] ============ drm_test_fb_xrgb8888_to_argb8888  =============
[12:01:40] [PASSED] single_pixel_source_buffer
[12:01:40] [PASSED] single_pixel_clip_rectangle
[12:01:40] [PASSED] well_known_colors
[12:01:40] [PASSED] destination_pitch
[12:01:40] ======== [PASSED] drm_test_fb_xrgb8888_to_argb8888 =========
[12:01:40] =========== drm_test_fb_xrgb8888_to_xrgb2101010  ===========
[12:01:40] [PASSED] single_pixel_source_buffer
[12:01:40] [PASSED] single_pixel_clip_rectangle
[12:01:40] [PASSED] well_known_colors
[12:01:40] [PASSED] destination_pitch
[12:01:40] ======= [PASSED] drm_test_fb_xrgb8888_to_xrgb2101010 =======
[12:01:40] =========== drm_test_fb_xrgb8888_to_argb2101010  ===========
[12:01:40] [PASSED] single_pixel_source_buffer
[12:01:40] [PASSED] single_pixel_clip_rectangle
[12:01:40] [PASSED] well_known_colors
[12:01:40] [PASSED] destination_pitch
[12:01:40] ======= [PASSED] drm_test_fb_xrgb8888_to_argb2101010 =======
[12:01:40] ============== drm_test_fb_xrgb8888_to_mono  ===============
[12:01:40] [PASSED] single_pixel_source_buffer
[12:01:40] [PASSED] single_pixel_clip_rectangle
[12:01:40] [PASSED] well_known_colors
[12:01:40] [PASSED] destination_pitch
[12:01:40] ========== [PASSED] drm_test_fb_xrgb8888_to_mono ===========
[12:01:40] ==================== drm_test_fb_swab  =====================
[12:01:40] [PASSED] single_pixel_source_buffer
[12:01:40] [PASSED] single_pixel_clip_rectangle
[12:01:40] [PASSED] well_known_colors
[12:01:40] [PASSED] destination_pitch
[12:01:40] ================ [PASSED] drm_test_fb_swab =================
[12:01:40] ============ drm_test_fb_xrgb8888_to_xbgr8888  =============
[12:01:40] [PASSED] single_pixel_source_buffer
[12:01:40] [PASSED] single_pixel_clip_rectangle
[12:01:40] [PASSED] well_known_colors
[12:01:40] [PASSED] destination_pitch
[12:01:40] ======== [PASSED] drm_test_fb_xrgb8888_to_xbgr8888 =========
[12:01:40] ============ drm_test_fb_xrgb8888_to_abgr8888  =============
[12:01:40] [PASSED] single_pixel_source_buffer
[12:01:40] [PASSED] single_pixel_clip_rectangle
[12:01:40] [PASSED] well_known_colors
[12:01:40] [PASSED] destination_pitch
[12:01:40] ======== [PASSED] drm_test_fb_xrgb8888_to_abgr8888 =========
[12:01:40] ================= drm_test_fb_clip_offset  =================
[12:01:40] [PASSED] pass through
[12:01:40] [PASSED] horizontal offset
[12:01:40] [PASSED] vertical offset
[12:01:40] [PASSED] horizontal and vertical offset
[12:01:40] [PASSED] horizontal offset (custom pitch)
[12:01:40] [PASSED] vertical offset (custom pitch)
[12:01:40] [PASSED] horizontal and vertical offset (custom pitch)
[12:01:40] ============= [PASSED] drm_test_fb_clip_offset =============
[12:01:40] ============== drm_test_fb_build_fourcc_list  ==============
[12:01:40] [PASSED] no native formats
[12:01:40] [PASSED] XRGB8888 as native format
[12:01:40] [PASSED] remove duplicates
[12:01:40] [PASSED] convert alpha formats
[12:01:40] [PASSED] random formats
[12:01:40] ========== [PASSED] drm_test_fb_build_fourcc_list ==========
[12:01:40] =================== drm_test_fb_memcpy  ====================
[12:01:40] [PASSED] single_pixel_source_buffer: XR24 little-endian (0x34325258)
[12:01:40] [PASSED] single_pixel_source_buffer: XRA8 little-endian (0x38415258)
[12:01:40] [PASSED] single_pixel_source_buffer: YU24 little-endian (0x34325559)
[12:01:40] [PASSED] single_pixel_clip_rectangle: XB24 little-endian (0x34324258)
[12:01:40] [PASSED] single_pixel_clip_rectangle: XRA8 little-endian (0x38415258)
[12:01:40] [PASSED] single_pixel_clip_rectangle: YU24 little-endian (0x34325559)
[12:01:40] [PASSED] well_known_colors: XB24 little-endian (0x34324258)
[12:01:40] [PASSED] well_known_colors: XRA8 little-endian (0x38415258)
[12:01:40] [PASSED] well_known_colors: YU24 little-endian (0x34325559)
[12:01:40] [PASSED] destination_pitch: XB24 little-endian (0x34324258)
[12:01:40] [PASSED] destination_pitch: XRA8 little-endian (0x38415258)
[12:01:40] [PASSED] destination_pitch: YU24 little-endian (0x34325559)
[12:01:40] =============== [PASSED] drm_test_fb_memcpy ================
[12:01:40] ============= [PASSED] drm_format_helper_test ==============
[12:01:40] ================= drm_format (18 subtests) =================
[12:01:40] [PASSED] drm_test_format_block_width_invalid
[12:01:40] [PASSED] drm_test_format_block_width_one_plane
[12:01:40] [PASSED] drm_test_format_block_width_two_plane
[12:01:40] [PASSED] drm_test_format_block_width_three_plane
[12:01:40] [PASSED] drm_test_format_block_width_tiled
[12:01:40] [PASSED] drm_test_format_block_height_invalid
[12:01:40] [PASSED] drm_test_format_block_height_one_plane
[12:01:40] [PASSED] drm_test_format_block_height_two_plane
[12:01:40] [PASSED] drm_test_format_block_height_three_plane
[12:01:40] [PASSED] drm_test_format_block_height_tiled
[12:01:40] [PASSED] drm_test_format_min_pitch_invalid
[12:01:40] [PASSED] drm_test_format_min_pitch_one_plane_8bpp
[12:01:40] [PASSED] drm_test_format_min_pitch_one_plane_16bpp
[12:01:40] [PASSED] drm_test_format_min_pitch_one_plane_24bpp
[12:01:40] [PASSED] drm_test_format_min_pitch_one_plane_32bpp
[12:01:40] [PASSED] drm_test_format_min_pitch_two_plane
[12:01:40] [PASSED] drm_test_format_min_pitch_three_plane_8bpp
[12:01:40] [PASSED] drm_test_format_min_pitch_tiled
[12:01:40] =================== [PASSED] drm_format ====================
[12:01:40] =============== drm_framebuffer (1 subtest) ================
[12:01:40] =============== drm_test_framebuffer_create  ===============
[12:01:40] [PASSED] ABGR8888 normal sizes
[12:01:40] [PASSED] ABGR8888 max sizes
[12:01:40] [PASSED] ABGR8888 pitch greater than min required
[12:01:40] [PASSED] ABGR8888 pitch less than min required
[12:01:40] [PASSED] ABGR8888 Invalid width
[12:01:40] [PASSED] ABGR8888 Invalid buffer handle
[12:01:40] [PASSED] No pixel format
[12:01:40] [PASSED] ABGR8888 Width 0
[12:01:40] [PASSED] ABGR8888 Height 0
[12:01:40] [PASSED] ABGR8888 Out of bound height * pitch combination
[12:01:40] [PASSED] ABGR8888 Large buffer offset
[12:01:40] [PASSED] ABGR8888 Set DRM_MODE_FB_MODIFIERS without modifiers
[12:01:40] [PASSED] ABGR8888 Valid buffer modifier
[12:01:40] [PASSED] ABGR8888 Invalid buffer modifier(DRM_FORMAT_MOD_SAMSUNG_64_32_TILE)
[12:01:40] [PASSED] ABGR8888 Extra pitches without DRM_MODE_FB_MODIFIERS
[12:01:40] [PASSED] ABGR8888 Extra pitches with DRM_MODE_FB_MODIFIERS
[12:01:40] [PASSED] NV12 Normal sizes
[12:01:40] [PASSED] NV12 Max sizes
[12:01:40] [PASSED] NV12 Invalid pitch
[12:01:40] [PASSED] NV12 Invalid modifier/missing DRM_MODE_FB_MODIFIERS flag
[12:01:40] [PASSED] NV12 different  modifier per-plane
[12:01:40] [PASSED] NV12 with DRM_FORMAT_MOD_SAMSUNG_64_32_TILE
[12:01:40] [PASSED] NV12 Valid modifiers without DRM_MODE_FB_MODIFIERS
[12:01:40] [PASSED] NV12 Modifier for inexistent plane
[12:01:40] [PASSED] NV12 Handle for inexistent plane
[12:01:40] [PASSED] NV12 Handle for inexistent plane without DRM_MODE_FB_MODIFIERS
[12:01:40] [PASSED] YVU420 DRM_MODE_FB_MODIFIERS set without modifier
[12:01:40] [PASSED] YVU420 Normal sizes
[12:01:40] [PASSED] YVU420 Max sizes
[12:01:40] [PASSED] YVU420 Invalid pitch
[12:01:40] [PASSED] YVU420 Different pitches
[12:01:40] [PASSED] YVU420 Different buffer offsets/pitches
[12:01:40] [PASSED] YVU420 Modifier set just for plane 0, without DRM_MODE_FB_MODIFIERS
[12:01:40] [PASSED] YVU420 Modifier set just for planes 0, 1, without DRM_MODE_FB_MODIFIERS
[12:01:40] [PASSED] YVU420 Modifier set just for plane 0, 1, with DRM_MODE_FB_MODIFIERS
[12:01:40] [PASSED] YVU420 Valid modifier
[12:01:40] [PASSED] YVU420 Different modifiers per plane
[12:01:40] [PASSED] YVU420 Modifier for inexistent plane
[12:01:40] [PASSED] X0L2 Normal sizes
[12:01:40] [PASSED] X0L2 Max sizes
[12:01:40] [PASSED] X0L2 Invalid pitch
[12:01:40] [PASSED] X0L2 Pitch greater than minimum required
[12:01:40] [PASSED] X0L2 Handle for inexistent plane
[12:01:40] [PASSED] X0L2 Offset for inexistent plane, without DRM_MODE_FB_MODIFIERS set
[12:01:40] [PASSED] X0L2 Modifier without DRM_MODE_FB_MODIFIERS set
[12:01:40] [PASSED] X0L2 Valid modifier
[12:01:40] [PASSED] X0L2 Modifier for inexistent plane
[12:01:40] =========== [PASSED] drm_test_framebuffer_create ===========
[12:01:40] ================= [PASSED] drm_framebuffer =================
[12:01:40] ================ drm_gem_shmem (8 subtests) ================
[12:01:40] [PASSED] drm_gem_shmem_test_obj_create
[12:01:40] [PASSED] drm_gem_shmem_test_obj_create_private
[12:01:40] [PASSED] drm_gem_shmem_test_pin_pages
[12:01:40] [PASSED] drm_gem_shmem_test_vmap
[12:01:40] [PASSED] drm_gem_shmem_test_get_pages_sgt
[12:01:40] [PASSED] drm_gem_shmem_test_get_sg_table
[12:01:40] [PASSED] drm_gem_shmem_test_madvise
[12:01:40] [PASSED] drm_gem_shmem_test_purge
[12:01:40] ================== [PASSED] drm_gem_shmem ==================
[12:01:40] === drm_atomic_helper_connector_hdmi_check (22 subtests) ===
[12:01:40] [PASSED] drm_test_check_broadcast_rgb_auto_cea_mode
[12:01:40] [PASSED] drm_test_check_broadcast_rgb_auto_cea_mode_vic_1
[12:01:40] [PASSED] drm_test_check_broadcast_rgb_full_cea_mode
[12:01:40] [PASSED] drm_test_check_broadcast_rgb_full_cea_mode_vic_1
[12:01:40] [PASSED] drm_test_check_broadcast_rgb_limited_cea_mode
[12:01:40] [PASSED] drm_test_check_broadcast_rgb_limited_cea_mode_vic_1
[12:01:40] [PASSED] drm_test_check_broadcast_rgb_crtc_mode_changed
[12:01:40] [PASSED] drm_test_check_broadcast_rgb_crtc_mode_not_changed
[12:01:40] [PASSED] drm_test_check_hdmi_funcs_reject_rate
[12:01:40] [PASSED] drm_test_check_max_tmds_rate_bpc_fallback
[12:01:40] [PASSED] drm_test_check_max_tmds_rate_format_fallback
[12:01:40] [PASSED] drm_test_check_output_bpc_crtc_mode_changed
[12:01:40] [PASSED] drm_test_check_output_bpc_crtc_mode_not_changed
[12:01:40] [PASSED] drm_test_check_output_bpc_dvi
[12:01:40] [PASSED] drm_test_check_output_bpc_format_vic_1
[12:01:40] [PASSED] drm_test_check_output_bpc_format_display_8bpc_only
[12:01:40] [PASSED] drm_test_check_output_bpc_format_display_rgb_only
[12:01:40] [PASSED] drm_test_check_output_bpc_format_driver_8bpc_only
[12:01:40] [PASSED] drm_test_check_output_bpc_format_driver_rgb_only
[12:01:40] [PASSED] drm_test_check_tmds_char_rate_rgb_8bpc
[12:01:40] [PASSED] drm_test_check_tmds_char_rate_rgb_10bpc
[12:01:40] [PASSED] drm_test_check_tmds_char_rate_rgb_12bpc
[12:01:40] ===== [PASSED] drm_atomic_helper_connector_hdmi_check ======
[12:01:40] === drm_atomic_helper_connector_hdmi_reset (6 subtests) ====
[12:01:40] [PASSED] drm_test_check_broadcast_rgb_value
[12:01:40] [PASSED] drm_test_check_bpc_8_value
[12:01:40] [PASSED] drm_test_check_bpc_10_value
[12:01:40] [PASSED] drm_test_check_bpc_12_value
[12:01:40] [PASSED] drm_test_check_format_value
[12:01:40] [PASSED] drm_test_check_tmds_char_value
[12:01:40] ===== [PASSED] drm_atomic_helper_connector_hdmi_reset ======
[12:01:40] ================= drm_managed (2 subtests) =================
[12:01:40] [PASSED] drm_test_managed_release_action
[12:01:40] [PASSED] drm_test_managed_run_action
[12:01:40] =================== [PASSED] drm_managed ===================
[12:01:40] =================== drm_mm (6 subtests) ====================
[12:01:40] [PASSED] drm_test_mm_init
[12:01:40] [PASSED] drm_test_mm_debug
[12:01:40] [PASSED] drm_test_mm_align32
[12:01:40] [PASSED] drm_test_mm_align64
[12:01:40] [PASSED] drm_test_mm_lowest
[12:01:40] [PASSED] drm_test_mm_highest
[12:01:40] ===================== [PASSED] drm_mm ======================
[12:01:40] ============= drm_modes_analog_tv (4 subtests) =============
[12:01:40] [PASSED] drm_test_modes_analog_tv_ntsc_480i
[12:01:40] [PASSED] drm_test_modes_analog_tv_ntsc_480i_inlined
[12:01:40] [PASSED] drm_test_modes_analog_tv_pal_576i
[12:01:40] [PASSED] drm_test_modes_analog_tv_pal_576i_inlined
[12:01:40] =============== [PASSED] drm_modes_analog_tv ===============
[12:01:40] ============== drm_plane_helper (2 subtests) ===============
[12:01:40] =============== drm_test_check_plane_state  ================
[12:01:40] [PASSED] clipping_simple
[12:01:40] [PASSED] clipping_rotate_reflect
[12:01:40] [PASSED] positioning_simple
[12:01:40] [PASSED] upscaling
[12:01:40] [PASSED] downscaling
[12:01:40] [PASSED] rounding1
[12:01:40] [PASSED] rounding2
[12:01:40] [PASSED] rounding3
[12:01:40] [PASSED] rounding4
[12:01:40] =========== [PASSED] drm_test_check_plane_state ============
[12:01:40] =========== drm_test_check_invalid_plane_state  ============
[12:01:40] [PASSED] positioning_invalid
[12:01:40] [PASSED] upscaling_invalid
[12:01:40] [PASSED] downscaling_invalid
[12:01:40] ======= [PASSED] drm_test_check_invalid_plane_state ========
[12:01:40] ================ [PASSED] drm_plane_helper =================
stty: 'standard input': Inappropriate ioctl for device
[12:01:40] ====== drm_connector_helper_tv_get_modes (1 subtest) =======
[12:01:40] ====== drm_test_connector_helper_tv_get_modes_check  =======
[12:01:40] [PASSED] None
[12:01:40] [PASSED] PAL
[12:01:40] [PASSED] NTSC
[12:01:40] [PASSED] Both, NTSC Default
[12:01:40] [PASSED] Both, PAL Default
[12:01:40] [PASSED] Both, NTSC Default, with PAL on command-line
[12:01:40] [PASSED] Both, PAL Default, with NTSC on command-line
[12:01:40] == [PASSED] drm_test_connector_helper_tv_get_modes_check ===
[12:01:40] ======== [PASSED] drm_connector_helper_tv_get_modes ========
[12:01:40] ================== drm_rect (9 subtests) ===================
[12:01:40] [PASSED] drm_test_rect_clip_scaled_div_by_zero
[12:01:40] [PASSED] drm_test_rect_clip_scaled_not_clipped
[12:01:40] [PASSED] drm_test_rect_clip_scaled_clipped
[12:01:40] [PASSED] drm_test_rect_clip_scaled_signed_vs_unsigned
[12:01:40] ================= drm_test_rect_intersect  =================
[12:01:40] [PASSED] top-left x bottom-right: 2x2+1+1 x 2x2+0+0
[12:01:40] [PASSED] top-right x bottom-left: 2x2+0+0 x 2x2+1-1
[12:01:40] [PASSED] bottom-left x top-right: 2x2+1-1 x 2x2+0+0
[12:01:40] [PASSED] bottom-right x top-left: 2x2+0+0 x 2x2+1+1
[12:01:40] [PASSED] right x left: 2x1+0+0 x 3x1+1+0
[12:01:40] [PASSED] left x right: 3x1+1+0 x 2x1+0+0
[12:01:40] [PASSED] up x bottom: 1x2+0+0 x 1x3+0-1
[12:01:40] [PASSED] bottom x up: 1x3+0-1 x 1x2+0+0
[12:01:40] [PASSED] touching corner: 1x1+0+0 x 2x2+1+1
[12:01:40] [PASSED] touching side: 1x1+0+0 x 1x1+1+0
[12:01:40] [PASSED] equal rects: 2x2+0+0 x 2x2+0+0
[12:01:40] [PASSED] inside another: 2x2+0+0 x 1x1+1+1
[12:01:40] [PASSED] far away: 1x1+0+0 x 1x1+3+6
[12:01:40] [PASSED] points intersecting: 0x0+5+10 x 0x0+5+10
[12:01:40] [PASSED] points not intersecting: 0x0+0+0 x 0x0+5+10
[12:01:40] ============= [PASSED] drm_test_rect_intersect =============
[12:01:40] ================ drm_test_rect_calc_hscale  ================
[12:01:40] [PASSED] normal use
[12:01:40] [PASSED] out of max range
[12:01:40] [PASSED] out of min range
[12:01:40] [PASSED] zero dst
[12:01:40] [PASSED] negative src
[12:01:40] [PASSED] negative dst
[12:01:40] ============ [PASSED] drm_test_rect_calc_hscale ============
[12:01:40] ================ drm_test_rect_calc_vscale  ================
[12:01:40] [PASSED] normal use
[12:01:40] [PASSED] out of max range
[12:01:40] [PASSED] out of min range
[12:01:40] [PASSED] zero dst
[12:01:40] [PASSED] negative src
[12:01:40] [PASSED] negative dst
[12:01:40] ============ [PASSED] drm_test_rect_calc_vscale ============
[12:01:40] ================== drm_test_rect_rotate  ===================
[12:01:40] [PASSED] reflect-x
[12:01:40] [PASSED] reflect-y
[12:01:40] [PASSED] rotate-0
[12:01:40] [PASSED] rotate-90
[12:01:40] [PASSED] rotate-180
[12:01:40] [PASSED] rotate-270
[12:01:40] ============== [PASSED] drm_test_rect_rotate ===============
[12:01:40] ================ drm_test_rect_rotate_inv  =================
[12:01:40] [PASSED] reflect-x
[12:01:40] [PASSED] reflect-y
[12:01:40] [PASSED] rotate-0
[12:01:40] [PASSED] rotate-90
[12:01:40] [PASSED] rotate-180
[12:01:40] [PASSED] rotate-270
[12:01:40] ============ [PASSED] drm_test_rect_rotate_inv =============
[12:01:40] ==================== [PASSED] drm_rect =====================
[12:01:40] ============================================================
[12:01:40] Testing complete. Ran 511 tests: passed: 511
[12:01:40] Elapsed time: 23.965s total, 1.700s configuring, 22.094s building, 0.155s running

+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/ttm/tests/.kunitconfig ERROR:root:In file included from ../include/linux/build_bug.h:5,

                 from ../include/linux/container_of.h:5,
                 from ../include/linux/list.h:5,
                 from ../include/drm/ttm/ttm_resource.h:29,
                 from ../drivers/gpu/drm/ttm/tests/ttm_resource_test.c:5:
../drivers/gpu/drm/ttm/tests/ttm_resource_test.c: In function ‘ttm_resource_fini_basic’:
../drivers/gpu/drm/ttm/tests/ttm_resource_test.c:201:37: error: passing argument 1 of ‘list_empty’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  201 |  KUNIT_ASSERT_TRUE(test, list_empty(&res->lru));
      |                                     ^~~~~~~~~
      |                                     |
      |                                     struct ttm_lru_item *

../include/linux/compiler.h:76:40: note: in definition of macro ‘likely’
76 | # define likely(x) __builtin_expect(!!(x), 1)
| ^
../include/kunit/test.h:668:2: note: in expansion of macro ‘KUNIT_UNARY_ASSERTION’

  668 |  KUNIT_UNARY_ASSERTION(test,            \
      |  ^~~~~~~~~~~~~~~~~~~~~
../include/kunit/test.h:1232:2: note: in expansion of macro ‘KUNIT_TRUE_MSG_ASSERTION’
 1232 |  KUNIT_TRUE_MSG_ASSERTION(test,            \
      |  ^~~~~~~~~~~~~~~~~~~~~~~~
../include/kunit/test.h:1229:2: note: in expansion of macro ‘KUNIT_ASSERT_TRUE_MSG’
 1229 |  KUNIT_ASSERT_TRUE_MSG(test, condition, NULL)
      |  ^~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/ttm/tests/ttm_resource_test.c:201:2: note: in expansion of macro ‘KUNIT_ASSERT_TRUE’
  201 |  KUNIT_ASSERT_TRUE(test, list_empty(&res->lru));
      |  ^~~~~~~~~~~~~~~~~

In file included from ../include/drm/ttm/ttm_resource.h:29,
from ../drivers/gpu/drm/ttm/tests/ttm_resource_test.c:5:
../include/linux/list.h:371:54: note: expected ‘const struct list_head *’ but argument is of type ‘struct ttm_lru_item *’
371 | static inline int list_empty(const struct list_head *head)

      |                              ~~~~~~~~~~~~~~~~~~~~~~~~^~~~
In file included from ../include/drm/drm_kunit_helpers.h:10,
                 from ../drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.h:13,
                 from ../drivers/gpu/drm/ttm/tests/ttm_bo_test.c:17:
../drivers/gpu/drm/ttm/tests/ttm_bo_test.c: In function ‘ttm_bo_unreserve_basic’:
../drivers/gpu/drm/ttm/tests/ttm_bo_test.c:268:17: error: passing argument 1 of ‘list_is_last’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  268 |    list_is_last(&res1->lru, &man->lru[bo->priority]), 1);
      |                 ^~~~~~~~~~
      |                 |
      |                 struct ttm_lru_item *

../include/kunit/test.h:707:15: note: in definition of macro ‘KUNIT_BASE_BINARY_ASSERTION’
707 | const typeof(left) __left = (left); \
| ^~~~
../include/kunit/test.h:1271:2: note: in expansion of macro ‘KUNIT_BINARY_INT_ASSERTION’

 1271 |  KUNIT_BINARY_INT_ASSERTION(test,           \
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~
../include/kunit/test.h:1268:2: note: in expansion of macro ‘KUNIT_ASSERT_EQ_MSG’
 1268 |  KUNIT_ASSERT_EQ_MSG(test, left, right, NULL)
      |  ^~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/ttm/tests/ttm_bo_test.c:267:2: note: in expansion of macro ‘KUNIT_ASSERT_EQ’
  267 |  KUNIT_ASSERT_EQ(test,
      |  ^~~~~~~~~~~~~~~
In file included from ../include/linux/mutex.h:15,
                 from ../include/linux/ww_mutex.h:20,
                 from ../include/linux/dma-resv.h:42,
                 from ../drivers/gpu/drm/ttm/tests/ttm_bo_test.c:5:
../include/linux/list.h:352:56: note: expected ‘const struct list_head *’ but argument is of type ‘struct ttm_lru_item *’
  352 | static inline int list_is_last(const struct list_head *list, const struct list_head *head)
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~
In file included from ../include/drm/drm_kunit_helpers.h:10,
                 from ../drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.h:13,
                 from ../drivers/gpu/drm/ttm/tests/ttm_bo_test.c:17:
../drivers/gpu/drm/ttm/tests/ttm_bo_test.c:268:17: error: passing argument 1 of ‘list_is_last’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  268 |    list_is_last(&res1->lru, &man->lru[bo->priority]), 1);
      |                 ^~~~~~~~~~
      |                 |
      |                 struct ttm_lru_item *

../include/kunit/test.h:707:31: note: in definition of macro ‘KUNIT_BASE_BINARY_ASSERTION’
707 | const typeof(left) __left = (left); \
| ^~~~
../include/kunit/test.h:1271:2: note: in expansion of macro ‘KUNIT_BINARY_INT_ASSERTION’

 1271 |  KUNIT_BINARY_INT_ASSERTION(test,           \
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~
../include/kunit/test.h:1268:2: note: in expansion of macro ‘KUNIT_ASSERT_EQ_MSG’
 1268 |  KUNIT_ASSERT_EQ_MSG(test, left, right, NULL)
      |  ^~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/ttm/tests/ttm_bo_test.c:267:2: note: in expansion of macro ‘KUNIT_ASSERT_EQ’
  267 |  KUNIT_ASSERT_EQ(test,
      |  ^~~~~~~~~~~~~~~
In file included from ../include/linux/mutex.h:15,
                 from ../include/linux/ww_mutex.h:20,
                 from ../include/linux/dma-resv.h:42,
                 from ../drivers/gpu/drm/ttm/tests/ttm_bo_test.c:5:
../include/linux/list.h:352:56: note: expected ‘const struct list_head *’ but argument is of type ‘struct ttm_lru_item *’
  352 | static inline int list_is_last(const struct list_head *list, const struct list_head *head)
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~
In file included from ../include/drm/drm_kunit_helpers.h:10,
                 from ../drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.h:13,
                 from ../drivers/gpu/drm/ttm/tests/ttm_bo_test.c:17:
../drivers/gpu/drm/ttm/tests/ttm_bo_test.c: In function ‘ttm_bo_unreserve_pinned’:
../drivers/gpu/drm/ttm/tests/ttm_bo_test.c:305:17: error: passing argument 1 of ‘list_is_last’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  305 |    list_is_last(&res2->lru, &priv->ttm_dev->pinned), 1);
      |                 ^~~~~~~~~~
      |                 |
      |                 struct ttm_lru_item *

../include/kunit/test.h:707:15: note: in definition of macro ‘KUNIT_BASE_BINARY_ASSERTION’
707 | const typeof(left) __left = (left); \
| ^~~~
../include/kunit/test.h:1271:2: note: in expansion of macro ‘KUNIT_BINARY_INT_ASSERTION’

 1271 |  KUNIT_BINARY_INT_ASSERTION(test,           \
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~
../include/kunit/test.h:1268:2: note: in expansion of macro ‘KUNIT_ASSERT_EQ_MSG’
 1268 |  KUNIT_ASSERT_EQ_MSG(test, left, right, NULL)
      |  ^~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/ttm/tests/ttm_bo_test.c:304:2: note: in expansion of macro ‘KUNIT_ASSERT_EQ’
  304 |  KUNIT_ASSERT_EQ(test,
      |  ^~~~~~~~~~~~~~~
In file included from ../include/linux/mutex.h:15,
                 from ../include/linux/ww_mutex.h:20,
                 from ../include/linux/dma-resv.h:42,
                 from ../drivers/gpu/drm/ttm/tests/ttm_bo_test.c:5:
../include/linux/list.h:352:56: note: expected ‘const struct list_head *’ but argument is of type ‘struct ttm_lru_item *’
  352 | static inline int list_is_last(const struct list_head *list, const struct list_head *head)
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~
In file included from ../include/drm/drm_kunit_helpers.h:10,
                 from ../drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.h:13,
                 from ../drivers/gpu/drm/ttm/tests/ttm_bo_test.c:17:
../drivers/gpu/drm/ttm/tests/ttm_bo_test.c:305:17: error: passing argument 1 of ‘list_is_last’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  305 |    list_is_last(&res2->lru, &priv->ttm_dev->pinned), 1);
      |                 ^~~~~~~~~~
      |                 |
      |                 struct ttm_lru_item *

../include/kunit/test.h:707:31: note: in definition of macro ‘KUNIT_BASE_BINARY_ASSERTION’
707 | const typeof(left) __left = (left); \
| ^~~~
../include/kunit/test.h:1271:2: note: in expansion of macro ‘KUNIT_BINARY_INT_ASSERTION’

 1271 |  KUNIT_BINARY_INT_ASSERTION(test,           \
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~
../include/kunit/test.h:1268:2: note: in expansion of macro ‘KUNIT_ASSERT_EQ_MSG’
 1268 |  KUNIT_ASSERT_EQ_MSG(test, left, right, NULL)
      |  ^~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/ttm/tests/ttm_bo_test.c:304:2: note: in expansion of macro ‘KUNIT_ASSERT_EQ’
  304 |  KUNIT_ASSERT_EQ(test,
      |  ^~~~~~~~~~~~~~~
In file included from ../include/linux/mutex.h:15,
                 from ../include/linux/ww_mutex.h:20,
                 from ../include/linux/dma-resv.h:42,
                 from ../drivers/gpu/drm/ttm/tests/ttm_bo_test.c:5:
../include/linux/list.h:352:56: note: expected ‘const struct list_head *’ but argument is of type ‘struct ttm_lru_item *’
  352 | static inline int list_is_last(const struct list_head *list, const struct list_head *head)
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~
In file included from ../include/drm/drm_kunit_helpers.h:10,
                 from ../drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.h:13,
                 from ../drivers/gpu/drm/ttm/tests/ttm_bo_test.c:17:
../drivers/gpu/drm/ttm/tests/ttm_bo_test.c:309:17: error: passing argument 1 of ‘list_is_last’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  309 |    list_is_last(&res1->lru, &priv->ttm_dev->pinned), 1);
      |                 ^~~~~~~~~~
      |                 |
      |                 struct ttm_lru_item *

../include/kunit/test.h:707:15: note: in definition of macro ‘KUNIT_BASE_BINARY_ASSERTION’
707 | const typeof(left) __left = (left); \
| ^~~~
../include/kunit/test.h:1271:2: note: in expansion of macro ‘KUNIT_BINARY_INT_ASSERTION’

 1271 |  KUNIT_BINARY_INT_ASSERTION(test,           \
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~
../include/kunit/test.h:1268:2: note: in expansion of macro ‘KUNIT_ASSERT_EQ_MSG’
 1268 |  KUNIT_ASSERT_EQ_MSG(test, left, right, NULL)
      |  ^~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/ttm/tests/ttm_bo_test.c:308:2: note: in expansion of macro ‘KUNIT_ASSERT_EQ’
  308 |  KUNIT_ASSERT_EQ(test,
      |  ^~~~~~~~~~~~~~~
In file included from ../include/linux/mutex.h:15,
                 from ../include/linux/ww_mutex.h:20,
                 from ../include/linux/dma-resv.h:42,
                 from ../drivers/gpu/drm/ttm/tests/ttm_bo_test.c:5:
../include/linux/list.h:352:56: note: expected ‘const struct list_head *’ but argument is of type ‘struct ttm_lru_item *’
  352 | static inline int list_is_last(const struct list_head *list, const struct list_head *head)
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~
In file included from ../include/drm/drm_kunit_helpers.h:10,
                 from ../drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.h:13,
                 from ../drivers/gpu/drm/ttm/tests/ttm_bo_test.c:17:
../drivers/gpu/drm/ttm/tests/ttm_bo_test.c:309:17: error: passing argument 1 of ‘list_is_last’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  309 |    list_is_last(&res1->lru, &priv->ttm_dev->pinned), 1);
      |                 ^~~~~~~~~~
      |                 |
      |                 struct ttm_lru_item *

../include/kunit/test.h:707:31: note: in definition of macro ‘KUNIT_BASE_BINARY_ASSERTION’
707 | const typeof(left) __left = (left); \
| ^~~~
../include/kunit/test.h:1271:2: note: in expansion of macro ‘KUNIT_BINARY_INT_ASSERTION’

 1271 |  KUNIT_BINARY_INT_ASSERTION(test,           \
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~
../include/kunit/test.h:1268:2: note: in expansion of macro ‘KUNIT_ASSERT_EQ_MSG’
 1268 |  KUNIT_ASSERT_EQ_MSG(test, left, right, NULL)
      |  ^~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/ttm/tests/ttm_bo_test.c:308:2: note: in expansion of macro ‘KUNIT_ASSERT_EQ’
  308 |  KUNIT_ASSERT_EQ(test,
      |  ^~~~~~~~~~~~~~~
In file included from ../include/linux/mutex.h:15,
                 from ../include/linux/ww_mutex.h:20,
                 from ../include/linux/dma-resv.h:42,
                 from ../drivers/gpu/drm/ttm/tests/ttm_bo_test.c:5:
../include/linux/list.h:352:56: note: expected ‘const struct list_head *’ but argument is of type ‘struct ttm_lru_item *’
  352 | static inline int list_is_last(const struct list_head *list, const struct list_head *head)
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~

cc1: some warnings being treated as errors
make[8]: *** [../scripts/Makefile.build:244: drivers/gpu/drm/ttm/tests/ttm_resource_test.o] Error 1 make[8]: *** Waiting for unfinished jobs....
cc1: some warnings being treated as errors
make[8]: *** [../scripts/Makefile.build:244: drivers/gpu/drm/ttm/tests/ttm_bo_test.o] Error 1 make[7]: *** [../scripts/Makefile.build:485: drivers/gpu/drm/ttm/tests] Error 2 make[7]: *** Waiting for unfinished jobs....
make[6]: *** [../scripts/Makefile.build:485: drivers/gpu/drm/ttm] Error 2
make[6]: *** Waiting for unfinished jobs....
make[5]: *** [../scripts/Makefile.build:485: drivers/gpu/drm] Error 2
make[4]: *** [../scripts/Makefile.build:485: drivers/gpu] Error 2
make[3]: *** [../scripts/Makefile.build:485: drivers] Error 2
make[2]: *** [/kernel/Makefile:1934: .] Error 2
make[1]: *** [/kernel/Makefile:240: __sub-make] Error 2
make: *** [Makefile:240: __sub-make] Error 2

[12:01:40] Configuring KUnit Kernel ...
Regenerating .config ...
Populating config with:

$ make ARCH=um O=.kunit olddefconfig
[12:01:42] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make ARCH=um O=.kunit --jobs=48
+ cleanup
++ stat -c %u:%g /kernel
+ chown -R 1003:1003 /kernel
#15 lore raw

Re: [PATCH v4 11/12] drm/ttm, drm/xe: Add a shrinker for xe bos

In reply to Thomas Hellström
kernel test robot noticed the following build errors:

Hi Thomas,

kernel test robot noticed the following build errors:

[auto build test ERROR on drm-xe/drm-xe-next]
[also build test ERROR on next-20240613]
[cannot apply to linus/master v6.10-rc3]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Thomas-Hellstr-m/drm-ttm-Allow-TTM-LRU-list-nodes-of-different-types/20240614-182911
base:   https://gitlab.freedesktop.org/drm/xe/kernel.git drm-xe-next
patch link:    https://lore.kernel.org/r/20240614102548.4364-12-thomas.hellstrom%40linux.intel.com
patch subject: [PATCH v4 11/12] drm/ttm, drm/xe: Add a shrinker for xe bos
config: i386-buildonly-randconfig-002-20240615 (https://download.01.org/0day-ci/archive/20240615/[email protected]/config)
compiler: gcc-9 (Ubuntu 9.5.0-4ubuntu2) 9.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240615/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

In file included from include/asm-generic/bug.h:22,

                    from arch/x86/include/asm/bug.h:87,
                    from include/linux/bug.h:5,
                    from include/linux/mmdebug.h:5,
                    from include/linux/mm.h:6,
                    from include/linux/pagemap.h:8,
                    from include/drm/ttm/ttm_tt.h:30,
                    from drivers/gpu/drm/xe/xe_bo.h:9,
                    from drivers/gpu/drm/xe/xe_bo.c:6:
   drivers/gpu/drm/xe/tests/xe_bo.c: In function 'shrink_test_run_device':
>> include/linux/kern_levels.h:5:18: error: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
       5 | #define KERN_SOH "\001"  /* ASCII Start Of Header */
         |                  ^~~~~~
   include/linux/printk.h:436:11: note: in definition of macro 'printk_index_wrap'
     436 |   _p_func(_fmt, ##__VA_ARGS__);    \
         |           ^~~~
   include/kunit/test.h:529:3: note: in expansion of macro 'printk'
     529 |   printk(lvl fmt, ##__VA_ARGS__);    \
         |   ^~~~~~
   include/kunit/test.h:535:2: note: in expansion of macro 'kunit_log'
     535 |  kunit_log(lvl, test, KUNIT_SUBTEST_INDENT "# %s: " fmt,  \
         |  ^~~~~~~~~
   include/kunit/test.h:548:2: note: in expansion of macro 'kunit_printk'
     548 |  kunit_printk(KERN_INFO, test, fmt, ##__VA_ARGS__)
         |  ^~~~~~~~~~~~
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
      14 | #define KERN_INFO KERN_SOH "6" /* informational */
         |                   ^~~~~~~~
   include/kunit/test.h:548:15: note: in expansion of macro 'KERN_INFO'
     548 |  kunit_printk(KERN_INFO, test, fmt, ##__VA_ARGS__)
         |               ^~~~~~~~~
   drivers/gpu/drm/xe/tests/xe_bo.c:381:2: note: in expansion of macro 'kunit_info'
     381 |  kunit_info(test, "Free ram is %lu bytes. Will allocate twice of that.\n",
         |  ^~~~~~~~~~
   In file included from drivers/gpu/drm/xe/xe_bo.c:2442:
   drivers/gpu/drm/xe/tests/xe_bo.c:381:34: note: format string is defined here
     381 |  kunit_info(test, "Free ram is %lu bytes. Will allocate twice of that.\n",
         |                                ~~^
         |                                  |
         |                                  long unsigned int
         |                                %u
   In file included from drivers/gpu/drm/xe/tests/xe_bo.c:6,
                    from drivers/gpu/drm/xe/xe_bo.c:2442:
>> include/kunit/test.h:50:31: error: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
      50 | #define KUNIT_SUBTEST_INDENT  "    "
         |                               ^~~~~~
   include/kunit/test.h:530:42: note: in definition of macro 'kunit_log'
     530 |   kunit_log_append((test_or_suite)->log, fmt,  \
         |                                          ^~~
   include/kunit/test.h:535:23: note: in expansion of macro 'KUNIT_SUBTEST_INDENT'
     535 |  kunit_log(lvl, test, KUNIT_SUBTEST_INDENT "# %s: " fmt,  \
         |                       ^~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:548:2: note: in expansion of macro 'kunit_printk'
     548 |  kunit_printk(KERN_INFO, test, fmt, ##__VA_ARGS__)
         |  ^~~~~~~~~~~~
   drivers/gpu/drm/xe/tests/xe_bo.c:381:2: note: in expansion of macro 'kunit_info'
     381 |  kunit_info(test, "Free ram is %lu bytes. Will allocate twice of that.\n",
         |  ^~~~~~~~~~
   In file included from drivers/gpu/drm/xe/xe_bo.c:2442:
   drivers/gpu/drm/xe/tests/xe_bo.c:381:34: note: format string is defined here
     381 |  kunit_info(test, "Free ram is %lu bytes. Will allocate twice of that.\n",
         |                                ~~^
         |                                  |
         |                                  long unsigned int
         |                                %u

cc1: all warnings being treated as errors

Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for REGMAP_SPI Depends on [n]: SPI [=n]
Selected by [y]:
- AD9739A [=y] && IIO [=y] && (SPI [=n] || COMPILE_TEST [=y])

vim +50 include/kunit/test.h

6d2426b2f258da David Gow        2021-06-24  43  
c3bba690a26432 Alan Maguire     2020-03-26  44  /*
c3bba690a26432 Alan Maguire     2020-03-26  45   * TAP specifies subtest stream indentation of 4 spaces, 8 spaces for a
c3bba690a26432 Alan Maguire     2020-03-26  46   * sub-subtest.  See the "Subtests" section in
c3bba690a26432 Alan Maguire     2020-03-26  47   * https://node-tap.org/tap-protocol/
c3bba690a26432 Alan Maguire     2020-03-26  48   */
b1eaa8b2a55c9d Michal Wajdeczko 2023-05-17  49  #define KUNIT_INDENT_LEN		4
c3bba690a26432 Alan Maguire     2020-03-26 @50  #define KUNIT_SUBTEST_INDENT		"    "
c3bba690a26432 Alan Maguire     2020-03-26  51  #define KUNIT_SUBSUBTEST_INDENT		"        "
c3bba690a26432 Alan Maguire     2020-03-26  52  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#2 lore raw

Re: [PATCH v4 01/12] drm/ttm: Allow TTM LRU list nodes of different types

In reply to Thomas Hellström
kernel test robot noticed the following build errors:

Hi Thomas,

kernel test robot noticed the following build errors:

[auto build test ERROR on drm-xe/drm-xe-next]
[also build test ERROR on linus/master v6.10-rc3 next-20240613] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Thomas-Hellstr-m/drm-ttm-Allow-TTM-LRU-list-nodes-of-different-types/20240614-182911
base:   https://gitlab.freedesktop.org/drm/xe/kernel.git drm-xe-next
patch link:    https://lore.kernel.org/r/20240614102548.4364-2-thomas.hellstrom%40linux.intel.com
patch subject: [PATCH v4 01/12] drm/ttm: Allow TTM LRU list nodes of different types
config: loongarch-randconfig-001-20240615 (https://download.01.org/0day-ci/archive/20240615/[email protected]/config)
compiler: loongarch64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240615/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

In file included from include/linux/build_bug.h:5,
from include/linux/container_of.h:5,
from include/linux/list.h:5,
from include/drm/ttm/ttm_resource.h:29,
from drivers/gpu/drm/ttm/tests/ttm_resource_test.c:5:
drivers/gpu/drm/ttm/tests/ttm_resource_test.c: In function 'ttm_resource_fini_basic':

>> drivers/gpu/drm/ttm/tests/ttm_resource_test.c:201:44: error: passing argument 1 of 'list_empty' from incompatible pointer type [-Werror=incompatible-pointer-types]
     201 |         KUNIT_ASSERT_TRUE(test, list_empty(&res->lru));
         |                                            ^~~~~~~~~
         |                                            |
         |                                            struct ttm_lru_item *
   include/linux/compiler.h:76:45: note: in definition of macro 'likely'
      76 | # define likely(x)      __builtin_expect(!!(x), 1)
         |                                             ^
   include/kunit/test.h:668:9: note: in expansion of macro 'KUNIT_UNARY_ASSERTION'
     668 |         KUNIT_UNARY_ASSERTION(test,                                            \
         |         ^~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1232:9: note: in expansion of macro 'KUNIT_TRUE_MSG_ASSERTION'
    1232 |         KUNIT_TRUE_MSG_ASSERTION(test,                                         \
         |         ^~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1229:9: note: in expansion of macro 'KUNIT_ASSERT_TRUE_MSG'
    1229 |         KUNIT_ASSERT_TRUE_MSG(test, condition, NULL)
         |         ^~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/ttm/tests/ttm_resource_test.c:201:9: note: in expansion of macro 'KUNIT_ASSERT_TRUE'
     201 |         KUNIT_ASSERT_TRUE(test, list_empty(&res->lru));
         |         ^~~~~~~~~~~~~~~~~

include/linux/list.h:371:54: note: expected 'const struct list_head *' but argument is of type 'struct ttm_lru_item *'
371 | static inline int list_empty(const struct list_head *head)
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~~
cc1: some warnings being treated as errors
--
In file included from include/drm/drm_kunit_helpers.h:10,
from drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.h:13,
from drivers/gpu/drm/ttm/tests/ttm_bo_test.c:17:
drivers/gpu/drm/ttm/tests/ttm_bo_test.c: In function 'ttm_bo_unreserve_basic':

>> drivers/gpu/drm/ttm/tests/ttm_bo_test.c:268:38: error: passing argument 1 of 'list_is_last' from incompatible pointer type [-Werror=incompatible-pointer-types]
     268 |                         list_is_last(&res1->lru, &man->lru[bo->priority]), 1);
         |                                      ^~~~~~~~~~
         |                                      |
         |                                      struct ttm_lru_item *
   include/kunit/test.h:707:22: note: in definition of macro 'KUNIT_BASE_BINARY_ASSERTION'
     707 |         const typeof(left) __left = (left);                                    \
         |                      ^~~~
   include/kunit/test.h:1271:9: note: in expansion of macro 'KUNIT_BINARY_INT_ASSERTION'
    1271 |         KUNIT_BINARY_INT_ASSERTION(test,                                       \
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1268:9: note: in expansion of macro 'KUNIT_ASSERT_EQ_MSG'
    1268 |         KUNIT_ASSERT_EQ_MSG(test, left, right, NULL)
         |         ^~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/ttm/tests/ttm_bo_test.c:267:9: note: in expansion of macro 'KUNIT_ASSERT_EQ'
     267 |         KUNIT_ASSERT_EQ(test,
         |         ^~~~~~~~~~~~~~~
   In file included from include/linux/mutex.h:15,
                    from include/linux/ww_mutex.h:20,
                    from include/linux/dma-resv.h:42,
                    from drivers/gpu/drm/ttm/tests/ttm_bo_test.c:5:
   include/linux/list.h:352:56: note: expected 'const struct list_head *' but argument is of type 'struct ttm_lru_item *'
     352 | static inline int list_is_last(const struct list_head *list, const struct list_head *head)
         |                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~
>> drivers/gpu/drm/ttm/tests/ttm_bo_test.c:268:38: error: passing argument 1 of 'list_is_last' from incompatible pointer type [-Werror=incompatible-pointer-types]
     268 |                         list_is_last(&res1->lru, &man->lru[bo->priority]), 1);
         |                                      ^~~~~~~~~~
         |                                      |
         |                                      struct ttm_lru_item *
   include/kunit/test.h:707:38: note: in definition of macro 'KUNIT_BASE_BINARY_ASSERTION'
     707 |         const typeof(left) __left = (left);                                    \
         |                                      ^~~~
   include/kunit/test.h:1271:9: note: in expansion of macro 'KUNIT_BINARY_INT_ASSERTION'
    1271 |         KUNIT_BINARY_INT_ASSERTION(test,                                       \
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1268:9: note: in expansion of macro 'KUNIT_ASSERT_EQ_MSG'
    1268 |         KUNIT_ASSERT_EQ_MSG(test, left, right, NULL)
         |         ^~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/ttm/tests/ttm_bo_test.c:267:9: note: in expansion of macro 'KUNIT_ASSERT_EQ'
     267 |         KUNIT_ASSERT_EQ(test,
         |         ^~~~~~~~~~~~~~~
   include/linux/list.h:352:56: note: expected 'const struct list_head *' but argument is of type 'struct ttm_lru_item *'
     352 | static inline int list_is_last(const struct list_head *list, const struct list_head *head)
         |                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~
   drivers/gpu/drm/ttm/tests/ttm_bo_test.c: In function 'ttm_bo_unreserve_pinned':
   drivers/gpu/drm/ttm/tests/ttm_bo_test.c:305:38: error: passing argument 1 of 'list_is_last' from incompatible pointer type [-Werror=incompatible-pointer-types]
     305 |                         list_is_last(&res2->lru, &priv->ttm_dev->pinned), 1);
         |                                      ^~~~~~~~~~
         |                                      |
         |                                      struct ttm_lru_item *
   include/kunit/test.h:707:22: note: in definition of macro 'KUNIT_BASE_BINARY_ASSERTION'
     707 |         const typeof(left) __left = (left);                                    \
         |                      ^~~~
   include/kunit/test.h:1271:9: note: in expansion of macro 'KUNIT_BINARY_INT_ASSERTION'
    1271 |         KUNIT_BINARY_INT_ASSERTION(test,                                       \
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1268:9: note: in expansion of macro 'KUNIT_ASSERT_EQ_MSG'
    1268 |         KUNIT_ASSERT_EQ_MSG(test, left, right, NULL)
         |         ^~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/ttm/tests/ttm_bo_test.c:304:9: note: in expansion of macro 'KUNIT_ASSERT_EQ'
     304 |         KUNIT_ASSERT_EQ(test,
         |         ^~~~~~~~~~~~~~~
   include/linux/list.h:352:56: note: expected 'const struct list_head *' but argument is of type 'struct ttm_lru_item *'
     352 | static inline int list_is_last(const struct list_head *list, const struct list_head *head)
         |                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~
   drivers/gpu/drm/ttm/tests/ttm_bo_test.c:305:38: error: passing argument 1 of 'list_is_last' from incompatible pointer type [-Werror=incompatible-pointer-types]
     305 |                         list_is_last(&res2->lru, &priv->ttm_dev->pinned), 1);
         |                                      ^~~~~~~~~~
         |                                      |
         |                                      struct ttm_lru_item *
   include/kunit/test.h:707:38: note: in definition of macro 'KUNIT_BASE_BINARY_ASSERTION'
     707 |         const typeof(left) __left = (left);                                    \
         |                                      ^~~~
   include/kunit/test.h:1271:9: note: in expansion of macro 'KUNIT_BINARY_INT_ASSERTION'
    1271 |         KUNIT_BINARY_INT_ASSERTION(test,                                       \
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1268:9: note: in expansion of macro 'KUNIT_ASSERT_EQ_MSG'
    1268 |         KUNIT_ASSERT_EQ_MSG(test, left, right, NULL)
         |         ^~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/ttm/tests/ttm_bo_test.c:304:9: note: in expansion of macro 'KUNIT_ASSERT_EQ'
     304 |         KUNIT_ASSERT_EQ(test,
         |         ^~~~~~~~~~~~~~~
   include/linux/list.h:352:56: note: expected 'const struct list_head *' but argument is of type 'struct ttm_lru_item *'
     352 | static inline int list_is_last(const struct list_head *list, const struct list_head *head)
         |                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~
   drivers/gpu/drm/ttm/tests/ttm_bo_test.c:309:38: error: passing argument 1 of 'list_is_last' from incompatible pointer type [-Werror=incompatible-pointer-types]
     309 |                         list_is_last(&res1->lru, &priv->ttm_dev->pinned), 1);
         |                                      ^~~~~~~~~~
         |                                      |
         |                                      struct ttm_lru_item *
   include/kunit/test.h:707:22: note: in definition of macro 'KUNIT_BASE_BINARY_ASSERTION'
     707 |         const typeof(left) __left = (left);                                    \
         |                      ^~~~
   include/kunit/test.h:1271:9: note: in expansion of macro 'KUNIT_BINARY_INT_ASSERTION'
    1271 |         KUNIT_BINARY_INT_ASSERTION(test,                                       \
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1268:9: note: in expansion of macro 'KUNIT_ASSERT_EQ_MSG'
    1268 |         KUNIT_ASSERT_EQ_MSG(test, left, right, NULL)
         |         ^~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/ttm/tests/ttm_bo_test.c:308:9: note: in expansion of macro 'KUNIT_ASSERT_EQ'
     308 |         KUNIT_ASSERT_EQ(test,
         |         ^~~~~~~~~~~~~~~
   include/linux/list.h:352:56: note: expected 'const struct list_head *' but argument is of type 'struct ttm_lru_item *'
     352 | static inline int list_is_last(const struct list_head *list, const struct list_head *head)
         |                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~
   drivers/gpu/drm/ttm/tests/ttm_bo_test.c:309:38: error: passing argument 1 of 'list_is_last' from incompatible pointer type [-Werror=incompatible-pointer-types]
     309 |                         list_is_last(&res1->lru, &priv->ttm_dev->pinned), 1);
         |                                      ^~~~~~~~~~
         |                                      |
         |                                      struct ttm_lru_item *
   include/kunit/test.h:707:38: note: in definition of macro 'KUNIT_BASE_BINARY_ASSERTION'
     707 |         const typeof(left) __left = (left);                                    \
         |                                      ^~~~
   include/kunit/test.h:1271:9: note: in expansion of macro 'KUNIT_BINARY_INT_ASSERTION'
    1271 |         KUNIT_BINARY_INT_ASSERTION(test,                                       \
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:1268:9: note: in expansion of macro 'KUNIT_ASSERT_EQ_MSG'
    1268 |         KUNIT_ASSERT_EQ_MSG(test, left, right, NULL)
         |         ^~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/ttm/tests/ttm_bo_test.c:308:9: note: in expansion of macro 'KUNIT_ASSERT_EQ'
     308 |         KUNIT_ASSERT_EQ(test,
         |         ^~~~~~~~~~~~~~~

include/linux/list.h:352:56: note: expected 'const struct list_head *' but argument is of type 'struct ttm_lru_item *'
352 | static inline int list_is_last(const struct list_head *list, const struct list_head *head)
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~~

vim +/list_empty +201 drivers/gpu/drm/ttm/tests/ttm_resource_test.c

9afc1e0aa4851e Karolina Stolarek 2023-11-29  180  
9afc1e0aa4851e Karolina Stolarek 2023-11-29  181  static void ttm_resource_fini_basic(struct kunit *test)
9afc1e0aa4851e Karolina Stolarek 2023-11-29  182  {
9afc1e0aa4851e Karolina Stolarek 2023-11-29  183  	struct ttm_resource_test_priv *priv = test->priv;
9afc1e0aa4851e Karolina Stolarek 2023-11-29  184  	struct ttm_resource *res;
9afc1e0aa4851e Karolina Stolarek 2023-11-29  185  	struct ttm_buffer_object *bo;
9afc1e0aa4851e Karolina Stolarek 2023-11-29  186  	struct ttm_place *place;
9afc1e0aa4851e Karolina Stolarek 2023-11-29  187  	struct ttm_resource_manager *man;
9afc1e0aa4851e Karolina Stolarek 2023-11-29  188  
9afc1e0aa4851e Karolina Stolarek 2023-11-29  189  	ttm_init_test_mocks(test, priv, TTM_PL_SYSTEM, 0);
9afc1e0aa4851e Karolina Stolarek 2023-11-29  190  	bo = priv->bo;
9afc1e0aa4851e Karolina Stolarek 2023-11-29  191  	place = priv->place;
9afc1e0aa4851e Karolina Stolarek 2023-11-29  192  
9afc1e0aa4851e Karolina Stolarek 2023-11-29  193  	man = ttm_manager_type(priv->devs->ttm_dev, place->mem_type);
9afc1e0aa4851e Karolina Stolarek 2023-11-29  194  
9afc1e0aa4851e Karolina Stolarek 2023-11-29  195  	res = kunit_kzalloc(test, sizeof(*res), GFP_KERNEL);
9afc1e0aa4851e Karolina Stolarek 2023-11-29  196  	KUNIT_ASSERT_NOT_NULL(test, res);
9afc1e0aa4851e Karolina Stolarek 2023-11-29  197  
9afc1e0aa4851e Karolina Stolarek 2023-11-29  198  	ttm_resource_init(bo, place, res);
9afc1e0aa4851e Karolina Stolarek 2023-11-29  199  	ttm_resource_fini(man, res);
9afc1e0aa4851e Karolina Stolarek 2023-11-29  200  
9afc1e0aa4851e Karolina Stolarek 2023-11-29 @201  	KUNIT_ASSERT_TRUE(test, list_empty(&res->lru));
9afc1e0aa4851e Karolina Stolarek 2023-11-29  202  	KUNIT_ASSERT_EQ(test, man->usage, 0);
9afc1e0aa4851e Karolina Stolarek 2023-11-29  203  }

9afc1e0aa4851e Karolina Stolarek 2023-11-29 204

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#12 lore raw

Re: [PATCH v4 09/12] drm/ttm/pool: Provide a helper to shrink pages

In reply to Thomas Hellström
kernel test robot noticed the following build warnings:

Hi Thomas,

kernel test robot noticed the following build warnings:

[auto build test WARNING on drm-xe/drm-xe-next]
[also build test WARNING on next-20240613]
[cannot apply to linus/master v6.10-rc3]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Thomas-Hellstr-m/drm-ttm-Allow-TTM-LRU-list-nodes-of-different-types/20240614-182911
base:   https://gitlab.freedesktop.org/drm/xe/kernel.git drm-xe-next
patch link:    https://lore.kernel.org/r/20240614102548.4364-10-thomas.hellstrom%40linux.intel.com
patch subject: [PATCH v4 09/12] drm/ttm/pool: Provide a helper to shrink pages
config: loongarch-defconfig (https://download.01.org/0day-ci/archive/20240615/[email protected]/config)
compiler: loongarch64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240615/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/ttm/ttm_pool.o: warning: objtool: __jump_table+0x0: special: can't find orig instruction

objdump-func vmlinux.o __jump_table:

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#10 lore raw

Re: [PATCH v4 08/12] drm/ttm: Add a virtual base class for graphics memory backup

In reply to Thomas Hellström

Hi Thomas,

kernel test robot noticed the following build warnings:

https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Thomas-Hellstr-m/drm-ttm-Allow-TTM-LRU-list-nodes-of-different-types/20240614-182911
base:   https://gitlab.freedesktop.org/drm/xe/kernel.git drm-xe-next
patch link:    https://lore.kernel.org/r/20240614102548.4364-9-thomas.hellstrom%40linux.intel.com
patch subject: [PATCH v4 08/12] drm/ttm: Add a virtual base class for graphics memory backup
config: x86_64-randconfig-161-20240617 (https://download.01.org/0day-ci/archive/20240617/[email protected]/config)
compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags

| Reported-by: kernel test robot <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

smatch warnings:
drivers/gpu/drm/ttm/ttm_backup_shmem.c:130 ttm_backup_shmem_create() error: dereferencing freed memory 'sbackup'

vim +/sbackup +130 drivers/gpu/drm/ttm/ttm_backup_shmem.c

827540d42dec01 Thomas Hellström 2024-06-14  119  struct ttm_backup *ttm_backup_shmem_create(loff_t size)
827540d42dec01 Thomas Hellström 2024-06-14  120  {
827540d42dec01 Thomas Hellström 2024-06-14  121  	struct ttm_backup_shmem *sbackup =
827540d42dec01 Thomas Hellström 2024-06-14  122  		kzalloc(sizeof(*sbackup), GFP_KERNEL | __GFP_ACCOUNT);
827540d42dec01 Thomas Hellström 2024-06-14  123  
827540d42dec01 Thomas Hellström 2024-06-14  124  	if (!sbackup)
827540d42dec01 Thomas Hellström 2024-06-14  125  		return ERR_PTR(-ENOMEM);
827540d42dec01 Thomas Hellström 2024-06-14  126  
827540d42dec01 Thomas Hellström 2024-06-14  127  	sbackup->filp = shmem_file_setup("ttm shmem backup", size, 0);
827540d42dec01 Thomas Hellström 2024-06-14  128  	if (IS_ERR(sbackup->filp)) {
827540d42dec01 Thomas Hellström 2024-06-14  129  		kfree(sbackup);
                                                                      ^^^^^^^

Freed

827540d42dec01 Thomas Hellström 2024-06-14 @130  		return ERR_CAST(sbackup->filp);
                                                                                ^^^^^^^^^^^^^

Use after free

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki