Cc: Eric Anholt <eric@xxxxxxxxxx> Signed-off-by: Qiang Yu <yuq825@xxxxxxxxx> --- drivers/gpu/drm/v3d/v3d_gem.c | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/v3d/v3d_gem.c b/drivers/gpu/drm/v3d/v3d_gem.c index 4c4b59ae2c81..b7c4e56dafd2 100644 --- a/drivers/gpu/drm/v3d/v3d_gem.c +++ b/drivers/gpu/drm/v3d/v3d_gem.c @@ -291,8 +291,7 @@ v3d_lookup_bos(struct drm_device *dev, u32 bo_count) { u32 *handles; - int ret = 0; - int i; + int ret; job->bo_count = bo_count; @@ -304,19 +303,10 @@ 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; + return -ENOMEM; } if (copy_from_user(handles, @@ -324,26 +314,13 @@ v3d_lookup_bos(struct drm_device *dev, job->bo_count * sizeof(u32))) { ret = -EFAULT; DRM_DEBUG("Failed to copy in GEM handles\n"); - goto fail; + goto out; } - 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); + ret = drm_gem_objects_lookup(file_priv, handles, + job->bo_count, &job->bo); -fail: +out: kvfree(handles); return ret; } -- 2.17.1 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel