diff options
author | Rob Clark <[email protected]> | 2019-04-16 11:10:01 -0700 |
---|---|---|
committer | Rob Clark <[email protected]> | 2019-04-25 14:13:31 -0700 |
commit | 96d2e4ab8ad394a4c3e8d315880b7af7a0cc824c (patch) | |
tree | 3f1775c7f6011db797701b36579765b4faed5e1a /src | |
parent | 650391868935ce047b7108f1c4f25f97323f8031 (diff) |
freedreno: add robustness support
Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src')
4 files changed, 57 insertions, 0 deletions
diff --git a/src/gallium/drivers/freedreno/freedreno_context.c b/src/gallium/drivers/freedreno/freedreno_context.c index 4e86d099974..bf26d00bc1e 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.c +++ b/src/gallium/drivers/freedreno/freedreno_context.c @@ -208,6 +208,39 @@ fd_set_debug_callback(struct pipe_context *pctx, memset(&ctx->debug, 0, sizeof(ctx->debug)); } +static uint32_t +fd_get_reset_count(struct fd_context *ctx, bool per_context) +{ + uint64_t val; + enum fd_param_id param = + per_context ? FD_CTX_FAULTS : FD_GLOBAL_FAULTS; + int ret = fd_pipe_get_param(ctx->pipe, param, &val); + debug_assert(!ret); + return val; +} + +static enum pipe_reset_status +fd_get_device_reset_status(struct pipe_context *pctx) +{ + struct fd_context *ctx = fd_context(pctx); + int context_faults = fd_get_reset_count(ctx, true); + int global_faults = fd_get_reset_count(ctx, false); + enum pipe_reset_status status; + + if (context_faults != ctx->context_reset_count) { + status = PIPE_GUILTY_CONTEXT_RESET; + } else if (global_faults != ctx->global_reset_count) { + status = PIPE_INNOCENT_CONTEXT_RESET; + } else { + status = PIPE_NO_RESET; + } + + ctx->context_reset_count = context_faults; + ctx->global_reset_count = global_faults; + + return status; +} + /* TODO we could combine a few of these small buffers (solid_vbuf, * blit_texcoord_vbuf, and vsc_size_mem, into a single buffer and * save a tiny bit of memory @@ -304,6 +337,11 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen, ctx->screen = screen; ctx->pipe = fd_pipe_new2(screen->dev, FD_PIPE_3D, prio); + if (fd_device_version(screen->dev) >= FD_VERSION_ROBUSTNESS) { + ctx->context_reset_count = fd_get_reset_count(ctx, true); + ctx->global_reset_count = fd_get_reset_count(ctx, false); + } + ctx->primtypes = primtypes; ctx->primtype_mask = 0; for (i = 0; i < PIPE_PRIM_MAX; i++) @@ -321,6 +359,7 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen, pctx->flush = fd_context_flush; pctx->emit_string_marker = fd_emit_string_marker; pctx->set_debug_callback = fd_set_debug_callback; + pctx->get_device_reset_status = fd_get_device_reset_status; pctx->create_fence_fd = fd_create_fence_fd; pctx->fence_server_sync = fd_fence_server_sync; pctx->texture_barrier = fd_texture_barrier; diff --git a/src/gallium/drivers/freedreno/freedreno_context.h b/src/gallium/drivers/freedreno/freedreno_context.h index 85f17c81a9d..d389a42e62d 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.h +++ b/src/gallium/drivers/freedreno/freedreno_context.h @@ -228,6 +228,14 @@ struct fd_context { */ struct pipe_fence_handle *last_fence; + /* track last known reset status globally and per-context to + * determine if more resets occurred since then. If global reset + * count increases, it means some other context crashed. If + * per-context reset count increases, it means we crashed the + * gpu. + */ + uint32_t context_reset_count, global_reset_count; + /* Are we in process of shadowing a resource? Used to detect recursion * in transfer_map, and skip unneeded synchronization. */ diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c index fdf26390718..58640a82b0b 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.c +++ b/src/gallium/drivers/freedreno/freedreno_screen.c @@ -200,6 +200,10 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_PACKED_UNIFORMS: return !is_a2xx(screen); + case PIPE_CAP_ROBUST_BUFFER_ACCESS_BEHAVIOR: + case PIPE_CAP_DEVICE_RESET_STATUS_QUERY: + return screen->has_robustness; + case PIPE_CAP_VERTEXID_NOBASE: return is_a3xx(screen) || is_a4xx(screen); @@ -819,6 +823,11 @@ fd_screen_create(struct fd_device *dev, struct renderonly *ro) screen->priority_mask = (1 << val) - 1; } + if ((fd_device_version(dev) >= FD_VERSION_ROBUSTNESS) && + (fd_pipe_get_param(screen->pipe, FD_PP_PGTABLE, &val) == 0)) { + screen->has_robustness = val; + } + struct sysinfo si; sysinfo(&si); screen->ram_size = si.totalram; diff --git a/src/gallium/drivers/freedreno/freedreno_screen.h b/src/gallium/drivers/freedreno/freedreno_screen.h index d8d045a4642..35685be1d22 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.h +++ b/src/gallium/drivers/freedreno/freedreno_screen.h @@ -70,6 +70,7 @@ struct fd_screen { uint32_t num_vsc_pipes; uint32_t priority_mask; bool has_timestamp; + bool has_robustness; unsigned num_perfcntr_groups; const struct fd_perfcntr_group *perfcntr_groups; |