Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 177048
b: refs/heads/master
c: 9c51ba1
h: refs/heads/master
v: v3
  • Loading branch information
Thomas Hellstrom authored and Dave Airlie committed Dec 16, 2009
1 parent 7e68beb commit d8d3278
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: aaa207369436d04bb85382ddbb688a5b9461fd21
refs/heads/master: 9c51ba1db37cab780f38b2210913959f22d7b830
36 changes: 31 additions & 5 deletions trunk/drivers/gpu/drm/ttm/ttm_bo.c
Original file line number Diff line number Diff line change
Expand Up @@ -685,19 +685,45 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
struct ttm_buffer_object *bo;
int ret, put_count = 0;

retry:
spin_lock(&glob->lru_lock);
if (list_empty(&man->lru)) {
spin_unlock(&glob->lru_lock);
return -EBUSY;
}

bo = list_first_entry(&man->lru, struct ttm_buffer_object, lru);
kref_get(&bo->list_kref);
ret = ttm_bo_reserve_locked(bo, interruptible, no_wait, false, 0);
if (likely(ret == 0))
put_count = ttm_bo_del_from_lru(bo);

ret = ttm_bo_reserve_locked(bo, false, true, false, 0);

if (unlikely(ret == -EBUSY)) {
spin_unlock(&glob->lru_lock);
if (likely(!no_wait))
ret = ttm_bo_wait_unreserved(bo, interruptible);

kref_put(&bo->list_kref, ttm_bo_release_list);

/**
* We *need* to retry after releasing the lru lock.
*/

if (unlikely(ret != 0))
return ret;
goto retry;
}

put_count = ttm_bo_del_from_lru(bo);
spin_unlock(&glob->lru_lock);
if (unlikely(ret != 0))
return ret;

BUG_ON(ret != 0);

while (put_count--)
kref_put(&bo->list_kref, ttm_bo_ref_bug);

ret = ttm_bo_evict(bo, interruptible, no_wait);
ttm_bo_unreserve(bo);

kref_put(&bo->list_kref, ttm_bo_release_list);
return ret;
}
Expand Down

0 comments on commit d8d3278

Please sign in to comment.