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/panfrost/panfrost_gem.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c 
b/drivers/gpu/drm/panfrost/panfrost_gem.c
index 3a7fce428898..19fcbffb3e94 100644
--- a/drivers/gpu/drm/panfrost/panfrost_gem.c
+++ b/drivers/gpu/drm/panfrost/panfrost_gem.c
@@ -386,15 +386,11 @@ struct drm_gem_object *
 panfrost_gem_prime_import(struct drm_device *dev,
                          struct dma_buf *dma_buf)
 {
-       struct drm_gem_object *obj = dma_buf->priv;
+       struct drm_gem_object *obj;
 
-       if (dma_buf->ops == &panfrost_dma_buf_ops && obj->dev == dev) {
-               /* Importing dmabuf exported from our own gem increases
-                * refcount on gem itself instead of f_count of dmabuf.
-                */
-               drm_gem_object_get(obj);
+       obj = drm_gem_prime_self_import(dev, dma_buf, &panfrost_dma_buf_ops);
+       if (obj)
                return obj;
-       }
 
        return drm_gem_prime_import(dev, dma_buf);
 }
-- 
2.43.0

Reply via email to