anv: if queue is NULL in vm_bind return early

In the error handling path we end up creating a vk_sync and then later
we vk_sync_wait() on it. If that wait fails somehow we'll end up calling
vk_queue_set_lost(&queue->vk, ...) which would segfault if queue is
NULL.

If we end up in this situation (no queue), return directly whatever the
backend's vm_bind function returned, propagating the error up if
necessary.

Fixes: dd5362c78a ("anv/xe: try harder when the vm_bind ioctl fails")
Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31048>
(cherry picked from commit ed8d1d3c9b)
This commit is contained in:
Dylan Baker 2024-09-05 11:43:36 -07:00 committed by Eric Engestrom
parent 486539be66
commit 7e5192cbea
2 changed files with 6 additions and 4 deletions

View file

@ -684,7 +684,7 @@
"description": "anv: if queue is NULL in vm_bind return early",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "dd5362c78a1d2e8bb88cd321f510e5f9660775e1",
"notes": null

View file

@ -741,11 +741,13 @@ anv_sparse_bind_vm_bind(struct anv_device *device,
{
struct anv_queue *queue = submit->queue;
if (!queue)
assert(submit->wait_count == 0 && submit->signal_count == 0);
VkResult result = device->kmd_backend->vm_bind(device, submit,
ANV_VM_BIND_FLAG_NONE);
if (!queue) {
assert(submit->wait_count == 0 && submit->signal_count == 0 &&
submit->binds_len == 1);
return result;
}
if (result == VK_ERROR_OUT_OF_HOST_MEMORY) {
/* If we get this, the system is under memory pressure. First we