|
@@ -170,9 +170,8 @@ void ttm_tt_destroy(struct ttm_tt *ttm)
|
|
|
ttm_tt_unbind(ttm);
|
|
|
}
|
|
|
|
|
|
- if (ttm->state == tt_unbound) {
|
|
|
- ttm->bdev->driver->ttm_tt_unpopulate(ttm);
|
|
|
- }
|
|
|
+ if (ttm->state == tt_unbound)
|
|
|
+ ttm_tt_unpopulate(ttm);
|
|
|
|
|
|
if (!(ttm->page_flags & TTM_PAGE_FLAG_PERSISTENT_SWAP) &&
|
|
|
ttm->swap_storage)
|
|
@@ -362,7 +361,7 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage)
|
|
|
page_cache_release(to_page);
|
|
|
}
|
|
|
|
|
|
- ttm->bdev->driver->ttm_tt_unpopulate(ttm);
|
|
|
+ ttm_tt_unpopulate(ttm);
|
|
|
ttm->swap_storage = swap_storage;
|
|
|
ttm->page_flags |= TTM_PAGE_FLAG_SWAPPED;
|
|
|
if (persistent_swap_storage)
|
|
@@ -375,3 +374,23 @@ out_err:
|
|
|
|
|
|
return ret;
|
|
|
}
|
|
|
+
|
|
|
+static void ttm_tt_clear_mapping(struct ttm_tt *ttm)
|
|
|
+{
|
|
|
+ pgoff_t i;
|
|
|
+ struct page **page = ttm->pages;
|
|
|
+
|
|
|
+ for (i = 0; i < ttm->num_pages; ++i) {
|
|
|
+ (*page)->mapping = NULL;
|
|
|
+ (*page++)->index = 0;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void ttm_tt_unpopulate(struct ttm_tt *ttm)
|
|
|
+{
|
|
|
+ if (ttm->state == tt_unpopulated)
|
|
|
+ return;
|
|
|
+
|
|
|
+ ttm_tt_clear_mapping(ttm);
|
|
|
+ ttm->bdev->driver->ttm_tt_unpopulate(ttm);
|
|
|
+}
|