/* * For now only support pinning in TT memory, for two reasons: * 1) Avoid pinning in a placement not accessible to some importers. * 2) Pinning in VRAM requires PIN accounting which is a to-do.
*/ if (xe_bo_is_pinned(bo) && !xe_bo_is_mem_type(bo, XE_PL_TT)) {
drm_dbg(&xe->drm, "Can't migrate pinned bo for dma-buf pin.\n"); return -EINVAL;
}
ret = xe_bo_migrate(bo, XE_PL_TT); if (ret) { if (ret != -EINTR && ret != -ERESTARTSYS)
drm_dbg(&xe->drm, "Failed migrating dma-buf to TT memory: %pe\n",
ERR_PTR(ret)); return ret;
}
ret = xe_bo_pin_external(bo, true);
xe_assert(xe, !ret);
if (!attach->peer2peer && !xe_bo_can_migrate(bo, XE_PL_TT)) return ERR_PTR(-EOPNOTSUPP);
if (!xe_bo_is_pinned(bo)) { if (!attach->peer2peer)
r = xe_bo_migrate(bo, XE_PL_TT); else
r = xe_bo_validate(bo, NULL, false); if (r) return ERR_PTR(r);
}
switch (bo->ttm.resource->mem_type) { case XE_PL_TT:
sgt = drm_prime_pages_to_sg(obj->dev,
bo->ttm.ttm->pages,
bo->ttm.ttm->num_pages); if (IS_ERR(sgt)) return sgt;
if (dma_map_sgtable(attach->dev, sgt, dir,
DMA_ATTR_SKIP_CPU_SYNC)) goto error_free; break;
case XE_PL_VRAM0: case XE_PL_VRAM1:
r = xe_ttm_vram_mgr_alloc_sgt(xe_bo_device(bo),
bo->ttm.resource, 0,
bo->ttm.base.size, attach->dev,
dir, &sgt); if (r) return ERR_PTR(r); break; default: return ERR_PTR(-EINVAL);
}
if (dma_buf->ops == &xe_dmabuf_ops) {
obj = dma_buf->priv; if (obj->dev == dev &&
!XE_TEST_ONLY(test && test->force_different_devices)) { /* * Importing dmabuf exported from out own gem increases * refcount on gem itself instead of f_count of dmabuf.
*/
drm_gem_object_get(obj); return obj;
}
}
/* * Don't publish the bo until we have a valid attachment, and a * valid attachment needs the bo address. So pre-create a bo before * creating the attachment and publish.
*/
bo = xe_bo_alloc(); if (IS_ERR(bo)) return ERR_CAST(bo);
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.