Replace the open-coded self-import check with the drm core
helper drm_gem_prime_self_import(), which performs the same ops and
device match and returns the backing GEM object with a reference.

Assisted-by: GitHub-Copilot:claude-opus-4.8
Signed-off-by: Niranjana Vishwanathapura <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
index b33c300e26e2..5863f6605308 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
@@ -549,17 +549,9 @@ struct drm_gem_object *amdgpu_gem_prime_import(struct 
drm_device *dev,
        struct dma_buf_attachment *attach;
        struct drm_gem_object *obj;
 
-       if (dma_buf->ops == &amdgpu_dmabuf_ops) {
-               obj = dma_buf->priv;
-               if (obj->dev == dev) {
-                       /*
-                        * Importing dmabuf exported from out own gem increases
-                        * refcount on gem itself instead of f_count of dmabuf.
-                        */
-                       drm_gem_object_get(obj);
-                       return obj;
-               }
-       }
+       obj = drm_gem_prime_self_import(dev, dma_buf, &amdgpu_dmabuf_ops);
+       if (obj)
+               return obj;
 
        obj = amdgpu_dma_buf_create_obj(dev, dma_buf);
        if (IS_ERR(obj))
-- 
2.43.0

Reply via email to