summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2016-02-08 11:08:35 +0100
committerAlex Deucher <alexander.deucher@amd.com>2016-02-10 14:17:16 -0500
commitcc325d1913475655b81c0417ba04c84f168ac78c (patch)
tree6dcc586983e753988a4b2713678f78bbb49ded6e /drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
parent04db4caf5c836c211977a54c9218f2cdee14897f (diff)
drm/amdgpu: check userptrs mm earlier
Instead of when we try to bind it check the usermm when we try to use it in the IOCTLs. Signed-off-by: Christian König <christian.koenig@amd.com> Acked-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
index c4341dd4b6a4..90d6fc1618aa 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
@@ -93,6 +93,7 @@ static int amdgpu_bo_list_set(struct amdgpu_device *adev,
bool has_userptr = false;
unsigned i;
+ int r;
array = drm_malloc_ab(num_entries, sizeof(struct amdgpu_bo_list_entry));
if (!array)
@@ -102,17 +103,26 @@ static int amdgpu_bo_list_set(struct amdgpu_device *adev,
for (i = 0; i < num_entries; ++i) {
struct amdgpu_bo_list_entry *entry = &array[i];
struct drm_gem_object *gobj;
+ struct mm_struct *usermm;
gobj = drm_gem_object_lookup(adev->ddev, filp, info[i].bo_handle);
- if (!gobj)
+ if (!gobj) {
+ r = -ENOENT;
goto error_free;
+ }
entry->robj = amdgpu_bo_ref(gem_to_amdgpu_bo(gobj));
drm_gem_object_unreference_unlocked(gobj);
entry->priority = min(info[i].bo_priority,
AMDGPU_BO_LIST_MAX_PRIORITY);
- if (amdgpu_ttm_tt_has_userptr(entry->robj->tbo.ttm))
+ usermm = amdgpu_ttm_tt_get_usermm(entry->robj->tbo.ttm);
+ if (usermm) {
+ if (usermm != current->mm) {
+ r = -EPERM;
+ goto error_free;
+ }
has_userptr = true;
+ }
entry->tv.bo = &entry->robj->tbo;
entry->tv.shared = true;
@@ -142,7 +152,7 @@ static int amdgpu_bo_list_set(struct amdgpu_device *adev,
error_free:
drm_free_large(array);
- return -ENOENT;
+ return r;
}
struct amdgpu_bo_list *