drm/tegra: Extract tegra_gem_lookup()
authorMikko Perttunen <mperttunen@nvidia.com>
Thu, 10 Jun 2021 11:04:47 +0000 (14:04 +0300)
committerThierry Reding <treding@nvidia.com>
Tue, 10 Aug 2021 12:44:31 +0000 (14:44 +0200)
The static function host1x_bo_lookup() in drm.c is also useful
elsewhere. Extract it as tegra_gem_lookup() in gem.c.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
drivers/gpu/drm/tegra/drm.c
drivers/gpu/drm/tegra/gem.c
drivers/gpu/drm/tegra/gem.h

index 0e2a6f2..f7dc50e 100644 (file)
@@ -107,20 +107,6 @@ static void tegra_drm_context_free(struct tegra_drm_context *context)
        kfree(context);
 }
 
-static struct host1x_bo *
-host1x_bo_lookup(struct drm_file *file, u32 handle)
-{
-       struct drm_gem_object *gem;
-       struct tegra_bo *bo;
-
-       gem = drm_gem_object_lookup(file, handle);
-       if (!gem)
-               return NULL;
-
-       bo = to_tegra_bo(gem);
-       return &bo->base;
-}
-
 static int host1x_reloc_copy_from_user(struct host1x_reloc *dest,
                                       struct drm_tegra_reloc __user *src,
                                       struct drm_device *drm,
@@ -151,11 +137,11 @@ static int host1x_reloc_copy_from_user(struct host1x_reloc *dest,
 
        dest->flags = HOST1X_RELOC_READ | HOST1X_RELOC_WRITE;
 
-       dest->cmdbuf.bo = host1x_bo_lookup(file, cmdbuf);
+       dest->cmdbuf.bo = tegra_gem_lookup(file, cmdbuf);
        if (!dest->cmdbuf.bo)
                return -ENOENT;
 
-       dest->target.bo = host1x_bo_lookup(file, target);
+       dest->target.bo = tegra_gem_lookup(file, target);
        if (!dest->target.bo)
                return -ENOENT;
 
@@ -238,7 +224,7 @@ int tegra_drm_submit(struct tegra_drm_context *context,
                        goto fail;
                }
 
-               bo = host1x_bo_lookup(file, cmdbuf.handle);
+               bo = tegra_gem_lookup(file, cmdbuf.handle);
                if (!bo) {
                        err = -ENOENT;
                        goto fail;
index 26af8da..6ec598f 100644 (file)
@@ -707,3 +707,16 @@ struct drm_gem_object *tegra_gem_prime_import(struct drm_device *drm,
 
        return &bo->gem;
 }
+
+struct host1x_bo *tegra_gem_lookup(struct drm_file *file, u32 handle)
+{
+       struct drm_gem_object *gem;
+       struct tegra_bo *bo;
+
+       gem = drm_gem_object_lookup(file, handle);
+       if (!gem)
+               return NULL;
+
+       bo = to_tegra_bo(gem);
+       return &bo->base;
+}
index c15fd99..cb5146a 100644 (file)
@@ -80,4 +80,6 @@ struct dma_buf *tegra_gem_prime_export(struct drm_gem_object *gem,
 struct drm_gem_object *tegra_gem_prime_import(struct drm_device *drm,
                                              struct dma_buf *buf);
 
+struct host1x_bo *tegra_gem_lookup(struct drm_file *file, u32 handle);
+
 #endif