From 495bbbaadc93c574eb98dd2ad64bdca4d91d4152 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 4 Oct 2007 16:13:22 +1000 Subject: drm: fix page count calculation Also no need to do pre-populate work on single page --- linux-core/drm_bo_move.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'linux-core') diff --git a/linux-core/drm_bo_move.c b/linux-core/drm_bo_move.c index dae99181..2a35d45b 100644 --- a/linux-core/drm_bo_move.c +++ b/linux-core/drm_bo_move.c @@ -488,16 +488,6 @@ static int drm_bo_kmap_ttm(struct drm_buffer_object *bo, unsigned long start_pag BUG_ON(!ttm); - /* - * Populate the part we're mapping; - */ - - for (i=start_page; i< num_pages; ++i) { - d = drm_ttm_get_page(ttm, i); - if (!d) - return -ENOMEM; - } - if (num_pages == 1 && (mem->flags & DRM_BO_FLAG_CACHED)) { /* @@ -509,6 +499,15 @@ static int drm_bo_kmap_ttm(struct drm_buffer_object *bo, unsigned long start_pag map->page = drm_ttm_get_page(ttm, start_page); map->virtual = kmap(map->page); } else { + /* + * Populate the part we're mapping; + */ + + for (i = start_page; i< start_page + num_pages; ++i) { + d = drm_ttm_get_page(ttm, i); + if (!d) + return -ENOMEM; + } /* * We need to use vmap to get the desired page protection -- cgit v1.2.3