Mesa (staging/22.0): gallium/tc: zero alloc transfers

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Apr 14 21:33:37 UTC 2022


Module: Mesa
Branch: staging/22.0
Commit: af42a225aae0eb1c1779bf693aaad19f4606dd37
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=af42a225aae0eb1c1779bf693aaad19f4606dd37

Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Date:   Tue Mar  8 11:44:26 2022 +0100

gallium/tc: zero alloc transfers

Otherwise this causes trouble with unitialized memory, eg with:
   struct si_transfer {
      struct threaded_transfer b;
      struct si_resource *staging;
   };
'staging' will not be initialized and this causes #6109.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6109

Cc: mesa-stable
Acked-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Reviewed-by: Rob Clark <robdclark at chromium.org>
Reviewed-by: Christian Gmeiner <christian.gmeiner at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15298>
(cherry picked from commit 3c3a8f853dd8b43bfd51794f2a7d632feda396c4)

---

 .pick_status.json                               |  4 ++--
 src/gallium/auxiliary/util/u_threaded_context.c | 11 ++---------
 2 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index a9185c8b08c..e5522cef3bc 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -11996,7 +11996,7 @@
         "description": "gallium/tc: zero alloc transfers",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 5,
+        "resolution": 1,
         "because_sha": null
     },
     {
@@ -12684,7 +12684,7 @@
         "description": "gallium/tc: warn if an app is incompatible with cpu_storage",
         "nominated": false,
         "nomination_type": null,
-        "resolution": 4,
+        "resolution": 1,
         "because_sha": null
     },
     {
diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c
index 3045af7e4c8..c3007b93ab6 100644
--- a/src/gallium/auxiliary/util/u_threaded_context.c
+++ b/src/gallium/auxiliary/util/u_threaded_context.c
@@ -2181,15 +2181,10 @@ tc_buffer_map(struct pipe_context *_pipe,
          tres->cpu_storage = align_malloc(resource->width0, tc->map_buffer_alignment);
 
       if (tres->cpu_storage) {
-         struct threaded_transfer *ttrans = slab_alloc(&tc->pool_transfers);
+         struct threaded_transfer *ttrans = slab_zalloc(&tc->pool_transfers);
          ttrans->b.resource = resource;
-         ttrans->b.level = 0;
          ttrans->b.usage = usage;
          ttrans->b.box = *box;
-         ttrans->b.stride = 0;
-         ttrans->b.layer_stride = 0;
-         ttrans->b.offset = 0;
-         ttrans->staging = NULL;
          ttrans->valid_buffer_range = &tres->valid_buffer_range;
          ttrans->cpu_storage_mapped = true;
          *transfer = &ttrans->b;
@@ -2204,11 +2199,9 @@ tc_buffer_map(struct pipe_context *_pipe,
     * only get resource_copy_region.
     */
    if (usage & PIPE_MAP_DISCARD_RANGE) {
-      struct threaded_transfer *ttrans = slab_alloc(&tc->pool_transfers);
+      struct threaded_transfer *ttrans = slab_zalloc(&tc->pool_transfers);
       uint8_t *map;
 
-      ttrans->staging = NULL;
-
       u_upload_alloc(tc->base.stream_uploader, 0,
                      box->width + (box->x % tc->map_buffer_alignment),
                      tc->map_buffer_alignment, &ttrans->b.offset,



More information about the mesa-commit mailing list