diff options
author | Christian König <christian.koenig@amd.com> | 2014-08-07 09:36:01 +0200 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2014-08-11 11:04:24 -0400 |
commit | ddd00e33e17a62c5f44377ab42e7562ccfae7bd1 (patch) | |
tree | c891a3a9198cc82fafc2e4b2881c055a5351a272 /drivers/gpu/drm/radeon/radeon_ttm.c | |
parent | f72a113a71ab08c4df8a5f80ab2f8a140feb81f6 (diff) | |
download | lwn-ddd00e33e17a62c5f44377ab42e7562ccfae7bd1.tar.gz lwn-ddd00e33e17a62c5f44377ab42e7562ccfae7bd1.zip |
drm/radeon: add userptr flag to limit it to anonymous memory v2
Avoid problems with writeback by limiting userptr to anonymous memory.
v2: add commit and code comments
Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon_ttm.c')
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_ttm.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index b20933fa35c6..12e37b1ddc40 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c @@ -538,6 +538,16 @@ static int radeon_ttm_tt_pin_userptr(struct ttm_tt *ttm) if (current->mm != gtt->usermm) return -EPERM; + if (gtt->userflags & RADEON_GEM_USERPTR_ANONONLY) { + /* check that we only pin down anonymous memory + to prevent problems with writeback */ + unsigned long end = gtt->userptr + ttm->num_pages * PAGE_SIZE; + struct vm_area_struct *vma; + vma = find_vma(gtt->usermm, gtt->userptr); + if (!vma || vma->vm_file || vma->vm_end < end) + return -EPERM; + } + do { unsigned num_pages = ttm->num_pages - pinned; uint64_t userptr = gtt->userptr + pinned * PAGE_SIZE; |