anv: Implement Xe version of check_status()
authorJosé Roberto de Souza <jose.souza@intel.com>
Thu, 9 Feb 2023 20:34:50 +0000 (12:34 -0800)
committerMarge Bot <emma+marge@anholt.net>
Thu, 23 Mar 2023 13:27:39 +0000 (13:27 +0000)
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/22058>

src/intel/vulkan/anv_device.c
src/intel/vulkan/xe/anv_device.c
src/intel/vulkan/xe/anv_device.h

index b457b54..022cd53 100644 (file)
@@ -3036,8 +3036,18 @@ VkResult anv_CreateDevice(
       goto fail_device;
    }
 
+   switch (device->info->kmd_type) {
+   case INTEL_KMD_TYPE_I915:
+      device->vk.check_status = anv_i915_device_check_status;
+      break;
+   case INTEL_KMD_TYPE_XE:
+      device->vk.check_status = anv_xe_device_check_status;
+      break;
+   default:
+      unreachable("Missing");
+   }
+
    device->vk.command_buffer_ops = &anv_cmd_buffer_ops;
-   device->vk.check_status = anv_i915_device_check_status;
    device->vk.create_sync_for_memory = anv_create_sync_for_memory;
    vk_device_set_drm_fd(&device->vk, device->fd);
 
index bc3afb2..5414bee 100644 (file)
@@ -55,3 +55,26 @@ anv_xe_physical_device_get_parameters(struct anv_physical_device *device)
 
    return VK_SUCCESS;
 }
+
+VkResult
+anv_xe_device_check_status(struct vk_device *vk_device)
+{
+   struct anv_device *device = container_of(vk_device, struct anv_device, vk);
+   VkResult result = VK_SUCCESS;
+
+   for (uint32_t i = 0; i < device->queue_count; i++) {
+      struct drm_xe_engine_get_property engine_get_property = {
+         .engine_id = device->queues[i].engine_id,
+         .property = XE_ENGINE_GET_PROPERTY_BAN,
+      };
+      int ret = intel_ioctl(device->fd, DRM_IOCTL_XE_ENGINE_GET_PROPERTY,
+                            &engine_get_property);
+
+      if (ret || engine_get_property.value) {
+         result = vk_device_set_lost(&device->vk, "One or more queues banned");
+         break;
+      }
+   }
+
+   return result;
+}
index 026f5aa..6f290e5 100644 (file)
 #include <stdbool.h>
 
 #include "vulkan/vulkan_core.h"
+#include "vk_device.h"
 
 struct anv_device;
 struct anv_physical_device;
 
 bool anv_xe_device_destroy_vm(struct anv_device *device);
 VkResult anv_xe_device_setup_vm(struct anv_device *device);
+VkResult anv_xe_device_check_status(struct vk_device *vk_device);
 
 VkResult
 anv_xe_physical_device_get_parameters(struct anv_physical_device *device);