Merge tag 'amd-drm-next-5.11-2020-11-05' of git://people.freedesktop.org/~agd5f/linux...
[sfrench/cifs-2.6.git] / drivers / gpu / drm / amd / amdgpu / amdgpu_gem.c
index 5b50860eece416f0dbad59e60633c781ada63525..df94db19953289a5cddcb7516c26af3a8a68c585 100644 (file)
 
 #include "amdgpu.h"
 #include "amdgpu_display.h"
+#include "amdgpu_dma_buf.h"
 #include "amdgpu_xgmi.h"
 
-void amdgpu_gem_object_free(struct drm_gem_object *gobj)
+static const struct drm_gem_object_funcs amdgpu_gem_object_funcs;
+
+static void amdgpu_gem_object_free(struct drm_gem_object *gobj)
 {
        struct amdgpu_bo *robj = gem_to_amdgpu_bo(gobj);
 
@@ -87,6 +90,7 @@ retry:
                return r;
        }
        *obj = &bo->tbo.base;
+       (*obj)->funcs = &amdgpu_gem_object_funcs;
 
        return 0;
 }
@@ -119,8 +123,8 @@ void amdgpu_gem_force_release(struct amdgpu_device *adev)
  * Call from drm_gem_handle_create which appear in both new and open ioctl
  * case.
  */
-int amdgpu_gem_object_open(struct drm_gem_object *obj,
-                          struct drm_file *file_priv)
+static int amdgpu_gem_object_open(struct drm_gem_object *obj,
+                                 struct drm_file *file_priv)
 {
        struct amdgpu_bo *abo = gem_to_amdgpu_bo(obj);
        struct amdgpu_device *adev = amdgpu_ttm_adev(abo->tbo.bdev);
@@ -152,8 +156,8 @@ int amdgpu_gem_object_open(struct drm_gem_object *obj,
        return 0;
 }
 
-void amdgpu_gem_object_close(struct drm_gem_object *obj,
-                            struct drm_file *file_priv)
+static void amdgpu_gem_object_close(struct drm_gem_object *obj,
+                                   struct drm_file *file_priv)
 {
        struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj);
        struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
@@ -211,6 +215,15 @@ out_unlock:
        ttm_eu_backoff_reservation(&ticket, &list);
 }
 
+static const struct drm_gem_object_funcs amdgpu_gem_object_funcs = {
+       .free = amdgpu_gem_object_free,
+       .open = amdgpu_gem_object_open,
+       .close = amdgpu_gem_object_close,
+       .export = amdgpu_gem_prime_export,
+       .vmap = amdgpu_gem_prime_vmap,
+       .vunmap = amdgpu_gem_prime_vunmap,
+};
+
 /*
  * GEM ioctls.
  */