Skip to contentSkip to conversation

drm/vc4: Test for imported buffers with drm_gem_is_imported()

PATCH In review Thomas Zimmermann 2 participants 2 messages Apr 14, 2025 – Apr 24, 2025

Subsystems (3)
lore
Share & tools
lore

Thomas Zimmermann

author maintainer
#0 lore raw

PATCH 6/11 drm/vc4: Test for imported buffers with drm_gem_is_imported()

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.

Cc Maxime Ripard <[email protected]>
Cc Dave Stevenson <[email protected]>
Cc "Maíra Canal" <[email protected]>
Cc Raspberry Pi Kernel Maintenance <[email protected]>
---
 drivers/gpu/drm/vc4/vc4_bo.c  | 2 +-
 drivers/gpu/drm/vc4/vc4_gem.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/vc4/vc4_bo.c +1 -1
index 7125773889f1..b503fd0488b0 100644
@@ -556,7 +556,7 @@ static void vc4_free_object(struct drm_gem_object *gem_bo)
 	mutex_lock(&vc4->bo_lock);
 	/* If the object references someone else's memory, we can't cache it.
 	 */
-	if (gem_bo->import_attach) {
+	if (drm_gem_is_imported(gem_bo)) {
 		vc4_bo_destroy(bo);
 		goto out;
 	}
drivers/gpu/drm/vc4/vc4_gem.c +1 -1
index 8125f87edc60..3e79ad69250a 100644
@@ -1249,7 +1249,7 @@ int vc4_gem_madvise_ioctl(struct drm_device *dev, void *data,
 	/* Not sure it's safe to purge imported BOs. Let's just assume it's
 	 * not until proven otherwise.
 	 */
-	if (gem_obj->import_attach) {
+	if (drm_gem_is_imported(gem_obj)) {
 		DRM_DEBUG("madvise not supported on imported BOs\n");
 		ret = -EINVAL;
 		goto out_put_gem;
Signature · 1 line
2.49.0
maintainer Acked-by on v1 6/11
#1 lore raw
Quoted 11 lines · Thomas Zimmermann

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.

Cc Maxime Ripard <[email protected]>
Cc Dave Stevenson <[email protected]>
Cc "Maíra Canal" <[email protected]>
Cc Raspberry Pi Kernel Maintenance <[email protected]>
Quoted 34 lines
---
 drivers/gpu/drm/vc4/vc4_bo.c  | 2 +-
 drivers/gpu/drm/vc4/vc4_gem.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/vc4/vc4_bo.c +1 -1
index 7125773889f1..b503fd0488b0 100644
@@ -556,7 +556,7 @@ static void vc4_free_object(struct drm_gem_object *gem_bo)
        mutex_lock(&vc4->bo_lock);
        /* If the object references someone else's memory, we can't cache it.
         */
-       if (gem_bo->import_attach) {
+       if (drm_gem_is_imported(gem_bo)) {
                vc4_bo_destroy(bo);
                goto out;
        }
drivers/gpu/drm/vc4/vc4_gem.c +1 -2
index 8125f87edc60..3e79ad69250a 100644
@@ -1249,7 +1249,7 @@ int vc4_gem_madvise_ioctl(struct drm_device *dev, void *data,
        /* Not sure it's safe to purge imported BOs. Let's just assume it's
         * not until proven otherwise.
         */
-       if (gem_obj->import_attach) {
+       if (drm_gem_is_imported(gem_obj)) {
                DRM_DEBUG("madvise not supported on imported BOs\n");
                ret = -EINVAL;
                goto out_put_gem;
--

2.49.0