summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/radeon/radeon_gem.c
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2014-08-07 11:36:02 +0400
committerAlex Deucher <alexander.deucher@amd.com>2014-08-11 19:04:25 +0400
commit2a84a4476d6e13de72472f6ca4338aed0a8269b8 (patch)
treea39411c8cb0dfca623e12801511818a82cd4d74a /drivers/gpu/drm/radeon/radeon_gem.c
parentddd00e33e17a62c5f44377ab42e7562ccfae7bd1 (diff)
downloadlinux-2a84a4476d6e13de72472f6ca4338aed0a8269b8.tar.xz
drm/radeon: add userptr flag to directly validate the BO to GTT
This way we test userptr availability at BO creation time instead of first use. 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_gem.c')
-rw-r--r--drivers/gpu/drm/radeon/radeon_gem.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c
index 032736b429bf..450656027aba 100644
--- a/drivers/gpu/drm/radeon/radeon_gem.c
+++ b/drivers/gpu/drm/radeon/radeon_gem.c
@@ -291,7 +291,7 @@ int radeon_gem_userptr_ioctl(struct drm_device *dev, void *data,
/* reject unknown flag values */
if (args->flags & ~(RADEON_GEM_USERPTR_READONLY |
- RADEON_GEM_USERPTR_ANONONLY))
+ RADEON_GEM_USERPTR_ANONONLY | RADEON_GEM_USERPTR_VALIDATE))
return -EINVAL;
/* readonly pages not tested on older hardware */
@@ -312,6 +312,22 @@ int radeon_gem_userptr_ioctl(struct drm_device *dev, void *data,
if (r)
goto release_object;
+ if (args->flags & RADEON_GEM_USERPTR_VALIDATE) {
+ down_read(&current->mm->mmap_sem);
+ r = radeon_bo_reserve(bo, true);
+ if (r) {
+ up_read(&current->mm->mmap_sem);
+ goto release_object;
+ }
+
+ radeon_ttm_placement_from_domain(bo, RADEON_GEM_DOMAIN_GTT);
+ r = ttm_bo_validate(&bo->tbo, &bo->placement, true, false);
+ radeon_bo_unreserve(bo);
+ up_read(&current->mm->mmap_sem);
+ if (r)
+ goto release_object;
+ }
+
r = drm_gem_handle_create(filp, gobj, &handle);
/* drop reference from allocate - handle holds it now */
drm_gem_object_unreference_unlocked(gobj);