if (!xe_bo_is_mem_type(exported, mem_type)) {
KUNIT_FAIL(test, "Exported bo was not in expected memory type.\n"); return;
}
if (xe_bo_is_pinned(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 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",
ret); return;
}
/* Verify that also importer has been evicted to SYSTEM */ if (exported != imported && !xe_bo_is_mem_type(imported, XE_PL_SYSTEM)) {
KUNIT_FAIL(test, "Importer wasn't properly evicted.\n"); return;
}
/* Re-validate the importer. This should move also exporter in. */
ret = xe_bo_validate(imported, NULL, false); if (ret) { if (ret != -EINTR && ret != -ERESTARTSYS)
KUNIT_FAIL(test, "Validating importer failed with err=%d.\n",
ret); return;
}
/* * Did import succeed when it shouldn't due to lack of p2p support?
*/ if (params->force_different_devices &&
!p2p_enabled(params) &&
!(params->mem_mask & XE_BO_FLAG_SYSTEM)) {
KUNIT_FAIL(test, "xe_gem_prime_import() succeeded when it shouldn't have\n");
} else { int err;
/* Is everything where we expect it to be? */
xe_bo_lock(import_bo, false);
err = xe_bo_validate(import_bo, NULL, false);
/* Pinning in VRAM is not allowed. */ if (!is_dynamic(params) &&
params->force_different_devices &&
!(params->mem_mask & XE_BO_FLAG_SYSTEM))
KUNIT_EXPECT_EQ(test, err, -EINVAL); /* Otherwise only expect interrupts or success. */ elseif (err && err != -EINTR && err != -ERESTARTSYS)
KUNIT_EXPECT_TRUE(test, !err || err == -EINTR ||
err == -ERESTARTSYS);
if (!err)
check_residency(test, bo, import_bo, dmabuf);
xe_bo_unlock(import_bo);
}
drm_gem_object_put(import);
} elseif (PTR_ERR(import) != -EOPNOTSUPP) { /* Unexpected error code. */
KUNIT_FAIL(test, "xe_gem_prime_import failed with the wrong err=%ld\n",
PTR_ERR(import));
} elseif (!params->force_different_devices ||
p2p_enabled(params) ||
(params->mem_mask & XE_BO_FLAG_SYSTEM)) { /* Shouldn't fail if we can reuse same bo, use p2p or use system */
KUNIT_FAIL(test, "dynamic p2p attachment failed with err=%ld\n",
PTR_ERR(import));
}
dma_buf_put(dmabuf);
out:
drm_gem_object_put(&bo->ttm.base);
}
/* * We test the implementation with bos of different residency and with * importers with different capabilities; some lacking p2p support and some * lacking dynamic capabilities (attach_ops == NULL). We also fake * different devices avoiding the import shortcut that just reuses the same * gem object.
*/ staticconststruct dma_buf_test_params test_params[] = {
{.mem_mask = XE_BO_FLAG_VRAM0,
.attach_ops = &xe_dma_buf_attach_ops},
{.mem_mask = XE_BO_FLAG_VRAM0,
.attach_ops = &xe_dma_buf_attach_ops,
.force_different_devices = true},
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.