From 2c2858c2afda009c35556dad372ec6eb621e0142 Mon Sep 17 00:00:00 2001 From: Asahi Lina Date: Tue, 11 Jul 2023 02:23:33 +0900 Subject: [PATCH] asahi: wrap: Handle freeing shmems Needed for some Metal demos that end up creating multiple queues. This is still definitely broken/not fully correct, but it at least gets things working for those. Signed-off-by: Asahi Lina Part-of: --- src/asahi/lib/decode.c | 3 ++- src/asahi/lib/wrap.c | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/asahi/lib/decode.c b/src/asahi/lib/decode.c index 79dbc3808ee..638e2163947 100644 --- a/src/asahi/lib/decode.c +++ b/src/asahi/lib/decode.c @@ -818,7 +818,8 @@ agxdecode_track_free(struct agx_bo *bo) for (unsigned i = 0; i < mmap_count; ++i) { if (mmap_array[i].handle == bo->handle && - mmap_array[i].type == bo->type) { + (mmap_array[i].type == AGX_ALLOC_REGULAR) == + (bo->type == AGX_ALLOC_REGULAR)) { assert(!found && "mapped multiple times!"); found = true; diff --git a/src/asahi/lib/wrap.c b/src/asahi/lib/wrap.c index 741d0be451a..73c9d2106a5 100644 --- a/src/asahi/lib/wrap.c +++ b/src/asahi/lib/wrap.c @@ -228,6 +228,18 @@ wrap_Method(mach_port_t connection, uint32_t selector, const uint64_t *input, break; } + case AGX_SELECTOR_FREE_SHMEM: { + assert(inputCnt == 1); + assert(inputStruct == NULL); + assert(output == NULL); + assert(outputStruct == NULL); + + agxdecode_track_free( + &(struct agx_bo){.type = AGX_ALLOC_CMDBUF, .handle = input[0]}); + + break; + } + default: /* Dump the outputs */ if (outputCnt) {