Skip to content

Commit

Permalink
drm/ttm: de-inline ttm_bo_pin/unpin
Browse files Browse the repository at this point in the history
Those functions are going to become more complex, don't inline them any
more.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20220321132601.2161-4-christian.koenig@amd.com
  • Loading branch information
Christian König committed Mar 29, 2022
1 parent 6ce4431 commit 7842cf6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 28 deletions.
32 changes: 32 additions & 0 deletions drivers/gpu/drm/ttm/ttm_bo.c
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,38 @@ int ttm_mem_evict_first(struct ttm_device *bdev,
return ret;
}

/**
* ttm_bo_pin - Pin the buffer object.
* @bo: The buffer object to pin
*
* Make sure the buffer is not evicted any more during memory pressure.
* @bo must be unpinned again by calling ttm_bo_unpin().
*/
void ttm_bo_pin(struct ttm_buffer_object *bo)
{
dma_resv_assert_held(bo->base.resv);
WARN_ON_ONCE(!kref_read(&bo->kref));
++bo->pin_count;
}
EXPORT_SYMBOL(ttm_bo_pin);

/**
* ttm_bo_unpin - Unpin the buffer object.
* @bo: The buffer object to unpin
*
* Allows the buffer object to be evicted again during memory pressure.
*/
void ttm_bo_unpin(struct ttm_buffer_object *bo)
{
dma_resv_assert_held(bo->base.resv);
WARN_ON_ONCE(!kref_read(&bo->kref));
if (bo->pin_count)
--bo->pin_count;
else
WARN_ON_ONCE(true);
}
EXPORT_SYMBOL(ttm_bo_unpin);

/*
* Add the last move fence to the BO and reserve a new shared slot. We only use
* a shared slot to avoid unecessary sync and rely on the subsequent bo move to
Expand Down
30 changes: 2 additions & 28 deletions include/drm/ttm/ttm_bo_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -524,34 +524,8 @@ ssize_t ttm_bo_io(struct ttm_device *bdev, struct file *filp,
int ttm_bo_swapout(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx,
gfp_t gfp_flags);

/**
* ttm_bo_pin - Pin the buffer object.
* @bo: The buffer object to pin
*
* Make sure the buffer is not evicted any more during memory pressure.
*/
static inline void ttm_bo_pin(struct ttm_buffer_object *bo)
{
dma_resv_assert_held(bo->base.resv);
WARN_ON_ONCE(!kref_read(&bo->kref));
++bo->pin_count;
}

/**
* ttm_bo_unpin - Unpin the buffer object.
* @bo: The buffer object to unpin
*
* Allows the buffer object to be evicted again during memory pressure.
*/
static inline void ttm_bo_unpin(struct ttm_buffer_object *bo)
{
dma_resv_assert_held(bo->base.resv);
WARN_ON_ONCE(!kref_read(&bo->kref));
if (bo->pin_count)
--bo->pin_count;
else
WARN_ON_ONCE(true);
}
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,
Expand Down

0 comments on commit 7842cf6

Please sign in to comment.