aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/ttm/ttm_tt.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2010-03-09 01:33:26 -0500
committerDave Airlie <airlied@redhat.com>2010-03-14 20:31:43 -0400
commit72e942dd846f98e2d35aad5436d77a878ef05c5e (patch)
treebed31b516da9fd80058800caa6161b6e0f880595 /drivers/gpu/drm/ttm/ttm_tt.c
parentd424b925f7092b9d95e0a8556872349abe79d9b6 (diff)
drm/ttm: use drm calloc large and free large
Now that the drm core can do this, lets just use it, split the code out so TTM doesn't have to drag all of drmP.h in. Signed-off-by: Dave Airlie <airlied@redhat.com>
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 a759170763bb..bab6cd8d8a1e 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -28,13 +28,13 @@
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>
35#include <linux/file.h> 34#include <linux/file.h>
36#include <linux/swap.h> 35#include <linux/swap.h>
37#include "drm_cache.h" 36#include "drm_cache.h"
37#include "drm_mem_util.h"
38#include "ttm/ttm_module.h" 38#include "ttm/ttm_module.h"
39#include "ttm/ttm_bo_driver.h" 39#include "ttm/ttm_bo_driver.h"
40#include "ttm/ttm_placement.h" 40#include "ttm/ttm_placement.h"
@@ -43,32 +43,15 @@ static int ttm_tt_swapin(struct ttm_tt *ttm);
43 43
44/** 44/**
45 * Allocates storage for pointers to the pages that back the ttm. 45 * Allocates storage for pointers to the pages that back the ttm.
46 *
47 * Uses kmalloc if possible. Otherwise falls back to vmalloc.
48 */ 46 */
49static void ttm_tt_alloc_page_directory(struct ttm_tt *ttm) 47static void ttm_tt_alloc_page_directory(struct ttm_tt *ttm)
50{ 48{
51 unsigned long size = ttm->num_pages * sizeof(*ttm->pages); 49 ttm->pages = drm_calloc_large(ttm->num_pages, sizeof(*ttm->pages));
52 ttm->pages = NULL;
53
54 if (size <= PAGE_SIZE)
55 ttm->pages = kzalloc(size, GFP_KERNEL);
56
57 if (!ttm->pages) {
58 ttm->pages = vmalloc_user(size);
59 if (ttm->pages)
60 ttm->page_flags |= TTM_PAGE_FLAG_VMALLOC;
61 }
62} 50}
63 51
64static void ttm_tt_free_page_directory(struct ttm_tt *ttm) 52static void ttm_tt_free_page_directory(struct ttm_tt *ttm)
65{ 53{
66 if (ttm->page_flags & TTM_PAGE_FLAG_VMALLOC) { 54 drm_free_large(ttm->pages);
67 vfree(ttm->pages);
68 ttm->page_flags &= ~TTM_PAGE_FLAG_VMALLOC;
69 } else {
70 kfree(ttm->pages);
71 }
72 ttm->pages = NULL; 55 ttm->pages = NULL;
73} 56}
74 57