mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-18 10:13:57 +08:00
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>
This commit is contained in:
parent
f72a113a71
commit
ddd00e33e1
@ -290,7 +290,8 @@ int radeon_gem_userptr_ioctl(struct drm_device *dev, void *data,
|
||||
return -EACCES;
|
||||
|
||||
/* reject unknown flag values */
|
||||
if (args->flags & ~RADEON_GEM_USERPTR_READONLY)
|
||||
if (args->flags & ~(RADEON_GEM_USERPTR_READONLY |
|
||||
RADEON_GEM_USERPTR_ANONONLY))
|
||||
return -EINVAL;
|
||||
|
||||
/* readonly pages not tested on older hardware */
|
||||
|
@ -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;
|
||||
|
@ -816,6 +816,7 @@ struct drm_radeon_gem_create {
|
||||
* perform any operation.
|
||||
*/
|
||||
#define RADEON_GEM_USERPTR_READONLY (1 << 0)
|
||||
#define RADEON_GEM_USERPTR_ANONONLY (1 << 1)
|
||||
|
||||
struct drm_radeon_gem_userptr {
|
||||
uint64_t addr;
|
||||
|
Loading…
Reference in New Issue
Block a user