Skip to content

Commit

Permalink
drm/ttm: Memory accounting rework.
Browse files Browse the repository at this point in the history
Use inclusive zones to simplify accounting and its sysfs representation.
Use DMA32 accounting where applicable.

Add a sysfs interface to make the heuristically determined limits
readable and configurable.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Dave Airlie <airlied@linux.ie>
  • Loading branch information
Thomas Hellstrom authored and Dave Airlie committed Aug 19, 2009
1 parent e9840be commit 5fd9cba
Show file tree
Hide file tree
Showing 6 changed files with 453 additions and 119 deletions.
6 changes: 3 additions & 3 deletions drivers/gpu/drm/ttm/ttm_bo.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static void ttm_bo_release_list(struct kref *list_kref)
if (bo->destroy)
bo->destroy(bo);
else {
ttm_mem_global_free(bdev->mem_glob, bo->acc_size, false);
ttm_mem_global_free(bdev->mem_glob, bo->acc_size);
kfree(bo);
}
}
Expand Down Expand Up @@ -1065,14 +1065,14 @@ int ttm_buffer_object_create(struct ttm_bo_device *bdev,

size_t acc_size =
ttm_bo_size(bdev, (size + PAGE_SIZE - 1) >> PAGE_SHIFT);
ret = ttm_mem_global_alloc(mem_glob, acc_size, false, false, false);
ret = ttm_mem_global_alloc(mem_glob, acc_size, false, false);
if (unlikely(ret != 0))
return ret;

bo = kzalloc(sizeof(*bo), GFP_KERNEL);

if (unlikely(bo == NULL)) {
ttm_mem_global_free(mem_glob, acc_size, false);
ttm_mem_global_free(mem_glob, acc_size);
return -ENOMEM;
}

Expand Down
4 changes: 1 addition & 3 deletions drivers/gpu/drm/ttm/ttm_global.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ int ttm_global_item_ref(struct ttm_global_reference *ref)

mutex_lock(&item->mutex);
if (item->refcount == 0) {
item->object = kmalloc(ref->size, GFP_KERNEL);
item->object = kzalloc(ref->size, GFP_KERNEL);
if (unlikely(item->object == NULL)) {
ret = -ENOMEM;
goto out_err;
Expand All @@ -89,7 +89,6 @@ int ttm_global_item_ref(struct ttm_global_reference *ref)
mutex_unlock(&item->mutex);
return 0;
out_err:
kfree(item->object);
mutex_unlock(&item->mutex);
item->object = NULL;
return ret;
Expand All @@ -105,7 +104,6 @@ void ttm_global_item_unref(struct ttm_global_reference *ref)
BUG_ON(ref->object != item->object);
if (--item->refcount == 0) {
ref->release(ref);
kfree(item->object);
item->object = NULL;
}
mutex_unlock(&item->mutex);
Expand Down
Loading

0 comments on commit 5fd9cba

Please sign in to comment.