]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/xe/tests/xe_dma_buf: Set the drm_object::dma_buf member
authorThomas Hellström <thomas.hellstrom@linux.intel.com>
Thu, 21 Aug 2025 14:30:44 +0000 (16:30 +0200)
committerThomas Hellström <thomas.hellstrom@linux.intel.com>
Mon, 25 Aug 2025 08:23:55 +0000 (10:23 +0200)
This member is set when exporting using prime. However
the xe_gem_prime_export() alone doesn't set it, since it's done
later in the prime export flow.
For the test, set it manually and remove the hack that set it
temporarily when it was really needed.

Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Link: https://lore.kernel.org/r/20250821143045.106005-3-thomas.hellstrom@linux.intel.com
drivers/gpu/drm/xe/tests/xe_dma_buf.c

index c53f67ce4b0aa26b9e728bcaa518a92229e3c304..cde9530bef8c43c1d1cf6b80374ab902b2d6802e 100644 (file)
@@ -57,16 +57,12 @@ static void check_residency(struct kunit *test, struct xe_bo *exported,
                return;
 
        /*
-        * Evict exporter. Note that the gem object dma_buf member isn't
-        * set from xe_gem_prime_export(), and it's needed for the move_notify()
-        * functionality, so hack that up here. Evicting the exported bo will
+        * Evict exporter. Evicting the exported bo will
         * evict also the imported bo through the move_notify() functionality if
         * importer is on a different device. If they're on the same device,
         * the exporter and the importer should be the same bo.
         */
-       swap(exported->ttm.base.dma_buf, dmabuf);
        ret = xe_bo_evict(exported);
-       swap(exported->ttm.base.dma_buf, dmabuf);
        if (ret) {
                if (ret != -EINTR && ret != -ERESTARTSYS)
                        KUNIT_FAIL(test, "Evicting exporter failed with err=%d.\n",
@@ -139,6 +135,7 @@ static void xe_test_dmabuf_import_same_driver(struct xe_device *xe)
                           PTR_ERR(dmabuf));
                goto out;
        }
+       bo->ttm.base.dma_buf = dmabuf;
 
        import = xe_gem_prime_import(&xe->drm, dmabuf);
        if (!IS_ERR(import)) {
@@ -186,6 +183,7 @@ static void xe_test_dmabuf_import_same_driver(struct xe_device *xe)
                KUNIT_FAIL(test, "dynamic p2p attachment failed with err=%ld\n",
                           PTR_ERR(import));
        }
+       bo->ttm.base.dma_buf = NULL;
        dma_buf_put(dmabuf);
 out:
        drm_gem_object_put(&bo->ttm.base);