struct ttm_bo_device *bdev = bo->bdev;
struct ttm_mem_type_manager *man;
- reservation_object_assert_held(bo->resv);
+ reservation_object_assert_held(bo->base.resv);
if (!list_empty(&bo->lru))
return;
void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo,
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_add_to_lru(bo);
if (!pos->first)
continue;
- reservation_object_assert_held(pos->first->resv);
- reservation_object_assert_held(pos->last->resv);
+ reservation_object_assert_held(pos->first->base.resv);
+ reservation_object_assert_held(pos->last->base.resv);
man = &pos->first->bdev->man[TTM_PL_TT];
list_bulk_move_tail(&man->lru[i], &pos->first->lru,
if (!pos->first)
continue;
- reservation_object_assert_held(pos->first->resv);
- reservation_object_assert_held(pos->last->resv);
+ reservation_object_assert_held(pos->first->base.resv);
+ reservation_object_assert_held(pos->last->base.resv);
man = &pos->first->bdev->man[TTM_PL_VRAM];
list_bulk_move_tail(&man->lru[i], &pos->first->lru,
if (!pos->first)
continue;
- reservation_object_assert_held(pos->first->resv);
- reservation_object_assert_held(pos->last->resv);
+ reservation_object_assert_held(pos->first->base.resv);
+ reservation_object_assert_held(pos->last->base.resv);
lru = &pos->first->bdev->glob->swap_lru[i];
list_bulk_move_tail(lru, &pos->first->swap, &pos->last->swap);
{
int r;
- if (bo->resv == &bo->base._resv)
+ if (bo->base.resv == &bo->base._resv)
return 0;
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)
reservation_object_unlock(&bo->base._resv);
for (i = 0; fobj && i < fobj->shared_count; ++i) {
fence = rcu_dereference_protected(fobj->shared[i],
- reservation_object_held(bo->resv));
+ reservation_object_held(bo->base.resv));
if (!fence->ops->signaled)
dma_fence_enable_sw_signaling(fence);
/* Last resort, if we fail to allocate memory for the
* 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);
spin_lock(&glob->lru_lock);
goto error;
}
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 (reservation_object_test_signaled_rcu(&bo->base._resv, true)) {
ttm_bo_del_from_lru(bo);
spin_unlock(&glob->lru_lock);
- if (bo->resv != &bo->base._resv)
+ if (bo->base.resv != &bo->base._resv)
reservation_object_unlock(&bo->base._resv);
ttm_bo_cleanup_memtype_use(bo);
- reservation_object_unlock(bo->resv);
+ reservation_object_unlock(bo->base.resv);
return;
}
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);
error:
int ret;
if (unlikely(list_empty(&bo->ddestroy)))
- resv = bo->resv;
+ resv = bo->base.resv;
else
resv = &bo->base._resv;
long lret;
if (unlock_resv)
- reservation_object_unlock(bo->resv);
+ reservation_object_unlock(bo->base.resv);
spin_unlock(&glob->lru_lock);
lret = reservation_object_wait_timeout_rcu(resv, true,
return -EBUSY;
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,
* and is probably busy in ttm_bo_cleanup_memtype_use.
if (ret || unlikely(list_empty(&bo->ddestroy))) {
if (unlock_resv)
- reservation_object_unlock(bo->resv);
+ reservation_object_unlock(bo->base.resv);
spin_unlock(&glob->lru_lock);
return ret;
}
ttm_bo_cleanup_memtype_use(bo);
if (unlock_resv)
- reservation_object_unlock(bo->resv);
+ reservation_object_unlock(bo->base.resv);
return 0;
}
kref_get(&bo->list_kref);
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);
- reservation_object_lock(bo->resv, NULL);
+ reservation_object_lock(bo->base.resv, NULL);
spin_lock(&glob->lru_lock);
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);
} else {
spin_unlock(&glob->lru_lock);
struct ttm_placement placement;
int ret = 0;
- reservation_object_assert_held(bo->resv);
+ reservation_object_assert_held(bo->base.resv);
placement.num_placement = 0;
placement.num_busy_placement = 0;
{
bool ret = false;
- if (bo->resv == ctx->resv) {
- reservation_object_assert_held(bo->resv);
+ if (bo->base.resv == ctx->resv) {
+ reservation_object_assert_held(bo->base.resv);
if (ctx->flags & TTM_OPT_FLAG_ALLOW_RES_EVICT
|| !list_empty(&bo->ddestroy))
ret = true;
if (busy)
*busy = false;
} else {
- ret = reservation_object_trylock(bo->resv);
+ ret = reservation_object_trylock(bo->base.resv);
*locked = ret;
if (busy)
*busy = !ret;
return -EBUSY;
if (ctx->interruptible)
- r = reservation_object_lock_interruptible(busy_bo->resv,
+ r = reservation_object_lock_interruptible(busy_bo->base.resv,
ticket);
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
* of TTM.
*/
if (!r)
- reservation_object_unlock(busy_bo->resv);
+ reservation_object_unlock(busy_bo->base.resv);
return r == -EDEADLK ? -EBUSY : r;
}
if (!ttm_bo_evict_swapout_allowable(bo, ctx, &locked,
&busy)) {
if (busy && !busy_bo && ticket !=
- reservation_object_locking_ctx(bo->resv))
+ reservation_object_locking_ctx(bo->base.resv))
busy_bo = bo;
continue;
}
if (place && !bdev->driver->eviction_valuable(bo,
place)) {
if (locked)
- reservation_object_unlock(bo->resv);
+ reservation_object_unlock(bo->base.resv);
continue;
}
break;
spin_unlock(&man->move_lock);
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)) {
dma_fence_put(fence);
return ret;
struct ww_acquire_ctx *ticket;
int ret;
- ticket = reservation_object_locking_ctx(bo->resv);
+ ticket = reservation_object_locking_ctx(bo->base.resv);
do {
ret = (*man->func->get_node)(man, bo, place, mem);
if (unlikely(ret != 0))
bool type_found = false;
int i, ret;
- ret = reservation_object_reserve_shared(bo->resv, 1);
+ ret = reservation_object_reserve_shared(bo->base.resv, 1);
if (unlikely(ret))
return ret;
int ret = 0;
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.size = mem.num_pages << PAGE_SHIFT;
int ret;
uint32_t new_flags;
- reservation_object_assert_held(bo->resv);
+ reservation_object_assert_held(bo->base.resv);
/*
* Check whether we need to move buffer.
*/
if (resv) {
bo->resv = resv;
bo->base.resv = resv;
- reservation_object_assert_held(bo->resv);
+ reservation_object_assert_held(bo->base.resv);
} else {
bo->resv = &bo->base._resv;
bo->base.resv = &bo->base._resv;
* since otherwise lockdep will be angered in radeon.
*/
if (!resv) {
- locked = reservation_object_trylock(bo->resv);
+ locked = reservation_object_trylock(bo->base.resv);
WARN_ON(!locked);
}
long timeout = 15 * HZ;
if (no_wait) {
- if (reservation_object_test_signaled_rcu(bo->resv, true))
+ if (reservation_object_test_signaled_rcu(bo->base.resv, true))
return 0;
else
return -EBUSY;
}
- timeout = reservation_object_wait_timeout_rcu(bo->resv, true,
+ timeout = reservation_object_wait_timeout_rcu(bo->base.resv, true,
interruptible, timeout);
if (timeout < 0)
return timeout;
if (timeout == 0)
return -EBUSY;
- reservation_object_add_excl_fence(bo->resv, NULL);
+ reservation_object_add_excl_fence(bo->base.resv, NULL);
return 0;
}
EXPORT_SYMBOL(ttm_bo_wait);
* already swapped buffer.
*/
if (locked)
- reservation_object_unlock(bo->resv);
+ reservation_object_unlock(bo->base.resv);
kref_put(&bo->list_kref, ttm_bo_release_list);
return ret;
}
ret = mutex_lock_interruptible(&bo->wu_mutex);
if (unlikely(ret != 0))
return -ERESTARTSYS;
- if (!reservation_object_is_locked(bo->resv))
+ if (!reservation_object_is_locked(bo->base.resv))
goto out_unlock;
- ret = reservation_object_lock_interruptible(bo->resv, NULL);
+ ret = reservation_object_lock_interruptible(bo->base.resv, NULL);
if (ret == -EINTR)
ret = -ERESTARTSYS;
if (unlikely(ret != 0))
goto out_unlock;
- reservation_object_unlock(bo->resv);
+ reservation_object_unlock(bo->base.resv);
out_unlock:
mutex_unlock(&bo->wu_mutex);
list_for_each_entry_continue_reverse(entry, list, head) {
struct ttm_buffer_object *bo = entry->bo;
- reservation_object_unlock(bo->resv);
+ reservation_object_unlock(bo->base.resv);
}
}
if (list_empty(&bo->lru))
ttm_bo_add_to_lru(bo);
- reservation_object_unlock(bo->resv);
+ reservation_object_unlock(bo->base.resv);
}
spin_unlock(&glob->lru_lock);
ret = __ttm_bo_reserve(bo, intr, (ticket == NULL), ticket);
if (!ret && unlikely(atomic_read(&bo->cpu_writers) > 0)) {
- reservation_object_unlock(bo->resv);
+ reservation_object_unlock(bo->base.resv);
ret = -EBUSY;
if (!entry->num_shared)
continue;
- ret = reservation_object_reserve_shared(bo->resv,
+ ret = reservation_object_reserve_shared(bo->base.resv,
entry->num_shared);
if (!ret)
continue;
if (ret == -EDEADLK) {
if (intr) {
- ret = reservation_object_lock_slow_interruptible(bo->resv,
+ ret = reservation_object_lock_slow_interruptible(bo->base.resv,
ticket);
} else {
- reservation_object_lock_slow(bo->resv, ticket);
+ reservation_object_lock_slow(bo->base.resv, ticket);
ret = 0;
}
}
if (!ret && entry->num_shared)
- ret = reservation_object_reserve_shared(bo->resv,
+ ret = reservation_object_reserve_shared(bo->base.resv,
entry->num_shared);
if (unlikely(ret != 0)) {
list_for_each_entry(entry, list, head) {
bo = entry->bo;
if (entry->num_shared)
- reservation_object_add_shared_fence(bo->resv, fence);
+ reservation_object_add_shared_fence(bo->base.resv, fence);
else
- reservation_object_add_excl_fence(bo->resv, fence);
+ reservation_object_add_excl_fence(bo->base.resv, fence);
if (list_empty(&bo->lru))
ttm_bo_add_to_lru(bo);
else
ttm_bo_move_to_lru_tail(bo, NULL);
- reservation_object_unlock(bo->resv);
+ reservation_object_unlock(bo->base.resv);
}
spin_unlock(&glob->lru_lock);
if (ticket)