iris: Hook up device reset callbacks
This mechanism lets the driver inform the state tracker about GPU resets, say for destroying a robust API context and reporting a "device lost" error to the application, making it take action to deal with this.
This commit is contained in:
@@ -163,6 +163,7 @@ iris_init_batch(struct iris_batch *batch,
|
|||||||
struct iris_screen *screen,
|
struct iris_screen *screen,
|
||||||
struct iris_vtable *vtbl,
|
struct iris_vtable *vtbl,
|
||||||
struct pipe_debug_callback *dbg,
|
struct pipe_debug_callback *dbg,
|
||||||
|
struct pipe_device_reset_callback *reset,
|
||||||
struct iris_batch *all_batches,
|
struct iris_batch *all_batches,
|
||||||
enum iris_batch_name name,
|
enum iris_batch_name name,
|
||||||
uint8_t engine,
|
uint8_t engine,
|
||||||
@@ -171,6 +172,7 @@ iris_init_batch(struct iris_batch *batch,
|
|||||||
batch->screen = screen;
|
batch->screen = screen;
|
||||||
batch->vtbl = vtbl;
|
batch->vtbl = vtbl;
|
||||||
batch->dbg = dbg;
|
batch->dbg = dbg;
|
||||||
|
batch->reset = reset;
|
||||||
batch->name = name;
|
batch->name = name;
|
||||||
|
|
||||||
/* engine should be one of I915_EXEC_RENDER, I915_EXEC_BLT, etc. */
|
/* engine should be one of I915_EXEC_RENDER, I915_EXEC_BLT, etc. */
|
||||||
@@ -611,6 +613,11 @@ _iris_batch_flush(struct iris_batch *batch, const char *file, int line)
|
|||||||
* dubiously claim success...
|
* dubiously claim success...
|
||||||
*/
|
*/
|
||||||
if (ret == -EIO && replace_hw_ctx(batch)) {
|
if (ret == -EIO && replace_hw_ctx(batch)) {
|
||||||
|
if (batch->reset->reset) {
|
||||||
|
/* Tell the state tracker the device is lost and it was our fault. */
|
||||||
|
batch->reset->reset(batch->reset->data, PIPE_GUILTY_CONTEXT_RESET);
|
||||||
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -58,6 +58,7 @@ struct iris_batch {
|
|||||||
struct iris_screen *screen;
|
struct iris_screen *screen;
|
||||||
struct iris_vtable *vtbl;
|
struct iris_vtable *vtbl;
|
||||||
struct pipe_debug_callback *dbg;
|
struct pipe_debug_callback *dbg;
|
||||||
|
struct pipe_device_reset_callback *reset;
|
||||||
|
|
||||||
/** What batch is this? (e.g. IRIS_BATCH_RENDER/COMPUTE) */
|
/** What batch is this? (e.g. IRIS_BATCH_RENDER/COMPUTE) */
|
||||||
enum iris_batch_name name;
|
enum iris_batch_name name;
|
||||||
@@ -130,6 +131,7 @@ void iris_init_batch(struct iris_batch *batch,
|
|||||||
struct iris_screen *screen,
|
struct iris_screen *screen,
|
||||||
struct iris_vtable *vtbl,
|
struct iris_vtable *vtbl,
|
||||||
struct pipe_debug_callback *dbg,
|
struct pipe_debug_callback *dbg,
|
||||||
|
struct pipe_device_reset_callback *reset,
|
||||||
struct iris_batch *all_batches,
|
struct iris_batch *all_batches,
|
||||||
enum iris_batch_name name,
|
enum iris_batch_name name,
|
||||||
uint8_t ring,
|
uint8_t ring,
|
||||||
|
@@ -101,6 +101,18 @@ iris_lost_context_state(struct iris_batch *batch)
|
|||||||
memset(ice->state.last_grid, 0, sizeof(ice->state.last_grid));
|
memset(ice->state.last_grid, 0, sizeof(ice->state.last_grid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
iris_set_device_reset_callback(struct pipe_context *ctx,
|
||||||
|
const struct pipe_device_reset_callback *cb)
|
||||||
|
{
|
||||||
|
struct iris_context *ice = (struct iris_context *)ctx;
|
||||||
|
|
||||||
|
if (cb)
|
||||||
|
ice->reset = *cb;
|
||||||
|
else
|
||||||
|
memset(&ice->reset, 0, sizeof(ice->reset));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
iris_get_sample_position(struct pipe_context *ctx,
|
iris_get_sample_position(struct pipe_context *ctx,
|
||||||
unsigned sample_count,
|
unsigned sample_count,
|
||||||
@@ -210,6 +222,7 @@ iris_create_context(struct pipe_screen *pscreen, void *priv, unsigned flags)
|
|||||||
|
|
||||||
ctx->destroy = iris_destroy_context;
|
ctx->destroy = iris_destroy_context;
|
||||||
ctx->set_debug_callback = iris_set_debug_callback;
|
ctx->set_debug_callback = iris_set_debug_callback;
|
||||||
|
ctx->set_device_reset_callback = iris_set_device_reset_callback;
|
||||||
ctx->get_sample_position = iris_get_sample_position;
|
ctx->get_sample_position = iris_get_sample_position;
|
||||||
|
|
||||||
ice->shaders.urb_size = devinfo->urb.size;
|
ice->shaders.urb_size = devinfo->urb.size;
|
||||||
@@ -250,7 +263,7 @@ iris_create_context(struct pipe_screen *pscreen, void *priv, unsigned flags)
|
|||||||
|
|
||||||
for (int i = 0; i < IRIS_BATCH_COUNT; i++) {
|
for (int i = 0; i < IRIS_BATCH_COUNT; i++) {
|
||||||
iris_init_batch(&ice->batches[i], screen, &ice->vtbl, &ice->dbg,
|
iris_init_batch(&ice->batches[i], screen, &ice->vtbl, &ice->dbg,
|
||||||
ice->batches, (enum iris_batch_name) i,
|
&ice->reset, ice->batches, (enum iris_batch_name) i,
|
||||||
I915_EXEC_RENDER, priority);
|
I915_EXEC_RENDER, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -440,6 +440,9 @@ struct iris_context {
|
|||||||
/** A debug callback for KHR_debug output. */
|
/** A debug callback for KHR_debug output. */
|
||||||
struct pipe_debug_callback dbg;
|
struct pipe_debug_callback dbg;
|
||||||
|
|
||||||
|
/** A device reset status callback for notifying that the GPU is hosed. */
|
||||||
|
struct pipe_device_reset_callback reset;
|
||||||
|
|
||||||
/** Slab allocator for iris_transfer_map objects. */
|
/** Slab allocator for iris_transfer_map objects. */
|
||||||
struct slab_child_pool transfer_pool;
|
struct slab_child_pool transfer_pool;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user