So we can re-use it from elsewhere.

Signed-off-by: Boris Brezillon <boris.brezil...@collabora.com>
Reviewed-by: Steven Price <steven.pr...@arm.com>
---
 drivers/gpu/drm/panfrost/panfrost_drv.c | 53 ++++++++++++++-----------
 1 file changed, 29 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c 
b/drivers/gpu/drm/panfrost/panfrost_drv.c
index 40e4a4db3ab1..b131da3c9399 100644
--- a/drivers/gpu/drm/panfrost/panfrost_drv.c
+++ b/drivers/gpu/drm/panfrost/panfrost_drv.c
@@ -118,6 +118,34 @@ static int panfrost_ioctl_create_bo(struct drm_device 
*dev, void *data,
        return 0;
 }
 
+static int
+panfrost_get_job_mappings(struct drm_file *file_priv, struct panfrost_job *job)
+{
+       struct panfrost_file_priv *priv = file_priv->driver_priv;
+       unsigned int i;
+
+       job->mappings = kvmalloc_array(job->bo_count,
+                                      sizeof(*job->mappings),
+                                      GFP_KERNEL | __GFP_ZERO);
+       if (!job->mappings)
+               return -ENOMEM;
+
+       for (i = 0; i < job->bo_count; i++) {
+               struct panfrost_gem_mapping *mapping;
+               struct panfrost_gem_object *bo;
+
+               bo = to_panfrost_bo(job->bos[i]);
+               mapping = panfrost_gem_mapping_get(bo, priv);
+               if (!mapping)
+                       return -EINVAL;
+
+               atomic_inc(&bo->gpu_usecount);
+               job->mappings[i] = mapping;
+       }
+
+       return 0;
+}
+
 /**
  * panfrost_lookup_bos() - Sets up job->bo[] with the GEM objects
  * referenced by the job.
@@ -137,9 +165,6 @@ panfrost_lookup_bos(struct drm_device *dev,
                  struct drm_panfrost_submit *args,
                  struct panfrost_job *job)
 {
-       struct panfrost_file_priv *priv = file_priv->driver_priv;
-       struct panfrost_gem_object *bo;
-       unsigned int i;
        int ret;
 
        job->bo_count = args->bo_handle_count;
@@ -153,27 +178,7 @@ panfrost_lookup_bos(struct drm_device *dev,
        if (ret)
                return ret;
 
-       job->mappings = kvmalloc_array(job->bo_count,
-                                      sizeof(struct panfrost_gem_mapping *),
-                                      GFP_KERNEL | __GFP_ZERO);
-       if (!job->mappings)
-               return -ENOMEM;
-
-       for (i = 0; i < job->bo_count; i++) {
-               struct panfrost_gem_mapping *mapping;
-
-               bo = to_panfrost_bo(job->bos[i]);
-               mapping = panfrost_gem_mapping_get(bo, priv);
-               if (!mapping) {
-                       ret = -EINVAL;
-                       break;
-               }
-
-               atomic_inc(&bo->gpu_usecount);
-               job->mappings[i] = mapping;
-       }
-
-       return ret;
+       return panfrost_get_job_mappings(file_priv, job);
 }
 
 /**
-- 
2.31.1

Reply via email to