From ebda38196a15e49ae3bfef2e34684a4da126da49 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Tue, 14 Jun 2022 16:35:49 +0200 Subject: [PATCH] radeonsi: add helper to use si_screen::aux_context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This context needs to be locked before usage, and flushed after. If it's forgotten, radeonsi may crash (eg #6666). To avoid this kind of error, introduce 2 helpers. cc: mesa-stable Reviewed-by: Marek Olšák Part-of: (cherry picked from commit bda1c081bd6e9e4ec144f963c8899cd0d17b211f) --- .pick_status.json | 2 +- src/gallium/drivers/radeonsi/si_pipe.c | 13 +++++++++++++ src/gallium/drivers/radeonsi/si_pipe.h | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index 40021b2ee77..489ff4c36b3 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -526,7 +526,7 @@ "description": "radeonsi: add helper to use si_screen::aux_context", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null }, diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index 1bd1b9f6c19..de739f17857 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -1433,3 +1433,16 @@ struct pipe_screen *radeonsi_screen_create(int fd, const struct pipe_screen_conf drmFreeVersion(version); return rw ? rw->screen : NULL; } + +struct si_context* si_get_aux_context(struct si_screen *sscreen) +{ + simple_mtx_lock(&sscreen->aux_context_lock); + return (struct si_context*)sscreen->aux_context; +} + +void si_put_aux_context_flush(struct si_screen *sscreen) +{ + struct pipe_context *c = &((struct si_context*)sscreen->aux_context)->b; + c->flush(c, NULL, 0); + simple_mtx_unlock(&sscreen->aux_context_lock); +} diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index 8365f0ca71c..cba5d6e4653 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -1504,6 +1504,8 @@ void si_init_compute_functions(struct si_context *sctx); /* si_pipe.c */ void si_init_compiler(struct si_screen *sscreen, struct ac_llvm_compiler *compiler); void si_init_aux_async_compute_ctx(struct si_screen *sscreen); +struct si_context* si_get_aux_context(struct si_screen *sscreen); +void si_put_aux_context_flush(struct si_screen *sscreen); /* si_perfcounters.c */ void si_init_perfcounters(struct si_screen *screen);