winsys/amdgpu: make amdgpu_cs_context::flags & handles local
authorMarek Olšák <marek.olsak@amd.com>
Thu, 12 Jul 2018 03:19:15 +0000 (23:19 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 16 Jul 2018 17:32:33 +0000 (13:32 -0400)
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
src/gallium/winsys/amdgpu/drm/amdgpu_cs.h

index 6628ff9f170477ccc0360cb617b7031c409ab582..9aa489adaa46d9c8fbb34035d70c5b35d24006cd 100644 (file)
@@ -902,9 +902,7 @@ static void amdgpu_cs_context_cleanup(struct amdgpu_cs_context *cs)
 static void amdgpu_destroy_cs_context(struct amdgpu_cs_context *cs)
 {
    amdgpu_cs_context_cleanup(cs);
-   FREE(cs->flags);
    FREE(cs->real_buffers);
-   FREE(cs->handles);
    FREE(cs->slab_buffers);
    FREE(cs->sparse_buffers);
    FREE(cs->fence_dependencies);
@@ -1328,19 +1326,8 @@ void amdgpu_cs_submit_ib(void *job, int thread_index)
          goto bo_list_error;
       }
 
-      if (cs->max_real_submit < cs->num_real_buffers) {
-         FREE(cs->handles);
-         FREE(cs->flags);
-
-         cs->handles = MALLOC(sizeof(*cs->handles) * cs->num_real_buffers);
-         cs->flags = MALLOC(sizeof(*cs->flags) * cs->num_real_buffers);
-
-         if (!cs->handles || !cs->flags) {
-            cs->max_real_submit = 0;
-            r = -ENOMEM;
-            goto bo_list_error;
-         }
-      }
+      amdgpu_bo_handle *handles = alloca(sizeof(*handles) * cs->num_real_buffers);
+      uint8_t *flags = alloca(sizeof(*flags) * cs->num_real_buffers);
 
       num_handles = 0;
       for (i = 0; i < cs->num_real_buffers; ++i) {
@@ -1351,8 +1338,8 @@ void amdgpu_cs_submit_ib(void *job, int thread_index)
 
          assert(buffer->u.real.priority_usage != 0);
 
-         cs->handles[num_handles] = buffer->bo->bo;
-         cs->flags[num_handles] = (util_last_bit64(buffer->u.real.priority_usage) - 1) / 4;
+         handles[num_handles] = buffer->bo->bo;
+         flags[num_handles] = (util_last_bit64(buffer->u.real.priority_usage) - 1) / 4;
         ++num_handles;
       }
 
@@ -1361,7 +1348,7 @@ void amdgpu_cs_submit_ib(void *job, int thread_index)
 
       if (num_handles) {
          r = amdgpu_bo_list_create(ws->dev, num_handles,
-                                   cs->handles, cs->flags, &bo_list);
+                                   handles, flags, &bo_list);
       } else {
          r = 0;
       }
index 5f96193750bcc82872b27e0305b08c4c55893055..3b10cc66c21b9a03c696e35a572c67cca0d3fa23 100644 (file)
@@ -81,10 +81,6 @@ struct amdgpu_cs_context {
    unsigned                    num_real_buffers;
    struct amdgpu_cs_buffer     *real_buffers;
 
-   unsigned                    max_real_submit;
-   amdgpu_bo_handle            *handles;
-   uint8_t                     *flags;
-
    unsigned                    num_slab_buffers;
    unsigned                    max_slab_buffers;
    struct amdgpu_cs_buffer     *slab_buffers;