asahi: support unbinding VA in agx_va_free

useful for more sparse-y things.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33682>
This commit is contained in:
Alyssa Rosenzweig 2025-01-09 15:27:42 -05:00 committed by Marge Bot
parent c02235124f
commit 93bccc0914
4 changed files with 10 additions and 10 deletions

View file

@ -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);

View file

@ -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)

View file

@ -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);

View file

@ -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);