Skip to content

Commit 13acb36

Browse files
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
1 parent 41d351f commit 13acb36

4 files changed

Lines changed: 39 additions & 36 deletions

File tree

drivers/gpu/drm/ttm/ttm_bo.c

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,55 +1087,43 @@ void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo)
10871087
EXPORT_SYMBOL(ttm_bo_unmap_virtual);
10881088

10891089
/**
1090-
* ttm_bo_wait - wait for buffer idle.
1090+
* ttm_bo_wait_ctx - wait for buffer idle.
10911091
*
10921092
* @bo: The buffer object.
1093-
* @interruptible: Use interruptible wait.
1094-
* @no_wait: Return immediately if buffer is busy.
1093+
* @ctx: defines how to wait
10951094
*
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.
11021098
*/
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)
11051100
{
1106-
long timeout = 15 * HZ;
1101+
long ret;
11071102

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))
11101106
return 0;
11111107
else
11121108
return -EBUSY;
11131109
}
11141110

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))
11211116
return -EBUSY;
1122-
11231117
return 0;
11241118
}
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-
}
11311119
EXPORT_SYMBOL(ttm_bo_wait_ctx);
11321120

11331121
int ttm_bo_swapout(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx,
11341122
gfp_t gfp_flags)
11351123
{
11361124
struct ttm_place place;
11371125
bool locked;
1138-
int ret;
1126+
long ret;
11391127

11401128
/*
11411129
* While the bo may already reside in SYSTEM placement, set

drivers/gpu/drm/ttm/ttm_bo_util.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -548,9 +548,13 @@ EXPORT_SYMBOL(ttm_bo_vunmap);
548548
static int ttm_bo_wait_free_node(struct ttm_buffer_object *bo,
549549
bool dst_use_tt)
550550
{
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)
554558
return ret;
555559

556560
if (!dst_use_tt)
@@ -711,8 +715,7 @@ int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo)
711715
return ret;
712716

713717
/* If already idle, no need for ghost object dance. */
714-
ret = ttm_bo_wait(bo, false, true);
715-
if (ret != -EBUSY) {
718+
if (dma_resv_test_signaled(bo->base.resv, DMA_RESV_USAGE_BOOKKEEP)) {
716719
if (!bo->ttm) {
717720
/* See comment below about clearing. */
718721
ret = ttm_tt_create(bo, true);
@@ -749,8 +752,10 @@ int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo)
749752

750753
ret = dma_resv_copy_fences(&ghost->base._resv, bo->base.resv);
751754
/* Last resort, wait for the BO to be idle when we are OOM */
752-
if (ret)
753-
ttm_bo_wait(bo, false, false);
755+
if (ret) {
756+
dma_resv_wait_timeout(bo->base.resv, DMA_RESV_USAGE_BOOKKEEP,
757+
false, MAX_SCHEDULE_TIMEOUT);
758+
}
754759

755760
dma_resv_unlock(&ghost->base._resv);
756761
ttm_bo_put(ghost);

drivers/gpu/drm/vmwgfx/ttm_object.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
#include <linux/list.h>
4343
#include <linux/rcupdate.h>
4444

45+
#include <drm/ttm/ttm_bo.h>
46+
4547
/**
4648
* enum ttm_object_type
4749
*
@@ -321,4 +323,13 @@ static inline void ttm_base_object_noref_release(void)
321323
__acquire(RCU);
322324
rcu_read_unlock();
323325
}
326+
327+
static inline int ttm_bo_wait(struct ttm_buffer_object *bo, bool intr,
328+
bool no_wait)
329+
{
330+
struct ttm_operation_ctx ctx = { intr, no_wait };
331+
332+
return ttm_bo_wait_ctx(bo, &ctx);
333+
}
334+
324335
#endif

include/drm/ttm/ttm_bo.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ static inline void *ttm_kmap_obj_virtual(struct ttm_bo_kmap_obj *map,
347347
return map->virtual;
348348
}
349349

350-
int ttm_bo_wait(struct ttm_buffer_object *bo, bool interruptible, bool no_wait);
351350
int ttm_bo_wait_ctx(struct ttm_buffer_object *bo,
352351
struct ttm_operation_ctx *ctx);
353352
int ttm_bo_validate(struct ttm_buffer_object *bo,

0 commit comments

Comments
 (0)