Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fixes: 4f7fddbd716 ("panfrost: Pass size to panfrost_batch_get_scratchpad")
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3119>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3119>
                         thread_tls_alloc,
                         core_count);
 
-        return panfrost_batch_create_bo(batch, size,
+        if (batch->scratchpad) {
+                assert(batch->scratchpad->size >= size);
+        } else {
+                batch->scratchpad = panfrost_batch_create_bo(batch, size,
                                              PAN_BO_INVISIBLE,
                                              PAN_BO_ACCESS_PRIVATE |
                                              PAN_BO_ACCESS_RW |
                                              PAN_BO_ACCESS_VERTEX_TILER |
                                              PAN_BO_ACCESS_FRAGMENT);
+        }
+
+        return batch->scratchpad;
 }
 
 struct panfrost_bo *