diff --git a/src/asahi/lib/agx_device.c b/src/asahi/lib/agx_device.c index 3e179706750..32d337af6ee 100644 --- a/src/asahi/lib/agx_device.c +++ b/src/asahi/lib/agx_device.c @@ -85,10 +85,10 @@ agx_bo_free(struct agx_device *dev, struct agx_bo *bo) if (bo->_map) munmap(bo->_map, bo->size); - /* Free the VA. No need to unmap the BO, as the kernel will take care of that - * when we close it. + /* Free the VA. No need to unmap the BO or unbind the VA, as the kernel will + * take care of that when we close it. */ - agx_va_free(dev, bo->va); + agx_va_free(dev, bo->va, false); if (bo->prime_fd != -1) close(bo->prime_fd); diff --git a/src/asahi/lib/agx_device.h b/src/asahi/lib/agx_device.h index 8ff53118e9f..6627b32106e 100644 --- a/src/asahi/lib/agx_device.h +++ b/src/asahi/lib/agx_device.h @@ -244,7 +244,7 @@ struct agx_device_key agx_gather_device_key(struct agx_device *dev); struct agx_va *agx_va_alloc(struct agx_device *dev, uint64_t size_B, uint64_t align_B, enum agx_va_flags flags, uint64_t fixed_va); -void agx_va_free(struct agx_device *dev, struct agx_va *va); +void agx_va_free(struct agx_device *dev, struct agx_va *va, bool unbind); static inline bool agx_supports_timestamps(const struct agx_device *dev) diff --git a/src/asahi/lib/agx_va.c b/src/asahi/lib/agx_va.c index b6b5f333219..9908a1b5774 100644 --- a/src/asahi/lib/agx_va.c +++ b/src/asahi/lib/agx_va.c @@ -50,11 +50,15 @@ agx_va_alloc(struct agx_device *dev, uint64_t size_B, uint64_t align_B, } void -agx_va_free(struct agx_device *dev, struct agx_va *va) +agx_va_free(struct agx_device *dev, struct agx_va *va, bool unbind) { if (!va) return; + if (unbind) { + dev->ops.bo_bind(dev, NULL, va->addr, va->size_B, 0, 0, true); + } + struct util_vma_heap *heap = agx_vma_heap(dev, va->flags); simple_mtx_lock(&dev->vma_lock); diff --git a/src/asahi/vulkan/hk_buffer.c b/src/asahi/vulkan/hk_buffer.c index 8d422872b94..1c4621def8d 100644 --- a/src/asahi/vulkan/hk_buffer.c +++ b/src/asahi/vulkan/hk_buffer.c @@ -141,11 +141,7 @@ hk_DestroyBuffer(VkDevice device, VkBuffer _buffer, return; if (buffer->va) { - /* Unbind the VA */ - dev->dev.ops.bo_bind(&dev->dev, NULL, buffer->addr, buffer->va->size_B, 0, - 0, true); - - agx_va_free(&dev->dev, buffer->va); + agx_va_free(&dev->dev, buffer->va, true); } vk_buffer_destroy(&dev->vk, pAllocator, &buffer->vk);