drm/panthor: Test for imported buffers with drm_gem_is_imported()
authorThomas Zimmermann <tzimmermann@suse.de>
Mon, 17 Mar 2025 13:06:47 +0000 (14:06 +0100)
committerThomas Zimmermann <tzimmermann@suse.de>
Mon, 14 Apr 2025 08:53:11 +0000 (10:53 +0200)
Instead of testing import_attach for imported GEM buffers, invoke
drm_gem_is_imported() to do the test. The helper tests the dma_buf
itself while import_attach is just an artifact of the import. Prepares
to make import_attach optional.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Boris Brezillon <boris.brezillon@collabora.com>
Cc: Steven Price <steven.price@arm.com>
Cc: Liviu Dudau <liviu.dudau@arm.com>
Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
Reviewed-by: Steven Price <steven.price@arm.com>
Link: https://lore.kernel.org/r/20250317131923.238374-10-tzimmermann@suse.de
drivers/gpu/drm/panthor/panthor_gem.c
drivers/gpu/drm/panthor/panthor_mmu.c

index 8244a4e6c2a2b0aca53e46be868568e5917e8e26..fd014ccc3bfc3b054f1597233901812669e01af3 100644 (file)
@@ -155,7 +155,7 @@ static enum drm_gem_object_status panthor_gem_status(struct drm_gem_object *obj)
        struct panthor_gem_object *bo = to_panthor_bo(obj);
        enum drm_gem_object_status res = 0;
 
-       if (bo->base.base.import_attach || bo->base.pages)
+       if (drm_gem_is_imported(&bo->base.base) || bo->base.pages)
                res |= DRM_GEM_OBJECT_RESIDENT;
 
        return res;
index dc173c6edde0f3a0dec81764b474fbdce93d336d..6ca9a2642a4e12da3fbf1ea2bae1478dfd8692cb 100644 (file)
@@ -1104,7 +1104,7 @@ static void panthor_vm_bo_put(struct drm_gpuvm_bo *vm_bo)
        /* If the vm_bo object was destroyed, release the pin reference that
         * was hold by this object.
         */
-       if (unpin && !bo->base.base.import_attach)
+       if (unpin && !drm_gem_is_imported(&bo->base.base))
                drm_gem_shmem_unpin(&bo->base);
 
        drm_gpuvm_put(vm);
@@ -1235,7 +1235,7 @@ static int panthor_vm_prepare_map_op_ctx(struct panthor_vm_op_ctx *op_ctx,
        if (ret)
                goto err_cleanup;
 
-       if (!bo->base.base.import_attach) {
+       if (!drm_gem_is_imported(&bo->base.base)) {
                /* Pre-reserve the BO pages, so the map operation doesn't have to
                 * allocate.
                 */
@@ -1246,7 +1246,7 @@ static int panthor_vm_prepare_map_op_ctx(struct panthor_vm_op_ctx *op_ctx,
 
        sgt = drm_gem_shmem_get_pages_sgt(&bo->base);
        if (IS_ERR(sgt)) {
-               if (!bo->base.base.import_attach)
+               if (!drm_gem_is_imported(&bo->base.base))
                        drm_gem_shmem_unpin(&bo->base);
 
                ret = PTR_ERR(sgt);
@@ -1257,7 +1257,7 @@ static int panthor_vm_prepare_map_op_ctx(struct panthor_vm_op_ctx *op_ctx,
 
        preallocated_vm_bo = drm_gpuvm_bo_create(&vm->base, &bo->base.base);
        if (!preallocated_vm_bo) {
-               if (!bo->base.base.import_attach)
+               if (!drm_gem_is_imported(&bo->base.base))
                        drm_gem_shmem_unpin(&bo->base);
 
                ret = -ENOMEM;
@@ -1283,7 +1283,7 @@ static int panthor_vm_prepare_map_op_ctx(struct panthor_vm_op_ctx *op_ctx,
         * which will be released in panthor_vm_bo_put().
         */
        if (preallocated_vm_bo != op_ctx->map.vm_bo &&
-           !bo->base.base.import_attach)
+           !drm_gem_is_imported(&bo->base.base))
                drm_gem_shmem_unpin(&bo->base);
 
        op_ctx->map.bo_offset = offset;