Module: Mesa Branch: main Commit: 45cb2819f6a27f999918594a770a6fdb76b6faeb URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=45cb2819f6a27f999918594a770a6fdb76b6faeb
Author: José Roberto de Souza <[email protected]> Date: Thu Feb 9 12:34:50 2023 -0800 anv: Implement Xe version of check_status() Signed-off-by: José Roberto de Souza <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22058> --- src/intel/vulkan/anv_device.c | 12 +++++++++++- src/intel/vulkan/xe/anv_device.c | 23 +++++++++++++++++++++++ src/intel/vulkan/xe/anv_device.h | 2 ++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index b457b5428fe..022cd53700a 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -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); diff --git a/src/intel/vulkan/xe/anv_device.c b/src/intel/vulkan/xe/anv_device.c index bc3afb2fa35..5414beef5af 100644 --- a/src/intel/vulkan/xe/anv_device.c +++ b/src/intel/vulkan/xe/anv_device.c @@ -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; +} diff --git a/src/intel/vulkan/xe/anv_device.h b/src/intel/vulkan/xe/anv_device.h index 026f5aaccb5..6f290e56908 100644 --- a/src/intel/vulkan/xe/anv_device.h +++ b/src/intel/vulkan/xe/anv_device.h @@ -25,12 +25,14 @@ #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);
