anv: Handle external objects allocation in Xe
authorJosé Roberto de Souza <jose.souza@intel.com>
Fri, 10 Feb 2023 16:01:59 +0000 (08:01 -0800)
committerMarge Bot <emma+marge@anholt.net>
Wed, 15 Mar 2023 18:17:11 +0000 (18:17 +0000)
External(imported or exported) objects needs to have vm_id set to 0.

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/21885>

src/intel/vulkan/xe/anv_kmd_backend.c

index 01784ee..b76ba0b 100644 (file)
@@ -35,7 +35,11 @@ xe_gem_create(struct anv_device *device,
               enum anv_bo_alloc_flags alloc_flags)
 {
    struct drm_xe_gem_create gem_create = {
-     .vm_id = device->vm_id,
+     /* From xe_drm.h: If a VM is specified, this BO must:
+      * 1. Only ever be bound to that VM.
+      * 2. Cannot be exported as a PRIME fd.
+      */
+     .vm_id = alloc_flags & ANV_BO_ALLOC_EXTERNAL ? 0 : device->vm_id,
      .size = size,
      .flags = alloc_flags & ANV_BO_ALLOC_SCANOUT ? XE_GEM_CREATE_FLAG_SCANOUT : 0,
    };