aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorThomas Hellstrom <thellstrom@vmware.com>2014-01-03 05:47:23 -0500
committerThomas Hellstrom <thellstrom@vmware.com>2014-01-08 04:08:28 -0500
commit58aa6622d32af7d2c08d45085f44c54554a16ed7 (patch)
treeb24e02d873a323a79cc86b27a9c21fe80f2cc54f /drivers
parent667a50db0477d47fdff01c666f5ee1ce26b5264c (diff)
drm/ttm: Correctly set page mapping and -index members
Needed for some vm operations; most notably unmap_mapping_range() with even_cows = 0. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Reviewed-by: Brian Paul <brianp@vmware.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo_vm.c5
-rw-r--r--drivers/gpu/drm/ttm/ttm_tt.c27
2 files changed, 28 insertions, 4 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
index 12d7f53b7c13..cfcdf5b5440a 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
@@ -226,6 +226,9 @@ static int ttm_bo_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
226 } else if (unlikely(!page)) { 226 } else if (unlikely(!page)) {
227 break; 227 break;
228 } 228 }
229 page->mapping = vma->vm_file->f_mapping;
230 page->index = drm_vma_node_start(&bo->vma_node) +
231 page_offset;
229 pfn = page_to_pfn(page); 232 pfn = page_to_pfn(page);
230 } 233 }
231 234
@@ -263,6 +266,8 @@ static void ttm_bo_vm_open(struct vm_area_struct *vma)
263 struct ttm_buffer_object *bo = 266 struct ttm_buffer_object *bo =
264 (struct ttm_buffer_object *)vma->vm_private_data; 267 (struct ttm_buffer_object *)vma->vm_private_data;
265 268
269 WARN_ON(bo->bdev->dev_mapping != vma->vm_file->f_mapping);
270
266 (void)ttm_bo_reference(bo); 271 (void)ttm_bo_reference(bo);
267} 272}
268 273
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index 210d50365162..9af99084b344 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -170,9 +170,8 @@ void ttm_tt_destroy(struct ttm_tt *ttm)
170 ttm_tt_unbind(ttm); 170 ttm_tt_unbind(ttm);
171 } 171 }
172 172
173 if (ttm->state == tt_unbound) { 173 if (ttm->state == tt_unbound)
174 ttm->bdev->driver->ttm_tt_unpopulate(ttm); 174 ttm_tt_unpopulate(ttm);
175 }
176 175
177 if (!(ttm->page_flags & TTM_PAGE_FLAG_PERSISTENT_SWAP) && 176 if (!(ttm->page_flags & TTM_PAGE_FLAG_PERSISTENT_SWAP) &&
178 ttm->swap_storage) 177 ttm->swap_storage)
@@ -362,7 +361,7 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage)
362 page_cache_release(to_page); 361 page_cache_release(to_page);
363 } 362 }
364 363
365 ttm->bdev->driver->ttm_tt_unpopulate(ttm); 364 ttm_tt_unpopulate(ttm);
366 ttm->swap_storage = swap_storage; 365 ttm->swap_storage = swap_storage;
367 ttm->page_flags |= TTM_PAGE_FLAG_SWAPPED; 366 ttm->page_flags |= TTM_PAGE_FLAG_SWAPPED;
368 if (persistent_swap_storage) 367 if (persistent_swap_storage)
@@ -375,3 +374,23 @@ out_err:
375 374
376 return ret; 375 return ret;
377} 376}
377
378static void ttm_tt_clear_mapping(struct ttm_tt *ttm)
379{
380 pgoff_t i;
381 struct page **page = ttm->pages;
382
383 for (i = 0; i < ttm->num_pages; ++i) {
384 (*page)->mapping = NULL;
385 (*page++)->index = 0;
386 }
387}
388
389void ttm_tt_unpopulate(struct ttm_tt *ttm)
390{
391 if (ttm->state == tt_unpopulated)
392 return;
393
394 ttm_tt_clear_mapping(ttm);
395 ttm->bdev->driver->ttm_tt_unpopulate(ttm);
396}