aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/ttm/ttm_tt.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2010-04-04 22:37:28 -0400
committerTejun Heo <tj@kernel.org>2010-04-04 22:37:28 -0400
commit336f5899d287f06d8329e208fc14ce50f7ec9698 (patch)
tree9b762d450d5eb248a6ff8317badb7e223d93ed58 /drivers/gpu/drm/ttm/ttm_tt.c
parenta4ab2773205e8b94c18625455f85e3b6bb9d7ad6 (diff)
parentdb217dece3003df0841bacf9556b5c06aa097dae (diff)
Merge branch 'master' into export-slabh
Diffstat (limited to 'drivers/gpu/drm/ttm/ttm_tt.c')
-rw-r--r--drivers/gpu/drm/ttm/ttm_tt.c23
1 files changed, 3 insertions, 20 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index 0ef7f73ea56c..d5fd5b8faeb3 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -28,7 +28,6 @@
28 * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com> 28 * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
29 */ 29 */
30 30
31#include <linux/vmalloc.h>
32#include <linux/sched.h> 31#include <linux/sched.h>
33#include <linux/highmem.h> 32#include <linux/highmem.h>
34#include <linux/pagemap.h> 33#include <linux/pagemap.h>
@@ -36,6 +35,7 @@
36#include <linux/swap.h> 35#include <linux/swap.h>
37#include <linux/slab.h> 36#include <linux/slab.h>
38#include "drm_cache.h" 37#include "drm_cache.h"
38#include "drm_mem_util.h"
39#include "ttm/ttm_module.h" 39#include "ttm/ttm_module.h"
40#include "ttm/ttm_bo_driver.h" 40#include "ttm/ttm_bo_driver.h"
41#include "ttm/ttm_placement.h" 41#include "ttm/ttm_placement.h"
@@ -44,32 +44,15 @@ static int ttm_tt_swapin(struct ttm_tt *ttm);
44 44
45/** 45/**
46 * Allocates storage for pointers to the pages that back the ttm. 46 * Allocates storage for pointers to the pages that back the ttm.
47 *
48 * Uses kmalloc if possible. Otherwise falls back to vmalloc.
49 */ 47 */
50static void ttm_tt_alloc_page_directory(struct ttm_tt *ttm) 48static void ttm_tt_alloc_page_directory(struct ttm_tt *ttm)
51{ 49{
52 unsigned long size = ttm->num_pages * sizeof(*ttm->pages); 50 ttm->pages = drm_calloc_large(ttm->num_pages, sizeof(*ttm->pages));
53 ttm->pages = NULL;
54
55 if (size <= PAGE_SIZE)
56 ttm->pages = kzalloc(size, GFP_KERNEL);
57
58 if (!ttm->pages) {
59 ttm->pages = vmalloc_user(size);
60 if (ttm->pages)
61 ttm->page_flags |= TTM_PAGE_FLAG_VMALLOC;
62 }
63} 51}
64 52
65static void ttm_tt_free_page_directory(struct ttm_tt *ttm) 53static void ttm_tt_free_page_directory(struct ttm_tt *ttm)
66{ 54{
67 if (ttm->page_flags & TTM_PAGE_FLAG_VMALLOC) { 55 drm_free_large(ttm->pages);
68 vfree(ttm->pages);
69 ttm->page_flags &= ~TTM_PAGE_FLAG_VMALLOC;
70 } else {
71 kfree(ttm->pages);
72 }
73 ttm->pages = NULL; 56 ttm->pages = NULL;
74} 57}
75 58