anv: Move anv_device_check_status() code to i915/anv_device.c
authorJosé Roberto de Souza <jose.souza@intel.com>
Mon, 22 Aug 2022 21:12:46 +0000 (14:12 -0700)
committerMarge Bot <emma+marge@anholt.net>
Tue, 17 Jan 2023 17:10:18 +0000 (17:10 +0000)
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Rohan Garg <rohan.garg@intel.com>
Acked-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20428>

src/intel/vulkan/anv_device.c
src/intel/vulkan/anv_gem.c
src/intel/vulkan/anv_gem_stubs.c
src/intel/vulkan/anv_private.h
src/intel/vulkan/i915/anv_device.c
src/intel/vulkan/i915/anv_device.h

index 228cb09..ab42c83 100644 (file)
@@ -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)
index 2f8a58c..1bfc3a8 100644 (file)
@@ -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 = {
index 50e0105..4b62e12 100644 (file)
@@ -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");
index d466904..b58be9b 100644 (file)
@@ -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);
index 12a992c..ada5a85 100644 (file)
@@ -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;
+}
index aed187e..af42c22 100644 (file)
@@ -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);