From: Qiang Yu <yuq825@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: lima@lists.freedesktop.org,
Maxime Ripard <maxime.ripard@bootlin.com>,
David Airlie <airlied@linux.ie>, Qiang Yu <yuq825@gmail.com>,
Sean Paul <sean@poorly.run>
Subject: [PATCH v2 2/6] drm/v3d: use drm_gem_objects_lookup_user
Date: Fri, 27 Sep 2019 21:46:12 +0800 [thread overview]
Message-ID: <20190927134616.21899-3-yuq825@gmail.com> (raw)
In-Reply-To: <20190927134616.21899-1-yuq825@gmail.com>
v2:
use drm_gem_objects_lookup_user instead of
drm_gem_objects_lookup.
Cc: Eric Anholt <eric@anholt.net>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
---
drivers/gpu/drm/v3d/v3d_gem.c | 49 +++--------------------------------
1 file changed, 3 insertions(+), 46 deletions(-)
diff --git a/drivers/gpu/drm/v3d/v3d_gem.c b/drivers/gpu/drm/v3d/v3d_gem.c
index 4c4b59ae2c81..75a3b448f3fa 100644
--- a/drivers/gpu/drm/v3d/v3d_gem.c
+++ b/drivers/gpu/drm/v3d/v3d_gem.c
@@ -290,10 +290,6 @@ v3d_lookup_bos(struct drm_device *dev,
u64 bo_handles,
u32 bo_count)
{
- u32 *handles;
- int ret = 0;
- int i;
-
job->bo_count = bo_count;
if (!job->bo_count) {
@@ -304,48 +300,9 @@ v3d_lookup_bos(struct drm_device *dev,
return -EINVAL;
}
- job->bo = kvmalloc_array(job->bo_count,
- sizeof(struct drm_gem_cma_object *),
- GFP_KERNEL | __GFP_ZERO);
- if (!job->bo) {
- DRM_DEBUG("Failed to allocate validated BO pointers\n");
- return -ENOMEM;
- }
-
- handles = kvmalloc_array(job->bo_count, sizeof(u32), GFP_KERNEL);
- if (!handles) {
- ret = -ENOMEM;
- DRM_DEBUG("Failed to allocate incoming GEM handles\n");
- goto fail;
- }
-
- if (copy_from_user(handles,
- (void __user *)(uintptr_t)bo_handles,
- job->bo_count * sizeof(u32))) {
- ret = -EFAULT;
- DRM_DEBUG("Failed to copy in GEM handles\n");
- goto fail;
- }
-
- spin_lock(&file_priv->table_lock);
- for (i = 0; i < job->bo_count; i++) {
- struct drm_gem_object *bo = idr_find(&file_priv->object_idr,
- handles[i]);
- if (!bo) {
- DRM_DEBUG("Failed to look up GEM BO %d: %d\n",
- i, handles[i]);
- ret = -ENOENT;
- spin_unlock(&file_priv->table_lock);
- goto fail;
- }
- drm_gem_object_get(bo);
- job->bo[i] = bo;
- }
- spin_unlock(&file_priv->table_lock);
-
-fail:
- kvfree(handles);
- return ret;
+ return drm_gem_objects_lookup_user(file_priv,
+ (void __user *)(uintptr_t)bo_handles,
+ job->bo_count, &job->bo);
}
static void
--
2.17.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2019-09-27 13:46 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-27 13:46 [PATCH v2 0/6] drm/lima: simplify driver by using more drm helpers Qiang Yu
2019-09-27 13:46 ` [PATCH v2 1/6] drm/gem: refine drm_gem_objects_lookup Qiang Yu
2019-09-27 13:57 ` Steven Price
2019-09-29 6:07 ` Qiang Yu
2019-10-09 15:07 ` Daniel Vetter
2019-10-09 16:05 ` Rob Herring
2019-10-09 16:22 ` Daniel Vetter
2019-09-27 13:46 ` Qiang Yu [this message]
2019-09-27 13:57 ` [PATCH v2 2/6] drm/v3d: use drm_gem_objects_lookup_user Steven Price
2019-09-27 13:46 ` [PATCH v2 3/6] drm/lima: use drm_gem_objects_lookup Qiang Yu
2019-09-27 13:46 ` [PATCH v2 4/6] drm/lima: use drm_gem_shmem_helpers Qiang Yu
2019-09-27 13:46 ` [PATCH v2 5/6] drm/lima: use drm_gem_(un)lock_reservations Qiang Yu
2019-09-27 13:46 ` [PATCH v2 6/6] drm/lima: add __GFP_NOWARN flag to all dma_alloc_wc Qiang Yu
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=20190927134616.21899-3-yuq825@gmail.com \
--to=yuq825@gmail.com \
--cc=airlied@linux.ie \
--cc=dri-devel@lists.freedesktop.org \
--cc=lima@lists.freedesktop.org \
--cc=maxime.ripard@bootlin.com \
--cc=sean@poorly.run \
/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