diff options
Diffstat (limited to 'drivers/gpu/drm/ttm/ttm_tt.c')
-rw-r--r-- | drivers/gpu/drm/ttm/ttm_tt.c | 23 |
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 0ef7f73ea56..d5fd5b8faeb 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 | */ |
50 | static void ttm_tt_alloc_page_directory(struct ttm_tt *ttm) | 48 | static 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 | ||
65 | static void ttm_tt_free_page_directory(struct ttm_tt *ttm) | 53 | static 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 | ||