Skip to content

Commit 429134d

Browse files
author
Iouri Tarassov
committed
drivers: hv: dxgkrnl: Use pin_user_pages instead of get_user_pages for DMA accessible memory
Pages, which are obtained by calling get_user_pages(), can be evicted from memory. pin_user_pages() should be used for memory, which is accessed by DMA. Signed-off-by: Iouri Tarassov <[email protected]>
1 parent a923b18 commit 429134d

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

drivers/hv/dxgkrnl/dxgadapter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ struct dxgallocation *dxgallocation_create(struct dxgprocess *process)
882882
void dxgallocation_stop(struct dxgallocation *alloc)
883883
{
884884
if (alloc->pages) {
885-
release_pages(alloc->pages, alloc->num_pages);
885+
unpin_user_pages(alloc->pages, alloc->num_pages);
886886
vfree(alloc->pages);
887887
alloc->pages = NULL;
888888
}

drivers/hv/dxgkrnl/dxgvmbus.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,6 +1457,7 @@ int create_existing_sysmem(struct dxgdevice *device,
14571457
u64 *pfn;
14581458
u32 pages_to_send;
14591459
u32 i;
1460+
u32 gup_flags = FOLL_LONGTERM;
14601461
struct dxgglobal *dxgglobal = dxggbl();
14611462

14621463
/*
@@ -1475,12 +1476,15 @@ int create_existing_sysmem(struct dxgdevice *device,
14751476
ret = -ENOMEM;
14761477
goto cleanup;
14771478
}
1478-
ret1 = get_user_pages_fast((unsigned long)sysmem, npages, !read_only,
1479-
dxgalloc->pages);
1479+
if (!read_only)
1480+
gup_flags |= FOLL_WRITE;
1481+
ret1 = pin_user_pages_fast((unsigned long)sysmem, npages, gup_flags,
1482+
dxgalloc->pages);
14801483
if (ret1 != npages) {
14811484
DXG_ERR("get_user_pages_fast failed: %d", ret1);
1482-
if (ret1 > 0 && ret1 < npages)
1483-
release_pages(dxgalloc->pages, ret1);
1485+
if (ret1 > 0 && ret1 < npages) {
1486+
unpin_user_pages(dxgalloc->pages, ret1);
1487+
}
14841488
vfree(dxgalloc->pages);
14851489
dxgalloc->pages = NULL;
14861490
ret = -ENOMEM;

0 commit comments

Comments
 (0)