aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/ttm/ttm_tt.c
diff options
context:
space:
mode:
authorThomas Hellstrom <thellstrom@vmware.com>2009-08-18 10:51:56 -0400
committerDave Airlie <airlied@linux.ie>2009-08-19 02:10:34 -0400
commita987fcaa805fcb24ba885c2e29fd4fdb6816f08f (patch)
tree561b6dd8e002e2eb1a75132b1edbd303782dc2fb /drivers/gpu/drm/ttm/ttm_tt.c
parent5fd9cbad3a4ae82c83c55b9c621d156c326724ef (diff)
ttm: Make parts of a struct ttm_bo_device global.
Common resources, like memory accounting and swap lists should be global and not per device. Introduce a struct ttm_bo_global to accomodate this, and register it with sysfs. Add a small sysfs interface to return the number of active buffer objects. 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.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index 4e1e2566d51..b0f73096d37 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); 169 ttm_mem_global_free(ttm->glob->mem_glob, PAGE_SIZE);
170 put_page(page); 170 put_page(page);
171 } 171 }
172 ttm->state = tt_unpopulated; 172 ttm->state = tt_unpopulated;
@@ -177,8 +177,7 @@ static void ttm_tt_free_user_pages(struct ttm_tt *ttm)
177static struct page *__ttm_tt_get_page(struct ttm_tt *ttm, int index) 177static struct page *__ttm_tt_get_page(struct ttm_tt *ttm, int index)
178{ 178{
179 struct page *p; 179 struct page *p;
180 struct ttm_bo_device *bdev = ttm->bdev; 180 struct ttm_mem_global *mem_glob = ttm->glob->mem_glob;
181 struct ttm_mem_global *mem_glob = bdev->mem_glob;
182 int ret; 181 int ret;
183 182
184 while (NULL == (p = ttm->pages[index])) { 183 while (NULL == (p = ttm->pages[index])) {
@@ -348,7 +347,7 @@ static void ttm_tt_free_alloced_pages(struct ttm_tt *ttm)
348 printk(KERN_ERR TTM_PFX 347 printk(KERN_ERR TTM_PFX
349 "Erroneous page count. " 348 "Erroneous page count. "
350 "Leaking pages.\n"); 349 "Leaking pages.\n");
351 ttm_mem_global_free_page(ttm->bdev->mem_glob, 350 ttm_mem_global_free_page(ttm->glob->mem_glob,
352 cur_page); 351 cur_page);
353 __free_page(cur_page); 352 __free_page(cur_page);
354 } 353 }
@@ -394,7 +393,7 @@ int ttm_tt_set_user(struct ttm_tt *ttm,
394 struct mm_struct *mm = tsk->mm; 393 struct mm_struct *mm = tsk->mm;
395 int ret; 394 int ret;
396 int write = (ttm->page_flags & TTM_PAGE_FLAG_WRITE) != 0; 395 int write = (ttm->page_flags & TTM_PAGE_FLAG_WRITE) != 0;
397 struct ttm_mem_global *mem_glob = ttm->bdev->mem_glob; 396 struct ttm_mem_global *mem_glob = ttm->glob->mem_glob;
398 397
399 BUG_ON(num_pages != ttm->num_pages); 398 BUG_ON(num_pages != ttm->num_pages);
400 BUG_ON((ttm->page_flags & TTM_PAGE_FLAG_USER) == 0); 399 BUG_ON((ttm->page_flags & TTM_PAGE_FLAG_USER) == 0);
@@ -439,8 +438,7 @@ struct ttm_tt *ttm_tt_create(struct ttm_bo_device *bdev, unsigned long size,
439 if (!ttm) 438 if (!ttm)
440 return NULL; 439 return NULL;
441 440
442 ttm->bdev = bdev; 441 ttm->glob = bdev->glob;
443
444 ttm->num_pages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT; 442 ttm->num_pages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
445 ttm->first_himem_page = ttm->num_pages; 443 ttm->first_himem_page = ttm->num_pages;
446 ttm->last_lomem_page = -1; 444 ttm->last_lomem_page = -1;