iris: Add batch_check_for_reset() to kmd backend

Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21700>
This commit is contained in:
José Roberto de Souza
2022-10-21 09:46:18 -07:00
committed by Marge Bot
parent e0ce31d7cf
commit 21d5034edb
5 changed files with 44 additions and 18 deletions
@@ -30,6 +30,7 @@
#include "drm-uapi/i915_drm.h"
#include "iris/iris_bufmgr.h"
#include "iris_batch.h"
#define FILE_DEBUG_FLAG DEBUG_BUFMGR
@@ -213,6 +214,32 @@ i915_gem_mmap(struct iris_bufmgr *bufmgr, struct iris_bo *bo)
return i915_gem_mmap_legacy(bufmgr, bo);
}
static enum pipe_reset_status
i915_batch_check_for_reset(struct iris_batch *batch)
{
struct iris_screen *screen = batch->screen;
enum pipe_reset_status status = PIPE_NO_RESET;
struct drm_i915_reset_stats stats = { .ctx_id = batch->ctx_id };
if (intel_ioctl(screen->fd, DRM_IOCTL_I915_GET_RESET_STATS, &stats))
DBG("DRM_IOCTL_I915_GET_RESET_STATS failed: %s\n", strerror(errno));
if (stats.batch_active != 0) {
/* A reset was observed while a batch from this hardware context was
* executing. Assume that this context was at fault.
*/
status = PIPE_GUILTY_CONTEXT_RESET;
} else if (stats.batch_pending != 0) {
/* A reset was observed while a batch from this context was in progress,
* but the batch was not executing. In this case, assume that the
* context was not at fault.
*/
status = PIPE_INNOCENT_CONTEXT_RESET;
}
return status;
}
const struct iris_kmd_backend *i915_get_backend(void)
{
static const struct iris_kmd_backend i915_backend = {
@@ -220,6 +247,7 @@ const struct iris_kmd_backend *i915_get_backend(void)
.bo_madvise = i915_bo_madvise,
.bo_set_caching = i915_bo_set_caching,
.gem_mmap = i915_gem_mmap,
.batch_check_for_reset = i915_batch_check_for_reset,
};
return &i915_backend;
}
+6 -18
View File
@@ -41,6 +41,7 @@
#include "iris_bufmgr.h"
#include "iris_context.h"
#include "iris_fence.h"
#include "iris_kmd_backend.h"
#include "iris_utrace.h"
#include "drm-uapi/i915_drm.h"
@@ -775,25 +776,12 @@ enum pipe_reset_status
iris_batch_check_for_reset(struct iris_batch *batch)
{
struct iris_screen *screen = batch->screen;
enum pipe_reset_status status = PIPE_NO_RESET;
struct drm_i915_reset_stats stats = { .ctx_id = batch->ctx_id };
if (intel_ioctl(screen->fd, DRM_IOCTL_I915_GET_RESET_STATS, &stats))
DBG("DRM_IOCTL_I915_GET_RESET_STATS failed: %s\n", strerror(errno));
if (stats.batch_active != 0) {
/* A reset was observed while a batch from this hardware context was
* executing. Assume that this context was at fault.
*/
status = PIPE_GUILTY_CONTEXT_RESET;
} else if (stats.batch_pending != 0) {
/* A reset was observed while a batch from this context was in progress,
* but the batch was not executing. In this case, assume that the
* context was not at fault.
*/
status = PIPE_INNOCENT_CONTEXT_RESET;
}
struct iris_bufmgr *bufmgr = screen->bufmgr;
const struct iris_kmd_backend *backend;
enum pipe_reset_status status;
backend = iris_bufmgr_get_kernel_driver_backend(bufmgr);
status = backend->batch_check_for_reset(batch);
if (status != PIPE_NO_RESET) {
/* Our context is likely banned, or at least in an unknown state.
* Throw it away and start with a fresh context. Ideally this may
+6
View File
@@ -2483,3 +2483,9 @@ iris_bufmgr_get_device_info(struct iris_bufmgr *bufmgr)
{
return &bufmgr->devinfo;
}
const struct iris_kmd_backend *
iris_bufmgr_get_kernel_driver_backend(struct iris_bufmgr *bufmgr)
{
return bufmgr->kmd_backend;
}
+2
View File
@@ -582,6 +582,8 @@ uint32_t iris_upload_border_color(struct iris_border_color_pool *pool,
uint64_t iris_bufmgr_vram_size(struct iris_bufmgr *bufmgr);
uint64_t iris_bufmgr_sram_size(struct iris_bufmgr *bufmgr);
const struct intel_device_info *iris_bufmgr_get_device_info(struct iris_bufmgr *bufmgr);
const struct iris_kmd_backend *
iris_bufmgr_get_kernel_driver_backend(struct iris_bufmgr *bufmgr);
enum iris_madvice {
IRIS_MADVICE_WILL_NEED = 0,
@@ -28,6 +28,7 @@
#include "dev/intel_device_info.h"
#include "dev/intel_kmd.h"
struct iris_batch;
struct iris_bo;
struct iris_bufmgr;
enum iris_heap;
@@ -41,6 +42,7 @@ struct iris_kmd_backend {
bool (*bo_madvise)(struct iris_bo *bo, enum iris_madvice state);
int (*bo_set_caching)(struct iris_bo *bo, bool cached);
void *(*gem_mmap)(struct iris_bufmgr *bufmgr, struct iris_bo *bo);
enum pipe_reset_status (*batch_check_for_reset)(struct iris_batch *batch);
};
const struct iris_kmd_backend *