Module: Mesa Branch: staging/21.2 Commit: a8c39e9a6880dd6e40330d95b9920d8ba72034f0 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a8c39e9a6880dd6e40330d95b9920d8ba72034f0
Author: Alyssa Rosenzweig <[email protected]> Date: Thu Aug 12 23:20:44 2021 +0000 panfrost: Don't use ralloc for resources ralloc is not thread safe, so we cannot use a pipe_screen as a ralloc context unless we lock the screen. The allocation patterns for resources are trivial, so just use malloc/calloc/free directly instead of ralloc. This fixes a segfault in: dEQP-EGL.functional.sharing.gles2.multithread.random.images.copytexsubimage2d.1 Signed-off-by: Alyssa Rosenzweig <[email protected]> Cc: mesa-stable Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12525> (cherry picked from commit e6924be737033a1fa2db6e9a356e53db81bd0079) --- .pick_status.json | 2 +- src/gallium/drivers/panfrost/pan_resource.c | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index c3327aa5572..f9187396445 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1246,7 +1246,7 @@ "description": "panfrost: Don't use ralloc for resources", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null }, diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index 1a9d5274f27..174994aa63f 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -67,7 +67,7 @@ panfrost_resource_from_handle(struct pipe_screen *pscreen, assert(whandle->type == WINSYS_HANDLE_TYPE_FD); - rsc = rzalloc(pscreen, struct panfrost_resource); + rsc = CALLOC_STRUCT(panfrost_resource); if (!rsc) return NULL; @@ -98,7 +98,7 @@ panfrost_resource_from_handle(struct pipe_screen *pscreen, crc_mode, &explicit_layout); if (!valid) { - ralloc_free(rsc); + FREE(rsc); return NULL; } @@ -107,7 +107,7 @@ panfrost_resource_from_handle(struct pipe_screen *pscreen, * memory space to mmap it etc. */ if (!rsc->image.data.bo) { - ralloc_free(rsc); + FREE(rsc); return NULL; } if (rsc->image.layout.crc_mode == PAN_IMAGE_CRC_OOB) @@ -550,7 +550,7 @@ panfrost_resource_set_damage_region(struct pipe_screen *screen, pres->damage.tile_map.stride * DIV_ROUND_UP(res->height0, 32); pres->damage.tile_map.data = - ralloc_size(pres, pres->damage.tile_map.size); + malloc(pres->damage.tile_map.size); } memset(pres->damage.tile_map.data, 0, pres->damage.tile_map.size); @@ -634,7 +634,7 @@ panfrost_resource_create_with_modifier(struct pipe_screen *screen, (PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT | PIPE_BIND_SHARED))) return panfrost_create_scanout_res(screen, template, modifier); - struct panfrost_resource *so = rzalloc(screen, struct panfrost_resource); + struct panfrost_resource *so = CALLOC_STRUCT(panfrost_resource); so->base = *template; so->base.screen = screen; @@ -672,7 +672,7 @@ panfrost_resource_create_with_modifier(struct pipe_screen *screen, panfrost_resource_set_damage_region(screen, &so->base, 0, NULL); if (template->bind & PIPE_BIND_INDEX_BUFFER) - so->index_cache = rzalloc(so, struct panfrost_minmax_cache); + so->index_cache = CALLOC_STRUCT(panfrost_minmax_cache); return (struct pipe_resource *)so; } @@ -723,8 +723,11 @@ panfrost_resource_destroy(struct pipe_screen *screen, if (rsrc->image.crc.bo) panfrost_bo_unreference(rsrc->image.crc.bo); + free(rsrc->index_cache); + free(rsrc->damage.tile_map.data); + util_range_destroy(&rsrc->valid_buffer_range); - ralloc_free(rsrc); + free(rsrc); } /* Most of the time we can do CPU-side transfers, but sometimes we need to use
