Mesa (master): panfrost: Reserve thread storage descriptor in panfrost_launch_grid()

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Apr 20 11:58:41 UTC 2021


Module: Mesa
Branch: master
Commit: 8d9b52f45a6b3fa39feddd16cc4d63b499c12640
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8d9b52f45a6b3fa39feddd16cc4d63b499c12640

Author: Boris Brezillon <boris.brezillon at collabora.com>
Date:   Mon Apr 19 09:43:48 2021 +0200

panfrost: Reserve thread storage descriptor in panfrost_launch_grid()

If we don't do that the compute batch is left with an empty thread
storage descriptor, and panfrost_batch_submit() tries to emit an FB
descriptors using invalid FB information.

Reported-by: Italo Nicola <italonicola at collabora.com>
Fixes: ff3eada7eb4e ("panfrost: Use the generic preload and FB helpers in the gallium driver")
Signed-off-by: Boris Brezillon <boris.brezillon at collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa at collabora.com>
Tested-by: Italo Nicola <italonicola at collabora.com>
Reviewed-by: Italo Nicola <italonicola at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10312>

---

 src/gallium/drivers/panfrost/pan_cmdstream.c | 2 +-
 src/gallium/drivers/panfrost/pan_compute.c   | 5 +++++
 src/gallium/drivers/panfrost/pan_context.c   | 2 +-
 src/gallium/drivers/panfrost/pan_job.c       | 6 +++---
 src/gallium/drivers/panfrost/pan_job.h       | 2 +-
 5 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c
index 660cf316d34..c16606b04a9 100644
--- a/src/gallium/drivers/panfrost/pan_cmdstream.c
+++ b/src/gallium/drivers/panfrost/pan_cmdstream.c
@@ -2267,7 +2267,7 @@ panfrost_emit_tls(struct panfrost_batch *batch)
         struct panfrost_device *dev = pan_device(batch->ctx->base.screen);
 
         /* Emitted with the FB descriptor on Midgard. */
-        if (!pan_is_bifrost(dev))
+        if (!pan_is_bifrost(dev) && batch->framebuffer.gpu)
                 return;
 
         struct panfrost_bo *tls_bo =
diff --git a/src/gallium/drivers/panfrost/pan_compute.c b/src/gallium/drivers/panfrost/pan_compute.c
index b25e1919ace..9624b7dec79 100644
--- a/src/gallium/drivers/panfrost/pan_compute.c
+++ b/src/gallium/drivers/panfrost/pan_compute.c
@@ -101,6 +101,11 @@ panfrost_launch_grid(struct pipe_context *pipe,
         struct panfrost_device *dev = pan_device(pipe->screen);
         struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
 
+        /* Reserve a thread storage descriptor now (will be emitted at submit
+         * time).
+         */
+        panfrost_batch_reserve_tls(batch, true);
+
         /* TODO: Indirect compute dispatch */
         assert(!info->indirect);
 
diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
index c158cb482ea..47f15511718 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -460,7 +460,7 @@ panfrost_direct_draw(struct panfrost_context *ctx,
 
         unsigned vertex_count = ctx->vertex_count;
 
-        mali_ptr shared_mem = panfrost_batch_reserve_tls(batch);
+        mali_ptr shared_mem = panfrost_batch_reserve_tls(batch, false);
 
         unsigned min_index = 0, max_index = 0;
         mali_ptr indices = 0;
diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c
index 0b47f87a437..72dffad6051 100644
--- a/src/gallium/drivers/panfrost/pan_job.c
+++ b/src/gallium/drivers/panfrost/pan_job.c
@@ -910,7 +910,7 @@ panfrost_batch_reserve_framebuffer(struct panfrost_batch *batch)
 }
 
 mali_ptr
-panfrost_batch_reserve_tls(struct panfrost_batch *batch)
+panfrost_batch_reserve_tls(struct panfrost_batch *batch, bool compute)
 {
         struct panfrost_device *dev = pan_device(batch->ctx->base.screen);
 
@@ -919,7 +919,7 @@ panfrost_batch_reserve_tls(struct panfrost_batch *batch)
         if (batch->tls.gpu)
                 return batch->tls.gpu;
 
-        if (pan_is_bifrost(dev)) {
+        if (pan_is_bifrost(dev) || compute) {
                 batch->tls = panfrost_pool_alloc_desc(&batch->pool, LOCAL_STORAGE);
         } else {
                 /* On Midgard, the FB descriptor contains a thread storage
@@ -1122,7 +1122,7 @@ panfrost_batch_submit(struct panfrost_batch *batch,
 
         panfrost_batch_to_fb_info(batch, &fb, rts, &zs, &s, false);
 
-        panfrost_batch_reserve_tls(batch);
+        panfrost_batch_reserve_tls(batch, false);
         panfrost_batch_draw_wallpaper(batch, &fb);
 
 
diff --git a/src/gallium/drivers/panfrost/pan_job.h b/src/gallium/drivers/panfrost/pan_job.h
index 080c7b9a60e..ed15ed0998a 100644
--- a/src/gallium/drivers/panfrost/pan_job.h
+++ b/src/gallium/drivers/panfrost/pan_job.h
@@ -200,6 +200,6 @@ mali_ptr
 panfrost_batch_reserve_framebuffer(struct panfrost_batch *batch);
 
 mali_ptr
-panfrost_batch_reserve_tls(struct panfrost_batch *batch);
+panfrost_batch_reserve_tls(struct panfrost_batch *batch, bool compute);
 
 #endif



More information about the mesa-commit mailing list