Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 179904
b: refs/heads/master
c: 1a961ce
h: refs/heads/master
v: v3
  • Loading branch information
Luca Barbieri authored and Dave Airlie committed Jan 25, 2010
1 parent ab683f3 commit 79a3cc3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 32 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: 8471a26b9c36c965d278020cc0699e2e95d120e5
refs/heads/master: 1a961ce09fe39df9a1b796df98794fd32c76c413
54 changes: 23 additions & 31 deletions trunk/drivers/gpu/drm/ttm/ttm_bo.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,52 +524,44 @@ static int ttm_bo_cleanup_refs(struct ttm_buffer_object *bo, bool remove_all)
static int ttm_bo_delayed_delete(struct ttm_bo_device *bdev, bool remove_all)
{
struct ttm_bo_global *glob = bdev->glob;
struct ttm_buffer_object *entry, *nentry;
struct list_head *list, *next;
int ret;
struct ttm_buffer_object *entry = NULL;
int ret = 0;

spin_lock(&glob->lru_lock);
list_for_each_safe(list, next, &bdev->ddestroy) {
entry = list_entry(list, struct ttm_buffer_object, ddestroy);
nentry = NULL;
if (list_empty(&bdev->ddestroy))
goto out_unlock;

/*
* Protect the next list entry from destruction while we
* unlock the lru_lock.
*/
entry = list_first_entry(&bdev->ddestroy,
struct ttm_buffer_object, ddestroy);
kref_get(&entry->list_kref);

for (;;) {
struct ttm_buffer_object *nentry = NULL;

if (next != &bdev->ddestroy) {
nentry = list_entry(next, struct ttm_buffer_object,
ddestroy);
if (entry->ddestroy.next != &bdev->ddestroy) {
nentry = list_first_entry(&entry->ddestroy,
struct ttm_buffer_object, ddestroy);
kref_get(&nentry->list_kref);
}
kref_get(&entry->list_kref);

spin_unlock(&glob->lru_lock);
ret = ttm_bo_cleanup_refs(entry, remove_all);
kref_put(&entry->list_kref, ttm_bo_release_list);
entry = nentry;

if (ret || !entry)
goto out;

spin_lock(&glob->lru_lock);
if (nentry) {
bool next_onlist = !list_empty(next);
spin_unlock(&glob->lru_lock);
kref_put(&nentry->list_kref, ttm_bo_release_list);
spin_lock(&glob->lru_lock);
/*
* Someone might have raced us and removed the
* next entry from the list. We don't bother restarting
* list traversal.
*/

if (!next_onlist)
break;
}
if (ret)
if (list_empty(&entry->ddestroy))
break;
}
ret = !list_empty(&bdev->ddestroy);
spin_unlock(&glob->lru_lock);

out_unlock:
spin_unlock(&glob->lru_lock);
out:
if (entry)
kref_put(&entry->list_kref, ttm_bo_release_list);
return ret;
}

Expand Down

0 comments on commit 79a3cc3

Please sign in to comment.