diff --git a/src/asahi/lib/agx_bo.h b/src/asahi/lib/agx_bo.h index 2061f5e2764..3fd7dc9f122 100644 --- a/src/asahi/lib/agx_bo.h +++ b/src/asahi/lib/agx_bo.h @@ -14,13 +14,6 @@ struct agx_device; -enum agx_alloc_type { - AGX_ALLOC_REGULAR = 0, - AGX_ALLOC_MEMMAP = 1, - AGX_ALLOC_CMDBUF = 2, - AGX_NUM_ALLOC, -}; - enum agx_bo_flags { /* BO is shared across processes (imported or exported) and therefore cannot * be cached locally @@ -50,7 +43,7 @@ struct agx_ptr { /* If CPU mapped, CPU address. NULL if not mapped */ void *cpu; - /* If type REGULAR, mapped GPU address */ + /* Mapped GPU address */ uint64_t gpu; }; @@ -64,8 +57,6 @@ struct agx_bo { /* The time this BO was used last, so we can evict stale BOs. */ time_t last_used; - enum agx_alloc_type type; - /* Creation attributes */ enum agx_bo_flags flags; size_t size; @@ -74,7 +65,7 @@ struct agx_bo { /* Mapping */ struct agx_ptr ptr; - /* Index unique only up to type, process-local */ + /* Process-local index */ uint32_t handle; /* DMA-BUF fd clone for adding fences to imports/exports */ diff --git a/src/asahi/lib/agx_device.c b/src/asahi/lib/agx_device.c index d5bf9a1056d..74969b893b6 100644 --- a/src/asahi/lib/agx_device.c +++ b/src/asahi/lib/agx_device.c @@ -171,7 +171,6 @@ agx_bo_alloc(struct agx_device *dev, size_t size, size_t align, /* Fresh handle */ assert(!memcmp(bo, &((struct agx_bo){}), sizeof(*bo))); - bo->type = AGX_ALLOC_REGULAR; bo->size = gem_create.size; bo->align = MAX2(dev->params.vm_page_size, align); bo->flags = flags; diff --git a/src/asahi/lib/agx_device_virtio.c b/src/asahi/lib/agx_device_virtio.c index 0bececefe7d..9812c4b4175 100644 --- a/src/asahi/lib/agx_device_virtio.c +++ b/src/asahi/lib/agx_device_virtio.c @@ -118,7 +118,6 @@ agx_virtio_bo_alloc(struct agx_device *dev, size_t size, size_t align, /* Fresh handle */ assert(!memcmp(bo, &((struct agx_bo){}), sizeof(*bo))); - bo->type = AGX_ALLOC_REGULAR; bo->size = size; bo->align = MAX2(dev->params.vm_page_size, align); bo->flags = flags; diff --git a/src/asahi/lib/decode.c b/src/asahi/lib/decode.c index 0eb4e4cf3e9..6713952fc66 100644 --- a/src/asahi/lib/decode.c +++ b/src/asahi/lib/decode.c @@ -25,9 +25,6 @@ struct libagxdecode_config lib_config; -UNUSED static const char *agx_alloc_types[AGX_NUM_ALLOC] = {"mem", "map", - "cmd"}; - static void agx_disassemble(void *_code, size_t maxlen, FILE *fp) { @@ -59,8 +56,7 @@ 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 && - (addr - it->ptr.gpu) < it->size) + if (addr >= it->ptr.gpu && (addr - it->ptr.gpu) < it->size) return it; } @@ -71,13 +67,8 @@ static struct agx_bo * agxdecode_find_handle(struct agxdecode_ctx *ctx, unsigned handle, unsigned type) { util_dynarray_foreach(&ctx->mmap_array, struct agx_bo, it) { - if (it->type != type) - continue; - - if (it->handle != handle) - continue; - - return it; + if (it->handle == handle) + return it; } return NULL; @@ -1030,7 +1021,7 @@ void agxdecode_track_alloc(struct agxdecode_ctx *ctx, struct agx_bo *alloc) { util_dynarray_foreach(&ctx->mmap_array, struct agx_bo, it) { - bool match = (it->handle == alloc->handle && it->type == alloc->type); + bool match = (it->handle == alloc->handle); assert(!match && "tried to alloc already allocated BO"); } @@ -1043,8 +1034,7 @@ agxdecode_track_free(struct agxdecode_ctx *ctx, struct agx_bo *bo) bool found = false; util_dynarray_foreach(&ctx->mmap_array, struct agx_bo, it) { - if (it->handle == bo->handle && - (it->type == AGX_ALLOC_REGULAR) == (bo->type == AGX_ALLOC_REGULAR)) { + if (it->handle == bo->handle) { assert(!found && "mapped multiple times!"); found = true; diff --git a/src/asahi/lib/wrap.c b/src/asahi/lib/wrap.c index bbcbd80a3e6..417186ad11a 100644 --- a/src/asahi/lib/wrap.c +++ b/src/asahi/lib/wrap.c @@ -171,12 +171,14 @@ wrap_Method(mach_port_t connection, uint32_t selector, const uint64_t *input, uint64_t *ptr = (uint64_t *)outputStruct; uint32_t *words = (uint32_t *)(ptr + 1); + bool mmap = inp[1]; + /* Construct a synthetic GEM handle for the shmem */ agxdecode_track_alloc(&(struct agx_bo){ - .handle = words[1], + .handle = words[1] ^ (mmap ? (1u << 30) : (1u << 29)), .ptr.cpu = (void *)*ptr, .size = words[0], - .type = inp[1] ? AGX_ALLOC_CMDBUF : AGX_ALLOC_MEMMAP}); + }); break; } @@ -209,7 +211,6 @@ wrap_Method(mach_port_t connection, uint32_t selector, const uint64_t *input, assert(resp->sub_size == resp->root_size); agxdecode_track_alloc(&(struct agx_bo){ - .type = AGX_ALLOC_REGULAR, .size = resp->sub_size, .handle = resp->handle, .ptr.gpu = resp->gpu_va, @@ -225,8 +226,7 @@ wrap_Method(mach_port_t connection, uint32_t selector, const uint64_t *input, assert(output == NULL); assert(outputStruct == NULL); - agxdecode_track_free( - &(struct agx_bo){.type = AGX_ALLOC_REGULAR, .handle = input[0]}); + agxdecode_track_free(&(struct agx_bo){.handle = input[0]}); break; } @@ -237,8 +237,7 @@ wrap_Method(mach_port_t connection, uint32_t selector, const uint64_t *input, assert(output == NULL); assert(outputStruct == NULL); - agxdecode_track_free( - &(struct agx_bo){.type = AGX_ALLOC_CMDBUF, .handle = input[0]}); + agxdecode_track_free(&(struct agx_bo){.handle = input[0] ^ (1u << 29)}); break; }