Revert "drm/ttm: add ttm_bo_pin()/ttm_bo_unpin() v2"

This reverts commit 5f6d5b58c5 which is
commit deb0814b43f370a448a498409d949e38c9d8f02e upstream.

It breaks the Android kernel abi, and is not needed for any Android
devices at this time.  If it is needed in the future, it can be brought
back in an abi-safe way.

Bug: 161946584
Change-Id: I16e61ac3c2787d37a4eac447fa7fa0e8bfdc804e
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
Greg Kroah-Hartman
2023-08-28 16:22:44 +00:00
parent 918b4c2c76
commit e06ad3b48e
3 changed files with 4 additions and 33 deletions

View File

@@ -115,7 +115,7 @@ static void ttm_bo_add_mem_to_lru(struct ttm_buffer_object *bo,
struct ttm_bo_device *bdev = bo->bdev; struct ttm_bo_device *bdev = bo->bdev;
struct ttm_resource_manager *man; struct ttm_resource_manager *man;
if (!list_empty(&bo->lru) || bo->pin_count) if (!list_empty(&bo->lru))
return; return;
if (mem->placement & TTM_PL_FLAG_NO_EVICT) if (mem->placement & TTM_PL_FLAG_NO_EVICT)
@@ -165,8 +165,7 @@ void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo,
ttm_bo_del_from_lru(bo); ttm_bo_del_from_lru(bo);
ttm_bo_add_mem_to_lru(bo, &bo->mem); ttm_bo_add_mem_to_lru(bo, &bo->mem);
if (bulk && !(bo->mem.placement & TTM_PL_FLAG_NO_EVICT) && if (bulk && !(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) {
!bo->pin_count) {
switch (bo->mem.mem_type) { switch (bo->mem.mem_type) {
case TTM_PL_TT: case TTM_PL_TT:
ttm_bo_bulk_move_set_pos(&bulk->tt[bo->priority], bo); ttm_bo_bulk_move_set_pos(&bulk->tt[bo->priority], bo);
@@ -545,9 +544,8 @@ static void ttm_bo_release(struct kref *kref)
* shrinkers, now that they are queued for * shrinkers, now that they are queued for
* destruction. * destruction.
*/ */
if (bo->mem.placement & TTM_PL_FLAG_NO_EVICT || bo->pin_count) { if (bo->mem.placement & TTM_PL_FLAG_NO_EVICT) {
bo->mem.placement &= ~TTM_PL_FLAG_NO_EVICT; bo->mem.placement &= ~TTM_PL_FLAG_NO_EVICT;
bo->pin_count = 0;
ttm_bo_del_from_lru(bo); ttm_bo_del_from_lru(bo);
ttm_bo_add_mem_to_lru(bo, &bo->mem); ttm_bo_add_mem_to_lru(bo, &bo->mem);
} }
@@ -1176,7 +1174,6 @@ int ttm_bo_init_reserved(struct ttm_bo_device *bdev,
bo->moving = NULL; bo->moving = NULL;
bo->mem.placement = TTM_PL_FLAG_CACHED; bo->mem.placement = TTM_PL_FLAG_CACHED;
bo->acc_size = acc_size; bo->acc_size = acc_size;
bo->pin_count = 0;
bo->sg = sg; bo->sg = sg;
if (resv) { if (resv) {
bo->base.resv = resv; bo->base.resv = resv;

View File

@@ -352,6 +352,7 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo,
return -ENOMEM; return -ENOMEM;
fbo->base = *bo; fbo->base = *bo;
fbo->base.mem.placement |= TTM_PL_FLAG_NO_EVICT;
ttm_bo_get(bo); ttm_bo_get(bo);
fbo->bo = bo; fbo->bo = bo;
@@ -371,7 +372,6 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo,
kref_init(&fbo->base.kref); kref_init(&fbo->base.kref);
fbo->base.destroy = &ttm_transfered_destroy; fbo->base.destroy = &ttm_transfered_destroy;
fbo->base.acc_size = 0; fbo->base.acc_size = 0;
fbo->base.pin_count = 1;
if (bo->type != ttm_bo_type_sg) if (bo->type != ttm_bo_type_sg)
fbo->base.base.resv = &fbo->base.base._resv; fbo->base.base.resv = &fbo->base.base._resv;

View File

@@ -157,7 +157,6 @@ struct ttm_buffer_object {
struct dma_fence *moving; struct dma_fence *moving;
unsigned priority; unsigned priority;
unsigned pin_count;
/** /**
* Special members that are protected by the reserve lock * Special members that are protected by the reserve lock
@@ -607,31 +606,6 @@ static inline bool ttm_bo_uses_embedded_gem_object(struct ttm_buffer_object *bo)
return bo->base.dev != NULL; return bo->base.dev != NULL;
} }
/**
* 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);
++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(!bo->pin_count);
--bo->pin_count;
}
int ttm_mem_evict_first(struct ttm_bo_device *bdev, int ttm_mem_evict_first(struct ttm_bo_device *bdev,
struct ttm_resource_manager *man, struct ttm_resource_manager *man,
const struct ttm_place *place, const struct ttm_place *place,