anv/xe: slightly improve error handling for the vm_bind ioctl

The reason we made the vm_bind ioctl return DEVICE_LOST on error is
that we thought there wasn't anything we could do if the ioctl failed.

Thomas Hellstrom pointed us that in case the system is under memory
pressure ENOMEM will be returned and there are things we can try to do
to make it work: either free memory or do fewer bind operations per
ioctl. For now let's just return the appropriate error for the case
(OUT_OF_HOST_MEMORY) so that maybe applications can try to something
about it. In the next patch we'll implement an additional strategy to
try to make things work.

Due to an unrleated failure, our CI system has also pointed out that
we were submitting invalid arguments, so we were getting an EINVAL.
Although we fixed that, these situations really shouldn't happen and
they should be easy to detect, so just put an assertion there, which
will make it easier for us developers to spot any issues.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28792>
This commit is contained in:
Paulo Zanoni
2024-03-08 16:04:12 -08:00
committed by Marge Bot
parent f17d7655fe
commit 045182092e
+7 -1
View File
@@ -253,11 +253,17 @@ xe_vm_bind_op(struct anv_device *device,
intel_bind_timeline_bind_begin(&device->bind_timeline);
}
int ret = intel_ioctl(device->fd, DRM_IOCTL_XE_VM_BIND, &args);
int errno_ = errno;
if (signal_bind_timeline)
intel_bind_timeline_bind_end(&device->bind_timeline);
if (ret) {
result = vk_device_set_lost(&device->vk, "vm_bind failed: %m");
assert(errno_ != EINVAL);
if (errno_ == ENOMEM)
result = vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
else
result = vk_device_set_lost(&device->vk,
"vm_bind failed with errno %d", errno_);
goto out_stackarray;
}