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

drm/ttm/vmwgfx: move ttm_bo_wait into VMWGFX

Not used anymore by other drivers or TTM itself.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Zack Rusin <zackr@vmware.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221125102137.1801-9-christian.koenig@amd.com

+39 -36
+16 -28
drivers/gpu/drm/ttm/ttm_bo.c
··· 1087 1087 EXPORT_SYMBOL(ttm_bo_unmap_virtual); 1088 1088 1089 1089 /** 1090 - * ttm_bo_wait - wait for buffer idle. 1090 + * ttm_bo_wait_ctx - wait for buffer idle. 1091 1091 * 1092 1092 * @bo: The buffer object. 1093 - * @interruptible: Use interruptible wait. 1094 - * @no_wait: Return immediately if buffer is busy. 1093 + * @ctx: defines how to wait 1095 1094 * 1096 - * This function must be called with the bo::mutex held, and makes 1097 - * sure any previous rendering to the buffer is completed. 1098 - * Note: It might be necessary to block validations before the 1099 - * wait by reserving the buffer. 1100 - * Returns -EBUSY if no_wait is true and the buffer is busy. 1101 - * Returns -ERESTARTSYS if interrupted by a signal. 1095 + * Waits for the buffer to be idle. Used timeout depends on the context. 1096 + * Returns -EBUSY if wait timed outt, -ERESTARTSYS if interrupted by a signal or 1097 + * zero on success. 1102 1098 */ 1103 - int ttm_bo_wait(struct ttm_buffer_object *bo, 1104 - bool interruptible, bool no_wait) 1099 + int ttm_bo_wait_ctx(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx) 1105 1100 { 1106 - long timeout = 15 * HZ; 1101 + long ret; 1107 1102 1108 - if (no_wait) { 1109 - if (dma_resv_test_signaled(bo->base.resv, DMA_RESV_USAGE_BOOKKEEP)) 1103 + if (ctx->no_wait_gpu) { 1104 + if (dma_resv_test_signaled(bo->base.resv, 1105 + DMA_RESV_USAGE_BOOKKEEP)) 1110 1106 return 0; 1111 1107 else 1112 1108 return -EBUSY; 1113 1109 } 1114 1110 1115 - timeout = dma_resv_wait_timeout(bo->base.resv, DMA_RESV_USAGE_BOOKKEEP, 1116 - interruptible, timeout); 1117 - if (timeout < 0) 1118 - return timeout; 1119 - 1120 - if (timeout == 0) 1111 + ret = dma_resv_wait_timeout(bo->base.resv, DMA_RESV_USAGE_BOOKKEEP, 1112 + ctx->interruptible, 15 * HZ); 1113 + if (unlikely(ret < 0)) 1114 + return ret; 1115 + if (unlikely(ret == 0)) 1121 1116 return -EBUSY; 1122 - 1123 1117 return 0; 1124 - } 1125 - EXPORT_SYMBOL(ttm_bo_wait); 1126 - 1127 - int ttm_bo_wait_ctx(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx) 1128 - { 1129 - return ttm_bo_wait(bo, ctx->interruptible, ctx->no_wait_gpu); 1130 1118 } 1131 1119 EXPORT_SYMBOL(ttm_bo_wait_ctx); 1132 1120 ··· 1123 1135 { 1124 1136 struct ttm_place place; 1125 1137 bool locked; 1126 - int ret; 1138 + long ret; 1127 1139 1128 1140 /* 1129 1141 * While the bo may already reside in SYSTEM placement, set
+12 -7
drivers/gpu/drm/ttm/ttm_bo_util.c
··· 548 548 static int ttm_bo_wait_free_node(struct ttm_buffer_object *bo, 549 549 bool dst_use_tt) 550 550 { 551 - int ret; 552 - ret = ttm_bo_wait(bo, false, false); 553 - if (ret) 551 + long ret; 552 + 553 + ret = dma_resv_wait_timeout(bo->base.resv, DMA_RESV_USAGE_BOOKKEEP, 554 + false, 15 * HZ); 555 + if (ret == 0) 556 + return -EBUSY; 557 + if (ret < 0) 554 558 return ret; 555 559 556 560 if (!dst_use_tt) ··· 715 711 return ret; 716 712 717 713 /* If already idle, no need for ghost object dance. */ 718 - ret = ttm_bo_wait(bo, false, true); 719 - if (ret != -EBUSY) { 714 + if (dma_resv_test_signaled(bo->base.resv, DMA_RESV_USAGE_BOOKKEEP)) { 720 715 if (!bo->ttm) { 721 716 /* See comment below about clearing. */ 722 717 ret = ttm_tt_create(bo, true); ··· 752 749 753 750 ret = dma_resv_copy_fences(&ghost->base._resv, bo->base.resv); 754 751 /* Last resort, wait for the BO to be idle when we are OOM */ 755 - if (ret) 756 - ttm_bo_wait(bo, false, false); 752 + if (ret) { 753 + dma_resv_wait_timeout(bo->base.resv, DMA_RESV_USAGE_BOOKKEEP, 754 + false, MAX_SCHEDULE_TIMEOUT); 755 + } 757 756 758 757 dma_resv_unlock(&ghost->base._resv); 759 758 ttm_bo_put(ghost);
+11
drivers/gpu/drm/vmwgfx/ttm_object.h
··· 42 42 #include <linux/list.h> 43 43 #include <linux/rcupdate.h> 44 44 45 + #include <drm/ttm/ttm_bo.h> 46 + 45 47 /** 46 48 * enum ttm_object_type 47 49 * ··· 323 321 __acquire(RCU); 324 322 rcu_read_unlock(); 325 323 } 324 + 325 + static inline int ttm_bo_wait(struct ttm_buffer_object *bo, bool intr, 326 + bool no_wait) 327 + { 328 + struct ttm_operation_ctx ctx = { intr, no_wait }; 329 + 330 + return ttm_bo_wait_ctx(bo, &ctx); 331 + } 332 + 326 333 #endif
-1
include/drm/ttm/ttm_bo.h
··· 347 347 return map->virtual; 348 348 } 349 349 350 - int ttm_bo_wait(struct ttm_buffer_object *bo, bool interruptible, bool no_wait); 351 350 int ttm_bo_wait_ctx(struct ttm_buffer_object *bo, 352 351 struct ttm_operation_ctx *ctx); 353 352 int ttm_bo_validate(struct ttm_buffer_object *bo,