From: "Christian König" <deathsimple@vodafone.de>
To: dri-devel@lists.freedesktop.org
Cc: jglisse@redhat.com
Subject: [PATCH 3/5] drm/radeon: add userptr flag to directly validate the BO to GTT
Date: Mon, 28 Jul 2014 13:30:10 +0200 [thread overview]
Message-ID: <1406547012-3105-3-git-send-email-deathsimple@vodafone.de> (raw)
In-Reply-To: <1406547012-3105-1-git-send-email-deathsimple@vodafone.de>
From: Christian König <christian.koenig@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
---
drivers/gpu/drm/radeon/radeon_gem.c | 18 +++++++++++++++++-
include/uapi/drm/radeon_drm.h | 1 +
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c
index e2c6f44..3ffb2f3 100644
--- a/drivers/gpu/drm/radeon/radeon_gem.c
+++ b/drivers/gpu/drm/radeon/radeon_gem.c
@@ -293,7 +293,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 */
@@ -314,6 +314,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(¤t->mm->mmap_sem);
+ r = radeon_bo_reserve(bo, true);
+ if (r) {
+ up_read(¤t->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(¤t->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);
diff --git a/include/uapi/drm/radeon_drm.h b/include/uapi/drm/radeon_drm.h
index 4080ad3..026111b 100644
--- a/include/uapi/drm/radeon_drm.h
+++ b/include/uapi/drm/radeon_drm.h
@@ -812,6 +812,7 @@ struct drm_radeon_gem_create {
#define RADEON_GEM_USERPTR_READONLY (1 << 0)
#define RADEON_GEM_USERPTR_ANONONLY (1 << 1)
+#define RADEON_GEM_USERPTR_VALIDATE (1 << 2)
struct drm_radeon_gem_userptr {
uint64_t addr;
--
1.9.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2014-07-28 11:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-28 11:30 [PATCH 1/5] drm/radeon: add userptr support v5 Christian König
2014-07-28 11:30 ` [PATCH 2/5] drm/radeon: add userptr flag to limit it to anonymous memory Christian König
2014-07-28 11:30 ` Christian König [this message]
2014-07-28 11:30 ` [PATCH 4/5] drm/radeon: add userptr flag to register MMU notifier Christian König
2014-07-28 11:30 ` [PATCH 5/5] drm/radeon: allow userptr write access under certain conditions Christian König
2014-07-28 15:27 ` [PATCH 1/5] drm/radeon: add userptr support v5 Daniel Vetter
2014-07-29 8:11 ` Christian König
-- strict thread matches above, loose matches on Subject: below --
2014-08-05 14:11 [PATCH 1/5] drm/radeon: add userptr support v6 Christian König
2014-08-05 14:11 ` [PATCH 3/5] drm/radeon: add userptr flag to directly validate the BO to GTT Christian König
2014-08-05 16:05 [PATCH 1/5] drm/radeon: add userptr support v7 Christian König
2014-08-05 16:05 ` [PATCH 3/5] drm/radeon: add userptr flag to directly validate the BO to GTT Christian König
2014-08-07 7:36 [PATCH 1/5] drm/radeon: add userptr support v8 Christian König
2014-08-07 7:36 ` [PATCH 3/5] drm/radeon: add userptr flag to directly validate the BO to GTT Christian König
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1406547012-3105-3-git-send-email-deathsimple@vodafone.de \
--to=deathsimple@vodafone.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=jglisse@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox