From 045182092e6faeab0adc0a556d1110b9d082f192 Mon Sep 17 00:00:00 2001 From: Paulo Zanoni Date: Fri, 8 Mar 2024 16:04:12 -0800 Subject: [PATCH] anv/xe: slightly improve error handling for the vm_bind ioctl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: José Roberto de Souza Signed-off-by: Paulo Zanoni Part-of: --- src/intel/vulkan/xe/anv_kmd_backend.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/intel/vulkan/xe/anv_kmd_backend.c b/src/intel/vulkan/xe/anv_kmd_backend.c index 2a7d945eafc..a229312498b 100644 --- a/src/intel/vulkan/xe/anv_kmd_backend.c +++ b/src/intel/vulkan/xe/anv_kmd_backend.c @@ -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; }