From e879b289947ffed8f435c3c394c30031fc84e8c0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Roberto=20de=20Souza?= Date: Mon, 22 Aug 2022 14:12:46 -0700 Subject: [PATCH] anv: Move anv_device_check_status() code to i915/anv_device.c MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: José Roberto de Souza Reviewed-by: Lionel Landwerlin Acked-by: Rohan Garg Acked-by: Marcin Ślusarz Part-of: --- src/intel/vulkan/anv_device.c | 26 +------------------------- src/intel/vulkan/anv_gem.c | 17 ----------------- src/intel/vulkan/anv_gem_stubs.c | 7 ------- src/intel/vulkan/anv_private.h | 2 -- src/intel/vulkan/i915/anv_device.c | 38 ++++++++++++++++++++++++++++++++++++++ src/intel/vulkan/i915/anv_device.h | 3 +++ 6 files changed, 42 insertions(+), 51 deletions(-) diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 228cb09..ab42c83 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -3111,8 +3111,6 @@ static struct intel_mapped_pinned_buffer_alloc aux_map_allocator = { .free = intel_aux_map_buffer_free, }; -static VkResult anv_device_check_status(struct vk_device *vk_device); - VkResult anv_CreateDevice( VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo, @@ -3218,7 +3216,7 @@ VkResult anv_CreateDevice( } device->vk.command_buffer_ops = &anv_cmd_buffer_ops; - device->vk.check_status = anv_device_check_status; + 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); @@ -3721,28 +3719,6 @@ VkResult anv_EnumerateInstanceLayerProperties( return vk_error(NULL, VK_ERROR_LAYER_NOT_PRESENT); } -static VkResult -anv_device_check_status(struct vk_device *vk_device) -{ - struct anv_device *device = container_of(vk_device, struct anv_device, vk); - - uint32_t active, pending; - int ret = anv_gem_context_get_reset_stats(device->fd, device->context_id, - &active, &pending); - if (ret == -1) { - /* We don't know the real error. */ - return vk_device_set_lost(&device->vk, "get_reset_stats failed: %m"); - } - - if (active) { - return vk_device_set_lost(&device->vk, "GPU hung on one of our command buffers"); - } else if (pending) { - return vk_device_set_lost(&device->vk, "GPU hung with commands in-flight"); - } - - return VK_SUCCESS; -} - VkResult anv_device_wait(struct anv_device *device, struct anv_bo *bo, int64_t timeout) diff --git a/src/intel/vulkan/anv_gem.c b/src/intel/vulkan/anv_gem.c index 2f8a58c..1bfc3a8 100644 --- a/src/intel/vulkan/anv_gem.c +++ b/src/intel/vulkan/anv_gem.c @@ -269,23 +269,6 @@ anv_gem_set_tiling(struct anv_device *device, } int -anv_gem_context_get_reset_stats(int fd, int context, - uint32_t *active, uint32_t *pending) -{ - struct drm_i915_reset_stats stats = { - .ctx_id = context, - }; - - int ret = intel_ioctl(fd, DRM_IOCTL_I915_GET_RESET_STATS, &stats); - if (ret == 0) { - *active = stats.batch_active; - *pending = stats.batch_pending; - } - - return ret; -} - -int anv_gem_handle_to_fd(struct anv_device *device, uint32_t gem_handle) { struct drm_prime_handle args = { diff --git a/src/intel/vulkan/anv_gem_stubs.c b/src/intel/vulkan/anv_gem_stubs.c index 50e0105..4b62e12 100644 --- a/src/intel/vulkan/anv_gem_stubs.c +++ b/src/intel/vulkan/anv_gem_stubs.c @@ -112,13 +112,6 @@ anv_gem_set_caching(struct anv_device *device, uint32_t gem_handle, } int -anv_gem_context_get_reset_stats(int fd, int context, - uint32_t *active, uint32_t *pending) -{ - unreachable("Unused"); -} - -int anv_gem_handle_to_fd(struct anv_device *device, uint32_t gem_handle) { unreachable("Unused"); diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index d466904..b58be9b 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -1351,8 +1351,6 @@ int anv_gem_wait(struct anv_device *device, uint32_t gem_handle, int64_t *timeou int anv_gem_set_tiling(struct anv_device *device, uint32_t gem_handle, uint32_t stride, uint32_t tiling); int anv_gem_get_tiling(struct anv_device *device, uint32_t gem_handle); -int anv_gem_context_get_reset_stats(int fd, int context, - uint32_t *active, uint32_t *pending); int anv_gem_handle_to_fd(struct anv_device *device, uint32_t gem_handle); uint32_t anv_gem_fd_to_handle(struct anv_device *device, int fd); int anv_gem_set_caching(struct anv_device *device, uint32_t gem_handle, uint32_t caching); diff --git a/src/intel/vulkan/i915/anv_device.c b/src/intel/vulkan/i915/anv_device.c index 12a992c..ada5a85e 100644 --- a/src/intel/vulkan/i915/anv_device.c +++ b/src/intel/vulkan/i915/anv_device.c @@ -204,3 +204,41 @@ fail_context: intel_gem_destroy_context(device->fd, device->context_id); return result; } + +static int +anv_gem_context_get_reset_stats(int fd, int context, + uint32_t *active, uint32_t *pending) +{ + struct drm_i915_reset_stats stats = { + .ctx_id = context, + }; + + int ret = intel_ioctl(fd, DRM_IOCTL_I915_GET_RESET_STATS, &stats); + if (ret == 0) { + *active = stats.batch_active; + *pending = stats.batch_pending; + } + + return ret; +} + +VkResult +anv_i915_device_check_status(struct vk_device *vk_device) +{ + struct anv_device *device = container_of(vk_device, struct anv_device, vk); + uint32_t active = 0, pending = 0; + int ret = anv_gem_context_get_reset_stats(device->fd, device->context_id, + &active, &pending); + if (ret == -1) { + /* We don't know the real error. */ + return vk_device_set_lost(&device->vk, "get_reset_stats failed: %m"); + } + + if (active) { + return vk_device_set_lost(&device->vk, "GPU hung on one of our command buffers"); + } else if (pending) { + return vk_device_set_lost(&device->vk, "GPU hung with commands in-flight"); + } + + return VK_SUCCESS; +} diff --git a/src/intel/vulkan/i915/anv_device.h b/src/intel/vulkan/i915/anv_device.h index aed187e..af42c22 100644 --- a/src/intel/vulkan/i915/anv_device.h +++ b/src/intel/vulkan/i915/anv_device.h @@ -23,6 +23,7 @@ #pragma once #include "vulkan/vulkan_core.h" +#include "vk_device.h" struct anv_device; struct anv_physical_device; @@ -34,3 +35,5 @@ VkResult anv_i915_device_setup_context(struct anv_device *device, const VkDeviceCreateInfo *pCreateInfo, const uint32_t num_queues); + +VkResult anv_i915_device_check_status(struct vk_device *vk_device); -- 2.7.4