aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/ttm/ttm_tt.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/ttm/ttm_tt.c')
-rw-r--r--drivers/gpu/drm/ttm/ttm_tt.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index 75f319090043..bf080abc86d1 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -55,9 +55,12 @@ static void ttm_tt_alloc_page_directory(struct ttm_tt *ttm)
55 55
56static void ttm_dma_tt_alloc_page_directory(struct ttm_dma_tt *ttm) 56static void ttm_dma_tt_alloc_page_directory(struct ttm_dma_tt *ttm)
57{ 57{
58 ttm->ttm.pages = drm_calloc_large(ttm->ttm.num_pages, sizeof(void*)); 58 ttm->ttm.pages = drm_calloc_large(ttm->ttm.num_pages,
59 ttm->dma_address = drm_calloc_large(ttm->ttm.num_pages, 59 sizeof(*ttm->ttm.pages) +
60 sizeof(*ttm->dma_address)); 60 sizeof(*ttm->dma_address) +
61 sizeof(*ttm->cpu_address));
62 ttm->cpu_address = (void *) (ttm->ttm.pages + ttm->ttm.num_pages);
63 ttm->dma_address = (void *) (ttm->cpu_address + ttm->ttm.num_pages);
61} 64}
62 65
63#ifdef CONFIG_X86 66#ifdef CONFIG_X86
@@ -228,7 +231,7 @@ int ttm_dma_tt_init(struct ttm_dma_tt *ttm_dma, struct ttm_bo_device *bdev,
228 231
229 INIT_LIST_HEAD(&ttm_dma->pages_list); 232 INIT_LIST_HEAD(&ttm_dma->pages_list);
230 ttm_dma_tt_alloc_page_directory(ttm_dma); 233 ttm_dma_tt_alloc_page_directory(ttm_dma);
231 if (!ttm->pages || !ttm_dma->dma_address) { 234 if (!ttm->pages) {
232 ttm_tt_destroy(ttm); 235 ttm_tt_destroy(ttm);
233 pr_err("Failed allocating page table\n"); 236 pr_err("Failed allocating page table\n");
234 return -ENOMEM; 237 return -ENOMEM;
@@ -243,7 +246,7 @@ void ttm_dma_tt_fini(struct ttm_dma_tt *ttm_dma)
243 246
244 drm_free_large(ttm->pages); 247 drm_free_large(ttm->pages);
245 ttm->pages = NULL; 248 ttm->pages = NULL;
246 drm_free_large(ttm_dma->dma_address); 249 ttm_dma->cpu_address = NULL;
247 ttm_dma->dma_address = NULL; 250 ttm_dma->dma_address = NULL;
248} 251}
249EXPORT_SYMBOL(ttm_dma_tt_fini); 252EXPORT_SYMBOL(ttm_dma_tt_fini);