diff options
author | Thomas Hellstrom <thellstrom@vmware.com> | 2009-08-17 10:28:39 -0400 |
---|---|---|
committer | Dave Airlie <airlied@linux.ie> | 2009-08-19 02:09:53 -0400 |
commit | 5fd9cbad3a4ae82c83c55b9c621d156c326724ef (patch) | |
tree | 1a0868a3bd2751fa861c083aeb3ac27f3f695694 /drivers/gpu/drm/ttm/ttm_tt.c | |
parent | e9840be8c23601285a70520b4898818f28ce8c2b (diff) |
drm/ttm: Memory accounting rework.
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>
Diffstat (limited to 'drivers/gpu/drm/ttm/ttm_tt.c')
-rw-r--r-- | drivers/gpu/drm/ttm/ttm_tt.c | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c index 75dc8bd24592..4e1e2566d519 100644 --- a/drivers/gpu/drm/ttm/ttm_tt.c +++ b/drivers/gpu/drm/ttm/ttm_tt.c | |||
@@ -166,7 +166,7 @@ static void ttm_tt_free_user_pages(struct ttm_tt *ttm) | |||
166 | set_page_dirty_lock(page); | 166 | set_page_dirty_lock(page); |
167 | 167 | ||
168 | ttm->pages[i] = NULL; | 168 | ttm->pages[i] = NULL; |
169 | ttm_mem_global_free(ttm->bdev->mem_glob, PAGE_SIZE, false); | 169 | ttm_mem_global_free(ttm->bdev->mem_glob, PAGE_SIZE); |
170 | put_page(page); | 170 | put_page(page); |
171 | } | 171 | } |
172 | ttm->state = tt_unpopulated; | 172 | ttm->state = tt_unpopulated; |
@@ -187,21 +187,14 @@ static struct page *__ttm_tt_get_page(struct ttm_tt *ttm, int index) | |||
187 | if (!p) | 187 | if (!p) |
188 | return NULL; | 188 | return NULL; |
189 | 189 | ||
190 | if (PageHighMem(p)) { | 190 | ret = ttm_mem_global_alloc_page(mem_glob, p, false, false); |
191 | ret = | 191 | if (unlikely(ret != 0)) |
192 | ttm_mem_global_alloc(mem_glob, PAGE_SIZE, | 192 | goto out_err; |
193 | false, false, true); | 193 | |
194 | if (unlikely(ret != 0)) | 194 | if (PageHighMem(p)) |
195 | goto out_err; | ||
196 | ttm->pages[--ttm->first_himem_page] = p; | 195 | ttm->pages[--ttm->first_himem_page] = p; |
197 | } else { | 196 | else |
198 | ret = | ||
199 | ttm_mem_global_alloc(mem_glob, PAGE_SIZE, | ||
200 | false, false, false); | ||
201 | if (unlikely(ret != 0)) | ||
202 | goto out_err; | ||
203 | ttm->pages[++ttm->last_lomem_page] = p; | 197 | ttm->pages[++ttm->last_lomem_page] = p; |
204 | } | ||
205 | } | 198 | } |
206 | return p; | 199 | return p; |
207 | out_err: | 200 | out_err: |
@@ -355,8 +348,8 @@ static void ttm_tt_free_alloced_pages(struct ttm_tt *ttm) | |||
355 | printk(KERN_ERR TTM_PFX | 348 | printk(KERN_ERR TTM_PFX |
356 | "Erroneous page count. " | 349 | "Erroneous page count. " |
357 | "Leaking pages.\n"); | 350 | "Leaking pages.\n"); |
358 | ttm_mem_global_free(ttm->bdev->mem_glob, PAGE_SIZE, | 351 | ttm_mem_global_free_page(ttm->bdev->mem_glob, |
359 | PageHighMem(cur_page)); | 352 | cur_page); |
360 | __free_page(cur_page); | 353 | __free_page(cur_page); |
361 | } | 354 | } |
362 | } | 355 | } |
@@ -411,7 +404,7 @@ int ttm_tt_set_user(struct ttm_tt *ttm, | |||
411 | */ | 404 | */ |
412 | 405 | ||
413 | ret = ttm_mem_global_alloc(mem_glob, num_pages * PAGE_SIZE, | 406 | ret = ttm_mem_global_alloc(mem_glob, num_pages * PAGE_SIZE, |
414 | false, false, false); | 407 | false, false); |
415 | if (unlikely(ret != 0)) | 408 | if (unlikely(ret != 0)) |
416 | return ret; | 409 | return ret; |
417 | 410 | ||
@@ -422,7 +415,7 @@ int ttm_tt_set_user(struct ttm_tt *ttm, | |||
422 | 415 | ||
423 | if (ret != num_pages && write) { | 416 | if (ret != num_pages && write) { |
424 | ttm_tt_free_user_pages(ttm); | 417 | ttm_tt_free_user_pages(ttm); |
425 | ttm_mem_global_free(mem_glob, num_pages * PAGE_SIZE, false); | 418 | ttm_mem_global_free(mem_glob, num_pages * PAGE_SIZE); |
426 | return -ENOMEM; | 419 | return -ENOMEM; |
427 | } | 420 | } |
428 | 421 | ||