Skip to content

Commit ab86142

Browse files
drm/ttm: remove persistent_swap_storage
Not used any more. Cleanup the code as well while at it. Signed-off-by: Christian König <christian.koenig@amd.com> Link: https://patchwork.freedesktop.org/patch/391079/?series=81804&rev=1 Reviewed-by: Dave Airlie <airlied@redhat.com>
1 parent 84d28b4 commit ab86142

4 files changed

Lines changed: 30 additions & 42 deletions

File tree

‎drivers/gpu/drm/ttm/ttm_bo.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1583,7 +1583,7 @@ int ttm_bo_swapout(struct ttm_bo_global *glob, struct ttm_operation_ctx *ctx)
15831583
if (bo->bdev->driver->swap_notify)
15841584
bo->bdev->driver->swap_notify(bo);
15851585

1586-
ret = ttm_tt_swapout(bo->bdev, bo->ttm, bo->persistent_swap_storage);
1586+
ret = ttm_tt_swapout(bo->bdev, bo->ttm);
15871587
out:
15881588

15891589
/**

‎drivers/gpu/drm/ttm/ttm_tt.c‎

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@ void ttm_tt_destroy_common(struct ttm_bo_device *bdev, struct ttm_tt *ttm)
148148
{
149149
ttm_tt_unpopulate(bdev, ttm);
150150

151-
if (!(ttm->page_flags & TTM_PAGE_FLAG_PERSISTENT_SWAP) &&
152-
ttm->swap_storage)
151+
if (ttm->swap_storage)
153152
fput(ttm->swap_storage);
154153

155154
ttm->swap_storage = NULL;
@@ -249,71 +248,67 @@ int ttm_tt_swapin(struct ttm_tt *ttm)
249248
struct file *swap_storage;
250249
struct page *from_page;
251250
struct page *to_page;
252-
int i;
253-
int ret = -ENOMEM;
251+
gfp_t gfp_mask;
252+
int i, ret;
254253

255254
swap_storage = ttm->swap_storage;
256255
BUG_ON(swap_storage == NULL);
257256

258257
swap_space = swap_storage->f_mapping;
258+
gfp_mask = mapping_gfp_mask(swap_space);
259+
if (ttm->page_flags & TTM_PAGE_FLAG_NO_RETRY)
260+
gfp_mask |= __GFP_RETRY_MAYFAIL;
259261

260262
for (i = 0; i < ttm->num_pages; ++i) {
261-
gfp_t gfp_mask = mapping_gfp_mask(swap_space);
262-
263-
gfp_mask |= (ttm->page_flags & TTM_PAGE_FLAG_NO_RETRY ? __GFP_RETRY_MAYFAIL : 0);
264-
from_page = shmem_read_mapping_page_gfp(swap_space, i, gfp_mask);
265-
263+
from_page = shmem_read_mapping_page_gfp(swap_space, i,
264+
gfp_mask);
266265
if (IS_ERR(from_page)) {
267266
ret = PTR_ERR(from_page);
268267
goto out_err;
269268
}
270269
to_page = ttm->pages[i];
271-
if (unlikely(to_page == NULL))
270+
if (unlikely(to_page == NULL)) {
271+
ret = -ENOMEM;
272272
goto out_err;
273+
}
273274

274275
copy_highpage(to_page, from_page);
275276
put_page(from_page);
276277
}
277278

278-
if (!(ttm->page_flags & TTM_PAGE_FLAG_PERSISTENT_SWAP))
279-
fput(swap_storage);
279+
fput(swap_storage);
280280
ttm->swap_storage = NULL;
281281
ttm->page_flags &= ~TTM_PAGE_FLAG_SWAPPED;
282282

283283
return 0;
284+
284285
out_err:
285286
return ret;
286287
}
287288

288-
int ttm_tt_swapout(struct ttm_bo_device *bdev,
289-
struct ttm_tt *ttm, struct file *persistent_swap_storage)
289+
int ttm_tt_swapout(struct ttm_bo_device *bdev, struct ttm_tt *ttm)
290290
{
291291
struct address_space *swap_space;
292292
struct file *swap_storage;
293293
struct page *from_page;
294294
struct page *to_page;
295-
int i;
296-
int ret = -ENOMEM;
297-
298-
if (!persistent_swap_storage) {
299-
swap_storage = shmem_file_setup("ttm swap",
300-
ttm->num_pages << PAGE_SHIFT,
301-
0);
302-
if (IS_ERR(swap_storage)) {
303-
pr_err("Failed allocating swap storage\n");
304-
return PTR_ERR(swap_storage);
305-
}
306-
} else {
307-
swap_storage = persistent_swap_storage;
295+
gfp_t gfp_mask;
296+
int i, ret;
297+
298+
swap_storage = shmem_file_setup("ttm swap",
299+
ttm->num_pages << PAGE_SHIFT,
300+
0);
301+
if (IS_ERR(swap_storage)) {
302+
pr_err("Failed allocating swap storage\n");
303+
return PTR_ERR(swap_storage);
308304
}
309305

310306
swap_space = swap_storage->f_mapping;
307+
gfp_mask = mapping_gfp_mask(swap_space);
308+
if (ttm->page_flags & TTM_PAGE_FLAG_NO_RETRY)
309+
gfp_mask |= __GFP_RETRY_MAYFAIL;
311310

312311
for (i = 0; i < ttm->num_pages; ++i) {
313-
gfp_t gfp_mask = mapping_gfp_mask(swap_space);
314-
315-
gfp_mask |= (ttm->page_flags & TTM_PAGE_FLAG_NO_RETRY ? __GFP_RETRY_MAYFAIL : 0);
316-
317312
from_page = ttm->pages[i];
318313
if (unlikely(from_page == NULL))
319314
continue;
@@ -332,13 +327,11 @@ int ttm_tt_swapout(struct ttm_bo_device *bdev,
332327
ttm_tt_unpopulate(bdev, ttm);
333328
ttm->swap_storage = swap_storage;
334329
ttm->page_flags |= TTM_PAGE_FLAG_SWAPPED;
335-
if (persistent_swap_storage)
336-
ttm->page_flags |= TTM_PAGE_FLAG_PERSISTENT_SWAP;
337330

338331
return 0;
332+
339333
out_err:
340-
if (!persistent_swap_storage)
341-
fput(swap_storage);
334+
fput(swap_storage);
342335

343336
return ret;
344337
}

‎include/drm/ttm/ttm_bo_api.h‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,6 @@ struct ttm_tt;
9090
* @kref: Reference count of this buffer object. When this refcount reaches
9191
* zero, the object is destroyed or put on the delayed delete list.
9292
* @mem: structure describing current placement.
93-
* @persistent_swap_storage: Usually the swap storage is deleted for buffers
94-
* pinned in physical memory. If this behaviour is not desired, this member
95-
* holds a pointer to a persistent shmem object.
9693
* @ttm: TTM structure holding system pages.
9794
* @evicted: Whether the object was evicted without user-space knowing.
9895
* @deleted: True if the object is only a zombie and already deleted.
@@ -139,7 +136,6 @@ struct ttm_buffer_object {
139136
*/
140137

141138
struct ttm_resource mem;
142-
struct file *persistent_swap_storage;
143139
struct ttm_tt *ttm;
144140
bool deleted;
145141

‎include/drm/ttm/ttm_tt.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ struct ttm_operation_ctx;
3636

3737
#define TTM_PAGE_FLAG_WRITE (1 << 3)
3838
#define TTM_PAGE_FLAG_SWAPPED (1 << 4)
39-
#define TTM_PAGE_FLAG_PERSISTENT_SWAP (1 << 5)
4039
#define TTM_PAGE_FLAG_ZERO_ALLOC (1 << 6)
4140
#define TTM_PAGE_FLAG_DMA32 (1 << 7)
4241
#define TTM_PAGE_FLAG_SG (1 << 8)
@@ -185,7 +184,7 @@ int ttm_tt_swapin(struct ttm_tt *ttm);
185184
* and cache flushes and potential page splitting / combining.
186185
*/
187186
int ttm_tt_set_placement_caching(struct ttm_tt *ttm, uint32_t placement);
188-
int ttm_tt_swapout(struct ttm_bo_device *bdev, struct ttm_tt *ttm, struct file *persistent_swap_storage);
187+
int ttm_tt_swapout(struct ttm_bo_device *bdev, struct ttm_tt *ttm);
189188

190189
/**
191190
* ttm_tt_populate - allocate pages for a ttm

0 commit comments

Comments
 (0)