summaryrefslogtreecommitdiff
path: root/src/intel/vulkan
diff options
context:
space:
mode:
authorJosé Roberto de Souza <jose.souza@intel.com>2022-08-22 14:12:46 -0700
committerMarge Bot <emma+marge@anholt.net>2023-01-17 17:10:18 +0000
commite879b289947ffed8f435c3c394c30031fc84e8c0 (patch)
treefd92c970d97c103b3d60d104ed33abb8f20f992b /src/intel/vulkan
parent94af444490f23497e5da2ef6ca351c592abf06a3 (diff)
anv: Move anv_device_check_status() code to i915/anv_device.c
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>
Diffstat (limited to 'src/intel/vulkan')
-rw-r--r--src/intel/vulkan/anv_device.c26
-rw-r--r--src/intel/vulkan/anv_gem.c17
-rw-r--r--src/intel/vulkan/anv_gem_stubs.c7
-rw-r--r--src/intel/vulkan/anv_private.h2
-rw-r--r--src/intel/vulkan/i915/anv_device.c38
-rw-r--r--src/intel/vulkan/i915/anv_device.h3
6 files changed, 42 insertions, 51 deletions
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 228cb09683d..ab42c836971 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 2f8a58cf205..1bfc3a88d6e 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 50e0105eb73..4b62e122f5f 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 d466904ca8d..b58be9b9771 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 12a992c9641..ada5a85e846 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 aed187e8102..af42c224161 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);