aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/ttm/ttm_bo_util.c
diff options
context:
space:
mode:
authorJerome Glisse <jglisse@redhat.com>2011-11-02 23:59:28 -0400
committerDave Airlie <airlied@redhat.com>2011-12-06 05:39:24 -0500
commitb1e5f172325547270f35e7d1e42416a606e1dbd2 (patch)
tree03fc21fd5f74add89441308008b45987d09cfbc6 /drivers/gpu/drm/ttm/ttm_bo_util.c
parent649bf3ca77343e3be1e0af8e21356fa569b1abd9 (diff)
drm/ttm: introduce callback for ttm_tt populate & unpopulate V4
Move the page allocation and freeing to driver callback and provide ttm code helper function for those. Most intrusive change, is the fact that we now only fully populate an object this simplify some of code designed around the page fault design. V2 Rebase on top of memory accounting overhaul V3 New rebase on top of more memory accouting changes V4 Rebase on top of no memory account changes (where/when is my delorean when i need it ?) Signed-off-by: Jerome Glisse <jglisse@redhat.com> Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Diffstat (limited to 'drivers/gpu/drm/ttm/ttm_bo_util.c')
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo_util.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 082fcaea583f..60f204d67dbb 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -244,7 +244,7 @@ static int ttm_copy_io_ttm_page(struct ttm_tt *ttm, void *src,
244 unsigned long page, 244 unsigned long page,
245 pgprot_t prot) 245 pgprot_t prot)
246{ 246{
247 struct page *d = ttm_tt_get_page(ttm, page); 247 struct page *d = ttm->pages[page];
248 void *dst; 248 void *dst;
249 249
250 if (!d) 250 if (!d)
@@ -281,7 +281,7 @@ static int ttm_copy_ttm_io_page(struct ttm_tt *ttm, void *dst,
281 unsigned long page, 281 unsigned long page,
282 pgprot_t prot) 282 pgprot_t prot)
283{ 283{
284 struct page *s = ttm_tt_get_page(ttm, page); 284 struct page *s = ttm->pages[page];
285 void *src; 285 void *src;
286 286
287 if (!s) 287 if (!s)
@@ -342,6 +342,12 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
342 if (old_iomap == NULL && ttm == NULL) 342 if (old_iomap == NULL && ttm == NULL)
343 goto out2; 343 goto out2;
344 344
345 if (ttm->state == tt_unpopulated) {
346 ret = ttm->bdev->driver->ttm_tt_populate(ttm);
347 if (ret)
348 goto out1;
349 }
350
345 add = 0; 351 add = 0;
346 dir = 1; 352 dir = 1;
347 353
@@ -502,10 +508,16 @@ static int ttm_bo_kmap_ttm(struct ttm_buffer_object *bo,
502{ 508{
503 struct ttm_mem_reg *mem = &bo->mem; pgprot_t prot; 509 struct ttm_mem_reg *mem = &bo->mem; pgprot_t prot;
504 struct ttm_tt *ttm = bo->ttm; 510 struct ttm_tt *ttm = bo->ttm;
505 struct page *d; 511 int ret;
506 int i;
507 512
508 BUG_ON(!ttm); 513 BUG_ON(!ttm);
514
515 if (ttm->state == tt_unpopulated) {
516 ret = ttm->bdev->driver->ttm_tt_populate(ttm);
517 if (ret)
518 return ret;
519 }
520
509 if (num_pages == 1 && (mem->placement & TTM_PL_FLAG_CACHED)) { 521 if (num_pages == 1 && (mem->placement & TTM_PL_FLAG_CACHED)) {
510 /* 522 /*
511 * We're mapping a single page, and the desired 523 * We're mapping a single page, and the desired
@@ -513,18 +525,9 @@ static int ttm_bo_kmap_ttm(struct ttm_buffer_object *bo,
513 */ 525 */
514 526
515 map->bo_kmap_type = ttm_bo_map_kmap; 527 map->bo_kmap_type = ttm_bo_map_kmap;
516 map->page = ttm_tt_get_page(ttm, start_page); 528 map->page = ttm->pages[start_page];
517 map->virtual = kmap(map->page); 529 map->virtual = kmap(map->page);
518 } else { 530 } else {
519 /*
520 * Populate the part we're mapping;
521 */
522 for (i = start_page; i < start_page + num_pages; ++i) {
523 d = ttm_tt_get_page(ttm, i);
524 if (!d)
525 return -ENOMEM;
526 }
527
528 /* 531 /*
529 * We need to use vmap to get the desired page protection 532 * We need to use vmap to get the desired page protection
530 * or to make the buffer object look contiguous. 533 * or to make the buffer object look contiguous.