From 1899ea319fabfdc1fa842f734b751c133145055a Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 1 Aug 2024 07:33:07 -0400 Subject: [PATCH] asahi: drop mprotect in decoding now that genxml does our decoding it's not buying us much. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/lib/agx_bo.h | 3 --- src/asahi/lib/decode.c | 39 ++------------------------------------- 2 files changed, 2 insertions(+), 40 deletions(-) diff --git a/src/asahi/lib/agx_bo.h b/src/asahi/lib/agx_bo.h index 9cbddead380..2061f5e2764 100644 --- a/src/asahi/lib/agx_bo.h +++ b/src/asahi/lib/agx_bo.h @@ -86,9 +86,6 @@ struct agx_bo { /* Update atomically */ int32_t refcnt; - /* Used while decoding, marked read-only */ - bool ro; - /* For debugging */ const char *label; diff --git a/src/asahi/lib/decode.c b/src/asahi/lib/decode.c index 7ffeae94d16..0eb4e4cf3e9 100644 --- a/src/asahi/lib/decode.c +++ b/src/asahi/lib/decode.c @@ -40,7 +40,6 @@ FILE *agxdecode_dump_stream; struct agxdecode_ctx { struct util_dynarray mmap_array; - struct util_dynarray ro_mappings; }; struct agxdecode_ctx * @@ -56,8 +55,8 @@ agxdecode_destroy_context(struct agxdecode_ctx *ctx) } static struct agx_bo * -agxdecode_find_mapped_gpu_mem_containing_rw(struct agxdecode_ctx *ctx, - uint64_t addr) +agxdecode_find_mapped_gpu_mem_containing(struct agxdecode_ctx *ctx, + uint64_t addr) { util_dynarray_foreach(&ctx->mmap_array, struct agx_bo, it) { if (it->type == AGX_ALLOC_REGULAR && addr >= it->ptr.gpu && @@ -68,21 +67,6 @@ agxdecode_find_mapped_gpu_mem_containing_rw(struct agxdecode_ctx *ctx, return NULL; } -static struct agx_bo * -agxdecode_find_mapped_gpu_mem_containing(struct agxdecode_ctx *ctx, - uint64_t addr) -{ - struct agx_bo *mem = agxdecode_find_mapped_gpu_mem_containing_rw(ctx, addr); - - if (mem && mem->ptr.cpu && !mem->ro) { - mprotect(mem->ptr.cpu, mem->size, PROT_READ); - mem->ro = true; - util_dynarray_append(&ctx->ro_mappings, struct agx_bo *, mem); - } - - return mem; -} - static struct agx_bo * agxdecode_find_handle(struct agxdecode_ctx *ctx, unsigned handle, unsigned type) { @@ -140,17 +124,6 @@ __agxdecode_fetch_gpu_mem(struct agxdecode_ctx *ctx, const struct agx_bo *mem, #define agxdecode_fetch_gpu_array(ctx, gpu_va, buf) \ agxdecode_fetch_gpu_mem(ctx, gpu_va, sizeof(buf), buf) -static void -agxdecode_map_read_write(struct agxdecode_ctx *ctx) -{ - util_dynarray_foreach(&ctx->ro_mappings, struct agx_bo *, it) { - (*it)->ro = false; - mprotect((*it)->ptr.cpu, (*it)->size, PROT_READ | PROT_WRITE); - } - - util_dynarray_clear(&ctx->ro_mappings); -} - /* Helpers for parsing the cmdstream */ #define DUMP_UNPACKED(T, var, str) \ @@ -863,8 +836,6 @@ agxdecode_image_heap(struct agxdecode_ctx *ctx, uint64_t heap, } free(map); - - agxdecode_map_read_write(ctx); } void @@ -946,8 +917,6 @@ agxdecode_drm_cmd_render(struct agxdecode_ctx *ctx, DUMP_FIELD((&fragment_attachments[i]), "0x%llx", size); DUMP_FIELD((&fragment_attachments[i]), "0x%llx", pointer); } - - agxdecode_map_read_write(ctx); } void @@ -966,8 +935,6 @@ agxdecode_drm_cmd_compute(struct agxdecode_ctx *ctx, agxdecode_sampler_heap(ctx, c->sampler_array, c->sampler_count); - agxdecode_map_read_write(ctx); - if (c->helper_program & 1) { fprintf(agxdecode_dump_stream, "Helper program:\n"); uint8_t buf[1024]; @@ -1055,8 +1022,6 @@ agxdecode_cmdstream(struct agxdecode_ctx *ctx, unsigned cmdbuf_handle, agxdecode_cs((uint32_t *)cmdbuf->ptr.cpu, cmd.encoder, verbose, ¶ms); else agxdecode_gfx((uint32_t *)cmdbuf->ptr.cpu, cmd.encoder, verbose, ¶ms); - - agxdecode_map_read_write(); } #endif