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>
This commit is contained in:
José Roberto de Souza
2022-08-22 14:12:46 -07:00
committed by Marge Bot
parent 94af444490
commit e879b28994
6 changed files with 42 additions and 51 deletions

View 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)

View File

@@ -268,23 +268,6 @@ anv_gem_set_tiling(struct anv_device *device,
return ret;
}
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)
{

View File

@@ -111,13 +111,6 @@ anv_gem_set_caching(struct anv_device *device, uint32_t gem_handle,
return 0;
}
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)
{

View 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);

View 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;
}

View 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);