Commit e532a135 authored by Gerd Hoffmann's avatar Gerd Hoffmann
parent 2e3c9ec4
...@@ -173,7 +173,7 @@ static void ttm_bo_add_mem_to_lru(struct ttm_buffer_object *bo, ...@@ -173,7 +173,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_mem_type_manager *man; struct ttm_mem_type_manager *man;
reservation_object_assert_held(bo->resv); reservation_object_assert_held(bo->base.resv);
if (!list_empty(&bo->lru)) if (!list_empty(&bo->lru))
return; return;
...@@ -244,7 +244,7 @@ static void ttm_bo_bulk_move_set_pos(struct ttm_lru_bulk_move_pos *pos, ...@@ -244,7 +244,7 @@ static void ttm_bo_bulk_move_set_pos(struct ttm_lru_bulk_move_pos *pos,
void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo, void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo,
struct ttm_lru_bulk_move *bulk) struct ttm_lru_bulk_move *bulk)
{ {
reservation_object_assert_held(bo->resv); reservation_object_assert_held(bo->base.resv);
ttm_bo_del_from_lru(bo); ttm_bo_del_from_lru(bo);
ttm_bo_add_to_lru(bo); ttm_bo_add_to_lru(bo);
...@@ -277,8 +277,8 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk) ...@@ -277,8 +277,8 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)
if (!pos->first) if (!pos->first)
continue; continue;
reservation_object_assert_held(pos->first->resv); reservation_object_assert_held(pos->first->base.resv);
reservation_object_assert_held(pos->last->resv); reservation_object_assert_held(pos->last->base.resv);
man = &pos->first->bdev->man[TTM_PL_TT]; man = &pos->first->bdev->man[TTM_PL_TT];
list_bulk_move_tail(&man->lru[i], &pos->first->lru, list_bulk_move_tail(&man->lru[i], &pos->first->lru,
...@@ -292,8 +292,8 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk) ...@@ -292,8 +292,8 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)
if (!pos->first) if (!pos->first)
continue; continue;
reservation_object_assert_held(pos->first->resv); reservation_object_assert_held(pos->first->base.resv);
reservation_object_assert_held(pos->last->resv); reservation_object_assert_held(pos->last->base.resv);
man = &pos->first->bdev->man[TTM_PL_VRAM]; man = &pos->first->bdev->man[TTM_PL_VRAM];
list_bulk_move_tail(&man->lru[i], &pos->first->lru, list_bulk_move_tail(&man->lru[i], &pos->first->lru,
...@@ -307,8 +307,8 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk) ...@@ -307,8 +307,8 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)
if (!pos->first) if (!pos->first)
continue; continue;
reservation_object_assert_held(pos->first->resv); reservation_object_assert_held(pos->first->base.resv);
reservation_object_assert_held(pos->last->resv); reservation_object_assert_held(pos->last->base.resv);
lru = &pos->first->bdev->glob->swap_lru[i]; lru = &pos->first->bdev->glob->swap_lru[i];
list_bulk_move_tail(lru, &pos->first->swap, &pos->last->swap); list_bulk_move_tail(lru, &pos->first->swap, &pos->last->swap);
...@@ -439,12 +439,12 @@ static int ttm_bo_individualize_resv(struct ttm_buffer_object *bo) ...@@ -439,12 +439,12 @@ static int ttm_bo_individualize_resv(struct ttm_buffer_object *bo)
{ {
int r; int r;
if (bo->resv == &bo->base._resv) if (bo->base.resv == &bo->base._resv)
return 0; return 0;
BUG_ON(!reservation_object_trylock(&bo->base._resv)); BUG_ON(!reservation_object_trylock(&bo->base._resv));
r = reservation_object_copy_fences(&bo->base._resv, bo->resv); r = reservation_object_copy_fences(&bo->base._resv, bo->base.resv);
if (r) if (r)
reservation_object_unlock(&bo->base._resv); reservation_object_unlock(&bo->base._resv);
...@@ -464,7 +464,7 @@ static void ttm_bo_flush_all_fences(struct ttm_buffer_object *bo) ...@@ -464,7 +464,7 @@ static void ttm_bo_flush_all_fences(struct ttm_buffer_object *bo)
for (i = 0; fobj && i < fobj->shared_count; ++i) { for (i = 0; fobj && i < fobj->shared_count; ++i) {
fence = rcu_dereference_protected(fobj->shared[i], fence = rcu_dereference_protected(fobj->shared[i],
reservation_object_held(bo->resv)); reservation_object_held(bo->base.resv));
if (!fence->ops->signaled) if (!fence->ops->signaled)
dma_fence_enable_sw_signaling(fence); dma_fence_enable_sw_signaling(fence);
...@@ -482,23 +482,23 @@ static void ttm_bo_cleanup_refs_or_queue(struct ttm_buffer_object *bo) ...@@ -482,23 +482,23 @@ static void ttm_bo_cleanup_refs_or_queue(struct ttm_buffer_object *bo)
/* Last resort, if we fail to allocate memory for the /* Last resort, if we fail to allocate memory for the
* fences block for the BO to become idle * fences block for the BO to become idle
*/ */
reservation_object_wait_timeout_rcu(bo->resv, true, false, reservation_object_wait_timeout_rcu(bo->base.resv, true, false,
30 * HZ); 30 * HZ);
spin_lock(&glob->lru_lock); spin_lock(&glob->lru_lock);
goto error; goto error;
} }
spin_lock(&glob->lru_lock); spin_lock(&glob->lru_lock);
ret = reservation_object_trylock(bo->resv) ? 0 : -EBUSY; ret = reservation_object_trylock(bo->base.resv) ? 0 : -EBUSY;
if (!ret) { if (!ret) {
if (reservation_object_test_signaled_rcu(&bo->base._resv, true)) { if (reservation_object_test_signaled_rcu(&bo->base._resv, true)) {
ttm_bo_del_from_lru(bo); ttm_bo_del_from_lru(bo);
spin_unlock(&glob->lru_lock); spin_unlock(&glob->lru_lock);
if (bo->resv != &bo->base._resv) if (bo->base.resv != &bo->base._resv)
reservation_object_unlock(&bo->base._resv); reservation_object_unlock(&bo->base._resv);
ttm_bo_cleanup_memtype_use(bo); ttm_bo_cleanup_memtype_use(bo);
reservation_object_unlock(bo->resv); reservation_object_unlock(bo->base.resv);
return; return;
} }
...@@ -514,9 +514,9 @@ static void ttm_bo_cleanup_refs_or_queue(struct ttm_buffer_object *bo) ...@@ -514,9 +514,9 @@ static void ttm_bo_cleanup_refs_or_queue(struct ttm_buffer_object *bo)
ttm_bo_add_to_lru(bo); ttm_bo_add_to_lru(bo);
} }
reservation_object_unlock(bo->resv); reservation_object_unlock(bo->base.resv);
} }
if (bo->resv != &bo->base._resv) if (bo->base.resv != &bo->base._resv)
reservation_object_unlock(&bo->base._resv); reservation_object_unlock(&bo->base._resv);
error: error:
...@@ -550,7 +550,7 @@ static int ttm_bo_cleanup_refs(struct ttm_buffer_object *bo, ...@@ -550,7 +550,7 @@ static int ttm_bo_cleanup_refs(struct ttm_buffer_object *bo,
int ret; int ret;
if (unlikely(list_empty(&bo->ddestroy))) if (unlikely(list_empty(&bo->ddestroy)))
resv = bo->resv; resv = bo->base.resv;
else else
resv = &bo->base._resv; resv = &bo->base._resv;
...@@ -563,7 +563,7 @@ static int ttm_bo_cleanup_refs(struct ttm_buffer_object *bo, ...@@ -563,7 +563,7 @@ static int ttm_bo_cleanup_refs(struct ttm_buffer_object *bo,
long lret; long lret;
if (unlock_resv) if (unlock_resv)
reservation_object_unlock(bo->resv); reservation_object_unlock(bo->base.resv);
spin_unlock(&glob->lru_lock); spin_unlock(&glob->lru_lock);
lret = reservation_object_wait_timeout_rcu(resv, true, lret = reservation_object_wait_timeout_rcu(resv, true,
...@@ -576,7 +576,7 @@ static int ttm_bo_cleanup_refs(struct ttm_buffer_object *bo, ...@@ -576,7 +576,7 @@ static int ttm_bo_cleanup_refs(struct ttm_buffer_object *bo,
return -EBUSY; return -EBUSY;
spin_lock(&glob->lru_lock); spin_lock(&glob->lru_lock);
if (unlock_resv && !reservation_object_trylock(bo->resv)) { if (unlock_resv && !reservation_object_trylock(bo->base.resv)) {
/* /*
* We raced, and lost, someone else holds the reservation now, * We raced, and lost, someone else holds the reservation now,
* and is probably busy in ttm_bo_cleanup_memtype_use. * and is probably busy in ttm_bo_cleanup_memtype_use.
...@@ -593,7 +593,7 @@ static int ttm_bo_cleanup_refs(struct ttm_buffer_object *bo, ...@@ -593,7 +593,7 @@ static int ttm_bo_cleanup_refs(struct ttm_buffer_object *bo,
if (ret || unlikely(list_empty(&bo->ddestroy))) { if (ret || unlikely(list_empty(&bo->ddestroy))) {
if (unlock_resv) if (unlock_resv)
reservation_object_unlock(bo->resv); reservation_object_unlock(bo->base.resv);
spin_unlock(&glob->lru_lock); spin_unlock(&glob->lru_lock);
return ret; return ret;
} }
...@@ -606,7 +606,7 @@ static int ttm_bo_cleanup_refs(struct ttm_buffer_object *bo, ...@@ -606,7 +606,7 @@ static int ttm_bo_cleanup_refs(struct ttm_buffer_object *bo,
ttm_bo_cleanup_memtype_use(bo); ttm_bo_cleanup_memtype_use(bo);
if (unlock_resv) if (unlock_resv)
reservation_object_unlock(bo->resv); reservation_object_unlock(bo->base.resv);
return 0; return 0;
} }
...@@ -632,14 +632,14 @@ static bool ttm_bo_delayed_delete(struct ttm_bo_device *bdev, bool remove_all) ...@@ -632,14 +632,14 @@ static bool ttm_bo_delayed_delete(struct ttm_bo_device *bdev, bool remove_all)
kref_get(&bo->list_kref); kref_get(&bo->list_kref);
list_move_tail(&bo->ddestroy, &removed); list_move_tail(&bo->ddestroy, &removed);
if (remove_all || bo->resv != &bo->base._resv) { if (remove_all || bo->base.resv != &bo->base._resv) {
spin_unlock(&glob->lru_lock); spin_unlock(&glob->lru_lock);
reservation_object_lock(bo->resv, NULL); reservation_object_lock(bo->base.resv, NULL);
spin_lock(&glob->lru_lock); spin_lock(&glob->lru_lock);
ttm_bo_cleanup_refs(bo, false, !remove_all, true); ttm_bo_cleanup_refs(bo, false, !remove_all, true);
} else if (reservation_object_trylock(bo->resv)) { } else if (reservation_object_trylock(bo->base.resv)) {
ttm_bo_cleanup_refs(bo, false, !remove_all, true); ttm_bo_cleanup_refs(bo, false, !remove_all, true);
} else { } else {
spin_unlock(&glob->lru_lock); spin_unlock(&glob->lru_lock);
...@@ -708,7 +708,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, ...@@ -708,7 +708,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo,
struct ttm_placement placement; struct ttm_placement placement;
int ret = 0; int ret = 0;
reservation_object_assert_held(bo->resv); reservation_object_assert_held(bo->base.resv);
placement.num_placement = 0; placement.num_placement = 0;
placement.num_busy_placement = 0; placement.num_busy_placement = 0;
...@@ -778,8 +778,8 @@ static bool ttm_bo_evict_swapout_allowable(struct ttm_buffer_object *bo, ...@@ -778,8 +778,8 @@ static bool ttm_bo_evict_swapout_allowable(struct ttm_buffer_object *bo,
{ {
bool ret = false; bool ret = false;
if (bo->resv == ctx->resv) { if (bo->base.resv == ctx->resv) {
reservation_object_assert_held(bo->resv); reservation_object_assert_held(bo->base.resv);
if (ctx->flags & TTM_OPT_FLAG_ALLOW_RES_EVICT if (ctx->flags & TTM_OPT_FLAG_ALLOW_RES_EVICT
|| !list_empty(&bo->ddestroy)) || !list_empty(&bo->ddestroy))
ret = true; ret = true;
...@@ -787,7 +787,7 @@ static bool ttm_bo_evict_swapout_allowable(struct ttm_buffer_object *bo, ...@@ -787,7 +787,7 @@ static bool ttm_bo_evict_swapout_allowable(struct ttm_buffer_object *bo,
if (busy) if (busy)
*busy = false; *busy = false;
} else { } else {
ret = reservation_object_trylock(bo->resv); ret = reservation_object_trylock(bo->base.resv);
*locked = ret; *locked = ret;
if (busy) if (busy)
*busy = !ret; *busy = !ret;
...@@ -815,10 +815,10 @@ static int ttm_mem_evict_wait_busy(struct ttm_buffer_object *busy_bo, ...@@ -815,10 +815,10 @@ static int ttm_mem_evict_wait_busy(struct ttm_buffer_object *busy_bo,
return -EBUSY; return -EBUSY;
if (ctx->interruptible) if (ctx->interruptible)
r = reservation_object_lock_interruptible(busy_bo->resv, r = reservation_object_lock_interruptible(busy_bo->base.resv,
ticket); ticket);
else else
r = reservation_object_lock(busy_bo->resv, ticket); r = reservation_object_lock(busy_bo->base.resv, ticket);
/* /*
* TODO: It would be better to keep the BO locked until allocation is at * TODO: It would be better to keep the BO locked until allocation is at
...@@ -826,7 +826,7 @@ static int ttm_mem_evict_wait_busy(struct ttm_buffer_object *busy_bo, ...@@ -826,7 +826,7 @@ static int ttm_mem_evict_wait_busy(struct ttm_buffer_object *busy_bo,
* of TTM. * of TTM.
*/ */
if (!r) if (!r)
reservation_object_unlock(busy_bo->resv); reservation_object_unlock(busy_bo->base.resv);
return r == -EDEADLK ? -EBUSY : r; return r == -EDEADLK ? -EBUSY : r;
} }
...@@ -852,7 +852,7 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev, ...@@ -852,7 +852,7 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
if (!ttm_bo_evict_swapout_allowable(bo, ctx, &locked, if (!ttm_bo_evict_swapout_allowable(bo, ctx, &locked,
&busy)) { &busy)) {
if (busy && !busy_bo && ticket != if (busy && !busy_bo && ticket !=
reservation_object_locking_ctx(bo->resv)) reservation_object_locking_ctx(bo->base.resv))
busy_bo = bo; busy_bo = bo;
continue; continue;
} }
...@@ -860,7 +860,7 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev, ...@@ -860,7 +860,7 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
if (place && !bdev->driver->eviction_valuable(bo, if (place && !bdev->driver->eviction_valuable(bo,
place)) { place)) {
if (locked) if (locked)
reservation_object_unlock(bo->resv); reservation_object_unlock(bo->base.resv);
continue; continue;
} }
break; break;
...@@ -932,9 +932,9 @@ static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo, ...@@ -932,9 +932,9 @@ static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
spin_unlock(&man->move_lock); spin_unlock(&man->move_lock);
if (fence) { if (fence) {
reservation_object_add_shared_fence(bo->resv, fence); reservation_object_add_shared_fence(bo->base.resv, fence);
ret = reservation_object_reserve_shared(bo->resv, 1); ret = reservation_object_reserve_shared(bo->base.resv, 1);
if (unlikely(ret)) { if (unlikely(ret)) {
dma_fence_put(fence); dma_fence_put(fence);
return ret; return ret;
...@@ -961,7 +961,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo, ...@@ -961,7 +961,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
struct ww_acquire_ctx *ticket; struct ww_acquire_ctx *ticket;
int ret; int ret;
ticket = reservation_object_locking_ctx(bo->resv); ticket = reservation_object_locking_ctx(bo->base.resv);
do { do {
ret = (*man->func->get_node)(man, bo, place, mem); ret = (*man->func->get_node)(man, bo, place, mem);
if (unlikely(ret != 0)) if (unlikely(ret != 0))
...@@ -1091,7 +1091,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo, ...@@ -1091,7 +1091,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
bool type_found = false; bool type_found = false;
int i, ret; int i, ret;
ret = reservation_object_reserve_shared(bo->resv, 1); ret = reservation_object_reserve_shared(bo->base.resv, 1);
if (unlikely(ret)) if (unlikely(ret))
return ret; return ret;
...@@ -1172,7 +1172,7 @@ static int ttm_bo_move_buffer(struct ttm_buffer_object *bo, ...@@ -1172,7 +1172,7 @@ static int ttm_bo_move_buffer(struct ttm_buffer_object *bo,
int ret = 0; int ret = 0;
struct ttm_mem_reg mem; struct ttm_mem_reg mem;
reservation_object_assert_held(bo->resv); reservation_object_assert_held(bo->base.resv);
mem.num_pages = bo->num_pages; mem.num_pages = bo->num_pages;
mem.size = mem.num_pages << PAGE_SHIFT; mem.size = mem.num_pages << PAGE_SHIFT;
...@@ -1242,7 +1242,7 @@ int ttm_bo_validate(struct ttm_buffer_object *bo, ...@@ -1242,7 +1242,7 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
int ret; int ret;
uint32_t new_flags; uint32_t new_flags;
reservation_object_assert_held(bo->resv); reservation_object_assert_held(bo->base.resv);
/* /*
* Check whether we need to move buffer. * Check whether we need to move buffer.
*/ */
...@@ -1334,7 +1334,7 @@ int ttm_bo_init_reserved(struct ttm_bo_device *bdev, ...@@ -1334,7 +1334,7 @@ int ttm_bo_init_reserved(struct ttm_bo_device *bdev,
if (resv) { if (resv) {
bo->resv = resv; bo->resv = resv;
bo->base.resv = resv; bo->base.resv = resv;
reservation_object_assert_held(bo->resv); reservation_object_assert_held(bo->base.resv);
} else { } else {
bo->resv = &bo->base._resv; bo->resv = &bo->base._resv;
bo->base.resv = &bo->base._resv; bo->base.resv = &bo->base._resv;
...@@ -1362,7 +1362,7 @@ int ttm_bo_init_reserved(struct ttm_bo_device *bdev, ...@@ -1362,7 +1362,7 @@ int ttm_bo_init_reserved(struct ttm_bo_device *bdev,
* since otherwise lockdep will be angered in radeon. * since otherwise lockdep will be angered in radeon.
*/ */
if (!resv) { if (!resv) {
locked = reservation_object_trylock(bo->resv); locked = reservation_object_trylock(bo->base.resv);
WARN_ON(!locked); WARN_ON(!locked);
} }
...@@ -1806,13 +1806,13 @@ int ttm_bo_wait(struct ttm_buffer_object *bo, ...@@ -1806,13 +1806,13 @@ int ttm_bo_wait(struct ttm_buffer_object *bo,
long timeout = 15 * HZ; long timeout = 15 * HZ;
if (no_wait) { if (no_wait) {
if (reservation_object_test_signaled_rcu(bo->resv, true)) if (reservation_object_test_signaled_rcu(bo->base.resv, true))
return 0; return 0;
else else
return -EBUSY; return -EBUSY;
} }
timeout = reservation_object_wait_timeout_rcu(bo->resv, true, timeout = reservation_object_wait_timeout_rcu(bo->base.resv, true,
interruptible, timeout); interruptible, timeout);
if (timeout < 0) if (timeout < 0)
return timeout; return timeout;
...@@ -1820,7 +1820,7 @@ int ttm_bo_wait(struct ttm_buffer_object *bo, ...@@ -1820,7 +1820,7 @@ int ttm_bo_wait(struct ttm_buffer_object *bo,
if (timeout == 0) if (timeout == 0)
return -EBUSY; return -EBUSY;
reservation_object_add_excl_fence(bo->resv, NULL); reservation_object_add_excl_fence(bo->base.resv, NULL);
return 0; return 0;
} }
EXPORT_SYMBOL(ttm_bo_wait); EXPORT_SYMBOL(ttm_bo_wait);
...@@ -1936,7 +1936,7 @@ int ttm_bo_swapout(struct ttm_bo_global *glob, struct ttm_operation_ctx *ctx) ...@@ -1936,7 +1936,7 @@ int ttm_bo_swapout(struct ttm_bo_global *glob, struct ttm_operation_ctx *ctx)
* already swapped buffer. * already swapped buffer.
*/ */
if (locked) if (locked)
reservation_object_unlock(bo->resv); reservation_object_unlock(bo->base.resv);
kref_put(&bo->list_kref, ttm_bo_release_list); kref_put(&bo->list_kref, ttm_bo_release_list);
return ret; return ret;
} }
...@@ -1974,14 +1974,14 @@ int ttm_bo_wait_unreserved(struct ttm_buffer_object *bo) ...@@ -1974,14 +1974,14 @@ int ttm_bo_wait_unreserved(struct ttm_buffer_object *bo)
ret = mutex_lock_interruptible(&bo->wu_mutex); ret = mutex_lock_interruptible(&bo->wu_mutex);
if (unlikely(ret != 0)) if (unlikely(ret != 0))
return -ERESTARTSYS; return -ERESTARTSYS;
if (!reservation_object_is_locked(bo->resv)) if (!reservation_object_is_locked(bo->base.resv))
goto out_unlock; goto out_unlock;
ret = reservation_object_lock_interruptible(bo->resv, NULL); ret = reservation_object_lock_interruptible(bo->base.resv, NULL);
if (ret == -EINTR) if (ret == -EINTR)
ret = -ERESTARTSYS; ret = -ERESTARTSYS;
if (unlikely(ret != 0)) if (unlikely(ret != 0))
goto out_unlock; goto out_unlock;
reservation_object_unlock(bo->resv); reservation_object_unlock(bo->base.resv);
out_unlock: out_unlock:
mutex_unlock(&bo->wu_mutex); mutex_unlock(&bo->wu_mutex);
......
...@@ -517,9 +517,9 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo, ...@@ -517,9 +517,9 @@ 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.resv = &fbo->base.base._resv; fbo->base.base.resv = &fbo->base.base._resv;
reservation_object_init(fbo->base.resv); reservation_object_init(fbo->base.base.resv);
ret = reservation_object_trylock(fbo->base.resv); ret = reservation_object_trylock(fbo->base.base.resv);
WARN_ON(!ret); WARN_ON(!ret);
*new_obj = &fbo->base; *new_obj = &fbo->base;
...@@ -689,7 +689,7 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo, ...@@ -689,7 +689,7 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
int ret; int ret;
struct ttm_buffer_object *ghost_obj; struct ttm_buffer_object *ghost_obj;
reservation_object_add_excl_fence(bo->resv, fence); reservation_object_add_excl_fence(bo->base.resv, fence);
if (evict) { if (evict) {
ret = ttm_bo_wait(bo, false, false); ret = ttm_bo_wait(bo, false, false);
if (ret) if (ret)
...@@ -716,7 +716,7 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo, ...@@ -716,7 +716,7 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
if (ret) if (ret)
return ret; return ret;
reservation_object_add_excl_fence(ghost_obj->resv, fence); reservation_object_add_excl_fence(ghost_obj->base.resv, fence);
/** /**
* If we're not moving to fixed memory, the TTM object * If we're not moving to fixed memory, the TTM object
...@@ -752,7 +752,7 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo, ...@@ -752,7 +752,7 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo,
int ret; int ret;
reservation_object_add_excl_fence(bo->resv, fence); reservation_object_add_excl_fence(bo->base.resv, fence);
if (!evict) { if (!evict) {
struct ttm_buffer_object *ghost_obj; struct ttm_buffer_object *ghost_obj;
...@@ -772,7 +772,7 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo, ...@@ -772,7 +772,7 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo,
if (ret) if (ret)
return ret; return ret;
reservation_object_add_excl_fence(ghost_obj->resv, fence); reservation_object_add_excl_fence(ghost_obj->base.resv, fence);
/** /**
* If we're not moving to fixed memory, the TTM object * If we're not moving to fixed memory, the TTM object
...@@ -841,7 +841,7 @@ int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo) ...@@ -841,7 +841,7 @@ int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo)
if (ret) if (ret)
return ret; return ret;
ret = reservation_object_copy_fences(ghost->resv, bo->resv); ret = reservation_object_copy_fences(ghost->base.resv, bo->base.resv);
/* Last resort, wait for the BO to be idle when we are OOM */ /* Last resort, wait for the BO to be idle when we are OOM */
if (ret) if (ret)
ttm_bo_wait(bo, false, false); ttm_bo_wait(bo, false, false);
......
...@@ -71,7 +71,7 @@ static vm_fault_t ttm_bo_vm_fault_idle(struct ttm_buffer_object *bo, ...@@ -71,7 +71,7 @@ static vm_fault_t ttm_bo_vm_fault_idle(struct ttm_buffer_object *bo,
ttm_bo_get(bo); ttm_bo_get(bo);
up_read(&vmf->vma->vm_mm->mmap_sem); up_read(&vmf->vma->vm_mm->mmap_sem);
(void) dma_fence_wait(bo->moving, true); (void) dma_fence_wait(bo->moving, true);
reservation_object_unlock(bo->resv); reservation_object_unlock(bo->base.resv);
ttm_bo_put(bo); ttm_bo_put(bo);
goto out_unlock; goto out_unlock;
} }
...@@ -131,7 +131,7 @@ static vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf) ...@@ -131,7 +131,7 @@ static vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf)
* for reserve, and if it fails, retry the fault after waiting * for reserve, and if it fails, retry the fault after waiting
* for the buffer to become unreserved. * for the buffer to become unreserved.
*/ */
if (unlikely(!reservation_object_trylock(bo->resv))) { if (unlikely(!reservation_object_trylock(bo->base.resv))) {
if (vmf->flags & FAULT_FLAG_ALLOW_RETRY) { if (vmf->flags & FAULT_FLAG_ALLOW_RETRY) {
if (!(vmf->flags & FAULT_FLAG_RETRY_NOWAIT)) { if (!(vmf->flags & FAULT_FLAG_RETRY_NOWAIT)) {
ttm_bo_get(bo); ttm_bo_get(bo);
...@@ -296,7 +296,7 @@ static vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf) ...@@ -296,7 +296,7 @@ static vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf)
out_io_unlock: out_io_unlock:
ttm_mem_io_unlock(man); ttm_mem_io_unlock(man);
out_unlock: out_unlock:
reservation_object_unlock(bo->resv); reservation_object_unlock(bo->base.resv);
return ret; return ret;
} }
......
...@@ -39,7 +39,7 @@ static void ttm_eu_backoff_reservation_reverse(struct list_head *list, ...@@ -39,7 +39,7 @@ static void ttm_eu_backoff_reservation_reverse(struct list_head *list,
list_for_each_entry_continue_reverse(entry, list, head) { list_for_each_entry_continue_reverse(entry, list, head) {
struct ttm_buffer_object *bo = entry->bo; struct ttm_buffer_object *bo = entry->bo;
reservation_object_unlock(bo->resv); reservation_object_unlock(bo->base.resv);
} }
} }
...@@ -71,7 +71,7 @@ void ttm_eu_backoff_reservation(struct ww_acquire_ctx *ticket, ...@@ -71,7 +71,7 @@ void ttm_eu_backoff_reservation(struct ww_acquire_ctx *ticket,
if (list_empty(&bo->lru)) if (list_empty(&bo->lru))
ttm_bo_add_to_lru(bo); ttm_bo_add_to_lru(bo);
reservation_object_unlock(bo->resv); reservation_object_unlock(bo->base.resv);
} }
spin_unlock(&glob->lru_lock); spin_unlock(&glob->lru_lock);
...@@ -114,7 +114,7 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket, ...@@ -114,7 +114,7 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket,
ret = __ttm_bo_reserve(bo, intr, (ticket == NULL), ticket); ret = __ttm_bo_reserve(bo, intr, (ticket == NULL), ticket);
if (!ret && unlikely(atomic_read(&bo->cpu_writers) > 0)) { if (!ret && unlikely(atomic_read(&bo->cpu_writers) > 0)) {
reservation_object_unlock(bo->resv); reservation_object_unlock(bo->base.resv);
ret = -EBUSY; ret = -EBUSY;
...@@ -130,7 +130,7 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket, ...@@ -130,7 +130,7 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket,
if (!entry->num_shared) if (!entry->num_shared)
continue; continue;
ret = reservation_object_reserve_shared(bo->resv, ret = reservation_object_reserve_shared(bo->base.resv,
entry->num_shared); entry->num_shared);
if (!ret) if (!ret)
continue; continue;
...@@ -144,16 +144,16 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket, ...@@ -144,16 +144,16 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket,
if (ret == -EDEADLK) { if (ret == -EDEADLK) {
if (intr) { if (intr) {
ret = reservation_object_lock_slow_interruptible(bo->resv, ret = reservation_object_lock_slow_interruptible(bo->base.resv,
ticket); ticket);
} else { } else {
reservation_object_lock_slow(bo->resv, ticket); reservation_object_lock_slow(bo->base.resv, ticket);
ret = 0; ret = 0;
} }
} }
if (!ret && entry->num_shared) if (!ret && entry->num_shared)
ret = reservation_object_reserve_shared(bo->resv, ret = reservation_object_reserve_shared(bo->base.resv,
entry->num_shared); entry->num_shared);
if (unlikely(ret != 0)) { if (unlikely(ret != 0)) {
...@@ -201,14 +201,14 @@ void ttm_eu_fence_buffer_objects(struct ww_acquire_ctx *ticket, ...@@ -201,14 +201,14 @@ void ttm_eu_fence_buffer_objects(struct ww_acquire_ctx *ticket,
list_for_each_entry(entry, list, head) { list_for_each_entry(entry, list, head) {
bo = entry->bo; bo = entry->bo;
if (entry->num_shared) if (entry->num_shared)
reservation_object_add_shared_fence(bo->resv, fence); reservation_object_add_shared_fence(bo->base.resv, fence);
else else
reservation_object_add_excl_fence(bo->resv, fence); reservation_object_add_excl_fence(bo->base.resv, fence);
if (list_empty(&bo->lru)) if (list_empty(&bo->lru))
ttm_bo_add_to_lru(bo); ttm_bo_add_to_lru(bo);
else else
ttm_bo_move_to_lru_tail(bo, NULL); ttm_bo_move_to_lru_tail(bo, NULL);
reservation_object_unlock(bo->resv); reservation_object_unlock(bo->base.resv);
} }
spin_unlock(&glob->lru_lock); spin_unlock(&glob->lru_lock);
if (ticket) if (ticket)
......
...@@ -48,7 +48,7 @@ int ttm_tt_create(struct ttm_buffer_object *bo, bool zero_alloc) ...@@ -48,7 +48,7 @@ int ttm_tt_create(struct ttm_buffer_object *bo, bool zero_alloc)
struct ttm_bo_device *bdev = bo->bdev; struct ttm_bo_device *bdev = bo->bdev;
uint32_t page_flags = 0; uint32_t page_flags = 0;
reservation_object_assert_held(bo->resv); reservation_object_assert_held(bo->base.resv);
if (bdev->need_dma32) if (bdev->need_dma32)
page_flags |= TTM_PAGE_FLAG_DMA32; page_flags |= TTM_PAGE_FLAG_DMA32;
......
...@@ -654,14 +654,14 @@ static inline int __ttm_bo_reserve(struct ttm_buffer_object *bo, ...@@ -654,14 +654,14 @@ static inline int __ttm_bo_reserve(struct ttm_buffer_object *bo,
if (WARN_ON(ticket)) if (WARN_ON(ticket))
return -EBUSY; return -EBUSY;
success = reservation_object_trylock(bo->resv); success = reservation_object_trylock(bo->base.resv);
return success ? 0 : -EBUSY; return success ? 0 : -EBUSY;
} }
if (interruptible) if (interruptible)
ret = reservation_object_lock_interruptible(bo->resv, ticket); ret = reservation_object_lock_interruptible(bo->base.resv, ticket);
else else
ret = reservation_object_lock(bo->resv, ticket); ret = reservation_object_lock(bo->base.resv, ticket);
if (ret == -EINTR) if (ret == -EINTR)
return -ERESTARTSYS; return -ERESTARTSYS;
return ret; return ret;
...@@ -745,10 +745,10 @@ static inline int ttm_bo_reserve_slowpath(struct ttm_buffer_object *bo, ...@@ -745,10 +745,10 @@ static inline int ttm_bo_reserve_slowpath(struct ttm_buffer_object *bo,
WARN_ON(!kref_read(&bo->kref)); WARN_ON(!kref_read(&bo->kref));
if (interruptible) if (interruptible)
ret = reservation_object_lock_slow_interruptible(bo->resv, ret = reservation_object_lock_slow_interruptible(bo->base.resv,
ticket); ticket);
else else
reservation_object_lock_slow(bo->resv, ticket); reservation_object_lock_slow(bo->base.resv, ticket);
if (likely(ret == 0)) if (likely(ret == 0))
ttm_bo_del_sub_from_lru(bo); ttm_bo_del_sub_from_lru(bo);
...@@ -773,7 +773,7 @@ static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo) ...@@ -773,7 +773,7 @@ static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)
else else
ttm_bo_move_to_lru_tail(bo, NULL); ttm_bo_move_to_lru_tail(bo, NULL);
spin_unlock(&bo->bdev->glob->lru_lock); spin_unlock(&bo->bdev->glob->lru_lock);
reservation_object_unlock(bo->resv); reservation_object_unlock(bo->base.resv);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment