iris: Fix vm bind of imported bos from other GPUs

The imported buffer may be created in a device with different
memory alignment and this can cause vm bind to fail because bo
size is smaller than vm bind range aligned.

Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22476>
This commit is contained in:
José Roberto de Souza
2023-03-28 08:49:30 -07:00
committed by Marge Bot
parent 41f1e6c84b
commit a5c57b9af7

View File

@@ -99,7 +99,13 @@ xe_gem_vm_bind_op(struct iris_bo *bo, uint32_t op)
};
uint32_t handle = op == XE_VM_BIND_OP_UNMAP ? 0 : bo->gem_handle;
uint64_t obj_offset = 0;
uint64_t range, obj_offset = 0;
if (iris_bo_is_imported(bo))
range = bo->size;
else
range = align64(bo->size,
iris_bufmgr_get_device_info(bo->bufmgr)->mem_alignment);
if (bo->real.userptr) {
handle = 0;
@@ -113,8 +119,7 @@ xe_gem_vm_bind_op(struct iris_bo *bo, uint32_t op)
.num_binds = 1,
.bind.obj = handle,
.bind.obj_offset = obj_offset,
.bind.range = align64(bo->size,
iris_bufmgr_get_device_info(bo->bufmgr)->mem_alignment),
.bind.range = range,
.bind.addr = intel_48b_address(bo->address),
.bind.op = op,
.num_syncs = 1,